diff options
author | Wolfram Sang <wsa+renesas@sang-engineering.com> | 2015-07-27 08:03:38 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2015-08-24 08:05:15 -0400 |
commit | cfa0327b0d03091e0c47249c080e50e287be762d (patch) | |
tree | 623f03aee6dc0bbdaada27b4f2cab5e4a7fd87fd /drivers/i2c/i2c-core.c | |
parent | 9bccc70a127cfe2a13e34d6b6e7300caae113f8f (diff) |
i2c: support 10 bit and slave addresses in sysfs 'new_device'
We now have seperate address spaces for 10 bit and we-are-slave clients.
Update the sysfs device instantiation method to support these types by
accepting the address offsets that are assigned to the extra address
spaces. Update the documentation, too.
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 | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index fc6d89316144..039817eaecb5 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -1158,6 +1158,16 @@ i2c_sysfs_new_device(struct device *dev, struct device_attribute *attr, | |||
1158 | return -EINVAL; | 1158 | return -EINVAL; |
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | if ((info.addr & I2C_ADDR_OFFSET_TEN_BIT) == I2C_ADDR_OFFSET_TEN_BIT) { | ||
1162 | info.addr &= ~I2C_ADDR_OFFSET_TEN_BIT; | ||
1163 | info.flags |= I2C_CLIENT_TEN; | ||
1164 | } | ||
1165 | |||
1166 | if (info.addr & I2C_ADDR_OFFSET_SLAVE) { | ||
1167 | info.addr &= ~I2C_ADDR_OFFSET_SLAVE; | ||
1168 | info.flags |= I2C_CLIENT_SLAVE; | ||
1169 | } | ||
1170 | |||
1161 | client = i2c_new_device(adap, &info); | 1171 | client = i2c_new_device(adap, &info); |
1162 | if (!client) | 1172 | if (!client) |
1163 | return -EINVAL; | 1173 | return -EINVAL; |
@@ -1209,7 +1219,7 @@ i2c_sysfs_delete_device(struct device *dev, struct device_attribute *attr, | |||
1209 | i2c_adapter_depth(adap)); | 1219 | i2c_adapter_depth(adap)); |
1210 | list_for_each_entry_safe(client, next, &adap->userspace_clients, | 1220 | list_for_each_entry_safe(client, next, &adap->userspace_clients, |
1211 | detected) { | 1221 | detected) { |
1212 | if (client->addr == addr) { | 1222 | if (i2c_encode_flags_to_addr(client) == addr) { |
1213 | dev_info(dev, "%s: Deleting device %s at 0x%02hx\n", | 1223 | dev_info(dev, "%s: Deleting device %s at 0x%02hx\n", |
1214 | "delete_device", client->name, client->addr); | 1224 | "delete_device", client->name, client->addr); |
1215 | 1225 | ||