diff options
author | Rodolfo Giometti <giometti@linux.it> | 2009-06-19 10:58:20 -0400 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-06-19 10:58:20 -0400 |
commit | f18c41daea14baee11252da268cdf5dcd57c7c10 (patch) | |
tree | ec42ed7000fa64925db3cd596737bd54d9fa71ca /drivers/i2c/i2c-core.c | |
parent | 99cd8e25875a109455b709b5a41d4891b8d8e58e (diff) |
i2c: Use rwsem instead of mutex for board info
By using rwsem we can easily manage recursive calls of
i2c_scan_static_board_info() function without breaking the locking.
Signed-off-by: Rodolfo Giometti <giometti@linux.it>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index eb084fa0df83..0e45c296d3d2 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/completion.h> | 33 | #include <linux/completion.h> |
34 | #include <linux/hardirq.h> | 34 | #include <linux/hardirq.h> |
35 | #include <linux/irqflags.h> | 35 | #include <linux/irqflags.h> |
36 | #include <linux/rwsem.h> | ||
36 | #include <asm/uaccess.h> | 37 | #include <asm/uaccess.h> |
37 | 38 | ||
38 | #include "i2c-core.h" | 39 | #include "i2c-core.h" |
@@ -509,7 +510,7 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter) | |||
509 | { | 510 | { |
510 | struct i2c_devinfo *devinfo; | 511 | struct i2c_devinfo *devinfo; |
511 | 512 | ||
512 | mutex_lock(&__i2c_board_lock); | 513 | down_read(&__i2c_board_lock); |
513 | list_for_each_entry(devinfo, &__i2c_board_list, list) { | 514 | list_for_each_entry(devinfo, &__i2c_board_list, list) { |
514 | if (devinfo->busnum == adapter->nr | 515 | if (devinfo->busnum == adapter->nr |
515 | && !i2c_new_device(adapter, | 516 | && !i2c_new_device(adapter, |
@@ -518,7 +519,7 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter) | |||
518 | "Can't create device at 0x%02x\n", | 519 | "Can't create device at 0x%02x\n", |
519 | devinfo->board_info.addr); | 520 | devinfo->board_info.addr); |
520 | } | 521 | } |
521 | mutex_unlock(&__i2c_board_lock); | 522 | up_read(&__i2c_board_lock); |
522 | } | 523 | } |
523 | 524 | ||
524 | static int i2c_do_add_adapter(struct device_driver *d, void *data) | 525 | static int i2c_do_add_adapter(struct device_driver *d, void *data) |