linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Yan Wang <rk.code@outlook.com>
Cc: linus.walleij@linaro.org, brgl@bgdev.pl,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] gpio: gpiolib: clear the array_info's memory space
Date: Thu, 4 May 2023 14:36:46 +0300	[thread overview]
Message-ID: <CAHp75VdFqL4e=awSg0pxnzEYLvWRenTYohRfZ5p-ZOc2B5Lzgg@mail.gmail.com> (raw)
In-Reply-To: <KL1PR01MB544880BE86B3890E33609C5AE66D9@KL1PR01MB5448.apcprd01.prod.exchangelabs.com>

On Thu, May 4, 2023 at 12:38 PM Yan Wang <rk.code@outlook.com> wrote:
> On 4/26/2023 10:42 PM, andy.shevchenko@gmail.com wrote:
> > Sun, Apr 23, 2023 at 09:59:43PM +0800, Yan Wang kirjoitti:
> >> if hardware number different to array index,it needs to clear to points
> >> memory space if the array_info have been assigned a value.
> > Can you explain a bit more what's going on there?

...

> I use gpiod_get_array() to get a gpio array form the node of DTS.
>
> the node is as follows:
> ...
> gpios = <&gpio1 0 0>, <&gpio1 10 0>;
> ...
>
> First scan pin-0 of gpio1,its index and hardware number are 0,
>
> if (descs->ndescs == 0 && gpio_chip_hwgpio(desc) == 0) {
>      ...
>      descs->info = array_info.
> }
>
> Then scan pin-10 , its index is 1 ,but hardware number is 10 .
>
> if (gpio_chip_hwgpio(desc) != descs->ndescs) {
>      array_info = NULL;
> }
> just set array_info = NULL, Should the array_info point to memory be
> cleared ?

This is a good question. The entire algorithm is a bit difficult to
understand from the first glance. I need some time to check it myself.

> if not cleared ,I use the gpiod_set_array_value_cansleep() to pull up or
> down pin-10 is invalid.

I'm not sure I follow. The array operations are against the given
array of the descriptors. If you ask to have that operation done, the
all descriptors in the array should be considered.

> I found that the set_mask and get_mask vlaues of descs->info are seted
> 0x03 in gpiod_get_array(),

Yes, this mask is for the argument. The 0x03 is the correct one.

> I think 0x401 is their correct value.

No. You have an array of two elements, and not 11.

> >> if (bitmap_full(array_info->get_mask, descs->ndescs)) {
> >> + /*clear descs->info*/
> >> + memset(array_info, 0, sizeof(struct gpio_array));
> >> array_info = NULL;
> >> }


-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2023-05-04 11:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-23 11:03 [PATCH v1] gpio: gpiolib: clear the array_info's memory space Yan Wang
2023-04-23 13:09 ` kernel test robot
2023-04-23 13:41 ` kernel test robot
2023-04-23 13:59   ` [PATCH v2] " Yan Wang
2023-04-26 14:42     ` andy.shevchenko
2023-04-27  6:13       ` Yan Wang
2023-05-04  9:36       ` Yan Wang
2023-05-04 11:36         ` Andy Shevchenko [this message]
2023-05-04 14:15           ` Yan Wang
2023-05-12  7:37             ` Yan Wang
2023-05-15  7:25     ` Linus Walleij

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='CAHp75VdFqL4e=awSg0pxnzEYLvWRenTYohRfZ5p-ZOc2B5Lzgg@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rk.code@outlook.com \
    /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).