Skip to content

Commit bb519cf

Browse files
kuu-rtrafaeljw
authored andcommitted
ACPI: platform_profile: Improve platform_profile_unregister()
Drivers usually call this method on error/exit paths and do not check for it's return value, which is always 0 anyway, so make it void. This is safe to do as currently all drivers use devm_platform_profile_register(). While at it, improve the style and make the function safer by checking for IS_ERR_OR_NULL before dereferencing the device pointer. Signed-off-by: Kurt Borja <kuurtb@gmail.com> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca> Link: https://patch.msgid.link/20250212190308.21209-1-kuurtb@gmail.com [ rjw: Minor changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent dd4f730 commit bb519cf

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

drivers/acpi/platform_profile.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -569,24 +569,23 @@ EXPORT_SYMBOL_GPL(platform_profile_register);
569569
/**
570570
* platform_profile_remove - Unregisters a platform profile class device
571571
* @dev: Class device
572-
*
573-
* Return: 0
574572
*/
575-
int platform_profile_remove(struct device *dev)
573+
void platform_profile_remove(struct device *dev)
576574
{
577-
struct platform_profile_handler *pprof = to_pprof_handler(dev);
578-
int id;
575+
struct platform_profile_handler *pprof;
576+
577+
if (IS_ERR_OR_NULL(dev))
578+
return;
579+
580+
pprof = to_pprof_handler(dev);
581+
579582
guard(mutex)(&profile_lock);
580583

581-
id = pprof->minor;
584+
ida_free(&platform_profile_ida, pprof->minor);
582585
device_unregister(&pprof->dev);
583-
ida_free(&platform_profile_ida, id);
584586

585587
sysfs_notify(acpi_kobj, NULL, "platform_profile");
586-
587588
sysfs_update_group(acpi_kobj, &platform_profile_group);
588-
589-
return 0;
590589
}
591590
EXPORT_SYMBOL_GPL(platform_profile_remove);
592591

include/linux/platform_profile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct platform_profile_ops {
4747
struct device *platform_profile_register(struct device *dev, const char *name,
4848
void *drvdata,
4949
const struct platform_profile_ops *ops);
50-
int platform_profile_remove(struct device *dev);
50+
void platform_profile_remove(struct device *dev);
5151
struct device *devm_platform_profile_register(struct device *dev, const char *name,
5252
void *drvdata,
5353
const struct platform_profile_ops *ops);

0 commit comments

Comments
 (0)