ACPI: platform_profile: Improve platform_profile_unregister()
JIRA: https://issues.redhat.com/browse/RHEL-105420 commit bb519cf6113473c09d571e555137a36d7e2c8566 Author: Kurt Borja <kuurtb@gmail.com> Date: Wed Feb 12 14:03:08 2025 -0500 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> Signed-off-by: David Arcari <darcari@redhat.com>
This commit is contained in:
parent
c455ea5f53
commit
e32456d5d6
|
@ -569,24 +569,23 @@ EXPORT_SYMBOL_GPL(platform_profile_register);
|
|||
/**
|
||||
* platform_profile_remove - Unregisters a platform profile class device
|
||||
* @dev: Class device
|
||||
*
|
||||
* Return: 0
|
||||
*/
|
||||
int platform_profile_remove(struct device *dev)
|
||||
void platform_profile_remove(struct device *dev)
|
||||
{
|
||||
struct platform_profile_handler *pprof = to_pprof_handler(dev);
|
||||
int id;
|
||||
struct platform_profile_handler *pprof;
|
||||
|
||||
if (IS_ERR_OR_NULL(dev))
|
||||
return;
|
||||
|
||||
pprof = to_pprof_handler(dev);
|
||||
|
||||
guard(mutex)(&profile_lock);
|
||||
|
||||
id = pprof->minor;
|
||||
ida_free(&platform_profile_ida, pprof->minor);
|
||||
device_unregister(&pprof->dev);
|
||||
ida_free(&platform_profile_ida, id);
|
||||
|
||||
sysfs_notify(acpi_kobj, NULL, "platform_profile");
|
||||
|
||||
sysfs_update_group(acpi_kobj, &platform_profile_group);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(platform_profile_remove);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ struct platform_profile_ops {
|
|||
struct device *platform_profile_register(struct device *dev, const char *name,
|
||||
void *drvdata,
|
||||
const struct platform_profile_ops *ops);
|
||||
int platform_profile_remove(struct device *dev);
|
||||
void platform_profile_remove(struct device *dev);
|
||||
struct device *devm_platform_profile_register(struct device *dev, const char *name,
|
||||
void *drvdata,
|
||||
const struct platform_profile_ops *ops);
|
||||
|
|
Loading…
Reference in New Issue