lkml.org 
[lkml]   [2012]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH V1 1/2] mfd: tps65910: use regmap for device register access.
On Wed, Feb 08, 2012 at 04:16:24PM +0530, Laxman Dewangan wrote:

> +static bool is_volatile_reg(struct device *dev, unsigned int reg)
> +{
> + struct tps65910 *tps65910 = dev_get_drvdata(dev);
> + return test_bit(reg, tps65910->cache_reg) ? false : true;
> +}

This is *really* odd. Why is this not static data (or mostly static
data), why does it vary at runtime?

> +static bool regmap_volatile_range(struct tps65910 *tps65910,
> + unsigned int reg, unsigned int bytes)
> +{
> + unsigned int i;
> + for (i = 0; i < bytes; i++)
> + if (!is_volatile_reg(tps65910->dev, reg + i))
> + return false;
> + return true;
> +}

I don't think this should be here (the naming is a bit of a clue - it's
named like a core function), see below where you're using it...

> + unsigned char *wbuf = src;
> + unsigned int ival;
> +
> + if (regmap_volatile_range(tps65910, reg, bytes))
> + return regmap_raw_write(tps65910->regmap, reg, src, bytes);
> +
> + /* If any of register is non-volatile then use byte-wise transfer */
> + for (i = 0; i < bytes; ++i) {
> + ival = (unsigned int) (*wbuf++);
> + ret = regmap_write(tps65910->regmap, reg, ival);
> + if (ret < 0)
> + return ret;
> + }

There's nothing specific to the driver about this, if this is a good
idea add support for it to the core.

> +void tps65910_enable_reg_cache(struct tps65910 *tps65910, int reg)
> +{
> + set_bit(reg, tps65910->cache_reg);
> +}
> +EXPORT_SYMBOL_GPL(tps65910_enable_reg_cache);

Why are you doing this? This looks very icky, and if it is needed there
needs to be more code here to make sure the register cache and device
are in sync.
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2012-02-08 12:43    [W:0.581 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site