Re: [PATCH v7 12/17] gpio: madera: Support Cirrus Logic Madera class codecs
From: Linus Walleij
Date: Tue Jan 16 2018 - 04:27:13 EST
On Mon, Jan 15, 2018 at 1:42 PM, Richard Fitzgerald
<rf@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> This adds support for the GPIOs on Cirrus Logic Madera class codecs.
> Any pins not used for special functions (see the pinctrl driver) can be
> used as general single-bit input or output lines. The number of available
> GPIOs varies between codecs.
>
> Signed-off-by: Nariman Poushin <nariman@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Charles Keepax <ckeepax@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
> Acked-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
I see Andy found more problems so fix those too..
> +#include <linux/device.h>
> +#include <linux/gpio.h>
Only
#include <linux/gpio/driver.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
Not for bool drivers, right, as Andy pointed out.
> +static struct gpio_chip template_chip = {
Why is this named "template"?
There is nothing template about it, it is what you use.
If you keep it like this, name it madera_chip or something.
> + .label = "madera",
> + .owner = THIS_MODULE,
> + .request = gpiochip_generic_request,
> + .free = gpiochip_generic_free,
> + .get_direction = madera_gpio_get_direction,
> + .direction_input = madera_gpio_direction_in,
> + .get = madera_gpio_get,
> + .direction_output = madera_gpio_direction_out,
> + .set = madera_gpio_set,
> + .set_config = gpiochip_generic_config,
Pretty cool! Have you tested this with e.g. open drain or debounce?
> + ret = gpiochip_add_pin_range(&madera_gpio->gpio_chip, "madera-pinctrl",
> + 0, 0, madera_gpio->gpio_chip.ngpio);
Are you using device tree for this?
In that case add the range in the device tree instead.
The gpiolib will pick that up for you by default and you don't even need
this code. See
git grep 'gpio-ranges' arch/arm/boot/dts
If you're also using this with platform data or ACPI or whatever, then
this is fine.
Yours,
Linus Walleij