mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v5] staging: greybus: Constify gb_audio_module_type
@ 2024-03-16 18:24 Ayush Tiwari
  2024-03-16 18:45 ` Fabio M. De Francesco
  2024-03-18 11:16 ` Dan Carpenter
  0 siblings, 2 replies; 5+ messages in thread
From: Ayush Tiwari @ 2024-03-16 18:24 UTC (permalink / raw)
  To: Larry.Finger, florian.c.schilhabel, gregkh, linux-kernel, linux-staging
  Cc: outreachy

Constify static struct kobj_type gb_audio_module_type to prevent
modification of data shared across many instances(instances here
refer to multiple kobject instances being created, since this same
gb_audio_module_type structure is used as a template for all audio
manager module kobjs, it is effectively 'shared' across all these
instances), ensuring that the structure's usage is consistent and
predictable throughout the driver and allowing the compiler to place
it in read-only memory. The gb_audio_module_type structure is used
when initializing and adding kobj instances to the kernel's object
hierarchy. After adding const, any attempt to alter
gb_audio_module_type in the code would raise a compile-time error.
This enforcement ensures that the sysfs interface and operations for
audio modules remain stable.

Signed-off-by: Ayush Tiwari <ayushtiw0110@gmail.com>

---
Changes in v5: added more details as per feedback.

Changes in v4: added more details verifying the change.

Changes in v3: added the message that verifies the change,
as suggested by Julia

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-18 11:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-16 18:24 [PATCH v5] staging: greybus: Constify gb_audio_module_type Ayush Tiwari
2024-03-16 18:45 ` Fabio M. De Francesco
2024-03-18 11:16 ` Dan Carpenter
2024-03-18 11:25   ` Julia Lawall
2024-03-18 11:41     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®