qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 5/7] gpio: Add GPIO Aggregator/Repeater driver


From: Harish Jenny K N
Subject: Re: [PATCH v3 5/7] gpio: Add GPIO Aggregator/Repeater driver
Date: Tue, 3 Dec 2019 11:12:38 +0530
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

> +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 <address@hidden>");
> +MODULE_DESCRIPTION("GPIO Aggregator/Repeater");
> +MODULE_LICENSE("GPL v2");






reply via email to

[Prev in Thread] Current Thread [Next in Thread]