diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2008-10-17 11:51:12 -0400 |
---|---|---|
committer | Jean Delvare <khali@mahadeva.delvare> | 2008-10-17 11:51:12 -0400 |
commit | ee4cd32ee8a68e22081f698602e4315fb4272853 (patch) | |
tree | e44f309816eeb26727a23180ecede53f372705cd /drivers/hwmon/ams/ams-pmu.c | |
parent | 0a02002268bf624a8b0eaf3b4eb5c4207bd80d8b (diff) |
hwmon: (ams) Fix locking issues
Use a separate mutex to serialize input device creation/removal,
otheriwse we deadlock if we try to remove input device while it is
being polled. Also do not take ams_info.lock when it is not needed.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/ams/ams-pmu.c')
-rw-r--r-- | drivers/hwmon/ams/ams-pmu.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/hwmon/ams/ams-pmu.c b/drivers/hwmon/ams/ams-pmu.c index 9463e9768f6f..fb18b3d3162b 100644 --- a/drivers/hwmon/ams/ams-pmu.c +++ b/drivers/hwmon/ams/ams-pmu.c | |||
@@ -149,8 +149,6 @@ int __init ams_pmu_init(struct device_node *np) | |||
149 | const u32 *prop; | 149 | const u32 *prop; |
150 | int result; | 150 | int result; |
151 | 151 | ||
152 | mutex_lock(&ams_info.lock); | ||
153 | |||
154 | /* Set implementation stuff */ | 152 | /* Set implementation stuff */ |
155 | ams_info.of_node = np; | 153 | ams_info.of_node = np; |
156 | ams_info.exit = ams_pmu_exit; | 154 | ams_info.exit = ams_pmu_exit; |
@@ -161,10 +159,9 @@ int __init ams_pmu_init(struct device_node *np) | |||
161 | 159 | ||
162 | /* Get PMU command, should be 0x4e, but we can never know */ | 160 | /* Get PMU command, should be 0x4e, but we can never know */ |
163 | prop = of_get_property(ams_info.of_node, "reg", NULL); | 161 | prop = of_get_property(ams_info.of_node, "reg", NULL); |
164 | if (!prop) { | 162 | if (!prop) |
165 | result = -ENODEV; | 163 | return -ENODEV; |
166 | goto exit; | 164 | |
167 | } | ||
168 | ams_pmu_cmd = ((*prop) >> 8) & 0xff; | 165 | ams_pmu_cmd = ((*prop) >> 8) & 0xff; |
169 | 166 | ||
170 | /* Disable interrupts */ | 167 | /* Disable interrupts */ |
@@ -175,7 +172,7 @@ int __init ams_pmu_init(struct device_node *np) | |||
175 | 172 | ||
176 | result = ams_sensor_attach(); | 173 | result = ams_sensor_attach(); |
177 | if (result < 0) | 174 | if (result < 0) |
178 | goto exit; | 175 | return result; |
179 | 176 | ||
180 | /* Set default values */ | 177 | /* Set default values */ |
181 | ams_pmu_set_register(AMS_FF_LOW_LIMIT, 0x15); | 178 | ams_pmu_set_register(AMS_FF_LOW_LIMIT, 0x15); |
@@ -198,10 +195,5 @@ int __init ams_pmu_init(struct device_node *np) | |||
198 | 195 | ||
199 | printk(KERN_INFO "ams: Found PMU based motion sensor\n"); | 196 | printk(KERN_INFO "ams: Found PMU based motion sensor\n"); |
200 | 197 | ||
201 | result = 0; | 198 | return 0; |
202 | |||
203 | exit: | ||
204 | mutex_unlock(&ams_info.lock); | ||
205 | |||
206 | return result; | ||
207 | } | 199 | } |