All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regmap: speed up the regcache_init()
@ 2015-12-03  2:19 Xiubo Li
  2015-12-08 17:05 ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Xiubo Li @ 2015-12-03  2:19 UTC (permalink / raw)
  To: broonie; +Cc: linux-kernel, Xiubo Li

If the cache is not used by the device driver, there is not need to
check the striding of the registers. It will just return 0 from
regcache_init() and let the register striding be checked in proper
place when needed.

Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com>
---
 drivers/base/regmap/regcache.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 4c07802..edc3bd9 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -100,15 +100,15 @@ 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) {
 		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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] regmap: speed up the regcache_init()
  2015-12-03  2:19 [PATCH] regmap: speed up the regcache_init() Xiubo Li
@ 2015-12-08 17:05 ` Mark Brown
  2015-12-09  3:17   ` Xiubo Li
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2015-12-08 17:05 UTC (permalink / raw)
  To: Xiubo Li; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 597 bytes --]

On Thu, Dec 03, 2015 at 10:19:10AM +0800, Xiubo Li wrote:

> If the cache is not used by the device driver, there is not need to
> check the striding of the registers. It will just return 0 from
> regcache_init() and let the register striding be checked in proper
> place when needed.

> -	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) {
>  		map->cache_bypass = true;
>  		return 0;
>  	}

If we're not using the register cache why are there defaults in the
first place?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] regmap: speed up the regcache_init()
  2015-12-08 17:05 ` Mark Brown
@ 2015-12-09  3:17   ` Xiubo Li
  2015-12-09 15:05     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Xiubo Li @ 2015-12-09  3:17 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel



On 09/12/2015 01:05, Mark Brown wrote:
> On Thu, Dec 03, 2015 at 10:19:10AM +0800, Xiubo Li wrote:
>
>> If the cache is not used by the device driver, there is not need to
>> check the striding of the registers. It will just return 0 from
>> regcache_init() and let the register striding be checked in proper
>> place when needed.
>> -	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) {
>>   		map->cache_bypass = true;
>>   		return 0;
>>   	}
> If we're not using the register cache why are there defaults in the
> first place?
Yes, usually when the register cache is not used, the number of the
defaults should be zero, but for some drivers like drv2267.c/led_lp8860.c
will add the defaults register values though the cache type is
REGCACHE_NONE for some reasons.

This patch may be not the best, but will be a bit meaningful for some
drivers like drv2267.c/led_lp8860.c for now.

Thanks,

BRs

Xiubo









^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] regmap: speed up the regcache_init()
  2015-12-09  3:17   ` Xiubo Li
@ 2015-12-09 15:05     ` Mark Brown
  2015-12-10  1:37       ` Xiubo Li
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2015-12-09 15:05 UTC (permalink / raw)
  To: Xiubo Li; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 614 bytes --]

On Wed, Dec 09, 2015 at 11:17:22AM +0800, Xiubo Li wrote:

> Yes, usually when the register cache is not used, the number of the
> defaults should be zero, but for some drivers like drv2267.c/led_lp8860.c
> will add the defaults register values though the cache type is
> REGCACHE_NONE for some reasons.

I can't find either of those in the kernel tree...

> This patch may be not the best, but will be a bit meaningful for some
> drivers like drv2267.c/led_lp8860.c for now.

TBH if we're going to do something here it might be as well to print a
warning if something is providing register defaults but no cache.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] regmap: speed up the regcache_init()
  2015-12-09 15:05     ` Mark Brown
@ 2015-12-10  1:37       ` Xiubo Li
  0 siblings, 0 replies; 5+ messages in thread
From: Xiubo Li @ 2015-12-10  1:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel



On 09/12/2015 23:05, Mark Brown wrote:
> On Wed, Dec 09, 2015 at 11:17:22AM +0800, Xiubo Li wrote:
>
>> Yes, usually when the register cache is not used, the number of the
>> defaults should be zero, but for some drivers like drv2267.c/led_lp8860.c
>> will add the defaults register values though the cache type is
>> REGCACHE_NONE for some reasons.
> I can't find either of those in the kernel tree...
This could be found in the for-next branch of regmap tree.


>> This patch may be not the best, but will be a bit meaningful for some
>> drivers like drv2267.c/led_lp8860.c for now.
> TBH if we're going to do something here it might be as well to print a
> warning if something is providing register defaults but no cache.
Yes, Agreed.

I will enhance this later in another patch, just abandon this one please.




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-12-10  1:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-03  2:19 [PATCH] regmap: speed up the regcache_init() Xiubo Li
2015-12-08 17:05 ` Mark Brown
2015-12-09  3:17   ` Xiubo Li
2015-12-09 15:05     ` Mark Brown
2015-12-10  1:37       ` Xiubo Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.