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]
Date:   Thu, 29 Jun 2023 09:27:03 +0800
From:   ChiYuan Huang <cy_huang@...htek.com>
To:     Mark Brown <broonie@...nel.org>
CC:     <krzysztof.kozlowski+dt@...aro.org>, <conor+dt@...nel.org>,
        <robh+dt@...nel.org>, <lgirdwood@...il.com>,
        <devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] regulator: rt5739: Add DID check and compatible for
 rt5733

On Wed, Jun 28, 2023 at 12:47:50PM +0100, Mark Brown wrote:
> On Wed, Jun 28, 2023 at 04:47:17PM +0800, cy_huang@...htek.com wrote:
> 
> > +	if (did == RT5733_CHIPDIE_ID) {
> > +		min_uV = RT5733_VOLT_MINUV;
> > +		max_uV = RT5733_VOLT_MAXUV;
> > +		step_uV = RT5733_VOLT_STPUV;
> > +	} else {
> > +		min_uV = RT5739_VOLT_MINUV;
> > +		max_uV = RT5739_VOLT_MAXUV;
> > +		step_uV = RT5739_VOLT_STPUV;
> > +	}
> 
> It would be better to write these as switch statements so if any more
> variants turn up they can be added more easily.

Since the IC difference is only voltage range and step, They can be retrieved from the
regulator description.

To check DID here may not a good coding.

I may rewrite it as below
  max_uV = desc->min_uV + desc->uV_step * (desc->n_voltages - 1);

And put a switch case for DID check in 'init_regulator_desc'.

Is it better?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ