From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Klara Modin <klarasmodin@gmail.com>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
"Marek Behún" <kabel@kernel.org>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Daire McNamara" <daire.mcnamara@microchip.com>,
"Daniel Palmer" <daniel@thingy.jp>,
"Romain Perier" <romain.perier@gmail.com>,
"Avi Fishman" <avifishman70@gmail.com>,
"Tomer Maimon" <tmaimon77@gmail.com>,
"Tali Perry" <tali.perry1@gmail.com>,
"Patrick Venture" <venture@google.com>,
"Nancy Yuen" <yuenn@google.com>,
"Benjamin Fair" <benjaminfair@google.com>,
"Grygorii Strashko" <grygorii.strashko@ti.com>,
"Santosh Shilimkar" <ssantosh@kernel.org>,
"Kevin Hilman" <khilman@kernel.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org,
linux-arm-kernel@lists.infradead.org, openbmc@lists.ozlabs.org,
linux-omap@vger.kernel.org,
"Bartosz Golaszewski" <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH 01/12] gpio: mmio: use new GPIO line value setter callbacks
Date: Wed, 18 Jun 2025 14:34:43 +0200 [thread overview]
Message-ID: <CAMRc=Mf==gzqXEUMd3D_-XYG7Bg7dSMLgjg3sq5-GoB1BUGchA@mail.gmail.com> (raw)
In-Reply-To: <2rw2sncevdiyirpdovotztlg77apcq2btzytuv5jnm55aqhlne@swtts3hl53tw>
On Wed, Jun 18, 2025 at 1:59 PM Klara Modin <klarasmodin@gmail.com> wrote:
>
> Hi,
>
> On 2025-06-10 14:33:11 +0200, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > struct gpio_chip now has callbacks for setting line values that return
> > an integer, allowing to indicate failures. Convert the driver to using
> > them.
> >
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > ---
> > drivers/gpio/gpio-mmio.c | 53 ++++++++++++++++++++++++++++++------------------
> > 1 file changed, 33 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
> > index 4841e4ebe7a67d0f954e9a6f995ec5758f124edd..9169eccadb238efe944d494054b1e009f16eee7f 100644
> > --- a/drivers/gpio/gpio-mmio.c
> > +++ b/drivers/gpio/gpio-mmio.c
> > @@ -211,11 +211,12 @@ static int bgpio_get_multiple_be(struct gpio_chip *gc, unsigned long *mask,
> > return 0;
> > }
> >
> > -static void bgpio_set_none(struct gpio_chip *gc, unsigned int gpio, int val)
> > +static int bgpio_set_none(struct gpio_chip *gc, unsigned int gpio, int val)
> > {
> > + return 0;
> > }
> >
> > -static void bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
> > +static int bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
> > {
> > unsigned long mask = bgpio_line2mask(gc, gpio);
> > unsigned long flags;
> > @@ -230,10 +231,12 @@ static void bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
> > gc->write_reg(gc->reg_dat, gc->bgpio_data);
> >
> > raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
> > +
> > + return 0;
> > }
> >
> > -static void bgpio_set_with_clear(struct gpio_chip *gc, unsigned int gpio,
> > - int val)
> > +static int bgpio_set_with_clear(struct gpio_chip *gc, unsigned int gpio,
> > + int val)
> > {
> > unsigned long mask = bgpio_line2mask(gc, gpio);
> >
> > @@ -241,9 +244,11 @@ static void bgpio_set_with_clear(struct gpio_chip *gc, unsigned int gpio,
> > gc->write_reg(gc->reg_set, mask);
> > else
> > gc->write_reg(gc->reg_clr, mask);
> > +
> > + return 0;
> > }
> >
> > -static void bgpio_set_set(struct gpio_chip *gc, unsigned int gpio, int val)
> > +static int bgpio_set_set(struct gpio_chip *gc, unsigned int gpio, int val)
> > {
> > unsigned long mask = bgpio_line2mask(gc, gpio);
> > unsigned long flags;
> > @@ -258,6 +263,8 @@ static void bgpio_set_set(struct gpio_chip *gc, unsigned int gpio, int val)
> > gc->write_reg(gc->reg_set, gc->bgpio_data);
> >
> > raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
> > +
> > + return 0;
> > }
> >
> > static void bgpio_multiple_get_masks(struct gpio_chip *gc,
> > @@ -298,21 +305,25 @@ static void bgpio_set_multiple_single_reg(struct gpio_chip *gc,
> > raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
> > }
> >
> > -static void bgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
> > +static int bgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
> > unsigned long *bits)
> > {
> > bgpio_set_multiple_single_reg(gc, mask, bits, gc->reg_dat);
> > +
> > + return 0;
> > }
> >
> > -static void bgpio_set_multiple_set(struct gpio_chip *gc, unsigned long *mask,
> > - unsigned long *bits)
> > +static int bgpio_set_multiple_set(struct gpio_chip *gc, unsigned long *mask,
> > + unsigned long *bits)
> > {
> > bgpio_set_multiple_single_reg(gc, mask, bits, gc->reg_set);
> > +
> > + return 0;
> > }
> >
> > -static void bgpio_set_multiple_with_clear(struct gpio_chip *gc,
> > - unsigned long *mask,
> > - unsigned long *bits)
> > +static int bgpio_set_multiple_with_clear(struct gpio_chip *gc,
> > + unsigned long *mask,
> > + unsigned long *bits)
> > {
> > unsigned long set_mask, clear_mask;
> >
> > @@ -322,6 +333,8 @@ static void bgpio_set_multiple_with_clear(struct gpio_chip *gc,
> > gc->write_reg(gc->reg_set, set_mask);
> > if (clear_mask)
> > gc->write_reg(gc->reg_clr, clear_mask);
> > +
> > + return 0;
> > }
> >
> > static int bgpio_dir_return(struct gpio_chip *gc, unsigned int gpio, bool dir_out)
> > @@ -510,18 +523,18 @@ static int bgpio_setup_io(struct gpio_chip *gc,
> > if (set && clr) {
> > gc->reg_set = set;
> > gc->reg_clr = clr;
> > - gc->set = bgpio_set_with_clear;
> > - gc->set_multiple = bgpio_set_multiple_with_clear;
> > + gc->set_rv = bgpio_set_with_clear;
> > + gc->set_multiple_rv = bgpio_set_multiple_with_clear;
> > } else if (set && !clr) {
> > gc->reg_set = set;
> > - gc->set = bgpio_set_set;
> > - gc->set_multiple = bgpio_set_multiple_set;
> > + gc->set_rv = bgpio_set_set;
> > + gc->set_multiple_rv = bgpio_set_multiple_set;
> > } else if (flags & BGPIOF_NO_OUTPUT) {
> > - gc->set = bgpio_set_none;
> > - gc->set_multiple = NULL;
> > + gc->set_rv = bgpio_set_none;
> > + gc->set_multiple_rv = NULL;
> > } else {
> > - gc->set = bgpio_set;
> > - gc->set_multiple = bgpio_set_multiple;
> > + gc->set_rv = bgpio_set;
> > + gc->set_multiple_rv = bgpio_set_multiple;
> > }
> >
> > if (!(flags & BGPIOF_UNREADABLE_REG_SET) &&
> > @@ -654,7 +667,7 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev,
> > }
> >
> > gc->bgpio_data = gc->read_reg(gc->reg_dat);
> > - if (gc->set == bgpio_set_set &&
> > + if (gc->set_rv == bgpio_set_set &&
> > !(flags & BGPIOF_UNREADABLE_REG_SET))
> > gc->bgpio_data = gc->read_reg(gc->reg_set);
> >
> >
> > --
> > 2.48.1
> >
>
> Isn't this missing to convert gc->set() to gc-set_rv() in several
> places?
>
> Without the attached diff I get a null pointer reference on e.g. the
> spacemit k1 driver.
>
Ah, yes, sorry for this and thanks for the catch. I will send a follow-up.
Bartosz
next prev parent reply other threads:[~2025-06-18 12:34 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 12:33 [PATCH 00/12] gpio: convert another round of GPIO drivers to using new line value setters Bartosz Golaszewski
2025-06-10 12:33 ` [PATCH 01/12] gpio: mmio: use new GPIO line value setter callbacks Bartosz Golaszewski
2025-06-10 21:16 ` Linus Walleij
2025-06-18 11:59 ` Klara Modin
2025-06-18 12:34 ` Bartosz Golaszewski [this message]
2025-06-18 16:21 ` Mark Brown
2025-06-18 16:24 ` Bartosz Golaszewski
[not found] ` <CGME20250618164320eucas1p28174732f38fd279fbba72f07887e5da5@eucas1p2.samsung.com>
2025-06-18 16:43 ` Marek Szyprowski
2025-06-18 17:00 ` Bartosz Golaszewski
2025-06-10 12:33 ` [PATCH 02/12] gpio: mm-lantiq: " Bartosz Golaszewski
2025-06-10 22:01 ` Linus Walleij
2025-06-10 12:33 ` [PATCH 03/12] gpio: moxtet: " Bartosz Golaszewski
2025-06-13 14:40 ` Marek Behún
2025-06-10 12:33 ` [PATCH 04/12] gpio: mpc5200: " Bartosz Golaszewski
2025-06-10 12:33 ` [PATCH 05/12] gpio: mpfs: " Bartosz Golaszewski
2025-06-10 12:33 ` [PATCH 06/12] gpio: mpsse: " Bartosz Golaszewski
2025-06-10 12:33 ` [PATCH 07/12] gpio: msc313: " Bartosz Golaszewski
2025-06-11 22:21 ` Daniel Palmer
2025-06-10 12:33 ` [PATCH 08/12] gpio: nomadik: " Bartosz Golaszewski
2025-06-10 22:06 ` Linus Walleij
2025-06-10 12:33 ` [PATCH 09/12] gpio: npcm-sgpio: " Bartosz Golaszewski
2025-06-10 12:33 ` [PATCH 10/12] gpio: octeon: " Bartosz Golaszewski
2025-06-10 12:33 ` [PATCH 11/12] gpio: omap: " Bartosz Golaszewski
2025-06-10 12:33 ` [PATCH 12/12] gpio: palmas: " Bartosz Golaszewski
2025-06-17 9:14 ` [PATCH 00/12] gpio: convert another round of GPIO drivers to using new line value setters 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=Mf==gzqXEUMd3D_-XYG7Bg7dSMLgjg3sq5-GoB1BUGchA@mail.gmail.com' \
--to=brgl@bgdev.pl \
--cc=avifishman70@gmail.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=benjaminfair@google.com \
--cc=conor.dooley@microchip.com \
--cc=daire.mcnamara@microchip.com \
--cc=daniel@thingy.jp \
--cc=grygorii.strashko@ti.com \
--cc=kabel@kernel.org \
--cc=khilman@kernel.org \
--cc=klarasmodin@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=openbmc@lists.ozlabs.org \
--cc=romain.perier@gmail.com \
--cc=ssantosh@kernel.org \
--cc=tali.perry1@gmail.com \
--cc=tmaimon77@gmail.com \
--cc=venture@google.com \
--cc=yuenn@google.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).