[PATCH] ARM: sunxi: gpio: Add Allwinner SoCs GPIO drivers

Linus Walleij linus.walleij at linaro.org
Wed Jan 23 10:39:11 EST 2013


On Wed, Jan 23, 2013 at 10:34 AM, Maxime Ripard
<maxime.ripard at free-electrons.com> wrote:

> The IP responsible for the muxing on the Allwinner SoCs are also
> handling the GPIOs on the system. This patch adds the needed driver that
> relies on the pinctrl driver for most of its operations.
>
> The number of pins available for GPIOs operations are already declared
> in the pinctrl driver, we only need to probe a generic driver to handle
> the banks available for each SoC.
>
> This driver has been tested on a A13-Olinuxino.
>
> Signed-off-by: Maxime Ripard <maxime.ripard at free-electrons.com>

Overall this is VERY NICE!

> +       char *func, *pin_name;
(...)
> +       pin_name = kzalloc(5, GFP_KERNEL);
> +       if (!pin_name)
> +               return -ENOMEM;
> +
> +       ret = sprintf(pin_name, "P%c%d", 'A' + bank, pin);
> +       if (!ret)
> +               goto error;
(...)
> +error:
> +       kfree(pin_name);

Isn't this a bit awkward?

Can't you either use something like a local
static char foo[MAX_SIZE]; or atleast try to use
one of the static string print functions from <linux/kernel.h>:

/* lib/printf utilities */

extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...);
extern __printf(2, 0) int vsprintf(char *buf, const char *, va_list);
extern __printf(3, 4)
int snprintf(char *buf, size_t size, const char *fmt, ...);
extern __printf(3, 0)
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
extern __printf(3, 4)
int scnprintf(char *buf, size_t size, const char *fmt, ...);
extern __printf(3, 0)
int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
extern __printf(2, 3)
char *kasprintf(gfp_t gfp, const char *fmt, ...);
extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list