olpc: x01: convert platform driver to use dev_groups
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Jul 2019 12:43:45 +0000 (14:43 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Aug 2019 11:23:14 +0000 (13:23 +0200)
Platform drivers now have the option to have the platform core create
and remove any needed sysfs attribute files.  So take advantage of that
and do not register "by hand" a lid sysfs file.

Cc: Darren Hart <dvhart@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: platform-driver-x86@vger.kernel.org
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20190731124349.4474-7-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/platform/olpc/olpc-xo1-sci.c

index 25ce1b3..99a28ce 100644 (file)
@@ -157,6 +157,12 @@ static ssize_t lid_wake_mode_set(struct device *dev,
 static DEVICE_ATTR(lid_wake_mode, S_IWUSR | S_IRUGO, lid_wake_mode_show,
                   lid_wake_mode_set);
 
+static struct attribute *lid_attrs[] = {
+       &dev_attr_lid_wake_mode.attr,
+       NULL,
+};
+ATTRIBUTE_GROUPS(lid);
+
 /*
  * Process all items in the EC's SCI queue.
  *
@@ -510,17 +516,8 @@ static int setup_lid_switch(struct platform_device *pdev)
                goto err_register;
        }
 
-       r = device_create_file(&lid_switch_idev->dev, &dev_attr_lid_wake_mode);
-       if (r) {
-               dev_err(&pdev->dev, "failed to create wake mode attr: %d\n", r);
-               goto err_create_attr;
-       }
-
        return 0;
 
-err_create_attr:
-       input_unregister_device(lid_switch_idev);
-       lid_switch_idev = NULL;
 err_register:
        input_free_device(lid_switch_idev);
        return r;
@@ -528,7 +525,6 @@ err_register:
 
 static void free_lid_switch(void)
 {
-       device_remove_file(&lid_switch_idev->dev, &dev_attr_lid_wake_mode);
        input_unregister_device(lid_switch_idev);
 }
 
@@ -624,6 +620,7 @@ static int xo1_sci_remove(struct platform_device *pdev)
 static struct platform_driver xo1_sci_driver = {
        .driver = {
                .name = "olpc-xo1-sci-acpi",
+               .dev_groups = lid_groups,
        },
        .probe = xo1_sci_probe,
        .remove = xo1_sci_remove,