* [PATCH] regmap: Check readable regs in _regmap_read
@ 2014-02-10 10:46 Michal Simek
2014-02-10 10:53 ` Lars-Peter Clausen
0 siblings, 1 reply; 5+ messages in thread
From: Michal Simek @ 2014-02-10 10:46 UTC (permalink / raw)
To: linux-kernel, monstr; +Cc: Arnd Bergmann, Mark Brown, Greg Kroah-Hartman
[-- Attachment #1: Type: text/plain, Size: 597 bytes --]
Check if regs are readable.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
drivers/base/regmap/regmap.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 6a19515..7569dfc 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1725,6 +1725,9 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
int ret;
void *context = _regmap_map_get_context(map);
+ if (!regmap_readable(map, reg))
+ return -EIO;
+
WARN_ON(!map->reg_read);
if (!map->cache_bypass) {
--
1.8.2.3
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] regmap: Check readable regs in _regmap_read
2014-02-10 10:46 [PATCH] regmap: Check readable regs in _regmap_read Michal Simek
@ 2014-02-10 10:53 ` Lars-Peter Clausen
2014-02-10 11:00 ` Michal Simek
2014-02-10 11:49 ` Mark Brown
0 siblings, 2 replies; 5+ messages in thread
From: Lars-Peter Clausen @ 2014-02-10 10:53 UTC (permalink / raw)
To: Michal Simek
Cc: linux-kernel, monstr, Arnd Bergmann, Mark Brown,
Greg Kroah-Hartman
On 02/10/2014 11:46 AM, Michal Simek wrote:
> Check if regs are readable.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> drivers/base/regmap/regmap.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
> index 6a19515..7569dfc 100644
> --- a/drivers/base/regmap/regmap.c
> +++ b/drivers/base/regmap/regmap.c
> @@ -1725,6 +1725,9 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
> int ret;
> void *context = _regmap_map_get_context(map);
>
> + if (!regmap_readable(map, reg))
> + return -EIO;
> +
This will cause issues with devices where registers are writable, but not
readable, but we keep the register value in the cache.
> WARN_ON(!map->reg_read);
>
> if (!map->cache_bypass) {
> --
> 1.8.2.3
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] regmap: Check readable regs in _regmap_read
2014-02-10 10:53 ` Lars-Peter Clausen
@ 2014-02-10 11:00 ` Michal Simek
2014-02-10 11:49 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Michal Simek @ 2014-02-10 11:00 UTC (permalink / raw)
To: Lars-Peter Clausen
Cc: Michal Simek, linux-kernel, Arnd Bergmann, Mark Brown,
Greg Kroah-Hartman
[-- Attachment #1: Type: text/plain, Size: 1279 bytes --]
Hi Lars,
On 02/10/2014 11:53 AM, Lars-Peter Clausen wrote:
> On 02/10/2014 11:46 AM, Michal Simek wrote:
>> Check if regs are readable.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>
>> drivers/base/regmap/regmap.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
>> index 6a19515..7569dfc 100644
>> --- a/drivers/base/regmap/regmap.c
>> +++ b/drivers/base/regmap/regmap.c
>> @@ -1725,6 +1725,9 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
>> int ret;
>> void *context = _regmap_map_get_context(map);
>>
>> + if (!regmap_readable(map, reg))
>> + return -EIO;
>> +
>
> This will cause issues with devices where registers are writable, but not readable, but we keep the register value in the cache.
And can you read from registers if they are not readable?
Even read from cache.
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] regmap: Check readable regs in _regmap_read
2014-02-10 10:53 ` Lars-Peter Clausen
2014-02-10 11:00 ` Michal Simek
@ 2014-02-10 11:49 ` Mark Brown
2014-02-10 11:54 ` Michal Simek
1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2014-02-10 11:49 UTC (permalink / raw)
To: Lars-Peter Clausen
Cc: Michal Simek, linux-kernel, monstr, Arnd Bergmann,
Greg Kroah-Hartman
[-- Attachment #1: Type: text/plain, Size: 680 bytes --]
On Mon, Feb 10, 2014 at 11:53:38AM +0100, Lars-Peter Clausen wrote:
> On 02/10/2014 11:46 AM, Michal Simek wrote:
> >Check if regs are readable.
> >+ if (!regmap_readable(map, reg))
> >+ return -EIO;
> This will cause issues with devices where registers are writable,
> but not readable, but we keep the register value in the cache.
Yes, exactly - this is deliberately not done so we can fake up
readability using the cache. All the 7x9 devices are like this for
example, there's just no read support in the hardware (or if there is
it's not related to the register map). If we were going to check it
should be at the point where we are about to interact with the hardware.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] regmap: Check readable regs in _regmap_read
2014-02-10 11:49 ` Mark Brown
@ 2014-02-10 11:54 ` Michal Simek
0 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2014-02-10 11:54 UTC (permalink / raw)
To: Mark Brown
Cc: Lars-Peter Clausen, Michal Simek, linux-kernel, Arnd Bergmann,
Greg Kroah-Hartman
[-- Attachment #1: Type: text/plain, Size: 1211 bytes --]
Hi Mark,
On 02/10/2014 12:49 PM, Mark Brown wrote:
> On Mon, Feb 10, 2014 at 11:53:38AM +0100, Lars-Peter Clausen wrote:
>> On 02/10/2014 11:46 AM, Michal Simek wrote:
>>> Check if regs are readable.
>
>>> + if (!regmap_readable(map, reg))
>>> + return -EIO;
>
>> This will cause issues with devices where registers are writable,
>> but not readable, but we keep the register value in the cache.
>
> Yes, exactly - this is deliberately not done so we can fake up
> readability using the cache. All the 7x9 devices are like this for
> example, there's just no read support in the hardware (or if there is
> it's not related to the register map). If we were going to check it
> should be at the point where we are about to interact with the hardware.
ok. Then let me send v2 and more this checking below cache
because missing this checking is also wrong.
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-02-10 11:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-10 10:46 [PATCH] regmap: Check readable regs in _regmap_read Michal Simek
2014-02-10 10:53 ` Lars-Peter Clausen
2014-02-10 11:00 ` Michal Simek
2014-02-10 11:49 ` Mark Brown
2014-02-10 11:54 ` Michal Simek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox