Skip to content

Commit 43ec2f4

Browse files
dlechProject516
authored andcommitted
add I2C_CLASS_LEGOEV3
1 parent 8285212 commit 43ec2f4

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

drivers/i2c/i2c-core-base.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,20 +2442,23 @@ static int i2c_detect_address(struct i2c_client *temp_client,
24422442
int addr = temp_client->addr;
24432443
int err;
24442444

2445-
/* Make sure the address is valid */
2446-
err = i2c_check_7bit_addr_validity_strict(addr);
2447-
if (err) {
2448-
dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n",
2449-
addr);
2450-
return err;
2445+
/* Make sure the address is valid - LEGO devices can break the rules */
2446+
if (!(driver->class & I2C_CLASS_LEGOEV3)) {
2447+
err = i2c_check_7bit_addr_validity_strict(addr);
2448+
if (err) {
2449+
dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n",
2450+
addr);
2451+
return err;
2452+
}
24512453
}
24522454

24532455
/* Skip if already in use (7 bit, no need to encode flags) */
24542456
if (i2c_check_addr_busy(adapter, addr))
24552457
return 0;
24562458

2457-
/* Make sure there is something at this address */
2458-
if (!i2c_default_probe(adapter, addr))
2459+
/* Make sure there is something at this address - skip for LEGO drivers */
2460+
if (!(driver->class & I2C_CLASS_LEGOEV3)
2461+
&& !i2c_default_probe(adapter, addr))
24592462
return 0;
24602463

24612464
/* Finally call the custom detection function */

include/linux/i2c.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ static inline void i2c_mark_adapter_resumed(struct i2c_adapter *adap)
870870
#define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */
871871
/* Warn users that the adapter doesn't support classes anymore */
872872
#define I2C_CLASS_DEPRECATED (1<<8)
873+
#define I2C_CLASS_LEGOEV3 (1<<31) /* LEGO EV3 sensors */
873874

874875
/* Internal numbers to terminate lists */
875876
#define I2C_CLIENT_END 0xfffeU

0 commit comments

Comments
 (0)