* [PATCH] mtd: concat: use container_of_const() in CONCAT()
@ 2026-09-24 21:14 Harshit Mogalapalli
2026-09-25 14:29 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Harshit Mogalapalli @ 2026-09-24 21:14 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
linux-mtd, linux-kernel
Cc: kernel-janitors, error27, harshit.m.mogalapalli, Luca Ceresoli
CONCAT() currently recovers the enclosing struct mtd_concat by casting
its embedded struct mtd_info pointer. This assumes mtd remains the first
member of the structure.
Use container_of_const() with the named member to make the relationship
explicit and preserve any const qualifier.
Suggested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
drivers/mtd/mtdconcat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index d54d309c30a0..354cc71cd722 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -31,7 +31,7 @@
* Given a pointer to the MTD object in the mtd_concat structure,
* we can retrieve the pointer to that structure with this macro.
*/
-#define CONCAT(x) ((struct mtd_concat *)(x))
+#define CONCAT(x) container_of_const(x, struct mtd_concat, mtd)
/*
* MTD methods which look up the relevant subdevice, translate the
--
2.52.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: concat: use container_of_const() in CONCAT()
2026-09-24 21:14 [PATCH] mtd: concat: use container_of_const() in CONCAT() Harshit Mogalapalli
@ 2026-09-25 14:29 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2026-09-25 14:29 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, linux-mtd, linux-kernel,
Harshit Mogalapalli
Cc: kernel-janitors, error27, Luca Ceresoli
On Thu, 24 Sep 2026 14:14:11 -0700, Harshit Mogalapalli wrote:
> CONCAT() currently recovers the enclosing struct mtd_concat by casting
> its embedded struct mtd_info pointer. This assumes mtd remains the first
> member of the structure.
>
> Use container_of_const() with the named member to make the relationship
> explicit and preserve any const qualifier.
>
> [...]
Applied to mtd/next, thanks!
[1/1] mtd: concat: use container_of_const() in CONCAT()
commit: 2e566a6830b82d95837c4d669c63a0c1abf766a9
Patche(s) should be available on mtd/linux.git and will be
part of the next PR (provided that no robot complains by then).
Kind regards,
Miquèl
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-25 14:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24 21:14 [PATCH] mtd: concat: use container_of_const() in CONCAT() Harshit Mogalapalli
2026-09-25 14:29 ` Miquel Raynal
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®