[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8259cc0c-93e2-4e62-3ce5-9372e2b40397@linaro.org>
Date: Thu, 6 Oct 2022 10:29:48 +0200
From: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
To: Martin Zaťovič <m.zatovic1@...il.com>,
robh+dt@...nel.org, krzysztof.kozlowski+dt@...aro.org,
linus.walleij@...aro.org, brgl@...ev.pl,
gregkh@...uxfoundation.org, jeffrey.l.hugo@...il.com,
andersson@...nel.org, Michael.Srba@...nam.cz, saravanak@...gle.com,
mani@...nel.org, hemantk@...eaurora.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
linux-gpio@...r.kernel.org
Subject: Re: [RFCv2 PATCH 2/4] bus: add Wiegand bus driver
On 05/10/2022 16:57, Martin Zaťovič wrote:
> The Wiegand bus driver spawns devices and matches them with
> drivers.
>
> Signed-off-by: Martin Zaťovič <m.zatovic1@...il.com>
> ---
> The bus driver currently assumes that any new Wiegand driver will
> have a matching entry in the devicetree. It is currently sufficient
> as I will only be implementing the GPIO driver. If someone
> implements a Wiegand driver that will not use devicetree, he will
> also have to edit this bus driver, in order to match properly. Is
> that a correct approach?
(...)
> +static struct wiegand_device *
> +of_register_wiegand_device(struct wiegand *wiegand, struct device_node *nc)
> +{
> + struct wiegand_device *dev;
> + const char *val;
> + int ret;
> +
> + dev = wiegand_alloc_device(wiegand);
> + if (!dev) {
> + dev_err(wiegand->dev,
> + "Wiegand device alloc error for %pOF\n", nc);
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + ret = of_property_read_string(nc, "compatible", &val);
> + if (ret) {
> + dev_err(wiegand->dev, "%pOF has no valid 'compatible' property (%d)\n",
> + nc, ret);
> + goto err_put;
> + }
> +
> + if (strcmp(val, "wiegand,wiegand-gpio") == 0) {
This does not look right. Bus can have any device attached, so limiting
some bus behavior to a specific device is not really scalable.
Anyway device and node matching should not be with strcmp but rather
of_*_match().
Best regards,
Krzysztof
Powered by blists - more mailing lists