diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index af5172486fab..1cca2631e5b3 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -47,7 +47,6 @@ static DEFINE_MUTEX(core_lock); | |||
47 | static DEFINE_IDR(i2c_adapter_idr); | 47 | static DEFINE_IDR(i2c_adapter_idr); |
48 | 48 | ||
49 | static struct device_type i2c_client_type; | 49 | static struct device_type i2c_client_type; |
50 | static int i2c_check_addr(struct i2c_adapter *adapter, int addr); | ||
51 | static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver); | 50 | static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver); |
52 | 51 | ||
53 | /* ------------------------------------------------------------------------- */ | 52 | /* ------------------------------------------------------------------------- */ |
@@ -408,6 +407,22 @@ static int i2c_check_addr_validity(unsigned short addr) | |||
408 | return 0; | 407 | return 0; |
409 | } | 408 | } |
410 | 409 | ||
410 | static int __i2c_check_addr_busy(struct device *dev, void *addrp) | ||
411 | { | ||
412 | struct i2c_client *client = i2c_verify_client(dev); | ||
413 | int addr = *(int *)addrp; | ||
414 | |||
415 | if (client && client->addr == addr) | ||
416 | return -EBUSY; | ||
417 | return 0; | ||
418 | } | ||
419 | |||
420 | static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr) | ||
421 | { | ||
422 | return device_for_each_child(&adapter->dev, &addr, | ||
423 | __i2c_check_addr_busy); | ||
424 | } | ||
425 | |||
411 | /** | 426 | /** |
412 | * i2c_new_device - instantiate an i2c device | 427 | * i2c_new_device - instantiate an i2c device |
413 | * @adap: the adapter managing the device | 428 | * @adap: the adapter managing the device |
@@ -456,7 +471,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) | |||
456 | } | 471 | } |
457 | 472 | ||
458 | /* Check for address business */ | 473 | /* Check for address business */ |
459 | status = i2c_check_addr(adap, client->addr); | 474 | status = i2c_check_addr_busy(adap, client->addr); |
460 | if (status) | 475 | if (status) |
461 | goto out_err; | 476 | goto out_err; |
462 | 477 | ||
@@ -1064,21 +1079,6 @@ EXPORT_SYMBOL(i2c_del_driver); | |||
1064 | 1079 | ||
1065 | /* ------------------------------------------------------------------------- */ | 1080 | /* ------------------------------------------------------------------------- */ |
1066 | 1081 | ||
1067 | static int __i2c_check_addr(struct device *dev, void *addrp) | ||
1068 | { | ||
1069 | struct i2c_client *client = i2c_verify_client(dev); | ||
1070 | int addr = *(int *)addrp; | ||
1071 | |||
1072 | if (client && client->addr == addr) | ||
1073 | return -EBUSY; | ||
1074 | return 0; | ||
1075 | } | ||
1076 | |||
1077 | static int i2c_check_addr(struct i2c_adapter *adapter, int addr) | ||
1078 | { | ||
1079 | return device_for_each_child(&adapter->dev, &addr, __i2c_check_addr); | ||
1080 | } | ||
1081 | |||
1082 | /** | 1082 | /** |
1083 | * i2c_use_client - increments the reference count of the i2c client structure | 1083 | * i2c_use_client - increments the reference count of the i2c client structure |
1084 | * @client: the client being referenced | 1084 | * @client: the client being referenced |
@@ -1369,7 +1369,7 @@ static int i2c_detect_address(struct i2c_client *temp_client, | |||
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | /* Skip if already in use */ | 1371 | /* Skip if already in use */ |
1372 | if (i2c_check_addr(adapter, addr)) | 1372 | if (i2c_check_addr_busy(adapter, addr)) |
1373 | return 0; | 1373 | return 0; |
1374 | 1374 | ||
1375 | /* Make sure there is something at this address */ | 1375 | /* Make sure there is something at this address */ |
@@ -1475,7 +1475,7 @@ i2c_new_probed_device(struct i2c_adapter *adap, | |||
1475 | } | 1475 | } |
1476 | 1476 | ||
1477 | /* Check address availability */ | 1477 | /* Check address availability */ |
1478 | if (i2c_check_addr(adap, addr_list[i])) { | 1478 | if (i2c_check_addr_busy(adap, addr_list[i])) { |
1479 | dev_dbg(&adap->dev, "Address 0x%02x already in " | 1479 | dev_dbg(&adap->dev, "Address 0x%02x already in " |
1480 | "use, not probing\n", addr_list[i]); | 1480 | "use, not probing\n", addr_list[i]); |
1481 | continue; | 1481 | continue; |