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-boardinfo.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-boardinfo.c')
-rw-r--r-- | drivers/i2c/i2c-boardinfo.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/i2c/i2c-boardinfo.c b/drivers/i2c/i2c-boardinfo.c index ffb35f09df03..a26a34a06641 100644 --- a/drivers/i2c/i2c-boardinfo.c +++ b/drivers/i2c/i2c-boardinfo.c | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/i2c.h> | 20 | #include <linux/i2c.h> |
21 | #include <linux/rwsem.h> | ||
21 | 22 | ||
22 | #include "i2c-core.h" | 23 | #include "i2c-core.h" |
23 | 24 | ||
@@ -25,7 +26,7 @@ | |||
25 | /* These symbols are exported ONLY FOR the i2c core. | 26 | /* These symbols are exported ONLY FOR the i2c core. |
26 | * No other users will be supported. | 27 | * No other users will be supported. |
27 | */ | 28 | */ |
28 | DEFINE_MUTEX(__i2c_board_lock); | 29 | DECLARE_RWSEM(__i2c_board_lock); |
29 | EXPORT_SYMBOL_GPL(__i2c_board_lock); | 30 | EXPORT_SYMBOL_GPL(__i2c_board_lock); |
30 | 31 | ||
31 | LIST_HEAD(__i2c_board_list); | 32 | LIST_HEAD(__i2c_board_list); |
@@ -63,7 +64,7 @@ i2c_register_board_info(int busnum, | |||
63 | { | 64 | { |
64 | int status; | 65 | int status; |
65 | 66 | ||
66 | mutex_lock(&__i2c_board_lock); | 67 | down_write(&__i2c_board_lock); |
67 | 68 | ||
68 | /* dynamic bus numbers will be assigned after the last static one */ | 69 | /* dynamic bus numbers will be assigned after the last static one */ |
69 | if (busnum >= __i2c_first_dynamic_bus_num) | 70 | if (busnum >= __i2c_first_dynamic_bus_num) |
@@ -84,7 +85,7 @@ i2c_register_board_info(int busnum, | |||
84 | list_add_tail(&devinfo->list, &__i2c_board_list); | 85 | list_add_tail(&devinfo->list, &__i2c_board_list); |
85 | } | 86 | } |
86 | 87 | ||
87 | mutex_unlock(&__i2c_board_lock); | 88 | up_write(&__i2c_board_lock); |
88 | 89 | ||
89 | return status; | 90 | return status; |
90 | } | 91 | } |