public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: iio-mux: use flexible array member
@ 2026-03-15 22:45 Rosen Penev
  2026-03-16 14:16 ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Rosen Penev @ 2026-03-15 22:45 UTC (permalink / raw)
  To: linux-iio
  Cc: Peter Rosin, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, open list

Allows using struct_size to simplify allocation slightly.

Removes a pointer from the struct.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/iio/multiplexer/iio-mux.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/multiplexer/iio-mux.c b/drivers/iio/multiplexer/iio-mux.c
index b742ca9a99d1..8db061413829 100644
--- a/drivers/iio/multiplexer/iio-mux.c
+++ b/drivers/iio/multiplexer/iio-mux.c
@@ -33,8 +33,8 @@ struct mux {
 	struct iio_channel *parent;
 	struct iio_chan_spec *chan;
 	struct iio_chan_spec_ext_info *ext_info;
-	struct mux_child *child;
 	u32 delay_us;
+	struct mux_child child[];
 };
 
 static int iio_mux_select(struct mux *mux, int idx)
@@ -380,8 +380,7 @@ static int mux_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	sizeof_priv = sizeof(*mux);
-	sizeof_priv += sizeof(*mux->child) * children;
+	sizeof_priv = struct_size(mux, child, children);
 	sizeof_priv += sizeof(*mux->chan) * children;
 	sizeof_priv += sizeof_ext_info;
 
@@ -390,7 +389,6 @@ static int mux_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	mux = iio_priv(indio_dev);
-	mux->child = (struct mux_child *)(mux + 1);
 	mux->chan = (struct iio_chan_spec *)(mux->child + children);
 
 	platform_set_drvdata(pdev, indio_dev);
-- 
2.53.0


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

end of thread, other threads:[~2026-03-16 21:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-15 22:45 [PATCH] iio: iio-mux: use flexible array member Rosen Penev
2026-03-16 14:16 ` Andy Shevchenko
2026-03-16 18:11   ` Rosen Penev
2026-03-16 19:43     ` Andy Shevchenko
2026-03-16 21:12       ` Rosen Penev
2026-03-16 21:24         ` Andy Shevchenko

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