public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ian Lartey <ian@slimlogic.co.uk>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-leds@vger.kernel.org,
	linux-watchdog@vger.kernel.org, swarren@wwwdotorg.org,
	grant.likely@secretlab.ca, broonie@opensource.wolfsonmicro.com,
	rob.herring@calxeda.com, rob@landley.net, mturquette@linaro.org,
	cooloney@gmail.com, rpurdie@rpsys.net, sameo@linux.intel.com,
	wim@iguana.be, lgirdwood@gmail.com, gg@slimlogic.co.uk,
	j-keerthy@ti.com, ldewangan@nvidia.com, t-kristo@ti.com
Subject: Re: [PATCH v8 07/12] gpio: palmas: add in GPIO support for palmas charger
Date: Thu, 14 Mar 2013 11:58:10 +0000	[thread overview]
Message-ID: <5141BB52.6080604@slimlogic.co.uk> (raw)
In-Reply-To: <CACRpkdaNs+NmAbuwRYzn1xgjHy=7ZknJa-GD1+Q8HBsu53KQqQ@mail.gmail.com>

On 13/03/13 14:15, Linus Walleij wrote:
> Sorry for slow replies :-(
>
> On Thu, Mar 7, 2013 at 2:17 PM, Ian Lartey <ian@slimlogic.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?

Correct.
>
>> +{
>> +       /* 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?
>

Good points  - I missed the other bit shifts.


> Yours,
> Linus Walleij


Thanks

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


  reply	other threads:[~2013-03-14 11:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-07 13:17 [PATCH v8 01/12] mfd: DT bindings for the palmas family MFD Ian Lartey
2013-03-07 13:17 ` [PATCH v8 02/12] mfd: palmas: is_palmas_charger needed by multiple drivers Ian Lartey
2013-03-07 13:17 ` [PATCH v8 03/12] mfd: palmas add variant and OTP detection Ian Lartey
2013-03-07 13:17 ` [PATCH v8 04/12] regulator: palmas correct dt parsing Ian Lartey
2013-03-08  9:44   ` Mark Brown
2013-03-07 13:17 ` [PATCH v8 05/12] watchdog: add Palmas Watchdog support Ian Lartey
2013-03-07 13:17 ` [PATCH v8 06/12] watchdog: Kconfig for Palmas watchdog Ian Lartey
2013-03-07 13:17 ` [PATCH v8 07/12] gpio: palmas: add in GPIO support for palmas charger Ian Lartey
2013-03-13 14:15   ` Linus Walleij
2013-03-14 11:58     ` Ian Lartey [this message]
2013-03-07 13:17 ` [PATCH v8 08/12] gpio: palmas: Enable DT support for palmas gpio Ian Lartey
2013-03-13 14:20   ` Linus Walleij
2013-03-07 13:17 ` [PATCH v8 09/12] leds: Add support for Palmas LEDs Ian Lartey
2013-03-07 13:17 ` [PATCH v8 10/12] clk: Kconfig for Palmas clock driver Ian Lartey
2013-03-07 13:17 ` [PATCH v8 11/12] leds: Kconfig for Palmas LEDs Ian Lartey
2013-03-07 13:17 ` [PATCH v8 12/12] clk: add a clock driver for palmas Ian Lartey
2013-03-21 21:23   ` Mike Turquette
2013-03-07 13:23 ` [PATCH v8 0/12] Palmas Updates Ian Lartey
2013-03-08  7:12   ` Linus Walleij
2013-03-08 17:12     ` Ian Lartey
2013-03-13 20:28 ` [PATCH v8 01/12] mfd: DT bindings for the palmas family MFD Stephen Warren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5141BB52.6080604@slimlogic.co.uk \
    --to=ian@slimlogic.co.uk \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=cooloney@gmail.com \
    --cc=gg@slimlogic.co.uk \
    --cc=grant.likely@secretlab.ca \
    --cc=j-keerthy@ti.com \
    --cc=ldewangan@nvidia.com \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=mturquette@linaro.org \
    --cc=rob.herring@calxeda.com \
    --cc=rob@landley.net \
    --cc=rpurdie@rpsys.net \
    --cc=sameo@linux.intel.com \
    --cc=swarren@wwwdotorg.org \
    --cc=t-kristo@ti.com \
    --cc=wim@iguana.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox