2012-05-31 16:23:28

by Krystian Garbaciak

[permalink] [raw]
Subject: [PATCH 4/4] regmap: Minor optimisation for _regmap_raw_write().

Just to make things simplier inside the function.

Signed-off-by: Krystian Garbaciak <[email protected]>
---
drivers/base/regmap/regmap.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index c32d1a6..7581ad9 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -612,17 +612,18 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg,
{
int i;
int ret;
+ unsigned int val_num = val_len / map->format.val_bytes;

/* Check for unwritable registers before we start */
if (map->writeable_reg)
- for (i = 0; i < val_len / map->format.val_bytes; i++)
+ for (i = 0; i < val_num; i++)
if (!map->writeable_reg(map->dev, reg + i))
return -EINVAL;

if (!map->cache_bypass && map->format.parse_val) {
unsigned int ival;
int val_bytes = map->format.val_bytes;
- for (i = 0; i < val_len / map->format.val_bytes; i++) {
+ for (i = 0; i < val_num; i++) {
memcpy(map->work_buf, val + (i * val_bytes), val_bytes);
ival = map->format.parse_val(map->work_buf);
ret = regcache_write(map, reg + i, ival);
@@ -639,8 +640,8 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg,
}
}

- return _regmap_range_access(_regmap_bus_write, map, reg, (void *)val,
- val_len / map->format.val_bytes);
+ return _regmap_range_access(_regmap_bus_write,
+ map, reg, (void *)val, val_num);
}

int _regmap_write(struct regmap *map, unsigned int reg,
--
1.7.0.4


2012-05-31 16:44:21

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 4/4] regmap: Minor optimisation for _regmap_raw_write().

On Thu, May 31, 2012 at 05:11:38PM +0200, Krystian Garbaciak wrote:
> Just to make things simplier inside the function.

Again, what is this actually doing (ie, please improve your changelogs)?

It looks like it's just factoring constants out (which hopefully the
compiler can do but still is OK) - this looks good but should probably
be at the start rather than end of the series.


Attachments:
(No filename) (382.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2012-05-31 17:57:26

by Krystian Garbaciak

[permalink] [raw]
Subject: RE: [PATCH 4/4] regmap: Minor optimisation for _regmap_raw_write().

> On Thu, May 31, 2012 at 05:11:38PM +0200, Krystian Garbaciak wrote:
> > Just to make things simplier inside the function.
>
> Again, what is this actually doing (ie, please improve your changelogs)?
>
> It looks like it's just factoring constants out (which hopefully the compiler can do
> but still is OK) - this looks good but should probably be at the start rather than
> end of the series.

Yes, this is only to make the code a bit simpler. I will put it as a first patch then.

Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information,
some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it
is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure,
copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.

Please consider the environment before printing this e-mail