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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux