[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <585c4ad9-31fc-e87e-07c4-b8d6aa09c7e4@mentor.com>
Date: Tue, 3 Dec 2019 11:12:38 +0530
From: Harish Jenny K N <harish_kandiga@...tor.com>
To: Geert Uytterhoeven <geert+renesas@...der.be>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <bgolaszewski@...libre.com>,
Jonathan Corbet <corbet@....net>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Eugeniu Rosca <erosca@...adit-jv.com>
CC: Alexander Graf <graf@...zon.com>,
Peter Maydell <peter.maydell@...aro.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Phil Reid <preid@...ctromag.com.au>,
Marc Zyngier <marc.zyngier@....com>,
Christoffer Dall <christoffer.dall@....com>,
Magnus Damm <magnus.damm@...il.com>,
<linux-gpio@...r.kernel.org>, <linux-doc@...r.kernel.org>,
<devicetree@...r.kernel.org>, <linux-renesas-soc@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <qemu-devel@...gnu.org>
Subject: Re: [PATCH v3 5/7] gpio: Add GPIO Aggregator/Repeater driver
> +static int gpio_aggregator_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct gpio_desc **descs;
> + struct gpiochip_fwd *fwd;
> + int i, n;
> +
> + n = gpiod_count(dev, NULL);
> + if (n < 0)
> + return n;
> +
> + descs = devm_kmalloc_array(dev, n, sizeof(*descs), GFP_KERNEL);
> + if (!descs)
> + return -ENOMEM;
> +
> + for (i = 0; i < n; i++) {
> + descs[i] = devm_gpiod_get_index(dev, NULL, i, GPIOD_ASIS);
can you please add this check as well as we need to return EPROBE_DEFER.
if (desc[i] == ERR_PTR(-ENOENT))
< return -EPROBE_DEFER;
> + if (IS_ERR(descs[i]))
> + return PTR_ERR(descs[i]);
> + }
> +
> + fwd = gpiochip_fwd_create(dev, n, descs);
> + if (IS_ERR(fwd))
> + return PTR_ERR(fwd);
> +
> + platform_set_drvdata(pdev, fwd);
> + return 0;
> +}
> +
> +#ifdef CONFIG_OF
> +static const struct of_device_id gpio_aggregator_dt_ids[] = {
> + { .compatible = "gpio-repeater" },
> + /*
> + * Add GPIO-operated devices controlled from userspace below,
> + * or use "driver_override" in sysfs
> + */
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, gpio_aggregator_dt_ids);
> +#endif
> +
> +static struct platform_driver gpio_aggregator_driver = {
> + .probe = gpio_aggregator_probe,
> + .driver = {
> + .name = DRV_NAME,
> + .groups = gpio_aggregator_groups,
> + .of_match_table = of_match_ptr(gpio_aggregator_dt_ids),
> + },
> +};
> +
> +static int __init gpio_aggregator_init(void)
> +{
> + return platform_driver_register(&gpio_aggregator_driver);
> +}
> +module_init(gpio_aggregator_init);
> +
> +static void __exit gpio_aggregator_exit(void)
> +{
> + gpio_aggregator_remove_all();
> + platform_driver_unregister(&gpio_aggregator_driver);
> +}
> +module_exit(gpio_aggregator_exit);
> +
> +MODULE_AUTHOR("Geert Uytterhoeven <geert+renesas@...der.be>");
> +MODULE_DESCRIPTION("GPIO Aggregator/Repeater");
> +MODULE_LICENSE("GPL v2");
Powered by blists - more mailing lists