linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linaro.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	devicetree <devicetree@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH v2 3/3] gpio: Add Spreadtrum PMIC EIC driver support
Date: Wed, 28 Feb 2018 10:22:08 +0800	[thread overview]
Message-ID: <CAMz4kuJJpVEbvS8pUaqW6qQYo1K=y61yb+JsfU9rQ6GKNotRYw@mail.gmail.com> (raw)
In-Reply-To: <CAHp75Vfes+7yKRu1Q+V91c4SxPgNbvBKKDWLxy34Q+3GauRcoQ@mail.gmail.com>

On 27 February 2018 at 23:54, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Tue, Feb 27, 2018 at 4:35 AM, Baolin Wang <baolin.wang@linaro.org> wrote:
>> On 26 February 2018 at 20:02, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>>> On Mon, Feb 26, 2018 at 5:01 AM, Baolin Wang <baolin.wang@linaro.org> wrote:
>>>> On 25 February 2018 at 20:19, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>
>>>>>> +       for (n = 0; n < chip->ngpio; n++) {
>>>>>> +               if (!(BIT(n) & val))
>>>>>
>>>>> for_each_set_bit().
>>>>>
>>>>> At some point you may need just to go across lib/ in the kernel and
>>>>> see what we have there.
>>>>
>>>> I've considered the for_each_set_bit(), it need one 'unsigned long'
>>>> type parameter, but we get the value from regmap is 'u32' type. So we
>>>> need one extra conversion from 'u32' to 'unsigned long' like:
>>>>
>>>> unsigned long reg = val;
>>>>
>>>> for_each_set_bit(n, &reg, chip->ngpio) {
>>>>         .......
>>>> }
>>>>
>>>> If you like this conversion, then I can change to use
>>>> for_each_set_bit(). Thanks.
>>>
>>> Wouldn't it work like
>>>
>>> unsigned long val;
>>>
>>> ...regmap_read(..., &val);
>>>
>>> ?
>>
>> It can not work, regmap_read() expects 'unsigned int *'.
>
> Ah, OK, than the temporary variable is a left approach.
>
>> But I can
>> convert it like this:
>>
>> for_each_set_bit(n, (unsigned long *)&val, chip->ngpio) {
>>          .......
>> }
>
> No, this is a boilerplate for static analyzers and definitely UB.

OK. Thanks for pointing this issue out.

-- 
Baolin.wang
Best Regards

  reply	other threads:[~2018-02-28  2:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-24 10:44 [PATCH v2 1/3] dt-bindings: gpio: Add Spreadtrum EIC controller documentation Baolin Wang
2018-02-24 10:44 ` [PATCH v2 2/3] gpio: Add Spreadtrum EIC driver support Baolin Wang
2018-03-02  9:53   ` Linus Walleij
2018-03-02 10:48     ` Baolin Wang
2018-03-02 12:40       ` Linus Walleij
2018-02-24 10:44 ` [PATCH v2 3/3] gpio: Add Spreadtrum PMIC " Baolin Wang
2018-02-25 12:19   ` Andy Shevchenko
2018-02-26  3:01     ` Baolin Wang
2018-02-26 12:02       ` Andy Shevchenko
2018-02-27  2:35         ` Baolin Wang
2018-02-27 15:54           ` Andy Shevchenko
2018-02-28  2:22             ` Baolin Wang [this message]
2018-03-02 22:08 ` [PATCH v2 1/3] dt-bindings: gpio: Add Spreadtrum EIC controller documentation Rob Herring

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='CAMz4kuJJpVEbvS8pUaqW6qQYo1K=y61yb+JsfU9rQ6GKNotRYw@mail.gmail.com' \
    --to=baolin.wang@linaro.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).