diff options
author | Wolfram Sang <wsa+renesas@sang-engineering.com> | 2015-07-17 08:48:56 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2015-08-24 08:05:14 -0400 |
commit | 9bccc70a127cfe2a13e34d6b6e7300caae113f8f (patch) | |
tree | da17b6a3de9f47c5affd0b685b69524a67fd03f6 /drivers/i2c/i2c-core.c | |
parent | b4e2f6ac1281cd3e066919cc762eef4924e9fcc5 (diff) |
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>
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 7b18f31bf6c6..fc6d89316144 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -839,7 +839,7 @@ static int __i2c_check_addr_busy(struct device *dev, void *addrp) | |||
839 | struct i2c_client *client = i2c_verify_client(dev); | 839 | struct i2c_client *client = i2c_verify_client(dev); |
840 | int addr = *(int *)addrp; | 840 | int addr = *(int *)addrp; |
841 | 841 | ||
842 | if (client && client->addr == addr) | 842 | if (client && i2c_encode_flags_to_addr(client) == addr) |
843 | return -EBUSY; | 843 | return -EBUSY; |
844 | return 0; | 844 | return 0; |
845 | } | 845 | } |
@@ -993,7 +993,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) | |||
993 | } | 993 | } |
994 | 994 | ||
995 | /* Check for address business */ | 995 | /* 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)); |
997 | if (status) | 997 | if (status) |
998 | goto out_err; | 998 | goto out_err; |
999 | 999 | ||
@@ -2315,7 +2315,7 @@ static int i2c_detect_address(struct i2c_client *temp_client, | |||
2315 | return err; | 2315 | return err; |
2316 | } | 2316 | } |
2317 | 2317 | ||
2318 | /* Skip if already in use */ | 2318 | /* Skip if already in use (7 bit, no need to encode flags) */ |
2319 | if (i2c_check_addr_busy(adapter, addr)) | 2319 | if (i2c_check_addr_busy(adapter, addr)) |
2320 | return 0; | 2320 | return 0; |
2321 | 2321 | ||
@@ -2431,7 +2431,7 @@ i2c_new_probed_device(struct i2c_adapter *adap, | |||
2431 | continue; | 2431 | continue; |
2432 | } | 2432 | } |
2433 | 2433 | ||
2434 | /* Check address availability */ | 2434 | /* Check address availability (7 bit, no need to encode flags) */ |
2435 | if (i2c_check_addr_busy(adap, addr_list[i])) { | 2435 | if (i2c_check_addr_busy(adap, addr_list[i])) { |
2436 | dev_dbg(&adap->dev, "Address 0x%02x already in " | 2436 | dev_dbg(&adap->dev, "Address 0x%02x already in " |
2437 | "use, not probing\n", addr_list[i]); | 2437 | "use, not probing\n", addr_list[i]); |