lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240528122734.GA29970@pendragon.ideasonboard.com>
Date: Tue, 28 May 2024 15:27:34 +0300
From: Laurent Pinchart <laurent.pinchart@...asonboard.com>
To: Linus Walleij <linus.walleij@...aro.org>
Cc: linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
	linux-gpio@...r.kernel.org, linux-pwm@...r.kernel.org,
	Alexandru Ardelean <alexandru.ardelean@...log.com>,
	Bartosz Golaszewski <brgl@...ev.pl>,
	Conor Dooley <conor+dt@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Lee Jones <lee@...nel.org>, Rob Herring <robh@...nel.org>,
	Uwe Kleine-König <ukleinek@...nel.org>,
	Haibo Chen <haibo.chen@....com>
Subject: Re: [PATCH 4/5] gpio: adp5585: Add Analog Devices ADP5585 support

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@....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@....com>
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@...asonboard.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.

> > +       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@...aro.org>

Thank you.

-- 
Regards,

Laurent Pinchart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ