[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yqc0NQSLO2j2IHI3@sirena.org.uk>
Date: Mon, 13 Jun 2022 13:57:25 +0100
From: Mark Brown <broonie@...nel.org>
To: Jerome NEANNE <jneanne@...libre.com>
Cc: lgirdwood@...il.com, robh+dt@...nel.org, nm@...com,
kristo@...nel.org, will@...nel.org, lee.jones@...aro.org,
khilman@...libre.com, narmstrong@...libre.com, msp@...libre.com,
j-keerthy@...com, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Subject: Re: [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.
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists