Files
linux/drivers/platform/x86/firmware_attributes_class.c
Thomas Weißschuh b36faa8328 platform/x86: firmware_attributes_class: Simplify API
[ Upstream commit d03cfde56f ]

The module core already guarantees that a module can only be unloaded
after all other modules using its symbols have been unloaded.
As it's already the responsibility of the drivers using
firmware_attributes_class to clean up their devices before unloading,
the lifetime of the firmware_attributes_class can be bound to the
lifetime of the module.
This enables the direct usage of firmware_attributes_class from the
drivers, without having to go through the lifecycle functions,
leading to simplifications for both the subsystem and its users.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Link: https://lore.kernel.org/r/20250104-firmware-attributes-simplify-v1-2-949f9709e405@weissschuh.net
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Stable-dep-of: 5ff1fbb305 ("platform/x86: think-lmi: Fix class device unregistration")
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-07-10 16:04:50 +02:00

41 lines
982 B
C

// SPDX-License-Identifier: GPL-2.0-or-later
/* Firmware attributes class helper module */
#include <linux/module.h>
#include "firmware_attributes_class.h"
const struct class firmware_attributes_class = {
.name = "firmware-attributes",
};
EXPORT_SYMBOL_GPL(firmware_attributes_class);
static __init int fw_attributes_class_init(void)
{
return class_register(&firmware_attributes_class);
}
module_init(fw_attributes_class_init);
static __exit void fw_attributes_class_exit(void)
{
class_unregister(&firmware_attributes_class);
}
module_exit(fw_attributes_class_exit);
int fw_attributes_class_get(const struct class **fw_attr_class)
{
*fw_attr_class = &firmware_attributes_class;
return 0;
}
EXPORT_SYMBOL_GPL(fw_attributes_class_get);
int fw_attributes_class_put(void)
{
return 0;
}
EXPORT_SYMBOL_GPL(fw_attributes_class_put);
MODULE_AUTHOR("Mark Pearson <markpearson@lenovo.com>");
MODULE_DESCRIPTION("Firmware attributes class helper module");
MODULE_LICENSE("GPL");