Linux-GPIO Archive mirror
 help / color / mirror / Atom feed
From: Gilles BULOZ <gilles.buloz@kontron.com>
To: Kent Gibson <warthog618@gmail.com>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>, linux-gpio@vger.kernel.org
Subject: Re: [questions] : gpiolib and gpioset behaviour
Date: Mon, 29 Apr 2024 10:50:04 +0200	[thread overview]
Message-ID: <0916be3f-8549-30d2-349d-642f850e0810@kontron.com> (raw)
In-Reply-To: <20240427120902.GA367260@rigel>

On Sat, Apr 27, 2024 at 02:09 PM Kent Gibson wrote:
> On Fri, Apr 26, 2024 at 10:07:20AM +0800, Kent Gibson wrote:
>> On Mon, Apr 22, 2024 at 06:49:05PM +0200, Gilles BULOZ wrote:
>>> On Mon, Apr 22, 2024 at 3:55 PM Bartosz Golaszewski wrote :
>>>> On Mon, Apr 22, 2024 at 2:44 PM Gilles BULOZ <gilles.buloz@kontron.com> wrote:
>>>>>
>>
>> Note that the mask in gc->get_multiple() is unsigned long*, so it is a
>> pointer to an array of unsigned long.  Its width is not limited by
>> unsigned long, but by the bits parameter.  In your case the mask you pass
>> should contain multiple unsigned longs to achieve 112 bits.
>> Refer to gpiod_get_array_value_complex() for an example of building bitmap
>> masks to pass to gc->get_multiple(), in that case via
>> gpio_chip_get_multiple().
>>
>
> Bah, what was I saying here - both the mask AND bits parameters of
> get_multiple()/set_multiple() are bitmaps of width gc->ngpio, where the
> mask identifies the pins to get/set and bits contains the values.
>
> My bad - must've been before the coffee soaked in.
>

Yes, that's clear to me now thanks to your explainations.
I also understand now the allocation of these "mask" and "bits". I was
missing the fact that gpiod_get_array_value_complex() has two calls to
gpio_chip_get_multiple(), the first without new allocation (value_bitmap
directly passed as last parameter to gpio_chip_get_multiple() and the
second allocating "mask" and "bits" (on FASTPATH_NGPIO bits so 512 bits
by default as set by CONFIG_GPIOLIB_FASTPATH_LIMIT). The second call
is the one used in the path from ioctl GPIO_V2_LINE_GET_VALUES_IOCTL to
the driver so OK.
The same occurs for gpiod_set_array_value_complex() having two calls to
gpio_chip_set_multiple() where the second one is used for ioctl
GPIO_V2_LINE_SET_VALUES_IOCTL.

> Cheers,
> Kent.
>
> .


      reply	other threads:[~2024-04-29  8:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22 12:44 [questions] : gpiolib and gpioset behaviour Gilles BULOZ
2024-04-22 15:55 ` Bartosz Golaszewski
2024-04-22 16:49   ` Gilles BULOZ
2024-04-22 18:04     ` Bartosz Golaszewski
2024-04-26  2:07     ` Kent Gibson
2024-04-26 13:08       ` Gilles BULOZ
2024-04-26 13:37         ` Kent Gibson
2024-04-26 16:16           ` Gilles BULOZ
2024-04-27  0:23             ` Kent Gibson
2024-04-27 12:09       ` Kent Gibson
2024-04-29  8:50         ` Gilles BULOZ [this message]

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=0916be3f-8549-30d2-349d-642f850e0810@kontron.com \
    --to=gilles.buloz@kontron.com \
    --cc=brgl@bgdev.pl \
    --cc=linux-gpio@vger.kernel.org \
    --cc=warthog618@gmail.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 read-only IMAP folder(s) and NNTP newsgroup(s).