regmap: Correct comparison in regmap_cached
Subsystems (2)
PATCH 1/4 regmap: Correct comparison in regmap_cached
The cache pointer points to the actual memory used by the cache, as the comparison here is looking for the type of the cache it should check against cache_type.
--- drivers/base/regmap/regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/regmap/regmap.c +1 -1
@@ -99,7 +99,7 @@ bool regmap_cached(struct regmap *map, unsigned int reg)int ret;unsigned int val; -if (map->cache ==REGCACHE_NONE ) +if (map->cache_type ==REGCACHE_NONE )return false;if (!map->cache_ops)
Signature · 1 line
2.11.0
PATCH 2/4 regmap: Correct offset handling in regmap_volatile_range
The current implementation is broken for regmaps that have a reg_stride, since it doesn't take the stride into account. Correct this by using the helper function to calculate the register offset.
--- drivers/base/regmap/regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/regmap/regmap.c +1 -1
@@ -174,7 +174,7 @@ static bool regmap_volatile_range(struct regmap *map, unsigned int reg,unsigned int i;for (i =0 ; i < num; i++) -if (!regmap_volatile (map, reg + i)) +if (!regmap_volatile (map, reg +regmap_get_offset (map, i)))return false;return true;
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "regmap: Correct offset handling in regmap_volatile_range" to the regmap tree
The patch
regmap: Correct offset handling in regmap_volatile_range
has been applied to the regmap tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
b8f9a03b741ddfdde4aa8b607fa7d88eb63a6338Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Mon, 12 Feb 2018 18:15:45 +0000
Subject: [PATCH] regmap: Correct offset handling in regmap_volatile_range
The current implementation is broken for regmaps that have a reg_stride, since it doesn't take the stride into account. Correct this by using the helper function to calculate the register offset.
--- drivers/base/regmap/regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/regmap/regmap.c +1 -1
@@ -174,7 +174,7 @@ static bool regmap_volatile_range(struct regmap *map, unsigned int reg,unsigned int i;for (i =0 ; i < num; i++) -if (!regmap_volatile (map, reg + i)) +if (!regmap_volatile (map, reg +regmap_get_offset (map, i)))return false;return true;
Signature · 1 line
2.16.1
PATCH 3/4 regmap: Don't use format_val in regmap_bulk_read
In reply to Charles KeepaxA bulk read can be implemented either through regmap_raw_read, or by reading each register individually using regmap_read. Both regmap_read and regmap_bulk_read should return values in native endian. In the individual case the current implementation calls format_val to put the data into the output array, which can cause endian issues. The regmap_read will have already converted the data into native endian, if the hosts endian differs from the device then format_val will switch the endian back again.
Rather than using format_val simply use the code that is called if there is no format_val function. This code supports all cases except 24-bit but there don't appear to be any users of regmap_bulk_read for 24-bit. Additionally, it would have to be a big endian host for the old code to actually function correctly anyway.
--- drivers/base/regmap/regmap.c | 55 ++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 32 deletions(-)
drivers/base/regmap/regmap.c +23 -32
@@ -2709,47 +2709,38 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,for (i =0 ; i < val_count * val_bytes; i += val_bytes) map->format.parse_inplace (val + i); }else { +#ifdef CONFIG_64BIT +u64 *u64 = val; +#endif +u32 *u32 = val; +u16 *u16 = val; +u8 *u8 = val; +for (i =0 ; i < val_count; i++) {unsigned int ival; + ret =regmap_read (map, reg +regmap_get_offset (map, i), &ival);if (ret !=0 )return ret; -if (map->format.format_val) { - map->format.format_val (val + (i * val_bytes), ival,0 ); - }else { -/* Devices providing read and write -* operations can use the bulk I/O -* functions if they define a val_bytes, -* we assume that the values are native -* endian. -*/ -#ifdef CONFIG_64BIT -u64 *u64 = val; -#endif -u32 *u32 = val; -u16 *u16 = val; -u8 *u8 = val; - -switch (map->format.val_bytes) { +switch (map->format.val_bytes) {#ifdef CONFIG_64BIT -case 8 : - u64[i] = ival; -break ; +case 8 : + u64[i] = ival; +break ;#endif -case 4 : - u32[i] = ival; -break ; -case 2 : - u16[i] = ival; -break ; -case 1 : - u8[i] = ival; -break ; -default : -return -EINVAL ; - } +case 4 : + u32[i] = ival; +break ; +case 2 : + u16[i] = ival; +break ; +case 1 : + u8[i] = ival; +break ; +default : +return -EINVAL ; } } }
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "regmap: Don't use format_val in regmap_bulk_read" to the regmap tree
The patch
regmap: Don't use format_val in regmap_bulk_read
has been applied to the regmap tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
9ae27a8d1f3ebff09191fb8cb1341414547293b2Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Mon, 12 Feb 2018 18:15:46 +0000
Subject: [PATCH] regmap: Don't use format_val in regmap_bulk_read
A bulk read can be implemented either through regmap_raw_read, or by reading each register individually using regmap_read. Both regmap_read and regmap_bulk_read should return values in native endian. In the individual case the current implementation calls format_val to put the data into the output array, which can cause endian issues. The regmap_read will have already converted the data into native endian, if the hosts endian differs from the device then format_val will switch the endian back again.
Rather than using format_val simply use the code that is called if there is no format_val function. This code supports all cases except 24-bit but there don't appear to be any users of regmap_bulk_read for 24-bit. Additionally, it would have to be a big endian host for the old code to actually function correctly anyway.
--- drivers/base/regmap/regmap.c | 55 ++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 32 deletions(-)
drivers/base/regmap/regmap.c +23 -32
@@ -2709,47 +2709,38 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,for (i =0 ; i < val_count * val_bytes; i += val_bytes) map->format.parse_inplace (val + i); }else { +#ifdef CONFIG_64BIT +u64 *u64 = val; +#endif +u32 *u32 = val; +u16 *u16 = val; +u8 *u8 = val; +for (i =0 ; i < val_count; i++) {unsigned int ival; + ret =regmap_read (map, reg +regmap_get_offset (map, i), &ival);if (ret !=0 )return ret; -if (map->format.format_val) { - map->format.format_val (val + (i * val_bytes), ival,0 ); - }else { -/* Devices providing read and write -* operations can use the bulk I/O -* functions if they define a val_bytes, -* we assume that the values are native -* endian. -*/ -#ifdef CONFIG_64BIT -u64 *u64 = val; -#endif -u32 *u32 = val; -u16 *u16 = val; -u8 *u8 = val; - -switch (map->format.val_bytes) { +switch (map->format.val_bytes) {#ifdef CONFIG_64BIT -case 8 : - u64[i] = ival; -break ; +case 8 : + u64[i] = ival; +break ;#endif -case 4 : - u32[i] = ival; -break ; -case 2 : - u16[i] = ival; -break ; -case 1 : - u8[i] = ival; -break ; -default : -return -EINVAL ; - } +case 4 : + u32[i] = ival; +break ; +case 2 : + u16[i] = ival; +break ; +case 1 : + u8[i] = ival; +break ; +default : +return -EINVAL ; } } }
Signature · 1 line
2.16.1
PATCH 4/4 regmap: Use helper function for register offset
In reply to Charles KeepaxAs a helper function exists for calculating register offsets lets use that rather than open coding with the reg_stride.
--- drivers/base/regmap/regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/regmap/regmap.c +1 -1
@@ -1993,7 +1993,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,return -EINVAL ; } - ret =regmap_write (map, reg + (i * map->reg_stride), + ret =regmap_write (map, reg +regmap_get_offset (map, i), ival);if (ret)return ret;
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "regmap: Use helper function for register offset" to the regmap tree
The patch
regmap: Use helper function for register offset
has been applied to the regmap tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
45abcc556721a6d18e4af82e20e164044f0a3e36Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Mon, 12 Feb 2018 18:15:47 +0000
Subject: [PATCH] regmap: Use helper function for register offset
As a helper function exists for calculating register offsets lets use that rather than open coding with the reg_stride.
--- drivers/base/regmap/regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/regmap/regmap.c +1 -1
@@ -1993,7 +1993,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,return -EINVAL ; } - ret =regmap_write (map, reg + (i * map->reg_stride), + ret =regmap_write (map, reg +regmap_get_offset (map, i), ival);if (ret)return ret;
Signature · 1 line
2.16.1
Mark Brown
maintainerApplied "regmap: Correct comparison in regmap_cached" to the regmap tree
In reply to Charles KeepaxThe patch
regmap: Correct comparison in regmap_cached
has been applied to the regmap tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
71df179363a5a733a8932e9afb869760d7559383Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Mon, 12 Feb 2018 18:15:44 +0000
Subject: [PATCH] regmap: Correct comparison in regmap_cached
The cache pointer points to the actual memory used by the cache, as the comparison here is looking for the type of the cache it should check against cache_type.
--- drivers/base/regmap/regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/regmap/regmap.c +1 -1
@@ -99,7 +99,7 @@ bool regmap_cached(struct regmap *map, unsigned int reg)int ret;unsigned int val; -if (map->cache ==REGCACHE_NONE ) +if (map->cache_type ==REGCACHE_NONE )return false;if (!map->cache_ops)
Signature · 1 line
2.16.1