Skip to contentSkip to conversation

bay: Exit if notify handler cannot be installed

PATCH In review Holger Macht 2 participants 3 messages May 21, 2008 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bay: Exit if notify handler cannot be installed

If acpi_install_notify_handler() for a bay device fails, the bay driver is superfluous. Most likely, another driver (like libata) is already caring about this device anyway. Furthermore, register_hotplug_dock_device(acpi_handle) from the dock driver must not be called twice with the same handler. This would result in an endless loop consuming 100% of CPU. So clean up and exit.

---

drivers/acpi/bay.c +10 -6
index d2fc941..26038c2 100644
@@ -301,16 +301,20 @@ static int bay_add(acpi_handle handle, int id)
 	 */
 	pdev->dev.uevent_suppress = 0;
 
-	if (acpi_bay_add_fs(new_bay)) {
-		platform_device_unregister(new_bay->pdev);
-		goto bay_add_err;
-	}
-
 	/* register for events on this device */
 	status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
 			bay_notify, new_bay);
 	if (ACPI_FAILURE(status)) {
-		printk(KERN_ERR PREFIX "Error installing bay notify handler\n");
+		printk(KERN_INFO PREFIX "Error installing bay notify handler\n");
+		platform_device_unregister(new_bay->pdev);
+		goto bay_add_err;
+	}
+
+	if (acpi_bay_add_fs(new_bay)) {
+		acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
+					   bay_notify);
+		platform_device_unregister(new_bay->pdev);
+		goto bay_add_err;
 	}
 
 	/* if we are on a dock station, we should register for dock
#1 lore raw
Quoted 6 lines · Holger Macht

If acpi_install_notify_handler() for a bay device fails, the bay driver is superfluous. Most likely, another driver (like libata) is already caring about this device anyway. Furthermore, register_hotplug_dock_device(acpi_handle) from the dock driver must not be called twice with the same handler. This would result in an endless loop consuming 100% of CPU. So clean up and exit.

The bay driver still provides the only mechanism for calling the eject methods.

Signature · 1 line
Matthew Garrett | [email protected]
#2 lore raw
Quoted 10 lines · Matthew Garrett
Quoted 6 lines · Holger Macht

If acpi_install_notify_handler() for a bay device fails, the bay driver is superfluous. Most likely, another driver (like libata) is already caring about this device anyway. Furthermore, register_hotplug_dock_device(acpi_handle) from the dock driver must not be called twice with the same handler. This would result in an endless loop consuming 100% of CPU. So clean up and exit.

The bay driver still provides the only mechanism for calling the eject methods.

Yes, I'll send a patch on top of the libata hotplug fixes as soon as it's in for that. But this patch has nothing to do with this. Without it, you get an unusable system.

Regards,
Holger