[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=Mdjm8tgxF_76T3f6r3TwghLKtrFtUv7ywtX3-nEQzVGtA@mail.gmail.com>
Date: Tue, 27 Oct 2020 19:12:13 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Vincent Whitchurch <vincent.whitchurch@...s.com>
Cc: Bamvor Jian Zhang <bamv2005@...il.com>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <bgolaszewski@...libre.com>,
kernel@...s.com, devicetree <devicetree@...r.kernel.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] gpio: mockup: Allow probing from device tree
On Tue, Oct 27, 2020 at 2:54 PM Vincent Whitchurch
<vincent.whitchurch@...s.com> wrote:
>
> Allow the mockup driver to be probed via the device tree without any
> module parameters, allowing it to be used to configure and test higher
> level drivers like the leds-gpio driver and corresponding userspace
> before actual hardware is available.
>
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@...s.com>
> ---
> v2: Remove most of the added code, since the latest driver doesn't need it.
> Drop DT binding document, since Rob Herring was OK with not documenting
> this:
> https://lore.kernel.org/linux-devicetree/5baa1ae6.1c69fb81.847f2.3ab1@mx.google.com/
>
> drivers/gpio/gpio-mockup.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
> index 67ed4f238d43..c93892a6936a 100644
> --- a/drivers/gpio/gpio-mockup.c
> +++ b/drivers/gpio/gpio-mockup.c
> @@ -13,6 +13,7 @@
> #include <linux/gpio/driver.h>
> #include <linux/interrupt.h>
> #include <linux/irq.h>
> +#include <linux/of.h>
Please keep the includes ordered alphabetically.
> #include <linux/irq_sim.h>
> #include <linux/irqdomain.h>
> #include <linux/module.h>
> @@ -460,9 +461,18 @@ static int gpio_mockup_probe(struct platform_device *pdev)
> return 0;
> }
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id gpio_mockup_of_match[] = {
> + { .compatible = "gpio-mockup", },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, gpio_mockup_of_match);
> +#endif
You don't need this ifdef - of_match_ptr() will evaluate to NULL if
CONFIG_OF is disabled and the compiler will optimize this struct out.
Bartosz
> +
> static struct platform_driver gpio_mockup_driver = {
> .driver = {
> .name = "gpio-mockup",
> + .of_match_table = of_match_ptr(gpio_mockup_of_match),
> },
> .probe = gpio_mockup_probe,
> };
> @@ -556,8 +566,7 @@ static int __init gpio_mockup_init(void)
> {
> int i, num_chips, err;
>
> - if ((gpio_mockup_num_ranges < 2) ||
> - (gpio_mockup_num_ranges % 2) ||
> + if ((gpio_mockup_num_ranges % 2) ||
> (gpio_mockup_num_ranges > GPIO_MOCKUP_MAX_RANGES))
> return -EINVAL;
>
> --
> 2.28.0
>
Powered by blists - more mailing lists