mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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>
This commit is contained in:
parent
b4e2f6ac12
commit
9bccc70a12
1 changed files with 4 additions and 4 deletions
|
@ -839,7 +839,7 @@ static int __i2c_check_addr_busy(struct device *dev, void *addrp)
|
||||||
struct i2c_client *client = i2c_verify_client(dev);
|
struct i2c_client *client = i2c_verify_client(dev);
|
||||||
int addr = *(int *)addrp;
|
int addr = *(int *)addrp;
|
||||||
|
|
||||||
if (client && client->addr == addr)
|
if (client && i2c_encode_flags_to_addr(client) == addr)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -993,7 +993,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for address business */
|
/* Check for address business */
|
||||||
status = i2c_check_addr_busy(adap, client->addr);
|
status = i2c_check_addr_busy(adap, i2c_encode_flags_to_addr(client));
|
||||||
if (status)
|
if (status)
|
||||||
goto out_err;
|
goto out_err;
|
||||||
|
|
||||||
|
@ -2315,7 +2315,7 @@ static int i2c_detect_address(struct i2c_client *temp_client,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip if already in use */
|
/* Skip if already in use (7 bit, no need to encode flags) */
|
||||||
if (i2c_check_addr_busy(adapter, addr))
|
if (i2c_check_addr_busy(adapter, addr))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -2431,7 +2431,7 @@ i2c_new_probed_device(struct i2c_adapter *adap,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check address availability */
|
/* Check address availability (7 bit, no need to encode flags) */
|
||||||
if (i2c_check_addr_busy(adap, addr_list[i])) {
|
if (i2c_check_addr_busy(adap, addr_list[i])) {
|
||||||
dev_dbg(&adap->dev, "Address 0x%02x already in "
|
dev_dbg(&adap->dev, "Address 0x%02x already in "
|
||||||
"use, not probing\n", addr_list[i]);
|
"use, not probing\n", addr_list[i]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue