public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] w1: Use container_of_const() when all types are const
@ 2025-11-26 17:18 Krzysztof Kozlowski
  2025-11-26 19:27 ` david laight
  0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-26 17:18 UTC (permalink / raw)
  To: Krzysztof Kozlowski, linux-kernel; +Cc: Krzysztof Kozlowski

Use container_of_const(), which is preferred over container_of(), when
the argument 'ptr' and returned pointer are already const, for better
code safety and readability.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 drivers/w1/w1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 002d2639aa12..3b48d15390be 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -575,11 +575,11 @@ static int w1_uevent(const struct device *dev, struct kobj_uevent_env *env)
 	int err = 0;
 
 	if (dev->driver == &w1_master_driver) {
-		md = container_of(dev, struct w1_master, dev);
+		md = container_of_const(dev, struct w1_master, dev);
 		event_owner = "master";
 		name = md->name;
 	} else if (dev->driver == &w1_slave_driver) {
-		sl = container_of(dev, struct w1_slave, dev);
+		sl = container_of_const(dev, struct w1_slave, dev);
 		event_owner = "slave";
 		name = sl->name;
 	} else {
-- 
2.48.1


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

end of thread, other threads:[~2025-11-27  6:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-26 17:18 [PATCH] w1: Use container_of_const() when all types are const Krzysztof Kozlowski
2025-11-26 19:27 ` david laight
2025-11-27  6:58   ` Krzysztof Kozlowski

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