Message ID | 20250109150731.110799-18-kuurtb@gmail.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers | show |
Series | Hide platform_profile_handler from consumers | expand |
On 1/9/2025 09:06, Kurt Borja wrote: > Remove parent device *dev from platform_profile_handler, as it's no > longer accessed directly. Rename class_dev -> dev. > > Signed-off-by: Kurt Borja <kuurtb@gmail.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> > --- > drivers/acpi/platform_profile.c | 25 ++++++++++++------------- > 1 file changed, 12 insertions(+), 13 deletions(-) > > diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c > index c7a867bd01df..8c79ecab8a6d 100644 > --- a/drivers/acpi/platform_profile.c > +++ b/drivers/acpi/platform_profile.c > @@ -11,14 +11,13 @@ > #include <linux/platform_profile.h> > #include <linux/sysfs.h> > > -#define to_pprof_handler(d) (container_of(d, struct platform_profile_handler, class_dev)) > +#define to_pprof_handler(d) (container_of(d, struct platform_profile_handler, dev)) > > static DEFINE_MUTEX(profile_lock); > > struct platform_profile_handler { > const char *name; > - struct device *dev; > - struct device class_dev; > + struct device dev; > int minor; > unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; > const struct platform_profile_ops *ops; > @@ -91,8 +90,8 @@ static int _notify_class_profile(struct device *dev, void *data) > struct platform_profile_handler *handler = to_pprof_handler(dev); > > lockdep_assert_held(&profile_lock); > - sysfs_notify(&handler->class_dev.kobj, NULL, "profile"); > - kobject_uevent(&handler->class_dev.kobj, KOBJ_CHANGE); > + sysfs_notify(&handler->dev.kobj, NULL, "profile"); > + kobject_uevent(&handler->dev.kobj, KOBJ_CHANGE); > > return 0; > } > @@ -518,18 +517,18 @@ struct device *platform_profile_register(struct device *dev, const char *name, > pprof->name = name; > pprof->ops = ops; > pprof->minor = minor; > - pprof->class_dev.class = &platform_profile_class; > - pprof->class_dev.parent = dev; > - dev_set_drvdata(&pprof->class_dev, drvdata); > - dev_set_name(&pprof->class_dev, "platform-profile-%d", pprof->minor); > - err = device_register(&pprof->class_dev); > + pprof->dev.class = &platform_profile_class; > + pprof->dev.parent = dev; > + dev_set_drvdata(&pprof->dev, drvdata); > + dev_set_name(&pprof->dev, "platform-profile-%d", pprof->minor); > + err = device_register(&pprof->dev); > if (err) { > - put_device(&no_free_ptr(pprof)->class_dev); > + put_device(&no_free_ptr(pprof)->dev); > goto cleanup_ida; > } > > /* After this point, device_unregister will free pprof on error */ > - ppdev = &no_free_ptr(pprof)->class_dev; > + ppdev = &no_free_ptr(pprof)->dev; > > sysfs_notify(acpi_kobj, NULL, "platform_profile"); > > @@ -556,7 +555,7 @@ int platform_profile_remove(struct device *dev) > guard(mutex)(&profile_lock); > > id = pprof->minor; > - device_unregister(&pprof->class_dev); > + device_unregister(&pprof->dev); > ida_free(&platform_profile_ida, id); > > sysfs_notify(acpi_kobj, NULL, "platform_profile");
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c7a867bd01df..8c79ecab8a6d 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -11,14 +11,13 @@ #include <linux/platform_profile.h> #include <linux/sysfs.h> -#define to_pprof_handler(d) (container_of(d, struct platform_profile_handler, class_dev)) +#define to_pprof_handler(d) (container_of(d, struct platform_profile_handler, dev)) static DEFINE_MUTEX(profile_lock); struct platform_profile_handler { const char *name; - struct device *dev; - struct device class_dev; + struct device dev; int minor; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; const struct platform_profile_ops *ops; @@ -91,8 +90,8 @@ static int _notify_class_profile(struct device *dev, void *data) struct platform_profile_handler *handler = to_pprof_handler(dev); lockdep_assert_held(&profile_lock); - sysfs_notify(&handler->class_dev.kobj, NULL, "profile"); - kobject_uevent(&handler->class_dev.kobj, KOBJ_CHANGE); + sysfs_notify(&handler->dev.kobj, NULL, "profile"); + kobject_uevent(&handler->dev.kobj, KOBJ_CHANGE); return 0; } @@ -518,18 +517,18 @@ struct device *platform_profile_register(struct device *dev, const char *name, pprof->name = name; pprof->ops = ops; pprof->minor = minor; - pprof->class_dev.class = &platform_profile_class; - pprof->class_dev.parent = dev; - dev_set_drvdata(&pprof->class_dev, drvdata); - dev_set_name(&pprof->class_dev, "platform-profile-%d", pprof->minor); - err = device_register(&pprof->class_dev); + pprof->dev.class = &platform_profile_class; + pprof->dev.parent = dev; + dev_set_drvdata(&pprof->dev, drvdata); + dev_set_name(&pprof->dev, "platform-profile-%d", pprof->minor); + err = device_register(&pprof->dev); if (err) { - put_device(&no_free_ptr(pprof)->class_dev); + put_device(&no_free_ptr(pprof)->dev); goto cleanup_ida; } /* After this point, device_unregister will free pprof on error */ - ppdev = &no_free_ptr(pprof)->class_dev; + ppdev = &no_free_ptr(pprof)->dev; sysfs_notify(acpi_kobj, NULL, "platform_profile"); @@ -556,7 +555,7 @@ int platform_profile_remove(struct device *dev) guard(mutex)(&profile_lock); id = pprof->minor; - device_unregister(&pprof->class_dev); + device_unregister(&pprof->dev); ida_free(&platform_profile_ida, id); sysfs_notify(acpi_kobj, NULL, "platform_profile");
Remove parent device *dev from platform_profile_handler, as it's no longer accessed directly. Rename class_dev -> dev. Signed-off-by: Kurt Borja <kuurtb@gmail.com> --- drivers/acpi/platform_profile.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)