Re: [PATCH RESEND] regulator: rn5t618: add RC5T619 PMIC support

From: Leonard Crestez
Date: Fri Oct 13 2017 - 12:29:53 EST


On Sun, 2017-08-27 at 15:58 +0200, Pierre-Hugues Husson wrote:
> Extend the driver to support Ricoh RC5T619.
> Support the additional regulators and slightly different voltage ranges.
>
> @@ -101,10 +131,7 @@ static int rn5t618_regulator_probe(struct platform_device *pdev)
> Â config.dev = pdev->dev.parent;
> Â config.regmap = rn5t618->regmap;
> Â
> - for (i = 0; i < RN5T618_REG_NUM; i++) {
> - if (!regulators[i].name)
> - continue;
> -
> + for (i = 0; i < num_regulators; i++) {
> Â rdev = devm_regulator_register(&pdev->dev,
> Â ÂÂÂÂÂÂÂÂulators[i],
> Â ÂÂÂÂÂÂÂ&config);

This is wrong. The rn5t*_regulators arrays are indexed by RN5T618_*
constants and can have gaps. If you remove the check for
regulators[i].name then older models get errors like this:

rn5t618-regulator rn5t618-regulator: failed to register (null) regulator
rn5t618-regulator: probe of rn5t618-regulator failed with error -22

Either the check needs to be kep or otherwise regulator_desc arrays
should be modified. Indexing by RN5T618_* does not appear to be used so
maybe just use a flat array? That would also save a few bytes of
memory.

I know it's a late comment and the patch was already accepted, I just
noticed that rn5t567 fails to probe while working on something else.

--
Regards,
Leonard