Skip to content

Commit 9bccc70

Browse files
Wolfram SangWolfram Sang
authored andcommitted
i2c: take address space into account when checking for used addresses
It is not enough to compare the plain address value, we also need to check the flags enabling a different address space. E.g. it is valid to have address 0x50 as a 7-bit address and 0x050 as 10-bit address on the same bus. Same for addresses when we are the slave. Tested-by: Andrey Danin <danindrey@mail.ru> Acked-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
1 parent b4e2f6a commit 9bccc70

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/i2c/i2c-core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ static int __i2c_check_addr_busy(struct device *dev, void *addrp)
839839
struct i2c_client *client = i2c_verify_client(dev);
840840
int addr = *(int *)addrp;
841841

842-
if (client && client->addr == addr)
842+
if (client && i2c_encode_flags_to_addr(client) == addr)
843843
return -EBUSY;
844844
return 0;
845845
}
@@ -993,7 +993,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
993993
}
994994

995995
/* Check for address business */
996-
status = i2c_check_addr_busy(adap, client->addr);
996+
status = i2c_check_addr_busy(adap, i2c_encode_flags_to_addr(client));
997997
if (status)
998998
goto out_err;
999999

@@ -2315,7 +2315,7 @@ static int i2c_detect_address(struct i2c_client *temp_client,
23152315
return err;
23162316
}
23172317

2318-
/* Skip if already in use */
2318+
/* Skip if already in use (7 bit, no need to encode flags) */
23192319
if (i2c_check_addr_busy(adapter, addr))
23202320
return 0;
23212321

@@ -2431,7 +2431,7 @@ i2c_new_probed_device(struct i2c_adapter *adap,
24312431
continue;
24322432
}
24332433

2434-
/* Check address availability */
2434+
/* Check address availability (7 bit, no need to encode flags) */
24352435
if (i2c_check_addr_busy(adap, addr_list[i])) {
24362436
dev_dbg(&adap->dev, "Address 0x%02x already in "
24372437
"use, not probing\n", addr_list[i]);

0 commit comments

Comments
 (0)