* [PATCH 0/2] video: backlight: constify struct class usage @ 2024-03-05 12:21 Ricardo B. Marliere 2024-03-05 12:21 ` [PATCH 1/2] video: backlight: make backlight_class constant Ricardo B. Marliere ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Ricardo B. Marliere @ 2024-03-05 12:21 UTC (permalink / raw) To: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller Cc: dri-devel, linux-fbdev, linux-kernel, Ricardo B. Marliere, Greg Kroah-Hartman This is a simple and straight forward cleanup series that aims to make the class structures in backlight constant. This has been possible since 2023 [1]. [1]: https://lore.kernel.org/all/2023040248-customary-release-4aec@gregkh/ Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> --- Ricardo B. Marliere (2): video: backlight: make backlight_class constant video: backlight: lcd: make lcd_class constant drivers/video/backlight/backlight.c | 29 ++++++++++++++++------------- drivers/video/backlight/lcd.c | 23 +++++++++++++---------- 2 files changed, 29 insertions(+), 23 deletions(-) --- base-commit: cd1995b6ac7384149ad755b74e3c3eb25195ab81 change-id: 20240305-class_cleanup-backlight-62b91c38005e Best regards, -- Ricardo B. Marliere <ricardo@marliere.net> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] video: backlight: make backlight_class constant 2024-03-05 12:21 [PATCH 0/2] video: backlight: constify struct class usage Ricardo B. Marliere @ 2024-03-05 12:21 ` Ricardo B. Marliere 2024-03-25 10:50 ` Daniel Thompson 2024-03-05 12:21 ` [PATCH 2/2] video: backlight: lcd: make lcd_class constant Ricardo B. Marliere 2024-03-28 11:41 ` [PATCH 0/2] video: backlight: constify struct class usage Lee Jones 2 siblings, 1 reply; 10+ messages in thread From: Ricardo B. Marliere @ 2024-03-05 12:21 UTC (permalink / raw) To: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller Cc: dri-devel, linux-fbdev, linux-kernel, Ricardo B. Marliere, Greg Kroah-Hartman Since commit 43a7206b0963 ("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 backlight_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> --- drivers/video/backlight/backlight.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 86e1cdc8e369..d2feaebfd84a 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -317,8 +317,6 @@ static ssize_t scale_show(struct device *dev, } static DEVICE_ATTR_RO(scale); -static struct class *backlight_class; - #ifdef CONFIG_PM_SLEEP static int backlight_suspend(struct device *dev) { @@ -369,6 +367,12 @@ static struct attribute *bl_device_attrs[] = { }; ATTRIBUTE_GROUPS(bl_device); +static const struct class backlight_class = { + .name = "backlight", + .dev_groups = bl_device_groups, + .pm = &backlight_class_dev_pm_ops, +}; + /** * backlight_force_update - tell the backlight subsystem that hardware state * has changed @@ -418,7 +422,7 @@ struct backlight_device *backlight_device_register(const char *name, mutex_init(&new_bd->update_lock); mutex_init(&new_bd->ops_lock); - new_bd->dev.class = backlight_class; + new_bd->dev.class = &backlight_class; new_bd->dev.parent = parent; new_bd->dev.release = bl_device_release; dev_set_name(&new_bd->dev, "%s", name); @@ -510,7 +514,7 @@ struct backlight_device *backlight_device_get_by_name(const char *name) { struct device *dev; - dev = class_find_device_by_name(backlight_class, name); + dev = class_find_device_by_name(&backlight_class, name); return dev ? to_backlight_device(dev) : NULL; } @@ -678,7 +682,7 @@ struct backlight_device *of_find_backlight_by_node(struct device_node *node) { struct device *dev; - dev = class_find_device(backlight_class, NULL, node, of_parent_match); + dev = class_find_device(&backlight_class, NULL, node, of_parent_match); return dev ? to_backlight_device(dev) : NULL; } @@ -746,20 +750,19 @@ EXPORT_SYMBOL(devm_of_find_backlight); static void __exit backlight_class_exit(void) { - class_destroy(backlight_class); + class_unregister(&backlight_class); } static int __init backlight_class_init(void) { - backlight_class = class_create("backlight"); - if (IS_ERR(backlight_class)) { - pr_warn("Unable to create backlight class; errno = %ld\n", - PTR_ERR(backlight_class)); - return PTR_ERR(backlight_class); + int ret; + + ret = class_register(&backlight_class); + if (ret) { + pr_warn("Unable to create backlight class; errno = %d\n", ret); + return ret; } - backlight_class->dev_groups = bl_device_groups; - backlight_class->pm = &backlight_class_dev_pm_ops; INIT_LIST_HEAD(&backlight_dev_list); mutex_init(&backlight_dev_list_mutex); BLOCKING_INIT_NOTIFIER_HEAD(&backlight_notifier); -- 2.43.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] video: backlight: make backlight_class constant 2024-03-05 12:21 ` [PATCH 1/2] video: backlight: make backlight_class constant Ricardo B. Marliere @ 2024-03-25 10:50 ` Daniel Thompson 0 siblings, 0 replies; 10+ messages in thread From: Daniel Thompson @ 2024-03-25 10:50 UTC (permalink / raw) To: Ricardo B. Marliere Cc: Lee Jones, Jingoo Han, Helge Deller, dri-devel, linux-fbdev, linux-kernel, Greg Kroah-Hartman On Tue, Mar 05, 2024 at 09:21:17AM -0300, Ricardo B. Marliere wrote: > Since commit 43a7206b0963 ("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 backlight_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> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Daniel. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] video: backlight: lcd: make lcd_class constant 2024-03-05 12:21 [PATCH 0/2] video: backlight: constify struct class usage Ricardo B. Marliere 2024-03-05 12:21 ` [PATCH 1/2] video: backlight: make backlight_class constant Ricardo B. Marliere @ 2024-03-05 12:21 ` Ricardo B. Marliere 2024-03-25 10:51 ` Daniel Thompson 2024-03-28 11:41 ` [PATCH 0/2] video: backlight: constify struct class usage Lee Jones 2 siblings, 1 reply; 10+ messages in thread From: Ricardo B. Marliere @ 2024-03-05 12:21 UTC (permalink / raw) To: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller Cc: dri-devel, linux-fbdev, linux-kernel, Ricardo B. Marliere, Greg Kroah-Hartman Since commit 43a7206b0963 ("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> --- drivers/video/backlight/lcd.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c index 77c5cb2a44e2..ba4771cbd781 100644 --- a/drivers/video/backlight/lcd.c +++ b/drivers/video/backlight/lcd.c @@ -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; } -- 2.43.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] video: backlight: lcd: make lcd_class constant 2024-03-05 12:21 ` [PATCH 2/2] video: backlight: lcd: make lcd_class constant Ricardo B. Marliere @ 2024-03-25 10:51 ` Daniel Thompson 0 siblings, 0 replies; 10+ messages in thread From: Daniel Thompson @ 2024-03-25 10:51 UTC (permalink / raw) To: Ricardo B. Marliere Cc: Lee Jones, Jingoo Han, Helge Deller, dri-devel, linux-fbdev, linux-kernel, Greg Kroah-Hartman On Tue, Mar 05, 2024 at 09:21:18AM -0300, Ricardo B. Marliere wrote: > Since commit 43a7206b0963 ("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> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Daniel. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] video: backlight: constify struct class usage 2024-03-05 12:21 [PATCH 0/2] video: backlight: constify struct class usage Ricardo B. Marliere 2024-03-05 12:21 ` [PATCH 1/2] video: backlight: make backlight_class constant Ricardo B. Marliere 2024-03-05 12:21 ` [PATCH 2/2] video: backlight: lcd: make lcd_class constant Ricardo B. Marliere @ 2024-03-28 11:41 ` Lee Jones 2024-03-28 12:01 ` Greg Kroah-Hartman 2 siblings, 1 reply; 10+ messages in thread From: Lee Jones @ 2024-03-28 11:41 UTC (permalink / raw) To: Ricardo B. Marliere Cc: Daniel Thompson, Jingoo Han, Helge Deller, dri-devel, linux-fbdev, linux-kernel, Greg Kroah-Hartman On Tue, 05 Mar 2024, Ricardo B. Marliere wrote: > This is a simple and straight forward cleanup series that aims to make the > class structures in backlight constant. This has been possible since 2023 > [1]. > > [1]: https://lore.kernel.org/all/2023040248-customary-release-4aec@gregkh/ > > Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> > --- > Ricardo B. Marliere (2): > video: backlight: make backlight_class constant > video: backlight: lcd: make lcd_class constant > > drivers/video/backlight/backlight.c | 29 ++++++++++++++++------------- > drivers/video/backlight/lcd.c | 23 +++++++++++++---------- > 2 files changed, 29 insertions(+), 23 deletions(-) No longer apply. Please rebase on top of v6.9-rc1 or for-backlight-next. -- Lee Jones [李琼斯] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] video: backlight: constify struct class usage 2024-03-28 11:41 ` [PATCH 0/2] video: backlight: constify struct class usage Lee Jones @ 2024-03-28 12:01 ` Greg Kroah-Hartman 2024-03-28 12:46 ` Ricardo B. Marliere 0 siblings, 1 reply; 10+ messages in thread From: Greg Kroah-Hartman @ 2024-03-28 12:01 UTC (permalink / raw) To: Lee Jones Cc: Ricardo B. Marliere, Daniel Thompson, Jingoo Han, Helge Deller, dri-devel, linux-fbdev, linux-kernel On Thu, Mar 28, 2024 at 11:41:31AM +0000, Lee Jones wrote: > On Tue, 05 Mar 2024, Ricardo B. Marliere wrote: > > > This is a simple and straight forward cleanup series that aims to make the > > class structures in backlight constant. This has been possible since 2023 > > [1]. > > > > [1]: https://lore.kernel.org/all/2023040248-customary-release-4aec@gregkh/ > > > > Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> > > --- > > Ricardo B. Marliere (2): > > video: backlight: make backlight_class constant > > video: backlight: lcd: make lcd_class constant > > > > drivers/video/backlight/backlight.c | 29 ++++++++++++++++------------- > > drivers/video/backlight/lcd.c | 23 +++++++++++++---------- > > 2 files changed, 29 insertions(+), 23 deletions(-) > > No longer apply. > > Please rebase on top of v6.9-rc1 or for-backlight-next. As I already had this in my local tree, I've sent out a v2 at: https://lore.kernel.org/lkml/2024032805-putdown-mushy-a0f9@gregkh/ thanks, greg k-h ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] video: backlight: constify struct class usage 2024-03-28 12:01 ` Greg Kroah-Hartman @ 2024-03-28 12:46 ` Ricardo B. Marliere 2024-03-28 16:49 ` Greg Kroah-Hartman 0 siblings, 1 reply; 10+ messages in thread From: Ricardo B. Marliere @ 2024-03-28 12:46 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller, dri-devel, linux-fbdev, linux-kernel On 28 Mar 13:01, Greg Kroah-Hartman wrote: > On Thu, Mar 28, 2024 at 11:41:31AM +0000, Lee Jones wrote: > > On Tue, 05 Mar 2024, Ricardo B. Marliere wrote: > > > > > This is a simple and straight forward cleanup series that aims to make the > > > class structures in backlight constant. This has been possible since 2023 > > > [1]. > > > > > > [1]: https://lore.kernel.org/all/2023040248-customary-release-4aec@gregkh/ > > > > > > Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> > > > --- > > > Ricardo B. Marliere (2): > > > video: backlight: make backlight_class constant > > > video: backlight: lcd: make lcd_class constant > > > > > > drivers/video/backlight/backlight.c | 29 ++++++++++++++++------------- > > > drivers/video/backlight/lcd.c | 23 +++++++++++++---------- > > > 2 files changed, 29 insertions(+), 23 deletions(-) > > > > No longer apply. > > > > Please rebase on top of v6.9-rc1 or for-backlight-next. > > As I already had this in my local tree, I've sent out a v2 at: > https://lore.kernel.org/lkml/2024032805-putdown-mushy-a0f9@gregkh/ Thank you Greg. I will see what is left to be made const for -next. > > thanks, > > greg k-h ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] video: backlight: constify struct class usage 2024-03-28 12:46 ` Ricardo B. Marliere @ 2024-03-28 16:49 ` Greg Kroah-Hartman 2024-03-28 17:43 ` Ricardo B. Marliere 0 siblings, 1 reply; 10+ messages in thread From: Greg Kroah-Hartman @ 2024-03-28 16:49 UTC (permalink / raw) To: Ricardo B. Marliere Cc: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller, dri-devel, linux-fbdev, linux-kernel On Thu, Mar 28, 2024 at 09:46:01AM -0300, Ricardo B. Marliere wrote: > On 28 Mar 13:01, Greg Kroah-Hartman wrote: > > On Thu, Mar 28, 2024 at 11:41:31AM +0000, Lee Jones wrote: > > > On Tue, 05 Mar 2024, Ricardo B. Marliere wrote: > > > > > > > This is a simple and straight forward cleanup series that aims to make the > > > > class structures in backlight constant. This has been possible since 2023 > > > > [1]. > > > > > > > > [1]: https://lore.kernel.org/all/2023040248-customary-release-4aec@gregkh/ > > > > > > > > Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> > > > > --- > > > > Ricardo B. Marliere (2): > > > > video: backlight: make backlight_class constant > > > > video: backlight: lcd: make lcd_class constant > > > > > > > > drivers/video/backlight/backlight.c | 29 ++++++++++++++++------------- > > > > drivers/video/backlight/lcd.c | 23 +++++++++++++---------- > > > > 2 files changed, 29 insertions(+), 23 deletions(-) > > > > > > No longer apply. > > > > > > Please rebase on top of v6.9-rc1 or for-backlight-next. > > > > As I already had this in my local tree, I've sent out a v2 at: > > https://lore.kernel.org/lkml/2024032805-putdown-mushy-a0f9@gregkh/ > > Thank you Greg. I will see what is left to be made const for -next. Many of your patches were not picked up for -rc1, I'll be taking a bunch of them into my tree "soon" as that usually means the subsystem isn't as active. thanks, greg k-h ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] video: backlight: constify struct class usage 2024-03-28 16:49 ` Greg Kroah-Hartman @ 2024-03-28 17:43 ` Ricardo B. Marliere 0 siblings, 0 replies; 10+ messages in thread From: Ricardo B. Marliere @ 2024-03-28 17:43 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller, dri-devel, linux-fbdev, linux-kernel On 28 Mar 17:49, Greg Kroah-Hartman wrote: > On Thu, Mar 28, 2024 at 09:46:01AM -0300, Ricardo B. Marliere wrote: > > On 28 Mar 13:01, Greg Kroah-Hartman wrote: > > > On Thu, Mar 28, 2024 at 11:41:31AM +0000, Lee Jones wrote: > > > > On Tue, 05 Mar 2024, Ricardo B. Marliere wrote: > > > > > > > > > This is a simple and straight forward cleanup series that aims to make the > > > > > class structures in backlight constant. This has been possible since 2023 > > > > > [1]. > > > > > > > > > > [1]: https://lore.kernel.org/all/2023040248-customary-release-4aec@gregkh/ > > > > > > > > > > Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> > > > > > --- > > > > > Ricardo B. Marliere (2): > > > > > video: backlight: make backlight_class constant > > > > > video: backlight: lcd: make lcd_class constant > > > > > > > > > > drivers/video/backlight/backlight.c | 29 ++++++++++++++++------------- > > > > > drivers/video/backlight/lcd.c | 23 +++++++++++++---------- > > > > > 2 files changed, 29 insertions(+), 23 deletions(-) > > > > > > > > No longer apply. > > > > > > > > Please rebase on top of v6.9-rc1 or for-backlight-next. > > > > > > As I already had this in my local tree, I've sent out a v2 at: > > > https://lore.kernel.org/lkml/2024032805-putdown-mushy-a0f9@gregkh/ > > > > Thank you Greg. I will see what is left to be made const for -next. > > Many of your patches were not picked up for -rc1, I'll be taking a bunch > of them into my tree "soon" as that usually means the subsystem isn't as > active. Yup, I was keeping them in my inbox so as to resend but if you could pick them that would be great! Cheers, > > thanks, > > greg k-h ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-03-28 17:43 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-03-05 12:21 [PATCH 0/2] video: backlight: constify struct class usage Ricardo B. Marliere 2024-03-05 12:21 ` [PATCH 1/2] video: backlight: make backlight_class constant Ricardo B. Marliere 2024-03-25 10:50 ` Daniel Thompson 2024-03-05 12:21 ` [PATCH 2/2] video: backlight: lcd: make lcd_class constant Ricardo B. Marliere 2024-03-25 10:51 ` Daniel Thompson 2024-03-28 11:41 ` [PATCH 0/2] video: backlight: constify struct class usage Lee Jones 2024-03-28 12:01 ` Greg Kroah-Hartman 2024-03-28 12:46 ` Ricardo B. Marliere 2024-03-28 16:49 ` Greg Kroah-Hartman 2024-03-28 17:43 ` Ricardo B. Marliere
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).