Staging: quickstart: Cleanup quickstart_acpi_add
authorSzymon Janc <szymon@janc.net.pl>
Wed, 11 Jan 2012 22:22:42 +0000 (23:22 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2012 01:16:49 +0000 (17:16 -0800)
Signed-off-by: Szymon Janc <szymon@janc.net.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/quickstart/quickstart.c

index de98e18f9b4cc8e4bec9148e171c016b26389ea5..97e62e9faf60295b2129a692a9ce2faa0fc685b4 100644 (file)
@@ -262,29 +262,29 @@ static int quickstart_acpi_config(struct quickstart_acpi *quickstart, char *bid)
 
 static int quickstart_acpi_add(struct acpi_device *device)
 {
-       int ret = 0;
-       acpi_status status = AE_OK;
-       struct quickstart_acpi *quickstart = NULL;
+       int ret;
+       acpi_status status;
+       struct quickstart_acpi *quickstart;
 
        if (!device)
                return -EINVAL;
 
-       quickstart = kzalloc(sizeof(struct quickstart_acpi), GFP_KERNEL);
+       quickstart = kzalloc(sizeof(*quickstart), GFP_KERNEL);
        if (!quickstart)
                return -ENOMEM;
 
        quickstart->device = device;
+
        strcpy(acpi_device_name(device), QUICKSTART_ACPI_DEVICE_NAME);
        strcpy(acpi_device_class(device), QUICKSTART_ACPI_CLASS);
        device->driver_data = quickstart;
 
        /* Add button to list and initialize some stuff */
        ret = quickstart_acpi_config(quickstart, acpi_device_bid(device));
-       if (ret)
+       if (ret < 0)
                goto fail_config;
 
-       status = acpi_install_notify_handler(device->handle,
-                                               ACPI_ALL_NOTIFY,
+       status = acpi_install_notify_handler(device->handle, ACPI_ALL_NOTIFY,
                                                quickstart_acpi_notify,
                                                quickstart);
        if (ACPI_FAILURE(status)) {
@@ -293,10 +293,16 @@ static int quickstart_acpi_add(struct acpi_device *device)
                goto fail_installnotify;
        }
 
-       quickstart_acpi_ghid(quickstart);
+       ret = quickstart_acpi_ghid(quickstart);
+       if (ret < 0)
+               goto fail_ghid;
 
        return 0;
 
+fail_ghid:
+       acpi_remove_notify_handler(device->handle, ACPI_ALL_NOTIFY,
+                                               quickstart_acpi_notify);
+
 fail_installnotify:
        quickstart_btnlst_del(quickstart->btn);