[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211209082623.GF25091@packtop>
Date: Thu, 9 Dec 2021 08:26:24 +0000
From: Zev Weiss <zweiss@...inix.com>
To: Jonathan Neuschäfer <j.neuschaefer@....net>
CC: Andy Shevchenko <andy.shevchenko@...il.com>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
Tomer Maimon <tmaimon77@...il.com>,
"openbmc@...ts.ozlabs.org" <openbmc@...ts.ozlabs.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
Rob Herring <robh+dt@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>
Subject: Re: [PATCH v2 5/8] pinctrl: nuvoton: Add driver for WPCM450
On Wed, Dec 08, 2021 at 05:58:30AM PST, Jonathan Neuschäfer wrote:
>Hi,
>
>On Wed, Dec 08, 2021 at 01:24:18PM +0200, Andy Shevchenko wrote:
>> On Tuesday, December 7, 2021, Jonathan Neuschäfer <j.neuschaefer@....net>
>
><snip>
>
>> > +static void wpcm450_gpio_irqhandler(struct irq_desc *desc)
>> > +{
>> > + struct wpcm450_gpio *gpio = gpiochip_get_data(irq_desc_
>> > get_handler_data(desc));
>> > + struct wpcm450_pinctrl *pctrl = gpio->pctrl;
>> > + struct irq_chip *chip = irq_desc_get_chip(desc);
>> > + unsigned long pending;
>> > + unsigned long flags;
>> > + unsigned long ours;
>> > + unsigned int bit;
>> > +
>> > + ours = ((1UL << gpio->num_irqs) - 1) << gpio->first_irq_bit;
>>
>>
>> BIT()
>
>I'll use it, but in this case, I think it doesn't simplify much the
>whole expression all that much. Is there perhaps a macro that
>constructs a continuous bitmask of N bits, perhaps additionally
>left-shifted by M bits?
>
>Maybe somewhere in the bitmap_* API...
>
There's GENMASK(), though it takes a high bit and low bit rather than a
bit position and count, so it'd require a small bit of arithmetic, e.g.
lastbit = gpio->first_irq_bit + gpio->num_irqs - 1;
ours = GENMASK(lastbit, gpio->first_irq_bit);
or a manual shift:
ours = GENMASK(gpio->num_irqs - 1, 0) << gpio->first_irq_bit;
(I don't have any terribly strong opinions on which of these is best,
personally.)
Zev
Powered by blists - more mailing lists