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: <20250710093057.GB1431498@google.com>
Date: Thu, 10 Jul 2025 10:30:57 +0100
From: Lee Jones <lee@...nel.org>
To: Alex Elder <elder@...cstar.com>
Cc: lgirdwood@...il.com, broonie@...nel.org, alexandre.belloni@...tlin.com,
	robh@...nel.org, krzk+dt@...nel.org, conor+dt@...nel.org,
	mat.jonczyk@...pl, dlan@...too.org, paul.walmsley@...ive.com,
	palmer@...belt.com, aou@...s.berkeley.edu, alex@...ti.fr,
	troymitchell988@...il.com, guodong@...cstar.com,
	linux-rtc@...r.kernel.org, devicetree@...r.kernel.org,
	linux-riscv@...ts.infradead.org, spacemit@...ts.linux.dev,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v7 2/8] mfd: simple-mfd-i2c: specify max_register

On Thu, 10 Jul 2025, Lee Jones wrote:

> On Wed, 02 Jul 2025, Alex Elder wrote:
> 
> > All devices supported by simple MFD use the same 8-bit register
> > 8-bit value regmap configuration.  There is an option available
> > for a device to specify a custom configuration, but no existing
> > device uses it.
> > 
> > Rather than specify a "full" regmap configuration to use this
> > option, Lee Jones suggested allowing just the max_register value
> > to be specified in the simple_mfd_data structure.
> > 
> > Signed-off-by: Alex Elder <elder@...cstar.com>
> > Suggested-by: Lee Jones <lee@...nel.org>
> > ---
> > v2: - Allow max_register *and* regmap_config to be supplied
> > 
> >  drivers/mfd/simple-mfd-i2c.c | 15 ++++++++++++---
> >  drivers/mfd/simple-mfd-i2c.h |  1 +
> >  2 files changed, 13 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c
> > index 22159913bea03..3f959f4f98261 100644
> > --- a/drivers/mfd/simple-mfd-i2c.c
> > +++ b/drivers/mfd/simple-mfd-i2c.c
> > @@ -33,16 +33,25 @@ static int simple_mfd_i2c_probe(struct i2c_client *i2c)
> >  {
> >  	const struct simple_mfd_data *simple_mfd_data;
> >  	const struct regmap_config *regmap_config;
> 
> > +	struct regmap_config config;
> 
> Why do we need another regmap_config?
> 
> Can't we just remove the const and make use of the one above?
> 
> >  	struct regmap *regmap;
> >  	int ret;
> >  
> >  	simple_mfd_data = device_get_match_data(&i2c->dev);
> >  
> >  	/* If no regmap_config is specified, use the default 8reg and 8val bits */
> > -	if (!simple_mfd_data || !simple_mfd_data->regmap_config)
> > +	if (simple_mfd_data) {
> > +		if (simple_mfd_data->regmap_config)
> > +			config = *simple_mfd_data->regmap_config;
> 
> 			regmap_config = simple_mfd_data->regmap_config;
> 
> > +		else
> > +			config = regmap_config_8r_8v;
> 
> 			regmap_config = &regmap_config_8r_8v;
> > +
> > +		if (simple_mfd_data->max_register)
> > +			config.max_register = simple_mfd_data->max_register;
> > +		regmap_config = &config;
> > +	} else {
> >  		regmap_config = &regmap_config_8r_8v;
> 
> I suspect we don't need to have this line twice.
> 
> Either re-jig the if () above (I suspect this explains the existing
> complexity [multiple conditions]) or pre-set regmap_config to
> regmap_config_8r_8v and only over-write it if the conditions are met.

Not sure why this whole thing had to be reworked.

Why didn't the 2-liner I gave you work for you?

-- 
Lee Jones [李琼斯]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ