eeprom: at24: don't use the default regmap locking
Subsystems (2)
PATCH 1/1 eeprom: at24: don't use the default regmap locking
We need to always wait for the last write to complete and we want the regmap to be protected from concurrent access during that wait. That makes using the regmap's default locking impossible and we're protecting it with an external mutex.
Set an empty function as the callback for regmap's lock and unlock routines so that it doesn't allocate any internal resources for unnecessary locking.
---
This is a temporary solution - I'm working on a patch extending the regmap framework with locking policy options, which will allow users to manually lock & unlock regmaps if needed or disable locking at all.
drivers/misc/eeprom/at24.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/misc/eeprom/at24.c +9 -0
@@ -498,14 +498,23 @@ static unsigned int at24_get_offset_adj(u8 flags, unsigned int byte_len) } } +static void at24_regmap_lock_unlock_none (void *map) +{ + +} +static const struct regmap_config regmap_config_8 = { .reg_bits =8 , .val_bits =8 , + .lock = at24_regmap_lock_unlock_none, + .unlock = at24_regmap_lock_unlock_none, };static const struct regmap_config regmap_config_16 = { .reg_bits =16 , .val_bits =8 , + .lock = at24_regmap_lock_unlock_none, + .unlock = at24_regmap_lock_unlock_none, };static int at24_probe (struct i2c_client *client,const struct i2c_device_id *id)
Signature · 1 line
2.15.1
2017-12-03 22:47 GMT+01:00 Bartosz Golaszewski <[email protected]>:
Quoted 47 lines
We need to always wait for the last write to complete and we want the regmap to be protected from concurrent access during that wait. That makes using the regmap's default locking impossible and we're protecting it with an external mutex.
Set an empty function as the callback for regmap's lock and unlock routines so that it doesn't allocate any internal resources for unnecessary locking.
Signed-off-by Bartosz Golaszewski <[email protected]>---
This is a temporary solution - I'm working on a patch extending the regmap framework with locking policy options, which will allow users to manually lock & unlock regmaps if needed or disable locking at all.drivers/misc/eeprom/at24.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/misc/eeprom/at24.c +9
-1@@ -498,14 +498,23 @@ static unsigned int at24_get_offset_adj(u8 flags, unsigned int byte_len) } } +static void at24_regmap_lock_unlock_none (void *map) +{ + +} +static const struct regmap_config regmap_config_8 = { .reg_bits =8 , .val_bits =8 , + .lock = at24_regmap_lock_unlock_none, + .unlock = at24_regmap_lock_unlock_none, };static const struct regmap_config regmap_config_16 = { .reg_bits =16 , .val_bits =8 , + .lock = at24_regmap_lock_unlock_none, + .unlock = at24_regmap_lock_unlock_none, };static int at24_probe (struct i2c_client *client,const struct i2c_device_id *id) --
Quoted 2 lines
2.15.1
There were no comments. I applied this patch. These changes will be removed in 4.17 when we'll enable the newly added disable_locking variable in regmap config.
Bartosz
2017-12-10 19:57 GMT+01:00 Bartosz Golaszewski <[email protected]>:
Quoted 55 lines
2017-12-03 22:47 GMT+01:00 Bartosz Golaszewski <[email protected]>:
Quoted 47 lines
We need to always wait for the last write to complete and we want the regmap to be protected from concurrent access during that wait. That makes using the regmap's default locking impossible and we're protecting it with an external mutex.
Set an empty function as the callback for regmap's lock and unlock routines so that it doesn't allocate any internal resources for unnecessary locking.
Signed-off-by Bartosz Golaszewski <[email protected]>---
This is a temporary solution - I'm working on a patch extending the regmap framework with locking policy options, which will allow users to manually lock & unlock regmaps if needed or disable locking at all.drivers/misc/eeprom/at24.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/misc/eeprom/at24.c +9
-1@@ -498,14 +498,23 @@ static unsigned int at24_get_offset_adj(u8 flags, unsigned int byte_len) } } +static void at24_regmap_lock_unlock_none (void *map) +{ + +} +static const struct regmap_config regmap_config_8 = { .reg_bits =8 , .val_bits =8 , + .lock = at24_regmap_lock_unlock_none, + .unlock = at24_regmap_lock_unlock_none, };static const struct regmap_config regmap_config_16 = { .reg_bits =16 , .val_bits =8 , + .lock = at24_regmap_lock_unlock_none, + .unlock = at24_regmap_lock_unlock_none, };static int at24_probe (struct i2c_client *client,const struct i2c_device_id *id) --Quoted 2 lines
2.15.1
There were no comments. I applied this patch. These changes will be removed in 4.17 when we'll enable the newly added
disable_lockingvariable in regmap config.
Quoted 1 line
Bartosz
It turned out that this may cause problem with user space initiating operations on the regmap over debugfs entries. This has been correctly implemented in regmap and will be available from 4.16. I backed this patch out.
Thanks,
Bartosz