lkml.org 
[lkml]   [2022]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 2/5] mfd: drivers: Add TI TPS65219 PMIC support
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.
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2022-06-13 19:37    [W:0.120 / U:0.616 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site