提交 e4513a57 编写于 作者: B Bjorn Helgaas 提交者: Len Brown

ACPI: fix sonypi ACPI driver registration to unregister on failure

Remove the assumption that acpi_bus_register_driver() returns the number of
devices claimed.  Returning the count is unreliable because devices may be
hot-plugged in the future (admittedly not applicable for this driver).

This also fixes a bug: if sonypi_acpi_driver was registered but found no
devices, sonypi_exit() did not unregister it.
Signed-off-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 578b333b
...@@ -512,7 +512,7 @@ static struct sonypi_device { ...@@ -512,7 +512,7 @@ static struct sonypi_device {
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
static struct acpi_device *sonypi_acpi_device; static struct acpi_device *sonypi_acpi_device;
static int acpi_enabled; static int acpi_driver_registered;
#endif #endif
static int sonypi_ec_write(u8 addr, u8 value) static int sonypi_ec_write(u8 addr, u8 value)
...@@ -869,7 +869,7 @@ static irqreturn_t sonypi_irq(int irq, void *dev_id, struct pt_regs *regs) ...@@ -869,7 +869,7 @@ static irqreturn_t sonypi_irq(int irq, void *dev_id, struct pt_regs *regs)
sonypi_report_input_event(event); sonypi_report_input_event(event);
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
if (acpi_enabled) if (sonypi_acpi_device)
acpi_bus_generate_event(sonypi_acpi_device, 1, event); acpi_bus_generate_event(sonypi_acpi_device, 1, event);
#endif #endif
...@@ -1548,8 +1548,8 @@ static int __init sonypi_init(void) ...@@ -1548,8 +1548,8 @@ static int __init sonypi_init(void)
goto err_free_device; goto err_free_device;
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
if (acpi_bus_register_driver(&sonypi_acpi_driver) > 0) if (acpi_bus_register_driver(&sonypi_acpi_driver) >= 0)
acpi_enabled = 1; acpi_driver_registered = 1;
#endif #endif
return 0; return 0;
...@@ -1564,7 +1564,7 @@ static int __init sonypi_init(void) ...@@ -1564,7 +1564,7 @@ static int __init sonypi_init(void)
static void __exit sonypi_exit(void) static void __exit sonypi_exit(void)
{ {
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
if (acpi_enabled) if (acpi_driver_registered)
acpi_bus_unregister_driver(&sonypi_acpi_driver); acpi_bus_unregister_driver(&sonypi_acpi_driver);
#endif #endif
platform_device_unregister(sonypi_platform_device); platform_device_unregister(sonypi_platform_device);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册