2024-02-03 15:32:13

by Ricardo B. Marliere

[permalink] [raw]
Subject: [PATCH 0/2] drivers: media: struct bus_type cleanup

This series is part of an effort to cleanup the users of the driver
core, as can be seen in many recent patches authored by Greg across the
tree (e.g. [1]). Specifically, this series is part of the task of
splitting one of his TODOs [2].

---
[1]: https://lore.kernel.org/lkml/?q=f%3Agregkh%40linuxfoundation.org+s%3A%22make%22+and+s%3A%22const%22
[2]: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=bus_cleanup&id=26105f537f0c60eacfeb430abd2e05d7ddcdd8aa

Signed-off-by: Ricardo B. Marliere <[email protected]>

---
Ricardo B. Marliere (2):
media: cec: make cec_bus_type const
media: media-devnode: make media_bus_type const

drivers/media/cec/core/cec-core.c | 2 +-
drivers/media/mc/mc-devnode.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
---
base-commit: 41bccc98fb7931d63d03f326a746ac4d429c1dd3
change-id: 20240203-bus_cleanup-media-0ee6e332fef5

Best regards,
--
Ricardo B. Marliere <[email protected]>



2024-02-03 15:32:28

by Ricardo B. Marliere

[permalink] [raw]
Subject: [PATCH 1/2] media: cec: make cec_bus_type const

Now that the driver core can properly handle constant struct bus_type,
move the cec_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 <[email protected]>
Suggested-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Ricardo B. Marliere <[email protected]>
---
drivers/media/cec/core/cec-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/cec/core/cec-core.c b/drivers/media/cec/core/cec-core.c
index 7e153c5cad04..5a54db839e5d 100644
--- a/drivers/media/cec/core/cec-core.c
+++ b/drivers/media/cec/core/cec-core.c
@@ -93,7 +93,7 @@ static void cec_devnode_release(struct device *cd)
cec_delete_adapter(to_cec_adapter(devnode));
}

-static struct bus_type cec_bus_type = {
+static const struct bus_type cec_bus_type = {
.name = CEC_NAME,
};


--
2.43.0


2024-02-03 15:33:02

by Ricardo B. Marliere

[permalink] [raw]
Subject: [PATCH 2/2] media: media-devnode: make media_bus_type const

Now that the driver core can properly handle constant struct bus_type,
move the media_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 <[email protected]>
Suggested-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Ricardo B. Marliere <[email protected]>
---
drivers/media/mc/mc-devnode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/mc/mc-devnode.c b/drivers/media/mc/mc-devnode.c
index 680fbb3a9340..90646805bd81 100644
--- a/drivers/media/mc/mc-devnode.c
+++ b/drivers/media/mc/mc-devnode.c
@@ -63,7 +63,7 @@ static void media_devnode_release(struct device *cd)
pr_debug("%s: Media Devnode Deallocated\n", __func__);
}

-static struct bus_type media_bus_type = {
+static const struct bus_type media_bus_type = {
.name = MEDIA_NAME,
};


--
2.43.0


2024-02-03 15:59:43

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 2/2] media: media-devnode: make media_bus_type const

On Sat, Feb 03, 2024 at 12:31:27PM -0300, Ricardo B. Marliere wrote:
> Now that the driver core can properly handle constant struct bus_type,
> move the media_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 <[email protected]>
> Suggested-by: Greg Kroah-Hartman <[email protected]>
> Signed-off-by: Ricardo B. Marliere <[email protected]>
> ---
> drivers/media/mc/mc-devnode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Greg Kroah-Hartman <[email protected]>

2024-02-03 16:02:23

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 1/2] media: cec: make cec_bus_type const

On Sat, Feb 03, 2024 at 12:31:26PM -0300, Ricardo B. Marliere wrote:
> Now that the driver core can properly handle constant struct bus_type,
> move the cec_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 <[email protected]>
> Suggested-by: Greg Kroah-Hartman <[email protected]>
> Signed-off-by: Ricardo B. Marliere <[email protected]>
> ---
> drivers/media/cec/core/cec-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Greg Kroah-Hartman <[email protected]>

2024-02-04 08:47:54

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 1/2] media: cec: make cec_bus_type const

Hi Ricardo,

Thank you for the patch.

On Sat, Feb 03, 2024 at 12:31:26PM -0300, Ricardo B. Marliere wrote:
> Now that the driver core can properly handle constant struct bus_type,
> move the cec_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 <[email protected]>
> Suggested-by: Greg Kroah-Hartman <[email protected]>
> Signed-off-by: Ricardo B. Marliere <[email protected]>

Reviewed-by: Laurent Pinchart <[email protected]>

Hans, I assume you'll pick this patch. Could you also pick 2/2 from the
series ?

> ---
> drivers/media/cec/core/cec-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/cec/core/cec-core.c b/drivers/media/cec/core/cec-core.c
> index 7e153c5cad04..5a54db839e5d 100644
> --- a/drivers/media/cec/core/cec-core.c
> +++ b/drivers/media/cec/core/cec-core.c
> @@ -93,7 +93,7 @@ static void cec_devnode_release(struct device *cd)
> cec_delete_adapter(to_cec_adapter(devnode));
> }
>
> -static struct bus_type cec_bus_type = {
> +static const struct bus_type cec_bus_type = {
> .name = CEC_NAME,
> };
>

--
Regards,

Laurent Pinchart

2024-02-04 08:48:46

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 2/2] media: media-devnode: make media_bus_type const

Hi Ricardo,

Thank you for the patch.

On Sat, Feb 03, 2024 at 12:31:27PM -0300, Ricardo B. Marliere wrote:
> Now that the driver core can properly handle constant struct bus_type,
> move the media_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 <[email protected]>
> Suggested-by: Greg Kroah-Hartman <[email protected]>
> Signed-off-by: Ricardo B. Marliere <[email protected]>

Reviewed-by: Laurent Pinchart <[email protected]>

> ---
> drivers/media/mc/mc-devnode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/mc/mc-devnode.c b/drivers/media/mc/mc-devnode.c
> index 680fbb3a9340..90646805bd81 100644
> --- a/drivers/media/mc/mc-devnode.c
> +++ b/drivers/media/mc/mc-devnode.c
> @@ -63,7 +63,7 @@ static void media_devnode_release(struct device *cd)
> pr_debug("%s: Media Devnode Deallocated\n", __func__);
> }
>
> -static struct bus_type media_bus_type = {
> +static const struct bus_type media_bus_type = {
> .name = MEDIA_NAME,
> };
>
>

--
Regards,

Laurent Pinchart

2024-02-04 09:40:19

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH 1/2] media: cec: make cec_bus_type const

On 04/02/2024 09:47, Laurent Pinchart wrote:
> Hi Ricardo,
>
> Thank you for the patch.
>
> On Sat, Feb 03, 2024 at 12:31:26PM -0300, Ricardo B. Marliere wrote:
>> Now that the driver core can properly handle constant struct bus_type,
>> move the cec_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 <[email protected]>
>> Suggested-by: Greg Kroah-Hartman <[email protected]>
>> Signed-off-by: Ricardo B. Marliere <[email protected]>
>
> Reviewed-by: Laurent Pinchart <[email protected]>
>
> Hans, I assume you'll pick this patch. Could you also pick 2/2 from the
> series ?

Of course!

Hans

>
>> ---
>> drivers/media/cec/core/cec-core.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/cec/core/cec-core.c b/drivers/media/cec/core/cec-core.c
>> index 7e153c5cad04..5a54db839e5d 100644
>> --- a/drivers/media/cec/core/cec-core.c
>> +++ b/drivers/media/cec/core/cec-core.c
>> @@ -93,7 +93,7 @@ static void cec_devnode_release(struct device *cd)
>> cec_delete_adapter(to_cec_adapter(devnode));
>> }
>>
>> -static struct bus_type cec_bus_type = {
>> +static const struct bus_type cec_bus_type = {
>> .name = CEC_NAME,
>> };
>>
>