diff options
author | Davide Ciminaghi <ciminaghi@gnudd.com> | 2012-10-16 17:56:59 +0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-10-17 11:52:02 +0400 |
commit | 0d4529c534c1c664f25088eb5f5b4d7ce0ee2510 (patch) | |
tree | 5b080ef0a319b90fbcb0ab4eb768aae54851915e /include/linux/regmap.h | |
parent | ddffeb8c4d0331609ef2581d84de4d763607bd37 (diff) | |
download | linux-0d4529c534c1c664f25088eb5f5b4d7ce0ee2510.tar.xz |
regmap: make lock/unlock functions customizable
It is sometimes convenient for a regmap user to override the standard
regmap lock/unlock functions with custom functions.
For instance this can be useful in case an already existing spinlock
or mutex has to be used for locking a set of registers instead of the
internal regmap spinlock/mutex.
Note that the fast_io field of struct regmap_bus is ignored in case
custom locking functions are used.
Signed-off-by: Davide Ciminaghi <ciminaghi@gnudd.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'include/linux/regmap.h')
-rw-r--r-- | include/linux/regmap.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/include/linux/regmap.h b/include/linux/regmap.h index e3bcc3f4dcb8..5d243786f254 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -53,6 +53,9 @@ enum regmap_endian { REGMAP_ENDIAN_NATIVE, }; +typedef void (*regmap_lock)(void *); +typedef void (*regmap_unlock)(void *); + /** * Configuration for the register map of a device. * @@ -75,6 +78,12 @@ enum regmap_endian { * @precious_reg: Optional callback returning true if the rgister * should not be read outside of a call from the driver * (eg, a clear on read interrupt status register). + * @lock: Optional lock callback (overrides regmap's default lock + * function, based on spinlock or mutex). + * @unlock: As above for unlocking. + * @lock_arg: this field is passed as the only argument of lock/unlock + * functions (ignored in case regular lock/unlock functions + * are not overridden). * * @max_register: Optional, specifies the maximum valid register index. * @reg_defaults: Power on reset values for registers (for use with @@ -116,6 +125,9 @@ struct regmap_config { bool (*readable_reg)(struct device *dev, unsigned int reg); bool (*volatile_reg)(struct device *dev, unsigned int reg); bool (*precious_reg)(struct device *dev, unsigned int reg); + regmap_lock lock; + regmap_unlock unlock; + void *lock_arg; unsigned int max_register; const struct reg_default *reg_defaults; @@ -181,7 +193,9 @@ typedef void (*regmap_hw_free_context)(void *context); * Description of a hardware bus for the register map infrastructure. * * @fast_io: Register IO is fast. Use a spinlock instead of a mutex - * to perform locking. + * to perform locking. This field is ignored if custom lock/unlock + * functions are used (see fields lock/unlock of + * struct regmap_config). * @write: Write operation. * @gather_write: Write operation with split register/value, return -ENOTSUPP * if not implemented on a given device. |