Re: [PATCH] gpio: sim: fix the chip_name configfs item

From: Andy Shevchenko
Date: Mon Jul 11 2022 - 14:50:15 EST


On Mon, Jul 11, 2022 at 7:35 PM Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
>
> The chip_name configs attribute always displays the device name of the
> first GPIO bank because the logic of the relevant function is simply
> wrong.
>
> Fix it by correctly comparing the bank's swnode against the GPIO
> device's children.
>
> Fixes: cb8c474e79be ("gpio: sim: new testing module")
> Cc: stable@xxxxxxxxxxxxxxx
> Reported-by: Kent Gibson <warthog618@xxxxxxxxx>
> Signed-off-by: Bartosz Golaszewski <brgl@xxxxxxxx>

...

> struct gpio_sim_chip_name_ctx {
> - struct gpio_sim_device *dev;
> + struct fwnode_handle *swnode;

I would call it fwnode even if we know the backend provider.

> char *page;
> };

...

> struct fwnode_handle *swnode;

Do you still need this? See below.

...

> swnode = dev_fwnode(dev);
>
> + if (swnode == ctx->swnode)
> + return sprintf(ctx->page, "%s\n", dev_name(dev));

So, now it can be

if (device_match_fwnode(dev, ctx->fwnode))
return sprintf(...);

--
With Best Regards,
Andy Shevchenko