devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Jonas Jelonek <jelonek.jonas@gmail.com>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>,
	Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>, Peter Rosin <peda@axentia.se>,
	 Geert Uytterhoeven <geert+renesas@glider.be>,
	linux-gpio@vger.kernel.org,  devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	 Thomas Richard <thomas.richard@bootlin.com>
Subject: Re: [PATCH v5 2/2] gpio: add gpio-line-mux driver
Date: Mon, 10 Nov 2025 23:52:26 +0100	[thread overview]
Message-ID: <CACRpkdabTaVsqXOhy_QOdi3WNM3TPfEodt1miQkdcSrYWyYGxQ@mail.gmail.com> (raw)
In-Reply-To: <20251105163610.610793-3-jelonek.jonas@gmail.com>

Hi Jonas,

overall I'm really happy of how this has turned out!
Sorry for not reviewing very intensely the last two weeks :(

One review comment left:

On Wed, Nov 5, 2025 at 5:36 PM Jonas Jelonek <jelonek.jonas@gmail.com> wrote:

> +struct gpio_lmux {
> +       struct gpio_chip gc;
> +       struct mux_control *mux;
> +
> +       struct gpio_desc *muxed_gpio;
> +       /* dynamically sized, must be last */
> +       unsigned int gpio_mux_states[];
> +};

Dynamic arrays at the end of struct is a bit of a security pain
and we probably want to avoid them if we can.

The typical idiom should be:
...
    u32 num_gpio_mux_states;
    unsigned int gpio_mux_states[] __counted_by(num_gpio_mux_states);
};

> +static int gpio_lmux_probe(struct platform_device *pdev)
> +{
(...)
> +       ngpio = device_property_count_u32(dev, "gpio-line-mux-states");
> +       if (!ngpio)
> +               return -EINVAL;
> +
> +       size = struct_size(glm, gpio_mux_states, ngpio);
> +       glm = devm_kzalloc(dev, size, GFP_KERNEL);
> +       if (!glm)
> +               return -ENOMEM;

(...)

glm->num_gpio_mux_states = ngpio;

> +       ret = device_property_read_u32_array(dev, "gpio-line-mux-states",
> +                                            &glm->gpio_mux_states[0], ngpio);
> +       if (ret)
> +               return dev_err_probe(dev, ret, "could not get mux states\n");

We use this pattern in the core gpiolib for example.

With this addressed:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

      reply	other threads:[~2025-11-10 22:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-05 16:36 [PATCH v5 0/2] add gpio-line-mux Jonas Jelonek
2025-11-05 16:36 ` [PATCH v5 1/2] dt-bindings: gpio: add gpio-line-mux controller Jonas Jelonek
2025-11-06 17:47   ` Conor Dooley
2025-11-10 22:53   ` Linus Walleij
2025-11-05 16:36 ` [PATCH v5 2/2] gpio: add gpio-line-mux driver Jonas Jelonek
2025-11-10 22:52   ` Linus Walleij [this message]

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=CACRpkdabTaVsqXOhy_QOdi3WNM3TPfEodt1miQkdcSrYWyYGxQ@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=jelonek.jonas@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peda@axentia.se \
    --cc=robh@kernel.org \
    --cc=thomas.richard@bootlin.com \
    /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;
as well as URLs for NNTP newsgroup(s).