All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Kent Gibson <warthog618@gmail.com>,
	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>,
	"open list:GPIO SUBSYSTEM" <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 13:38:49 +0200	[thread overview]
Message-ID: <CAMRc=McD7jtBQ_CPV26Pzr63T6-o_aPpYt_CT-48H_mGuhxrGw@mail.gmail.com> (raw)
In-Reply-To: <CAHp75VeiGSJO5XnpQLMs=0nT=otVjC1tOsR7xp1gJ3tLHwUTaA@mail.gmail.com>

On Fri, Oct 23, 2020 at 12:24 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Fri, Oct 23, 2020 at 12:31 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >

[snip]

>
> > +struct gpiod_line_bulk {
> > +       struct gpiod_chip *owner;
> > +       unsigned int num_lines;
> > +       unsigned int max_lines;
> > +       struct gpiod_line *lines[1];
>
> Why not '[]' as we do in the kernel?
>

Because I want to be able to store a single line in this structure if I do:

    struct gpiod_line_bulk bulk;

Using [] makes the size of this structure not take into account the
last array member.

> > +};
>
> > +#define BULK_SINGLE_LINE_INIT(line) \
> > +               { gpiod_line_get_chip(line), 1, 1, { (line) } }
>
> Hmm... Perhaps union can help here?
>
> union {
>   struct *lines[];
>   struct *line;
> }
>
> num_lines == 1 exactly defines this.
>

Nope because gcc will scream:

error: flexible array member in union

Bartosz

  reply	other threads:[~2020-10-23 11:39 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 [this message]
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
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='CAMRc=McD7jtBQ_CPV26Pzr63T6-o_aPpYt_CT-48H_mGuhxrGw@mail.gmail.com' \
    --to=brgl@bgdev.pl \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=geert@linux-m68k.org \
    --cc=helmut.grohne@intenta.de \
    --cc=linux-gpio@vger.kernel.org \
    --cc=sunt.un.morcov@gmail.com \
    --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 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.