2015-12-10 02:49:34

by Xiubo Li

[permalink] [raw]
Subject: [PATCH] regmap: cache: Add warning info for the cache check

If there is no cache used for the drivers, the register drfaults
are not need any more. This patch will check this and print a
warning.

Signed-off-by: Xiubo Li <[email protected]>
---
drivers/base/regmap/regcache.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 1c0210a..bdcd401 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -100,15 +100,19 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
int i;
void *tmp_buf;

- for (i = 0; i < config->num_reg_defaults; i++)
- if (config->reg_defaults[i].reg % map->reg_stride)
- return -EINVAL;
-
if (map->cache_type == REGCACHE_NONE) {
+ if (config->num_reg_defaults)
+ dev_warn(map->dev,
+ "No cache used with register defualts set!\n");
+
map->cache_bypass = true;
return 0;
}

+ for (i = 0; i < config->num_reg_defaults; i++)
+ if (config->reg_defaults[i].reg % map->reg_stride)
+ return -EINVAL;
+
for (i = 0; i < ARRAY_SIZE(cache_types); i++)
if (cache_types[i]->type == map->cache_type)
break;
--
1.8.3.1


2015-12-10 12:45:47

by Charles Keepax

[permalink] [raw]
Subject: Re: [PATCH] regmap: cache: Add warning info for the cache check

On Thu, Dec 10, 2015 at 10:40:53AM +0800, Xiubo Li wrote:
> If there is no cache used for the drivers, the register drfaults

s/drfaults/defaults/

> are not need any more. This patch will check this and print a
> warning.
>
> Signed-off-by: Xiubo Li <[email protected]>
> ---
> drivers/base/regmap/regcache.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
> index 1c0210a..bdcd401 100644
> --- a/drivers/base/regmap/regcache.c
> +++ b/drivers/base/regmap/regcache.c
> @@ -100,15 +100,19 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
> int i;
> void *tmp_buf;
>
> - for (i = 0; i < config->num_reg_defaults; i++)
> - if (config->reg_defaults[i].reg % map->reg_stride)
> - return -EINVAL;
> -
> if (map->cache_type == REGCACHE_NONE) {
> + if (config->num_reg_defaults)
> + dev_warn(map->dev,
> + "No cache used with register defualts set!\n");

s/defualts/defaults/

Thanks,
Charles

2015-12-11 01:10:43

by Xiubo Li

[permalink] [raw]
Subject: Re: [PATCH] regmap: cache: Add warning info for the cache check



On 10/12/2015 20:45, Charles Keepax wrote:
> On Thu, Dec 10, 2015 at 10:40:53AM +0800, Xiubo Li wrote:
>> If there is no cache used for the drivers, the register drfaults
> s/drfaults/defaults/
Yes,Thanks.


>> are not need any more. This patch will check this and print a
>> warning.
>>
>> Signed-off-by: Xiubo Li <[email protected]>
>> ---
>> drivers/base/regmap/regcache.c | 12 ++++++++----
>> 1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
>> index 1c0210a..bdcd401 100644
>> --- a/drivers/base/regmap/regcache.c
>> +++ b/drivers/base/regmap/regcache.c
>> @@ -100,15 +100,19 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
>> int i;
>> void *tmp_buf;
>>
>> - for (i = 0; i < config->num_reg_defaults; i++)
>> - if (config->reg_defaults[i].reg % map->reg_stride)
>> - return -EINVAL;
>> -
>> if (map->cache_type == REGCACHE_NONE) {
>> + if (config->num_reg_defaults)
>> + dev_warn(map->dev,
>> + "No cache used with register defualts set!\n");
> s/defualts/defaults/
See the next version.


Thanks,

BRs

Xiubo

> Thanks,
> Charles