mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 05:39:42 -04:00
backlight: lcd: Make lcd_class constant
Since commit 43a7206b09 ("driver core: class: make class_register() take
a const *"), the driver core allows for struct class to be in read-only
memory, so move the lcd_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at boot time.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Link: https://lore.kernel.org/r/2024032809-enchanted-conducive-3677@gregkh
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
committed by
Lee Jones
parent
cda12ba555
commit
717bbf03d2
@@ -159,8 +159,6 @@ static ssize_t max_contrast_show(struct device *dev,
|
||||
}
|
||||
static DEVICE_ATTR_RO(max_contrast);
|
||||
|
||||
static struct class *lcd_class;
|
||||
|
||||
static void lcd_device_release(struct device *dev)
|
||||
{
|
||||
struct lcd_device *ld = to_lcd_device(dev);
|
||||
@@ -175,6 +173,11 @@ static struct attribute *lcd_device_attrs[] = {
|
||||
};
|
||||
ATTRIBUTE_GROUPS(lcd_device);
|
||||
|
||||
static const struct class lcd_class = {
|
||||
.name = "lcd",
|
||||
.dev_groups = lcd_device_groups,
|
||||
};
|
||||
|
||||
/**
|
||||
* lcd_device_register - register a new object of lcd_device class.
|
||||
* @name: the name of the new object(must be the same as the name of the
|
||||
@@ -202,7 +205,7 @@ struct lcd_device *lcd_device_register(const char *name, struct device *parent,
|
||||
mutex_init(&new_ld->ops_lock);
|
||||
mutex_init(&new_ld->update_lock);
|
||||
|
||||
new_ld->dev.class = lcd_class;
|
||||
new_ld->dev.class = &lcd_class;
|
||||
new_ld->dev.parent = parent;
|
||||
new_ld->dev.release = lcd_device_release;
|
||||
dev_set_name(&new_ld->dev, "%s", name);
|
||||
@@ -318,19 +321,19 @@ EXPORT_SYMBOL(devm_lcd_device_unregister);
|
||||
|
||||
static void __exit lcd_class_exit(void)
|
||||
{
|
||||
class_destroy(lcd_class);
|
||||
class_unregister(&lcd_class);
|
||||
}
|
||||
|
||||
static int __init lcd_class_init(void)
|
||||
{
|
||||
lcd_class = class_create("lcd");
|
||||
if (IS_ERR(lcd_class)) {
|
||||
pr_warn("Unable to create backlight class; errno = %ld\n",
|
||||
PTR_ERR(lcd_class));
|
||||
return PTR_ERR(lcd_class);
|
||||
int ret;
|
||||
|
||||
ret = class_register(&lcd_class);
|
||||
if (ret) {
|
||||
pr_warn("Unable to create backlight class; errno = %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
lcd_class->dev_groups = lcd_device_groups;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user