* [PATCH] gpio: gpiolib: make gpio_bus_type const
@ 2024-02-04 16:29 Ricardo B. Marliere
2024-02-04 18:34 ` Bartosz Golaszewski
2024-02-05 12:47 ` Greg Kroah-Hartman
0 siblings, 2 replies; 6+ messages in thread
From: Ricardo B. Marliere @ 2024-02-04 16:29 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski
Cc: linux-gpio, linux-kernel, Greg Kroah-Hartman, Ricardo B. Marliere
Now that the driver core can properly handle constant struct bus_type,
move the gpio_bus_type variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.
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/gpio/gpiolib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index d50a786f8176..24d046268a01 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -63,7 +63,7 @@ static int gpio_bus_match(struct device *dev, struct device_driver *drv)
return 1;
}
-static struct bus_type gpio_bus_type = {
+static const struct bus_type gpio_bus_type = {
.name = "gpio",
.match = gpio_bus_match,
};
---
base-commit: 3eac8bbed22e940ac1645a884f221bef408f675c
change-id: 20240204-bus_cleanup-gpio-57eea8d32a5a
Best regards,
--
Ricardo B. Marliere <ricardo@marliere.net>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: gpiolib: make gpio_bus_type const
2024-02-04 16:29 [PATCH] gpio: gpiolib: make gpio_bus_type const Ricardo B. Marliere
@ 2024-02-04 18:34 ` Bartosz Golaszewski
2024-02-04 19:41 ` Ricardo B. Marliere
2024-02-05 12:43 ` Greg Kroah-Hartman
2024-02-05 12:47 ` Greg Kroah-Hartman
1 sibling, 2 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2024-02-04 18:34 UTC (permalink / raw)
To: Ricardo B. Marliere
Cc: Linus Walleij, linux-gpio, linux-kernel, Greg Kroah-Hartman
On Sun, Feb 4, 2024 at 5:29 PM Ricardo B. Marliere <ricardo@marliere.net> wrote:
>
> Now that the driver core can properly handle constant struct bus_type,
> move the gpio_bus_type variable to be a constant structure as well,
> placing it into read-only memory which can not be modified at runtime.
>
> 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/gpio/gpiolib.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index d50a786f8176..24d046268a01 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -63,7 +63,7 @@ static int gpio_bus_match(struct device *dev, struct device_driver *drv)
> return 1;
> }
>
> -static struct bus_type gpio_bus_type = {
> +static const struct bus_type gpio_bus_type = {
> .name = "gpio",
> .match = gpio_bus_match,
> };
>
> ---
> base-commit: 3eac8bbed22e940ac1645a884f221bef408f675c
> change-id: 20240204-bus_cleanup-gpio-57eea8d32a5a
>
> Best regards,
> --
> Ricardo B. Marliere <ricardo@marliere.net>
>
Ha! Does the same work now for struct device_type?
Because I just sent this:
https://lore.kernel.org/linux-gpio/20240201162758.50733-1-brgl@bgdev.pl/
And maybe I should make it const right away.
Bart
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: gpiolib: make gpio_bus_type const
2024-02-04 18:34 ` Bartosz Golaszewski
@ 2024-02-04 19:41 ` Ricardo B. Marliere
2024-02-05 8:45 ` Bartosz Golaszewski
2024-02-05 12:43 ` Greg Kroah-Hartman
1 sibling, 1 reply; 6+ messages in thread
From: Ricardo B. Marliere @ 2024-02-04 19:41 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Linus Walleij, linux-gpio, linux-kernel, Greg Kroah-Hartman
Hi Bartosz,
On 4 Feb 19:34, Bartosz Golaszewski wrote:
> On Sun, Feb 4, 2024 at 5:29 PM Ricardo B. Marliere <ricardo@marliere.net> wrote:
> >
> > Now that the driver core can properly handle constant struct bus_type,
> > move the gpio_bus_type variable to be a constant structure as well,
> > placing it into read-only memory which can not be modified at runtime.
> >
> > 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/gpio/gpiolib.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> > index d50a786f8176..24d046268a01 100644
> > --- a/drivers/gpio/gpiolib.c
> > +++ b/drivers/gpio/gpiolib.c
> > @@ -63,7 +63,7 @@ static int gpio_bus_match(struct device *dev, struct device_driver *drv)
> > return 1;
> > }
> >
> > -static struct bus_type gpio_bus_type = {
> > +static const struct bus_type gpio_bus_type = {
> > .name = "gpio",
> > .match = gpio_bus_match,
> > };
> >
> > ---
> > base-commit: 3eac8bbed22e940ac1645a884f221bef408f675c
> > change-id: 20240204-bus_cleanup-gpio-57eea8d32a5a
> >
> > Best regards,
> > --
> > Ricardo B. Marliere <ricardo@marliere.net>
> >
>
> Ha! Does the same work now for struct device_type?
From a quick grep it seems to be the case, but maybe you should wait for
Greg for confirmation. Also found this:
https://lore.kernel.org/all/1305850262-9575-5-git-send-email-gregkh@suse.de/
Best regards,
- Ricardo.
>
> Because I just sent this:
> https://lore.kernel.org/linux-gpio/20240201162758.50733-1-brgl@bgdev.pl/
>
> And maybe I should make it const right away.
>
> Bart
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: gpiolib: make gpio_bus_type const
2024-02-04 19:41 ` Ricardo B. Marliere
@ 2024-02-05 8:45 ` Bartosz Golaszewski
0 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2024-02-05 8:45 UTC (permalink / raw)
To: Ricardo B. Marliere
Cc: Linus Walleij, linux-gpio, linux-kernel, Greg Kroah-Hartman,
Bartosz Golaszewski
On Sun, 4 Feb 2024 20:41:52 +0100, "Ricardo B. Marliere"
<ricardo@marliere.net> said:
> Hi Bartosz,
>
> On 4 Feb 19:34, Bartosz Golaszewski wrote:
>> On Sun, Feb 4, 2024 at 5:29 PM Ricardo B. Marliere <ricardo@marliere.net> wrote:
>> >
>> > Now that the driver core can properly handle constant struct bus_type,
>> > move the gpio_bus_type variable to be a constant structure as well,
>> > placing it into read-only memory which can not be modified at runtime.
>> >
>> > 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/gpio/gpiolib.c | 2 +-
>> > 1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
>> > index d50a786f8176..24d046268a01 100644
>> > --- a/drivers/gpio/gpiolib.c
>> > +++ b/drivers/gpio/gpiolib.c
>> > @@ -63,7 +63,7 @@ static int gpio_bus_match(struct device *dev, struct device_driver *drv)
>> > return 1;
>> > }
>> >
>> > -static struct bus_type gpio_bus_type = {
>> > +static const struct bus_type gpio_bus_type = {
>> > .name = "gpio",
>> > .match = gpio_bus_match,
>> > };
>> >
>> > ---
>> > base-commit: 3eac8bbed22e940ac1645a884f221bef408f675c
>> > change-id: 20240204-bus_cleanup-gpio-57eea8d32a5a
>> >
>> > Best regards,
>> > --
>> > Ricardo B. Marliere <ricardo@marliere.net>
>> >
>>
>> Ha! Does the same work now for struct device_type?
>
> From a quick grep it seems to be the case, but maybe you should wait for
> Greg for confirmation. Also found this:
> https://lore.kernel.org/all/1305850262-9575-5-git-send-email-gregkh@suse.de/
>
> Best regards,
> - Ricardo.
>
>
>
>>
>> Because I just sent this:
>> https://lore.kernel.org/linux-gpio/20240201162758.50733-1-brgl@bgdev.pl/
>>
>> And maybe I should make it const right away.
>>
>> Bart
>
Turns out it has been like that for years:
commit aed65af1cc2f6fc9ded5a8158f1405a02cf6d2ff
Author: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon Mar 28 09:12:52 2011 -0700
drivers: make device_type const
The device_type structure does not contain data that changes
during usage and should be const. This allows devices to declare
the struct const.
I have patches to change all the subsystems, but need the infra
structure change first.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
I queued your patch too.
Bart
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: gpiolib: make gpio_bus_type const
2024-02-04 18:34 ` Bartosz Golaszewski
2024-02-04 19:41 ` Ricardo B. Marliere
@ 2024-02-05 12:43 ` Greg Kroah-Hartman
1 sibling, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2024-02-05 12:43 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Ricardo B. Marliere, Linus Walleij, linux-gpio, linux-kernel
On Sun, Feb 04, 2024 at 07:34:43PM +0100, Bartosz Golaszewski wrote:
> On Sun, Feb 4, 2024 at 5:29 PM Ricardo B. Marliere <ricardo@marliere.net> wrote:
> >
> > Now that the driver core can properly handle constant struct bus_type,
> > move the gpio_bus_type variable to be a constant structure as well,
> > placing it into read-only memory which can not be modified at runtime.
> >
> > 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/gpio/gpiolib.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> > index d50a786f8176..24d046268a01 100644
> > --- a/drivers/gpio/gpiolib.c
> > +++ b/drivers/gpio/gpiolib.c
> > @@ -63,7 +63,7 @@ static int gpio_bus_match(struct device *dev, struct device_driver *drv)
> > return 1;
> > }
> >
> > -static struct bus_type gpio_bus_type = {
> > +static const struct bus_type gpio_bus_type = {
> > .name = "gpio",
> > .match = gpio_bus_match,
> > };
> >
> > ---
> > base-commit: 3eac8bbed22e940ac1645a884f221bef408f675c
> > change-id: 20240204-bus_cleanup-gpio-57eea8d32a5a
> >
> > Best regards,
> > --
> > Ricardo B. Marliere <ricardo@marliere.net>
> >
>
> Ha! Does the same work now for struct device_type?
Very much so, please feel free to do so, that's next on my list of
things to do for the tree.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: gpiolib: make gpio_bus_type const
2024-02-04 16:29 [PATCH] gpio: gpiolib: make gpio_bus_type const Ricardo B. Marliere
2024-02-04 18:34 ` Bartosz Golaszewski
@ 2024-02-05 12:47 ` Greg Kroah-Hartman
1 sibling, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2024-02-05 12:47 UTC (permalink / raw)
To: Ricardo B. Marliere
Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel
On Sun, Feb 04, 2024 at 01:29:42PM -0300, Ricardo B. Marliere wrote:
> Now that the driver core can properly handle constant struct bus_type,
> move the gpio_bus_type variable to be a constant structure as well,
> placing it into read-only memory which can not be modified at runtime.
>
> 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-05 19:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-04 16:29 [PATCH] gpio: gpiolib: make gpio_bus_type const Ricardo B. Marliere
2024-02-04 18:34 ` Bartosz Golaszewski
2024-02-04 19:41 ` Ricardo B. Marliere
2024-02-05 8:45 ` Bartosz Golaszewski
2024-02-05 12:43 ` Greg Kroah-Hartman
2024-02-05 12:47 ` Greg Kroah-Hartman
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).