[RFC PATCH 2/5] mfd: drivers: Add TI TPS65219 PMIC support

Mark Brown broonie at kernel.org
Mon Jun 13 05:57:25 PDT 2022


On Mon, Jun 13, 2022 at 11:06:01AM +0200, Jerome NEANNE wrote:

> +/**
> + * tps65219_reg_read: Read a single tps65219 register.
> + *
> + * @tps: Device to read from.
> + * @reg: Register to read.
> + * @val: Contians the value
> + */
> +int tps65219_reg_read(struct tps65219 *tps, unsigned int reg,
> +			unsigned int *val)
> +{
> +	return regmap_read(tps->regmap, reg, val);
> +}
> +EXPORT_SYMBOL_GPL(tps65219_reg_read);

It is better practice to just expose the regmap and let the function
drivers use it, that means the function drivers can just use standard
helper functions.

> +static int tps65219_update_bits(struct tps65219 *tps, unsigned int reg,
> +		unsigned int mask, unsigned int val)
> +{
> +	int ret;
> +	unsigned int data;
> +
> +	ret = regmap_read(tps->regmap, reg, &data);
> +	if (ret) {
> +		dev_err(tps->dev, "Read from reg 0x%x failed\n", reg);
> +		return ret;
> +	}
> +
> +	data &= ~mask;
> +	data |= val & mask;
> +
> +	mutex_lock(&tps->tps_lock);
> +	ret = tps65219_reg_write(tps, reg, data);
> +	if (ret)
> +		dev_err(tps->dev, "Write for reg 0x%x failed\n", reg);
> +	mutex_unlock(&tps->tps_lock);

It's not clear what this locking is intended to protect.  It looks like
this should just be using regmap_update_bits().

> +static const struct regmap_range tps65219_yes_ranges[] = {
> +	regmap_reg_range(TPS65219_REG_INT_SOURCE, TPS65219_REG_POWER_UP_STATUS),
> +};
> +
> +static const struct regmap_access_table tps65219_volatile_table = {
> +	.yes_ranges = tps65219_yes_ranges,
> +	.n_yes_ranges = ARRAY_SIZE(tps65219_yes_ranges),
> +};

tps65219_yes_ranges probably needs a clearer name.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20220613/11c975ac/attachment.sig>


More information about the linux-arm-kernel mailing list