Re: [PATCH v2] gpio: gpiolib: clear the array_info's memory space

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 4, 2023 at 12:38 PM Yan Wang <rk.code@xxxxxxxxxxx> wrote:
> On 4/26/2023 10:42 PM, andy.shevchenko@xxxxxxxxx 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




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux