Commit 98ceb75c authored by Jean Delvare's avatar Jean Delvare Committed by Benjamin Herrenschmidt

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: default avatarJean Delvare <khali@linux-fr.org>
Tested-by: default avatarChristian 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: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 33a470f6
...@@ -213,7 +213,7 @@ int __init ams_init(void) ...@@ -213,7 +213,7 @@ int __init ams_init(void)
return -ENODEV; return -ENODEV;
} }
void ams_exit(void) void ams_sensor_detach(void)
{ {
/* Remove input device */ /* Remove input device */
ams_input_exit(); ams_input_exit();
...@@ -221,9 +221,6 @@ void ams_exit(void) ...@@ -221,9 +221,6 @@ void ams_exit(void)
/* Remove attributes */ /* Remove attributes */
device_remove_file(&ams_info.of_dev->dev, &dev_attr_current); device_remove_file(&ams_info.of_dev->dev, &dev_attr_current);
/* Shut down implementation */
ams_info.exit();
/* Flush interrupt worker /* Flush interrupt worker
* *
* We do this after ams_info.exit(), because an interrupt might * We do this after ams_info.exit(), because an interrupt might
...@@ -239,6 +236,12 @@ void ams_exit(void) ...@@ -239,6 +236,12 @@ void ams_exit(void)
pmf_unregister_irq_client(&ams_freefall_client); pmf_unregister_irq_client(&ams_freefall_client);
} }
static void __exit ams_exit(void)
{
/* Shut down implementation */
ams_info.exit();
}
MODULE_AUTHOR("Stelian Pop, Michael Hanselmann"); MODULE_AUTHOR("Stelian Pop, Michael Hanselmann");
MODULE_DESCRIPTION("Apple Motion Sensor driver"); MODULE_DESCRIPTION("Apple Motion Sensor driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -238,6 +238,8 @@ static int ams_i2c_probe(struct i2c_client *client, ...@@ -238,6 +238,8 @@ static int ams_i2c_probe(struct i2c_client *client,
static int ams_i2c_remove(struct i2c_client *client) static int ams_i2c_remove(struct i2c_client *client)
{ {
if (ams_info.has_device) { if (ams_info.has_device) {
ams_sensor_detach();
/* Disable interrupts */ /* Disable interrupts */
ams_i2c_set_irq(AMS_IRQ_ALL, 0); ams_i2c_set_irq(AMS_IRQ_ALL, 0);
......
...@@ -133,6 +133,8 @@ static void ams_pmu_get_xyz(s8 *x, s8 *y, s8 *z) ...@@ -133,6 +133,8 @@ static void ams_pmu_get_xyz(s8 *x, s8 *y, s8 *z)
static void ams_pmu_exit(void) static void ams_pmu_exit(void)
{ {
ams_sensor_detach();
/* Disable interrupts */ /* Disable interrupts */
ams_pmu_set_irq(AMS_IRQ_ALL, 0); ams_pmu_set_irq(AMS_IRQ_ALL, 0);
......
...@@ -61,6 +61,7 @@ extern struct ams ams_info; ...@@ -61,6 +61,7 @@ extern struct ams ams_info;
extern void ams_sensors(s8 *x, s8 *y, s8 *z); extern void ams_sensors(s8 *x, s8 *y, s8 *z);
extern int ams_sensor_attach(void); extern int ams_sensor_attach(void);
extern void ams_sensor_detach(void);
extern int ams_pmu_init(struct device_node *np); extern int ams_pmu_init(struct device_node *np);
extern int ams_i2c_init(struct device_node *np); extern int ams_i2c_init(struct device_node *np);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment