i2c: Fix device name for 10-bit slave address
10-bit addresses overlap with traditional 7-bit addresses, leading in device name collisions. Add an arbitrary offset to 10-bit addresses to prevent this collision. The offset was chosen so that the address is still easily recognizable. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Wolfram Sang <w.sang@pengutronix.de>
This commit is contained in:
committed by
Jean Delvare
parent
cc6bcf7d2e
commit
cbb4451404
@@ -539,8 +539,10 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
|
||||
client->dev.type = &i2c_client_type;
|
||||
client->dev.of_node = info->of_node;
|
||||
|
||||
/* For 10-bit clients, add an arbitrary offset to avoid collisions */
|
||||
dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap),
|
||||
client->addr);
|
||||
client->addr | ((client->flags & I2C_CLIENT_TEN)
|
||||
? 0xa000 : 0));
|
||||
status = device_register(&client->dev);
|
||||
if (status)
|
||||
goto out_err;
|
||||
|
Reference in New Issue
Block a user