* PGP Signed by an unknown keyI did not wanted to make the list of register in core driver. Wanted to leave the decision to the sub-devices driver where they need to enable cache based on their requirements.
On Wed, Feb 08, 2012 at 04:16:24PM +0530, Laxman Dewangan wrote:
+static bool is_volatile_reg(struct device *dev, unsigned int reg)This is *really* odd. Why is this not static data (or mostly static
+{
+ struct tps65910 *tps65910 = dev_get_drvdata(dev);
+ return test_bit(reg, tps65910->cache_reg) ? false : true;
+}
data), why does it vary at runtime?
Oops, the function is copied from the regmap and so this error... sorry..+static bool regmap_volatile_range(struct tps65910 *tps65910,I don't think this should be here (the naming is a bit of a clue - it's
+ 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;
+}
named like a core function), see below where you're using it...
This function added because there is no bulk_write function in core driver which supports the non-volatile in the list. Even if number of bytes read is 1.+ unsigned char *wbuf = src;There's nothing specific to the driver about this, if this is a good
+ 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;
+ }
idea add support for it to the core.
I think If register are volatile then read/write happen to device only i.e. without caching. There is no entry for such register in cache table. Once this is cache enable, new entry is created on cache and the first value for the cache-val is read from device. So it will be in sync. All read/writes are io-locked in regmap and so not seeing any issue here.+void tps65910_enable_reg_cache(struct tps65910 *tps65910, int reg)Why are you doing this? This looks very icky, and if it is needed there
+{
+ set_bit(reg, tps65910->cache_reg);
+}
+EXPORT_SYMBOL_GPL(tps65910_enable_reg_cache);
needs to be more code here to make sure the register cache and device
are in sync.
* Unknown Key
* 0x6E30FDDD