Message ID | 1427236179-18580-1-git-send-email-srinivas.kandagatla@linaro.org (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
On Tue, Mar 24, 2015 at 10:29:39PM +0000, Srinivas Kandagatla wrote: > This patch introduces regmap_get_max_register() function which would be > used by the infrastructures like eeprom framework built on top of > regmap. In what way would it be used? > +int regmap_get_max_register(struct regmap *map) > +{ > + return map->max_register ? : -EINVAL; > +} Please write the logic out properly, don't abuse the ternery operator.
On 24/03/15 22:36, Mark Brown wrote: > On Tue, Mar 24, 2015 at 10:29:39PM +0000, Srinivas Kandagatla wrote: > >> This patch introduces regmap_get_max_register() function which would be >> used by the infrastructures like eeprom framework built on top of >> regmap. > > In what way would it be used? Its used in 2 purposes 1> It is used for sanity check purposes of the register ranges provided via DT/non-DT eeprom data cells. 2> To stop user reading when eeprom binary from /sys/class/eeprom/*/eeprom > >> +int regmap_get_max_register(struct regmap *map) >> +{ >> + return map->max_register ? : -EINVAL; >> +} > > Please write the logic out properly, don't abuse the ternery operator. Am happy to change it to your preference in next version, but this GNU extensions widely used in the kernel $ grep -rR "return.*? :" ./linux | wc -l 115 > -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, 2015-03-24 at 23:05 +0000, Srinivas Kandagatla wrote: > On 24/03/15 22:36, Mark Brown wrote: > >> +int regmap_get_max_register(struct regmap *map) > >> +{ > >> + return map->max_register ? : -EINVAL; > >> +} > > > > Please write the logic out properly, don't abuse the ternery operator. > Am happy to change it to your preference in next version, but this GNU > extensions widely used in the kernel > > $ grep -rR "return.*? :" ./linux | wc -l > 115 Double that when you add the ?: variants $ git grep -E "return.*\?\s*:" | wc -l 253 There are ~530 uses like: return <foo> ? <foo> : -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index d2f8a81..6fd234b 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -2616,6 +2616,18 @@ int regmap_get_val_bytes(struct regmap *map) } EXPORT_SYMBOL_GPL(regmap_get_val_bytes); +/* + * regmap_get_max_register(): Report the max register value + * + * Report the max register value, mainly intended to for use by + * generic infrastructure built on top of regmap. + */ +int regmap_get_max_register(struct regmap *map) +{ + return map->max_register ? : -EINVAL; +} +EXPORT_SYMBOL_GPL(regmap_get_max_register); + int regmap_parse_val(struct regmap *map, const void *buf, unsigned int *val) { diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 4419b99..c46dbf3 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -433,6 +433,7 @@ int regmap_update_bits_check_async(struct regmap *map, unsigned int reg, unsigned int mask, unsigned int val, bool *change); int regmap_get_val_bytes(struct regmap *map); +int regmap_get_max_register(struct regmap *map); int regmap_async_complete(struct regmap *map); bool regmap_can_raw_write(struct regmap *map); @@ -676,6 +677,12 @@ static inline int regmap_get_val_bytes(struct regmap *map) return -EINVAL; } +static inline int regmap_get_max_register(struct regmap *map) +{ + WARN_ONCE(1, "regmap API is disabled"); + return -EINVAL; +} + static inline int regcache_sync(struct regmap *map) { WARN_ONCE(1, "regmap API is disabled");
This patch introduces regmap_get_max_register() function which would be used by the infrastructures like eeprom framework built on top of regmap. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> --- drivers/base/regmap/regmap.c | 12 ++++++++++++ include/linux/regmap.h | 7 +++++++ 2 files changed, 19 insertions(+)