diff options
author | Jean Delvare <khali@linux-fr.org> | 2010-01-30 23:03:23 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-02-03 01:39:49 -0500 |
commit | 98ceb75c7c14eada76b0aa9f03a635a735cee3cb (patch) | |
tree | d514b307399db60cdbc1fd9461e8b5af5655ca0a /drivers/hwmon/ams | |
parent | 33a470f6d5e1879c26f16f6b34dc09f82d44f6e9 (diff) |
macintosh/hwmon/ams: Fix device removal sequence
Some code that is in ams_exit() (the module exit code) should instead
be called when the device (not module) is removed. It probably doesn't
make much of a difference in the PMU case, but in the I2C case it does
matter.
I make no guarantee that my fix isn't racy, I'm not familiar enough
with the ams driver code to tell for sure.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Christian Kujau <lists@nerdbynature.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Stelian Pop <stelian@popies.net>
Cc: Michael Hanselmann <linux-kernel@hansmi.ch>
Cc: stable@kernel.org
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/hwmon/ams')
-rw-r--r-- | drivers/hwmon/ams/ams-core.c | 11 | ||||
-rw-r--r-- | drivers/hwmon/ams/ams-i2c.c | 2 | ||||
-rw-r--r-- | drivers/hwmon/ams/ams-pmu.c | 2 | ||||
-rw-r--r-- | drivers/hwmon/ams/ams.h | 1 |
4 files changed, 12 insertions, 4 deletions
diff --git a/drivers/hwmon/ams/ams-core.c b/drivers/hwmon/ams/ams-core.c index 6c9ace1b76f6..2ad62c339cd2 100644 --- a/drivers/hwmon/ams/ams-core.c +++ b/drivers/hwmon/ams/ams-core.c | |||
@@ -213,7 +213,7 @@ int __init ams_init(void) | |||
213 | return -ENODEV; | 213 | return -ENODEV; |
214 | } | 214 | } |
215 | 215 | ||
216 | void ams_exit(void) | 216 | void ams_sensor_detach(void) |
217 | { | 217 | { |
218 | /* Remove input device */ | 218 | /* Remove input device */ |
219 | ams_input_exit(); | 219 | ams_input_exit(); |
@@ -221,9 +221,6 @@ void ams_exit(void) | |||
221 | /* Remove attributes */ | 221 | /* Remove attributes */ |
222 | device_remove_file(&ams_info.of_dev->dev, &dev_attr_current); | 222 | device_remove_file(&ams_info.of_dev->dev, &dev_attr_current); |
223 | 223 | ||
224 | /* Shut down implementation */ | ||
225 | ams_info.exit(); | ||
226 | |||
227 | /* Flush interrupt worker | 224 | /* Flush interrupt worker |
228 | * | 225 | * |
229 | * We do this after ams_info.exit(), because an interrupt might | 226 | * We do this after ams_info.exit(), because an interrupt might |
@@ -239,6 +236,12 @@ void ams_exit(void) | |||
239 | pmf_unregister_irq_client(&ams_freefall_client); | 236 | pmf_unregister_irq_client(&ams_freefall_client); |
240 | } | 237 | } |
241 | 238 | ||
239 | static void __exit ams_exit(void) | ||
240 | { | ||
241 | /* Shut down implementation */ | ||
242 | ams_info.exit(); | ||
243 | } | ||
244 | |||
242 | MODULE_AUTHOR("Stelian Pop, Michael Hanselmann"); | 245 | MODULE_AUTHOR("Stelian Pop, Michael Hanselmann"); |
243 | MODULE_DESCRIPTION("Apple Motion Sensor driver"); | 246 | MODULE_DESCRIPTION("Apple Motion Sensor driver"); |
244 | MODULE_LICENSE("GPL"); | 247 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/hwmon/ams/ams-i2c.c b/drivers/hwmon/ams/ams-i2c.c index 2cbf8a6506c7..abeecd27b484 100644 --- a/drivers/hwmon/ams/ams-i2c.c +++ b/drivers/hwmon/ams/ams-i2c.c | |||
@@ -238,6 +238,8 @@ static int ams_i2c_probe(struct i2c_client *client, | |||
238 | static int ams_i2c_remove(struct i2c_client *client) | 238 | static int ams_i2c_remove(struct i2c_client *client) |
239 | { | 239 | { |
240 | if (ams_info.has_device) { | 240 | if (ams_info.has_device) { |
241 | ams_sensor_detach(); | ||
242 | |||
241 | /* Disable interrupts */ | 243 | /* Disable interrupts */ |
242 | ams_i2c_set_irq(AMS_IRQ_ALL, 0); | 244 | ams_i2c_set_irq(AMS_IRQ_ALL, 0); |
243 | 245 | ||
diff --git a/drivers/hwmon/ams/ams-pmu.c b/drivers/hwmon/ams/ams-pmu.c index fb18b3d3162b..4f61b3ee1b08 100644 --- a/drivers/hwmon/ams/ams-pmu.c +++ b/drivers/hwmon/ams/ams-pmu.c | |||
@@ -133,6 +133,8 @@ static void ams_pmu_get_xyz(s8 *x, s8 *y, s8 *z) | |||
133 | 133 | ||
134 | static void ams_pmu_exit(void) | 134 | static void ams_pmu_exit(void) |
135 | { | 135 | { |
136 | ams_sensor_detach(); | ||
137 | |||
136 | /* Disable interrupts */ | 138 | /* Disable interrupts */ |
137 | ams_pmu_set_irq(AMS_IRQ_ALL, 0); | 139 | ams_pmu_set_irq(AMS_IRQ_ALL, 0); |
138 | 140 | ||
diff --git a/drivers/hwmon/ams/ams.h b/drivers/hwmon/ams/ams.h index 5ed387b0bd9a..b28d7e27a031 100644 --- a/drivers/hwmon/ams/ams.h +++ b/drivers/hwmon/ams/ams.h | |||
@@ -61,6 +61,7 @@ extern struct ams ams_info; | |||
61 | 61 | ||
62 | extern void ams_sensors(s8 *x, s8 *y, s8 *z); | 62 | extern void ams_sensors(s8 *x, s8 *y, s8 *z); |
63 | extern int ams_sensor_attach(void); | 63 | extern int ams_sensor_attach(void); |
64 | extern void ams_sensor_detach(void); | ||
64 | 65 | ||
65 | extern int ams_pmu_init(struct device_node *np); | 66 | extern int ams_pmu_init(struct device_node *np); |
66 | extern int ams_i2c_init(struct device_node *np); | 67 | extern int ams_i2c_init(struct device_node *np); |