From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-pwm@vger.kernel.org,
"Alexandru Ardelean" <alexandru.ardelean@analog.com>,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
"Conor Dooley" <conor+dt@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Lee Jones" <lee@kernel.org>, "Rob Herring" <robh@kernel.org>,
"Uwe Kleine-König" <ukleinek@kernel.org>,
"Haibo Chen" <haibo.chen@nxp.com>
Subject: Re: [PATCH 4/5] gpio: adp5585: Add Analog Devices ADP5585 support
Date: Tue, 28 May 2024 21:09:41 +0300 [thread overview]
Message-ID: <20240528180941.GA10903@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20240528122734.GA29970@pendragon.ideasonboard.com>
On Tue, May 28, 2024 at 03:27:34PM +0300, Laurent Pinchart wrote:
> Hi Linus,
>
> On Tue, May 28, 2024 at 01:54:29PM +0200, Linus Walleij wrote:
> > On Mon, May 20, 2024 at 9:59 PM Laurent Pinchart wrote:
> >
> > > From: Haibo Chen <haibo.chen@nxp.com>
> > >
> > > The ADP5585 is a 10/11 input/output port expander with a built in keypad
> > > matrix decoder, programmable logic, reset generator, and PWM generator.
> > > This driver supports the GPIO function using the platform device
> > > registered by the core MFD driver.
> > >
> > > The driver is derived from an initial implementation from NXP, available
> > > in commit 451f61b46b76 ("MLK-25917-2 gpio: adp5585-gpio: add
> > > adp5585-gpio support") in their BSP kernel tree. It has been extensively
> > > rewritten.
> > >
> > > Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >
> > (...)
> >
> > > +static int adp5585_gpio_direction_input(struct gpio_chip *chip, unsigned int off)
> > > +{
> > > + struct adp5585_gpio_dev *adp5585_gpio = gpiochip_get_data(chip);
> > > + unsigned int bank = ADP5585_BANK(off);
> > > + unsigned int bit = ADP5585_BIT(off);
> > > +
> > > + guard(mutex)(&adp5585_gpio->lock);
> > > +
> > > + return regmap_update_bits(adp5585_gpio->regmap,
> > > + ADP5585_GPIO_DIRECTION_A + bank,
> > > + bit, 0);
> >
> > First, I love the guarded mutex!
>
> Yes, it's neat :-)
>
> > But doesn't regmap already contain a mutex? Or is this one of those
> > cases where regmap has been instantiated without a lock?
>
> regmap indeed includes a lock, but it will lock each register access
> independently. In adp5585_gpio_get_value() we need to read two
> registers atomically, so we need to cover them by a single lock.
>
> I could drop the lock from regmap, but I would then likely need to
> introduce a lock in the parent mfd device that both the PWM and GPIO
> children would use to protect bus access. That may make sense in the
> future, but is a bit overkill for now I think.
Actually, I think I can drop the lock. Concurrent access to the
registers from different GPIOs are protected by the regmap lock, and
concurrent access to groups of registers for the same GPIO isn't a valid
use case as callers shouldn't do that.
> > > + gc = &adp5585_gpio->gpio_chip;
> > > + gc->parent = dev;
> > > + gc->direction_input = adp5585_gpio_direction_input;
> > > + gc->direction_output = adp5585_gpio_direction_output;
> >
> > And chance to implemen ->get_direction()?
>
> Sure, I'll add that to v2.
>
> > Other than this I think the driver is ready for merge, so with the
> > comments fixed or addressed:
> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>
> Thank you.
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2024-05-28 18:09 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 19:59 [PATCH 0/5] ADP5585 GPIO expander, PWM and keypad controller support Laurent Pinchart
2024-05-20 19:59 ` [PATCH 1/5] dt-bindings: trivial-devices: Drop adi,adp5585 and adi,adp5585-02 Laurent Pinchart
2024-05-21 19:02 ` Krzysztof Kozlowski
2024-05-21 19:44 ` Laurent Pinchart
2024-05-20 19:59 ` [PATCH 2/5] dt-bindings: Add bindings for the Analog Devices ADP5585 Laurent Pinchart
2024-05-21 19:05 ` Krzysztof Kozlowski
2024-05-21 19:43 ` Laurent Pinchart
2024-05-22 6:57 ` Krzysztof Kozlowski
2024-05-22 7:20 ` Krzysztof Kozlowski
2024-05-22 7:22 ` Laurent Pinchart
2024-05-22 7:40 ` Krzysztof Kozlowski
2024-05-23 23:16 ` Laurent Pinchart
2024-05-28 15:12 ` Rob Herring
2024-05-28 18:08 ` Laurent Pinchart
2024-05-28 22:02 ` Saravana Kannan
2024-05-28 22:21 ` Laurent Pinchart
2024-05-20 19:59 ` [PATCH 3/5] mfd: adp5585: Add Analog Devices ADP5585 core support Laurent Pinchart
2024-05-23 8:29 ` Bough Chen
2024-05-23 20:18 ` Laurent Pinchart
2024-05-20 19:59 ` [PATCH 4/5] gpio: adp5585: Add Analog Devices ADP5585 support Laurent Pinchart
2024-05-28 11:54 ` Linus Walleij
2024-05-28 12:27 ` Laurent Pinchart
2024-05-28 18:09 ` Laurent Pinchart [this message]
2024-05-20 19:59 ` [PATCH 5/5] pwm: " Laurent Pinchart
2024-05-21 8:51 ` Uwe Kleine-König
2024-05-21 10:09 ` Laurent Pinchart
2024-05-21 13:05 ` Uwe Kleine-König
2024-05-22 10:13 ` Laurent Pinchart
2024-05-22 10:23 ` Uwe Kleine-König
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=20240528180941.GA10903@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=alexandru.ardelean@analog.com \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=haibo.chen@nxp.com \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=robh@kernel.org \
--cc=ukleinek@kernel.org \
/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).