From: "Andrew F. Davis" <afd@ti.com>
To: Mark Brown <broonie@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, "Andrew F . Davis" <afd@ti.com>
Subject: [PATCH 2/3] regcache: flat: Un-inline index lookup from cache access
Date: Sun, 7 Jan 2018 17:22:33 -0600 [thread overview]
Message-ID: <20180107232234.11064-2-afd@ti.com> (raw)
In-Reply-To: <20180107232234.11064-1-afd@ti.com>
This makes the code slightly more readable and allows for cleaner
addition of functionality in later patches.
Signed-off-by: Andrew F. Davis <afd@ti.com>
---
drivers/base/regmap/regcache-flat.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/base/regmap/regcache-flat.c b/drivers/base/regmap/regcache-flat.c
index 2ea5fc84a374..99a7792210b3 100644
--- a/drivers/base/regmap/regcache-flat.c
+++ b/drivers/base/regmap/regcache-flat.c
@@ -37,9 +37,12 @@ static int regcache_flat_init(struct regmap *map)
cache = map->cache;
- for (i = 0; i < map->num_reg_defaults; i++)
- cache[regcache_flat_get_index(map, map->reg_defaults[i].reg)] =
- map->reg_defaults[i].def;
+ for (i = 0; i < map->num_reg_defaults; i++) {
+ unsigned int reg = map->reg_defaults[i].reg;
+ unsigned int index = regcache_flat_get_index(map, reg);
+
+ cache[index] = map->reg_defaults[i].def;
+ }
return 0;
}
@@ -56,8 +59,9 @@ static int regcache_flat_read(struct regmap *map,
unsigned int reg, unsigned int *value)
{
unsigned int *cache = map->cache;
+ unsigned int index = regcache_flat_get_index(map, reg);
- *value = cache[regcache_flat_get_index(map, reg)];
+ *value = cache[index];
return 0;
}
@@ -66,8 +70,9 @@ static int regcache_flat_write(struct regmap *map, unsigned int reg,
unsigned int value)
{
unsigned int *cache = map->cache;
+ unsigned int index = regcache_flat_get_index(map, reg);
- cache[regcache_flat_get_index(map, reg)] = value;
+ cache[index] = value;
return 0;
}
--
2.15.1
next prev parent reply other threads:[~2018-01-07 23:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-07 23:22 [PATCH 1/3] regcache: flat: Use cache element type in sizeof Andrew F. Davis
2018-01-07 23:22 ` Andrew F. Davis [this message]
2018-01-07 23:22 ` [PATCH 3/3] regcache: flat: Add valid bit to this cache type Andrew F. Davis
2018-01-08 12:08 ` Mark Brown
2018-01-08 16:25 ` Andrew F. Davis
2018-01-08 16:36 ` Mark Brown
2018-01-08 16:46 ` Andrew F. Davis
2018-01-09 16:24 ` Mark Brown
2018-01-09 17:47 ` Andrew F. Davis
2018-01-10 12:02 ` Mark Brown
2018-01-08 11:59 ` [PATCH 1/3] regcache: flat: Use cache element type in sizeof Mark Brown
2018-01-08 16:25 ` Andrew F. Davis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180107232234.11064-2-afd@ti.com \
--to=afd@ti.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome