Skip to contentSkip to conversation

HID: playstation: convert to use dev_groups

PATCH In review Greg Kroah-Hartman 3 participants 4 messages Aug 4, 2022 – Aug 25, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: playstation: convert to use dev_groups

There is no need for a driver to individually add/create device groups, the driver core will do it automatically for you. Convert the hid-playstation driver to use the dev_groups pointer instead of manually calling the driver core to create the group and have it be cleaned up later on by the devm core.

Cc Roderick Colenbrander <[email protected]>
Cc Jiri Kosina <[email protected]>
Cc Benjamin Tissoires <[email protected]>
---
 drivers/hid/hid-playstation.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/hid/hid-playstation.c +5 -11
index b1b5721b5d8f..40050eb85c0a 100644
@@ -692,15 +692,12 @@ static ssize_t hardware_version_show(struct device *dev,
 
 static DEVICE_ATTR_RO(hardware_version);
 
-static struct attribute *ps_device_attributes[] = {
+static struct attribute *ps_device_attrs[] = {
 	&dev_attr_firmware_version.attr,
 	&dev_attr_hardware_version.attr,
 	NULL
 };
-
-static const struct attribute_group ps_device_attribute_group = {
-	.attrs = ps_device_attributes,
-};
+ATTRIBUTE_GROUPS(ps_device);
 
 static int dualsense_get_calibration_data(struct dualsense *ds)
 {
@@ -1448,12 +1445,6 @@ static int ps_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		}
 	}
 
-	ret = devm_device_add_group(&hdev->dev, &ps_device_attribute_group);
-	if (ret) {
-		hid_err(hdev, "Failed to register sysfs nodes.\n");
-		goto err_close;
-	}
-
 	return ret;
 
 err_close:
@@ -1487,6 +1478,9 @@ static struct hid_driver ps_driver = {
 	.probe		= ps_probe,
 	.remove		= ps_remove,
 	.raw_event	= ps_raw_event,
+	.driver = {
+		.dev_groups = ps_device_groups,
+	},
 };
 
 static int __init ps_init(void)
Signature · 1 line
2.37.1
Acked-by on v1 1/1
#1 lore raw

Hi Greg,

Thanks for the patch. It looks good and confirmed it working properly. (Replying from personal email... corporate email systems *Exchange* don't work well with GIT)

Thanks,
Roderick Colenbrander

Quoted 65 lines · Greg Kroah-Hartman

There is no need for a driver to individually add/create device groups, the driver core will do it automatically for you. Convert the hid-playstation driver to use the dev_groups pointer instead of manually calling the driver core to create the group and have it be cleaned up later on by the devm core.

Cc Roderick Colenbrander <[email protected]>
Cc Jiri Kosina <[email protected]>
Cc Benjamin Tissoires <[email protected]>
---
 drivers/hid/hid-playstation.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/hid/hid-playstation.c +5 -12
index b1b5721b5d8f..40050eb85c0a 100644
@@ -692,15 +692,12 @@ static ssize_t hardware_version_show(struct device *dev,
 
 static DEVICE_ATTR_RO(hardware_version);
 
-static struct attribute *ps_device_attributes[] = {
+static struct attribute *ps_device_attrs[] = {
        &dev_attr_firmware_version.attr,
        &dev_attr_hardware_version.attr,
        NULL
 };
-
-static const struct attribute_group ps_device_attribute_group = {
-       .attrs = ps_device_attributes,
-};
+ATTRIBUTE_GROUPS(ps_device);
 
 static int dualsense_get_calibration_data(struct dualsense *ds)
 {
@@ -1448,12 +1445,6 @@ static int ps_probe(struct hid_device *hdev, const struct hid_device_id *id)
                }
        }
 
-       ret = devm_device_add_group(&hdev->dev, &ps_device_attribute_group);
-       if (ret) {
-               hid_err(hdev, "Failed to register sysfs nodes.\n");
-               goto err_close;
-       }
-
        return ret;
 
 err_close:
@@ -1487,6 +1478,9 @@ static struct hid_driver ps_driver = {
        .probe          = ps_probe,
        .remove         = ps_remove,
        .raw_event      = ps_raw_event,
+       .driver = {
+               .dev_groups = ps_device_groups,
+       },
 };
 
 static int __init ps_init(void)
--

2.37.1

maintainer
#2 lore raw
Quoted 7 lines · Roderick Colenbrander

Hi Greg,

Thanks for the patch. It looks good and confirmed it working properly. (Replying from personal email... corporate email systems *Exchange* don't work well with GIT)

Sorry for the delay, was off for a bit. Queued in for-6.1/sony.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs
#3 lore raw
Quoted 11 lines · Jiri Kosina
Quoted 7 lines · Roderick Colenbrander

Hi Greg,

Thanks for the patch. It looks good and confirmed it working properly. (Replying from personal email... corporate email systems *Exchange* don't work well with GIT)

Sorry for the delay, was off for a bit. Queued in for-6.1/sony.

No worries, thanks!