All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Jack Winch <sunt.un.morcov@gmail.com>,
	Helmut Grohne <helmut.grohne@intenta.de>,
	linux-gpio@vger.kernel.org,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: Re: [libgpiod][PATCH] treewide: rework struct gpiod_line_bulk
Date: Fri, 23 Oct 2020 19:24:47 +0800	[thread overview]
Message-ID: <20201023112447.GA24669@sol> (raw)
In-Reply-To: <20201023092831.5842-1-brgl@bgdev.pl>

On Fri, Oct 23, 2020 at 11:28:31AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> Current implementation of struct gpiod_line_bulk uses stack memory
> excessively. The structure is big: it's an array 64 pointers + 4 bytes
> size. That amounts to 260 bytes on 32-bit and 516 bytes on 64-bit
> architectures respectively. It's also used everywhere as all functions
> dealing with single lines eventually end up calling bulk counterparts.
> 
> The rework addresses it by making the bulk structure opaque and
> providing appropriate interfaces for library users while retaining a way
> for internal users to allocate single line bulks on the stack.
> 
> The macro-based loop has been removed. In its place we provide a function
> iterating over all lines held by a bulk and calling the provided callback
> function for each line as well as a new line bulk iterator which works
> similarily to chip and line iterators.
> 
> Since bulk operations can now fail, a bunch of test-cases has been added
> to cover the relevant code.
> 
> While at it: using the word offset both when referring to line's HW
> offset in a chip as well as the offset in a bulk leads to confusion.
> This patch renames the bulk offset to index.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>  bindings/cxx/gpiod.hpp        |  18 ++-
>  bindings/cxx/line_bulk.cpp    | 112 +++++++++--------
>  bindings/python/gpiodmodule.c | 182 +++++++++++++++++++--------
>  include/gpiod.h               | 169 +++++++++++++------------
>  lib/core.c                    | 178 +++++++++++++++++++--------
>  lib/ctxless.c                 |  53 +++++---
>  lib/helpers.c                 |  61 +++++----
>  lib/iter.c                    |  33 +++++
>  tests/Makefile.am             |   1 +
>  tests/gpiod-test.h            |   5 +
>  tests/tests-bulk.c            | 158 ++++++++++++++++++++++++
>  tests/tests-chip.c            |  59 +++++----
>  tests/tests-event.c           |  73 +++++++----
>  tests/tests-iter.c            |  26 ++++
>  tests/tests-line.c            | 225 +++++++++++++---------------------
>  15 files changed, 888 insertions(+), 465 deletions(-)
>  create mode 100644 tests/tests-bulk.c
> 
> diff --git a/bindings/cxx/gpiod.hpp b/bindings/cxx/gpiod.hpp
> index 8dfc172..83f543f 100644
> --- a/bindings/cxx/gpiod.hpp
> +++ b/bindings/cxx/gpiod.hpp
> @@ -626,18 +626,18 @@ public:
>  
>  	/**
>  	 * @brief Get the line at given offset.
> -	 * @param offset Offset of the line to get.
> +	 * @param index Offset of the line to get.
>  	 * @return Reference to the line object.
>  	 */

The comment still says "Offset" and so is still confusing.
Change it to something like: "Index of the line within the bulk"?

And document what happens if index >= size()?

Similarly elsewhere.

That is just the one thing that got my attention - I'll try to
find time to go over the whole patch in the next few days.

Cheers,
Kent.


  parent reply	other threads:[~2020-10-23 11:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23  9:28 [libgpiod][PATCH] treewide: rework struct gpiod_line_bulk Bartosz Golaszewski
2020-10-23 10:24 ` Andy Shevchenko
2020-10-23 11:38   ` Bartosz Golaszewski
2020-10-23 12:06     ` Andy Shevchenko
2020-10-23 12:09       ` Andy Shevchenko
2020-10-23 12:44         ` Bartosz Golaszewski
2020-10-23 14:17           ` Andy Shevchenko
2020-10-23 15:14             ` Bartosz Golaszewski
2020-10-23 11:24 ` Kent Gibson [this message]
2020-10-24  8:01 ` Kent Gibson
2020-10-25 20:25   ` Bartosz Golaszewski

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=20201023112447.GA24669@sol \
    --to=warthog618@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=brgl@bgdev.pl \
    --cc=geert@linux-m68k.org \
    --cc=helmut.grohne@intenta.de \
    --cc=linux-gpio@vger.kernel.org \
    --cc=sunt.un.morcov@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.