X86 platform drivers
 help / color / mirror / Atom feed
* [PATCH] platform/x86/amd/hsmp: Remove devm_* call for sysfs and use dev_groups
@ 2024-04-10 12:17 Suma Hegde
  2024-04-10 12:24 ` Hans de Goede
  0 siblings, 1 reply; 3+ messages in thread
From: Suma Hegde @ 2024-04-10 12:17 UTC (permalink / raw)
  To: platform-driver-x86
  Cc: ilpo.jarvinen, hdegoede, Suma Hegde, Naveen Krishna Chatradhi

Instead of manually calling devm_device_add_groups(), use
dev_groups.

Signed-off-by: Suma Hegde <suma.hegde@amd.com>
Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
---
This is based on the suggestions from Hans de Goede when Greg
Kroah-Hartman had suggested to switch to use device_add_groups().

 drivers/platform/x86/amd/hsmp.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/amd/hsmp.c b/drivers/platform/x86/amd/hsmp.c
index 1927be901108..d6b43d8e798b 100644
--- a/drivers/platform/x86/amd/hsmp.c
+++ b/drivers/platform/x86/amd/hsmp.c
@@ -693,15 +693,29 @@ static int hsmp_create_non_acpi_sysfs_if(struct device *dev)
 		hsmp_create_attr_list(attr_grp, dev, i);
 	}
 
-	return devm_device_add_groups(dev, hsmp_attr_grps);
+	dev->driver->dev_groups = hsmp_attr_grps;
+
+	return 0;
 }
 
+/* Number of sysfs groups to be created in case of ACPI probing */
+#define NUM_HSMP_SYSFS_GRPS	1
+
 static int hsmp_create_acpi_sysfs_if(struct device *dev)
 {
+	const struct attribute_group **hsmp_attr_grps;
 	struct attribute_group *attr_grp;
 	u16 sock_ind;
 	int ret;
 
+	/* Null terminated list of attribute groups */
+	hsmp_attr_grps = devm_kcalloc(dev, NUM_HSMP_SYSFS_GRPS + 1,
+				      sizeof(*hsmp_attr_grps),
+				      GFP_KERNEL);
+
+	if (!hsmp_attr_grps)
+		return -ENOMEM;
+
 	attr_grp = devm_kzalloc(dev, sizeof(struct attribute_group), GFP_KERNEL);
 	if (!attr_grp)
 		return -ENOMEM;
@@ -716,7 +730,12 @@ static int hsmp_create_acpi_sysfs_if(struct device *dev)
 	if (ret)
 		return ret;
 
-	return devm_device_add_group(dev, attr_grp);
+	hsmp_attr_grps[0] = attr_grp;
+	hsmp_attr_grps[1] = NULL;
+
+	dev->driver->dev_groups	= hsmp_attr_grps;
+
+	return 0;
 }
 
 static int hsmp_cache_proto_ver(u16 sock_ind)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-10 12:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-10 12:17 [PATCH] platform/x86/amd/hsmp: Remove devm_* call for sysfs and use dev_groups Suma Hegde
2024-04-10 12:24 ` Hans de Goede
2024-04-10 12:54   ` Hegde, Suma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox