Re: [PATCH v7 08/12] pinctrl: Add pinctrl driver for the RK805 PMIC

From: Linus Walleij
Date: Thu Aug 03 2017 - 03:40:18 EST


On Fri, Jul 21, 2017 at 1:18 PM, Joseph Chen <chenjh@xxxxxxxxxxxxxx> wrote:

> RK805 is one of Rockchip PMICs family, it has 2 output only GPIOs.
>
> This driver is also designed for other Rockchip PMICs to expend.
> Different PMIC maybe have different pin features, for example,
> RK816 has one pin which can be used for TS or GPIO(input/out).
> The mainly difference between PMICs pins are pinmux, direction
> and output value, that is 'struct rk805_pin_config'.
>
> Signed-off-by: Joseph Chen <chenjh@xxxxxxxxxxxxxx>

OK nice! Some comments:

> +config PINCTRL_RK805
> + tristate "Pinctrl and GPIO driver for RK805 PMIC"
> + depends on MFD_RK808 && GPIOLIB

Nowadays I would recommend simply:

depends on MFD_RK808
select GPIOLIB

> +#include <linux/delay.h>
> +#include <linux/gpio.h>

Just #include <linux/gpio/driver.h>

> +#define FUNCTION_GROUP(fname, mux, gname) \
> + { \
> + .name = #fname, \
> + .groups = gname##_gpio_groups, \
> + .ngroups = ARRAY_SIZE(gname##_gpio_groups), \
> + .mux_option = RK805_PINMUX_##mux, \
> + }
> +
> +#define PINGROUP(pg_name, pin_id) \
> + { \
> + .name = #pg_name, \
> + .pins = {RK805_##pin_id}, \
> + .npins = 1, \
> + }
> +
> +/* RK805: 2 output only GPIOs */
> +static const struct pinctrl_pin_desc rk805_pins_desc[] = {
> + PINCTRL_PIN(RK805_GPIO0, "gpio0"),
> + PINCTRL_PIN(RK805_GPIO1, "gpio1"),
> +};
> +
> +static const struct rk805_pin_function rk805_pin_functions[] = {
> + FUNCTION_GROUP(gpio, GPIO, rk805),
> +};
> +
> +static const struct rk805_pin_group rk805_pin_groups[] = {
> + PINGROUP(gpio0, GPIO0),
> + PINGROUP(gpio1, GPIO1),
> +};

It looks like the macros just obscure things? Why not simply inline the data
and open code it as it is just two pins?

Apart from this it looks nice and complete.

Yours,
Linus Walleij