aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-core.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-10-24 12:16:57 -0400
committerJean Delvare <khali@endymion.delvare>2010-10-24 12:16:57 -0400
commit97cc4d49cfcda1c2dad89c00b62a25b628ce2115 (patch)
tree1c9120a9e5db76df3f82338c64a2a19d88aedcbc /drivers/i2c/i2c-core.c
parentd582963a027fd63f8dfc97a0bf3654d4380e34ce (diff)
i2c: Let i2c_parent_is_i2c_adapter return the parent adapter
This makes the calling site's code clearer IMHO. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Michael Lawnick <ml.lawnick@gmx.de>
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r--drivers/i2c/i2c-core.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index bea4c5021d26..40e563de0508 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -425,14 +425,14 @@ static int __i2c_check_addr_busy(struct device *dev, void *addrp)
425/* walk up mux tree */ 425/* walk up mux tree */
426static int i2c_check_mux_parents(struct i2c_adapter *adapter, int addr) 426static int i2c_check_mux_parents(struct i2c_adapter *adapter, int addr)
427{ 427{
428 struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter);
428 int result; 429 int result;
429 430
430 result = device_for_each_child(&adapter->dev, &addr, 431 result = device_for_each_child(&adapter->dev, &addr,
431 __i2c_check_addr_busy); 432 __i2c_check_addr_busy);
432 433
433 if (!result && i2c_parent_is_i2c_adapter(adapter)) 434 if (!result && parent)
434 result = i2c_check_mux_parents( 435 result = i2c_check_mux_parents(parent, addr);
435 to_i2c_adapter(adapter->dev.parent), addr);
436 436
437 return result; 437 return result;
438} 438}
@@ -453,11 +453,11 @@ static int i2c_check_mux_children(struct device *dev, void *addrp)
453 453
454static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr) 454static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr)
455{ 455{
456 struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter);
456 int result = 0; 457 int result = 0;
457 458
458 if (i2c_parent_is_i2c_adapter(adapter)) 459 if (parent)
459 result = i2c_check_mux_parents( 460 result = i2c_check_mux_parents(parent, addr);
460 to_i2c_adapter(adapter->dev.parent), addr);
461 461
462 if (!result) 462 if (!result)
463 result = device_for_each_child(&adapter->dev, &addr, 463 result = device_for_each_child(&adapter->dev, &addr,
@@ -472,8 +472,10 @@ static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr)
472 */ 472 */
473void i2c_lock_adapter(struct i2c_adapter *adapter) 473void i2c_lock_adapter(struct i2c_adapter *adapter)
474{ 474{
475 if (i2c_parent_is_i2c_adapter(adapter)) 475 struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter);
476 i2c_lock_adapter(to_i2c_adapter(adapter->dev.parent)); 476
477 if (parent)
478 i2c_lock_adapter(parent);
477 else 479 else
478 rt_mutex_lock(&adapter->bus_lock); 480 rt_mutex_lock(&adapter->bus_lock);
479} 481}
@@ -485,8 +487,10 @@ EXPORT_SYMBOL_GPL(i2c_lock_adapter);
485 */ 487 */
486static int i2c_trylock_adapter(struct i2c_adapter *adapter) 488static int i2c_trylock_adapter(struct i2c_adapter *adapter)
487{ 489{
488 if (i2c_parent_is_i2c_adapter(adapter)) 490 struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter);
489 return i2c_trylock_adapter(to_i2c_adapter(adapter->dev.parent)); 491
492 if (parent)
493 return i2c_trylock_adapter(parent);
490 else 494 else
491 return rt_mutex_trylock(&adapter->bus_lock); 495 return rt_mutex_trylock(&adapter->bus_lock);
492} 496}
@@ -497,8 +501,10 @@ static int i2c_trylock_adapter(struct i2c_adapter *adapter)
497 */ 501 */
498void i2c_unlock_adapter(struct i2c_adapter *adapter) 502void i2c_unlock_adapter(struct i2c_adapter *adapter)
499{ 503{
500 if (i2c_parent_is_i2c_adapter(adapter)) 504 struct i2c_adapter *parent = i2c_parent_is_i2c_adapter(adapter);
501 i2c_unlock_adapter(to_i2c_adapter(adapter->dev.parent)); 505
506 if (parent)
507 i2c_unlock_adapter(parent);
502 else 508 else
503 rt_mutex_unlock(&adapter->bus_lock); 509 rt_mutex_unlock(&adapter->bus_lock);
504} 510}