lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 13 Mar 2013 15:15:16 +0100
From:	Linus Walleij <linus.walleij@...aro.org>
To:	Ian Lartey <ian@...mlogic.co.uk>
Cc:	linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org, linux-leds@...r.kernel.org,
	linux-watchdog@...r.kernel.org, swarren@...dotorg.org,
	grant.likely@...retlab.ca, broonie@...nsource.wolfsonmicro.com,
	rob.herring@...xeda.com, rob@...dley.net, mturquette@...aro.org,
	cooloney@...il.com, rpurdie@...ys.net, sameo@...ux.intel.com,
	wim@...ana.be, lgirdwood@...il.com, gg@...mlogic.co.uk,
	j-keerthy@...com, ldewangan@...dia.com, t-kristo@...com
Subject: Re: [PATCH v8 07/12] gpio: palmas: add in GPIO support for palmas charger

Sorry for slow replies :-(

On Thu, Mar 7, 2013 at 2:17 PM, Ian Lartey <ian@...mlogic.co.uk> wrote:

> +static int palmas_gpio_read(struct palmas *palmas, unsigned int reg,
> +               int gpio, unsigned int *dest)

I don't like "int gpio" here, please use "int offset".

This is not a global GPIO number, it is an offset in the local gpio_chip,
right?

> +{
> +       /* registers for second bank are identical and offset by 0x9 */
> +       if (gpio > 7)
> +               reg += PALMAS_GPIO_DATA_IN2;
> +
> +       return palmas_read(palmas, PALMAS_GPIO_BASE, reg, dest);
> +}
> +
> +static int palmas_gpio_write(struct palmas *palmas, unsigned int reg,
> +               int gpio, unsigned int data)
> +{
> +       /* registers for second bank are identical and offset by 0x9 */
> +       if (gpio > 7)
> +               reg += PALMAS_GPIO_DATA_IN2;
> +
> +       return palmas_write(palmas, PALMAS_GPIO_BASE, reg, data);
> +}
> +
> +static int palmas_gpio_update_bits(struct palmas *palmas, unsigned int reg,
> +               int gpio, unsigned int mask, unsigned int data)
> +{
> +       /* registers for second bank are identical and offset by 0x9 */
> +       if (gpio > 7)
> +               reg += PALMAS_GPIO_DATA_IN2;
> +
> +       return palmas_update_bits(palmas, PALMAS_GPIO_BASE, reg, mask, data);
> +}


> -       ret = palmas_read(palmas, PALMAS_GPIO_BASE, PALMAS_GPIO_DATA_IN, &val);
> +       ret = palmas_gpio_read(palmas, PALMAS_GPIO_DATA_IN, offset, &val);

(Obviously you are passing the offset.)

> +               ret = palmas_gpio_write(palmas, PALMAS_GPIO_SET_DATA_OUT,
> +                               offset, BIT(offset % 8));
(..)
> +               ret = palmas_gpio_write(palmas, PALMAS_GPIO_CLEAR_DATA_OUT,
> +                               offset, BIT(offset % 8));
(...)
> +       ret = palmas_gpio_update_bits(palmas, PALMAS_GPIO_DATA_DIR,
> +                       offset, 1 << (offset % 8), 1 << (offset % 8));

Why aren't you using the BIT() macro here too?

Further: if these functions are always used like this, with offset
and some BIT() or (1 << (offset % 8)) why don't you move that
latter part into the static helper and just pass offset into the
helper?

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ