On Mon, Mar 23, 2026 at 3:00 AM Bartosz Golaszewski <[email protected]> wrote:
>
> On Sat, Mar 21, 2026 at 12:00 AM Rosen Penev <[email protected]> wrote:
> >
> > >
> > > static int gpio_mockup_probe(struct platform_device *pdev)
> > > {
> > >         ...
> > >         u16 ngpio;
> > >         ...
> > >         rv = device_property_read_u16(dev, "nr-gpios", &ngpio);
> > >         ...
> > >         gc->ngpio = ngpio;
> > >         ...
> > >         chip->lines = devm_kcalloc(dev, gc->ngpio,
> > >                                    sizeof(*chip->lines), GFP_KERNEL);
> > >
> > > But this begs the question: why add nr_lines when ngpio is already part
> > > of the struct:
> > Maintainers for some inexplicable reason want an extra variable for
> > __counted_by works.
>
> I believe what Kees means here is: you can use ngpio for __counted_by() like 
> so:
>
>   __counted_by(gc.ngpio)
__counted_by doesn't support nested variables like that.

drivers/gpio/gpio-mockup.c:59:61: error: ‘gc’ undeclared here (not in
a function)
   59 |         struct gpio_mockup_line_status lines[] __counted_by(gc.ngpio);
>
> I didn't think about it and I do prefer it of course over an extra field.
>
> Bart

Reply via email to