Input: cyapa - use device core to create driver-specific device attributes
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 29 Jul 2023 00:51:11 +0000 (17:51 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 6 Sep 2023 21:23:46 +0000 (14:23 -0700)
Instead of creating driver-specific device attributes with
devm_device_add_group() have device core do this by setting up dev_groups
pointer in the driver structure.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20230729005133.1095051-2-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/mouse/cyapa.c

index 05851bc32541f7c6917ed1ae9e434234baf9e5f0..a84098448f5b94d607dc5b86ceb5f04618783179 100644 (file)
@@ -1223,7 +1223,7 @@ static DEVICE_ATTR(baseline, S_IRUGO, cyapa_show_baseline, NULL);
 static DEVICE_ATTR(calibrate, S_IWUSR, NULL, cyapa_calibrate_store);
 static DEVICE_ATTR(mode, S_IRUGO, cyapa_show_mode, NULL);
 
-static struct attribute *cyapa_sysfs_entries[] = {
+static struct attribute *cyapa_attrs[] = {
        &dev_attr_firmware_version.attr,
        &dev_attr_product_id.attr,
        &dev_attr_update_fw.attr,
@@ -1232,10 +1232,7 @@ static struct attribute *cyapa_sysfs_entries[] = {
        &dev_attr_mode.attr,
        NULL,
 };
-
-static const struct attribute_group cyapa_sysfs_group = {
-       .attrs = cyapa_sysfs_entries,
-};
+ATTRIBUTE_GROUPS(cyapa);
 
 static void cyapa_disable_regulator(void *data)
 {
@@ -1302,12 +1299,6 @@ static int cyapa_probe(struct i2c_client *client)
                return error;
        }
 
-       error = devm_device_add_group(dev, &cyapa_sysfs_group);
-       if (error) {
-               dev_err(dev, "failed to create sysfs entries: %d\n", error);
-               return error;
-       }
-
        error = cyapa_prepare_wakeup_controls(cyapa);
        if (error) {
                dev_err(dev, "failed to prepare wakeup controls: %d\n", error);
@@ -1484,6 +1475,7 @@ MODULE_DEVICE_TABLE(of, cyapa_of_match);
 static struct i2c_driver cyapa_driver = {
        .driver = {
                .name = "cyapa",
+               .dev_groups = cyapa_groups,
                .pm = pm_ptr(&cyapa_pm_ops),
                .acpi_match_table = ACPI_PTR(cyapa_acpi_id),
                .of_match_table = of_match_ptr(cyapa_of_match),