mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Florian Fainelli <florian@openwrt.org>,
	David Brownell <david-b@pacbell.net>, Willy Tarreau <w@1wt.eu>,
	linux-kernel@vger.kernel.org,
	Samuel Ortiz <sameo@linux.intel.com>,
	Miguel Gaio <miguel.gaio@efixo.com>,
	dbrownell@users.sourceforge.net, Juhos Gabor <juhosg@openwrt.org>
Subject: Re: [PATCH v5] GPIO: add support for 74x164 serial-in/parallel-out 8-bit shift register
Date: Wed, 20 Oct 2010 09:52:13 +0200	[thread overview]
Message-ID: <AANLkTi==o4dJSfuC5HT64ZWb0f3ZMG-hjTiK8Sh9UYoR@mail.gmail.com> (raw)
In-Reply-To: <20101019160010.45750e1c.akpm@linux-foundation.org>

On Wed, Oct 20, 2010 at 1:00 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Tue, 19 Oct 2010 09:26:42 +0200
> Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:
>
>> On Mon, Oct 18, 2010 at 9:35 PM, Florian Fainelli <florian@openwrt.org> wrote:
>> > From: Miguel Gaio <miguel.gaio@efixo.com>
>> >
>> > This patch adds support for generic 74x164 serial-in/parallel-out 8-bits
>> > shift register. This driver can be used as a GPIO output expander.
>> >
>> ...
>> > +struct gen_74x164_chip {
>> > +       struct spi_device       *spi;
>> > +       struct gpio_chip        gpio_chip;
>> > +       struct mutex            lock;
>> > +       u8                      port_config;
>> > +};
>> ...
>> > +static void gen_74x164_set_value(struct gpio_chip *gc,
>> > +               unsigned offset, int val)
>> > +{
>> > +       struct gen_74x164_chip *chip = gpio_to_chip(gc);
>> > +       bool refresh;
>> > +
>> > +       mutex_lock(&chip->lock);
>> > +       if (val)
>> > +               chip->port_config |= (1 << offset);
>> > +       else
>> > +               chip->port_config &= ~(1 << offset);
>>
>> set_bit(), clear_bit() ?
>
> They're only to be used on `unsigned long' types, and `port_config' is
> u8.
>

Right as always! Maybe BIT()? Don't we have a {SET,CLEAR}_BIT()-like
macros somewhere?

#define SET_BIT(var,nr) (var) |= BIT((nr))
#define CLEAR_BIT(var,nr) (var) &= ~BIT((nr))
#define PUT_BIT(var,nr,value) do { \
        if ((value)) \
                SET_BIT((var), (nr)); \
        else \
                CLEAR_BIT((var), (nr)); \
} while(0)

May I make a patch and try to see who could use it? I suppose a
Coccinelle's semantic patch would be great here.

  reply	other threads:[~2010-10-20  7:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-18 19:35 Florian Fainelli
2010-10-19  7:26 ` Miguel Ojeda
2010-10-19 23:00   ` Andrew Morton
2010-10-20  7:52     ` Miguel Ojeda [this message]
2010-10-20  8:17       ` Miguel Ojeda
2010-10-20 12:42         ` Florian Fainelli
2010-10-20 13:26           ` Miguel Ojeda
2010-10-20 14:28             ` David Brownell
2010-10-20 12:51 ` Bastien ROUCARIES
2010-10-20 17:06   ` Florian Fainelli

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='AANLkTi==o4dJSfuC5HT64ZWb0f3ZMG-hjTiK8Sh9UYoR@mail.gmail.com' \
    --to=miguel.ojeda.sandonis@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david-b@pacbell.net \
    --cc=dbrownell@users.sourceforge.net \
    --cc=florian@openwrt.org \
    --cc=juhosg@openwrt.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miguel.gaio@efixo.com \
    --cc=sameo@linux.intel.com \
    --cc=w@1wt.eu \
    /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

all inboxes | Powered by JetHome®