From: Rosen Penev <rosenp@gmail.com>
To: linux-iio@vger.kernel.org
Cc: "Peter Rosin" <peda@axentia.se>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] iio: iio-mux: use flexible array member
Date: Sun, 15 Mar 2026 15:45:09 -0700 [thread overview]
Message-ID: <20260315224509.48111-1-rosenp@gmail.com> (raw)
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
next reply other threads:[~2026-03-15 22:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-15 22:45 Rosen Penev [this message]
2026-03-16 14:16 ` [PATCH] iio: iio-mux: use flexible array member 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260315224509.48111-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=peda@axentia.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox