regmap: add regmap_update_bits() helper
PATCH 1/1 regmap: add regmap_update_bits() helper
Add the regmap_update_bits() to simply the read/modify/write of registers in a single command. The function is taken from Linux regmap implementation.
--- include/regmap.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
include/regmap.h +23 -0
@@ -47,6 +47,29 @@ int regmap_read(struct regmap *map, uint offset, uint *valp);regmap_read (map, (uint32_t *)(ptr)->member - (uint32_t *)(ptr), valp)/** +* regmap_update_bits() - Perform a read/modify/write using a mask +* +* @map: The map returned by regmap_init_mem*() +* @offset: Offset of the memory +* @mask: Mask to apply to the read value +* @val: Value to apply to the value to write + */ +static inline int regmap_update_bits (struct regmap *map,uint offset, +uint mask,uint val) +{ +uint reg; +int ret; + + ret =regmap_read (map, offset, ®); +if (ret) +return ret; + + reg &= ~mask; + +return regmap_write (map, offset, reg | val); +} + +/** * regmap_init_mem() - Set up a new register map that uses memory access * * Use regmap_uninit() to free it.
Signature · 1 line
2.7.4
PATCH 1/1 regmap: add regmap_update_bits() helper
Hi Neil,
Quoted 16 lines · Neil Armstrong
Add the
regmap_update_bits()to simply the read/modify/write of registers in a single command. The function is taken from Linux regmap implementation.Signed-off-by Neil Armstrong <[email protected]>--- include/regmap.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)include/regmap.h +0
-0@@ -47,6 +47,29 @@ int regmap_read(struct regmap *map, uint offset, uint *valp);regmap_read (map, (uint32_t *)(ptr)->member - (uint32_t *)(ptr), valp)
include/regmap.h int regmap_read(struct regmap *map, uint offset, uint *valp); · line 58
Quoted 10 lines
include/regmap.h +9
-0/** +* regmap_update_bits() - Perform a read/modify/write using a mask +* +* @map: The map returned by regmap_init_mem*() +* @offset: Offset of the memory +* @mask: Mask to apply to the read value +* @val: Value to apply to the value to write +*/ +static inline int regmap_update_bits (struct regmap *map,uint offset, +uint mask,uint val)
Why is this inline? I think it would save code size to make it a normal function.
Also can you add a call to this function somewhere for sandbox, as a test?
Quoted 18 lines
include/regmap.h +14
-1+{ +uint reg; +int ret; + + ret =regmap_read (map, offset, ®); +if (ret) +return ret; + + reg &= ~mask; + +return regmap_write (map, offset, reg | val); +} + +/** * regmap_init_mem() - Set up a new register map that uses memory access * * Use regmap_uninit() to free it. --
Quoted 2 lines
2.7.4
Regards,
Simon
PATCH 1/1 regmap: add regmap_update_bits() helper
Hi,
Quoted 19 lines · Simon Glass
Hi Neil,
Quoted 16 lines · Neil Armstrong
Add the
regmap_update_bits()to simply the read/modify/write of registers in a single command. The function is taken from Linux regmap implementation.Signed-off-by Neil Armstrong <[email protected]>--- include/regmap.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)include/regmap.h +0
-0@@ -47,6 +47,29 @@ int regmap_read(struct regmap *map, uint offset, uint *valp);regmap_read (map, (uint32_t *)(ptr)->member - (uint32_t *)(ptr), valp)
Quoted 13 lines
include/regmap.h int regmap_read(struct regmap *map, uint offset, uint *valp); · line 58
Quoted 10 lines
include/regmap.h +9
-0/** +* regmap_update_bits() - Perform a read/modify/write using a mask +* +* @map: The map returned by regmap_init_mem*() +* @offset: Offset of the memory +* @mask: Mask to apply to the read value +* @val: Value to apply to the value to write +*/ +static inline int regmap_update_bits (struct regmap *map,uint offset, +uint mask,uint val)Why is this inline? I think it would save code size to make it a normal function.
Seemed a good idea, but I'll move it to the uclass.
Quoted 2 lines
Also can you add a call to this function somewhere for sandbox, as a test?
I did not find any test for regmap_read/write for sandbox, or maybe I missed it.
Quoted 16 lines
Quoted 16 lines
include/regmap.h +14
-0+{ +uint reg; +int ret; + + ret =regmap_read (map, offset, ®); +if (ret) +return ret; + + reg &= ~mask; + +return regmap_write (map, offset, reg | val); +} + +/** * regmap_init_mem() - Set up a new register map that uses memory access
Quoted 9 lines
Quoted 5 lines
include/regmap.h +0
-1* * Use regmap_uninit() to free it. -- 2.7.4
Regards,
Simon
Thanks,
Neil
PATCH 1/1 regmap: add regmap_update_bits() helper
Hi Neil,
Quoted 36 lines · Neil Armstrong
Hi,
Quoted 19 lines · Simon Glass
Hi Neil,
Quoted 16 lines · Neil Armstrong
Add the
regmap_update_bits()to simply the read/modify/write of registers in a single command. The function is taken from Linux regmap implementation.Signed-off-by Neil Armstrong <[email protected]>--- include/regmap.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)include/regmap.h +0
-0@@ -47,6 +47,29 @@ int regmap_read(struct regmap *map, uint offset, uint *valp);regmap_read (map, (uint32_t *)(ptr)->member - (uint32_t *)(ptr), valp)Quoted 13 lines
include/regmap.h int regmap_read(struct regmap *map, uint offset, uint *valp); · line 58
Quoted 10 lines
include/regmap.h +9
-0/** +* regmap_update_bits() - Perform a read/modify/write using a mask +* +* @map: The map returned by regmap_init_mem*() +* @offset: Offset of the memory +* @mask: Mask to apply to the read value +* @val: Value to apply to the value to write +*/ +static inline int regmap_update_bits (struct regmap *map,uint offset, +uint mask,uint val)Why is this inline? I think it would save code size to make it a normal function.
Quoted 7 lines
Seemed a good idea, but I'll move it to the uclass.
Quoted 2 lines
Also can you add a call to this function somewhere for sandbox, as a test?
I did not find any test for regmap_read/write for sandbox, or maybe I missed it.
No, that's why I'm asking :-)
Regards,
Simon