Messages in this thread | | | Date | Mon, 6 May 2019 12:37:33 +0900 | From | Mark Brown <> | Subject | Re: [PATCH v3 07/10] regulator: mt6358: Add support for MT6358 regulator |
| |
On Fri, May 03, 2019 at 05:31:14PM +0800, Hsin-Hsiung Wang wrote:
A few fairly minor things but mostly this looks good.
> +static const u32 vcama1_voltages[] = { > + 1800000, 2500000, 2700000, > + 2800000, 2900000, 3000000, > +};
> +static const u32 vcama2_voltages[] = { > + 1800000, 2500000, 2700000, > + 2800000, 2900000, 3000000, > +}; > +
These two tables look the same?
> +static int mt6358_get_voltage_sel(struct regulator_dev *rdev) > +{ > + int idx, ret; > + u32 selector; > + struct mt6358_regulator_info *info = rdev_get_drvdata(rdev); > + const u32 *pvol; > + > + ret = regmap_read(rdev->regmap, info->desc.vsel_reg, &selector); > + if (ret != 0) { > + dev_info(&rdev->dev, > + "Failed to get mt6358 %s vsel reg: %d\n", > + info->desc.name, ret); > + return ret; > + } > + > + selector = (selector & info->desc.vsel_mask) >> info->vsel_shift; > + pvol = (const u32 *)info->index_table; > + ret = -1; > + for (idx = 0; idx < info->desc.n_voltages; idx++) { > + if (pvol[idx] == selector) { > + ret = idx; > + break; > + } > + } > + > + return ret; > +}
I don't entirely understand what this is intended to do which suggests it could use some comments. As far as I can tell it's looking up the hardware selector in a table and then using the index of the entry in that table as the selector in order to deal with a sparse set of selectors, is that right? You should be able to handle this by having _list_voltage() return an error code for the invalid selectors though we don't have helpers for that yet as it's an unusual design.
Also -1 is not a good return value in the case where you fail to do a mapping, use -EINVAL.
> + ret = regmap_read(rdev->regmap, info->da_vsel_reg, ®val); > + if (ret != 0) { > + dev_info(&rdev->dev, > + "Failed to get mt6358 Buck %s vsel reg: %d\n", > + info->desc.name, ret); > + return ret; > + }
These error messages should be dev_err(). [unhandled content-type:application/pgp-signature] | |