2024-03-14 06:52:54

by Ayush Tiwari

[permalink] [raw]
Subject: [PATCH v2] staging: greybus: Constify static struct kobj_type gb_audio_module_type

Constify static struct kobj_type gb_audio_module_type to prevent
modification of data shared across many instances, ensuring that the
structure's usage is consistent and predictable throughout the driver
and allows the compiler to place it in read-only memory.

Signed-off-by: Ayush Tiwari <[email protected]>
---

Changes in v2: incorporated changes in commit message as suggested by
Alison

drivers/staging/greybus/audio_manager_module.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/audio_manager_module.c b/drivers/staging/greybus/audio_manager_module.c
index 5f9dcbdbc191..4a4dfb42f50f 100644
--- a/drivers/staging/greybus/audio_manager_module.c
+++ b/drivers/staging/greybus/audio_manager_module.c
@@ -144,7 +144,7 @@ static struct attribute *gb_audio_module_default_attrs[] = {
};
ATTRIBUTE_GROUPS(gb_audio_module_default);

-static struct kobj_type gb_audio_module_type = {
+static const struct kobj_type gb_audio_module_type = {
.sysfs_ops = &gb_audio_module_sysfs_ops,
.release = gb_audio_module_release,
.default_groups = gb_audio_module_default_groups,
--
2.40.1



2024-03-14 07:39:33

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH v2] staging: greybus: Constify static struct kobj_type gb_audio_module_type



On Thu, 14 Mar 2024, Ayush Tiwari wrote:

> Constify static struct kobj_type gb_audio_module_type to prevent
> modification of data shared across many instances, ensuring that the
> structure's usage is consistent and predictable throughout the driver
> and allows the compiler to place it in read-only memory.

It would be helpful for the log message to include some hints about what
you have done to verify that the change is correct.

julia

>
> Signed-off-by: Ayush Tiwari <[email protected]>
> ---
>
> Changes in v2: incorporated changes in commit message as suggested by
> Alison
>
> drivers/staging/greybus/audio_manager_module.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/greybus/audio_manager_module.c b/drivers/staging/greybus/audio_manager_module.c
> index 5f9dcbdbc191..4a4dfb42f50f 100644
> --- a/drivers/staging/greybus/audio_manager_module.c
> +++ b/drivers/staging/greybus/audio_manager_module.c
> @@ -144,7 +144,7 @@ static struct attribute *gb_audio_module_default_attrs[] = {
> };
> ATTRIBUTE_GROUPS(gb_audio_module_default);
>
> -static struct kobj_type gb_audio_module_type = {
> +static const struct kobj_type gb_audio_module_type = {
> .sysfs_ops = &gb_audio_module_sysfs_ops,
> .release = gb_audio_module_release,
> .default_groups = gb_audio_module_default_groups,
> --
> 2.40.1
>
>
>