From: Lars-Peter Clausen <lars@metafoo.de>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>,
Dimitris Papastamos <dp@opensource.wolfsonmicro.com>,
Jonathan Cameron <jic23@kernel.org>
Cc: Michael Hennerich <michael.hennerich@analog.com>,
<linux-kernel@vger.kernel.org>, <linux-iio@vger.kernel.org>,
<device-drivers-devel@blackfin.uclinux.org>, <drivers@analog.com>,
Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 2/7] regmap: Make reg_config reg_defaults const
Date: Wed, 16 Nov 2011 16:28:17 +0100 [thread overview]
Message-ID: <1321457302-8724-2-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1321457302-8724-1-git-send-email-lars@metafoo.de>
The reg_defaults field usually points to a static per driver array, which should
not be modified. Make requirement this explicit by making reg_defaults const.
To allow this the regcache_init code needs some minor changes. Previoulsy the
reg_config was not available in regcache_init and regmap->reg_defaults was used
to pass the default register set to regcache_init. Now that the reg_config is
available we can work on it directly.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/base/regmap/regcache.c | 5 ++---
include/linux/regmap.h | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 0ad6cfb..d687df6 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -108,7 +108,6 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
return -EINVAL;
}
- map->reg_defaults = config->reg_defaults;
map->num_reg_defaults = config->num_reg_defaults;
map->num_reg_defaults_raw = config->num_reg_defaults_raw;
map->reg_defaults_raw = config->reg_defaults_raw;
@@ -127,10 +126,10 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
* won't vanish from under us. We'll need to make
* a copy of it.
*/
- if (map->reg_defaults) {
+ if (config->reg_defaults) {
if (!map->num_reg_defaults)
return -EINVAL;
- tmp_buf = kmemdup(map->reg_defaults, map->num_reg_defaults *
+ tmp_buf = kmemdup(config->reg_defaults, map->num_reg_defaults *
sizeof(struct reg_default), GFP_KERNEL);
if (!tmp_buf)
return -ENOMEM;
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 1e4ec2b..458f15f 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -83,7 +83,7 @@ struct regmap_config {
bool (*precious_reg)(struct device *dev, unsigned int reg);
unsigned int max_register;
- struct reg_default *reg_defaults;
+ const struct reg_default *reg_defaults;
unsigned int num_reg_defaults;
enum regcache_type cache_type;
const void *reg_defaults_raw;
--
1.7.7.1
next prev parent reply other threads:[~2011-11-16 15:28 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-16 15:28 [PATCH 1/7] regmap: Move initialization of regcache related fields to regcache_init Lars-Peter Clausen
2011-11-16 15:28 ` Lars-Peter Clausen [this message]
2011-11-16 16:13 ` [PATCH 2/7] regmap: Make reg_config reg_defaults const Mark Brown
2011-11-16 16:23 ` Lars-Peter Clausen
2011-11-16 16:24 ` Mark Brown
2011-11-16 16:36 ` Lars-Peter Clausen
2011-11-16 16:39 ` Mark Brown
2011-11-16 16:50 ` Lars-Peter Clausen
2011-11-16 16:51 ` Mark Brown
2011-11-16 17:01 ` Lars-Peter Clausen
2011-11-16 17:09 ` Mark Brown
2011-11-16 17:20 ` Lars-Peter Clausen
2011-11-16 17:26 ` Mark Brown
2011-11-16 17:35 ` Mark Brown
2011-11-16 15:28 ` [PATCH 3/7] regmap: Properly round cache_word_size Lars-Peter Clausen
2011-11-16 16:14 ` Mark Brown
2011-11-16 16:25 ` Lars-Peter Clausen
2011-11-16 15:28 ` [PATCH 4/7] regmap: Try cached read before checking if a hardware read is possible Lars-Peter Clausen
2011-11-16 17:35 ` Mark Brown
2011-11-16 15:28 ` [PATCH 5/7] regmap: Check if a register is writable instead of readable in regcache_read Lars-Peter Clausen
2011-11-16 16:16 ` Mark Brown
2011-11-16 16:34 ` Lars-Peter Clausen
2011-11-16 16:38 ` Mark Brown
2011-11-16 16:52 ` Lars-Peter Clausen
2011-11-16 16:56 ` Mark Brown
2011-11-16 17:09 ` Lars-Peter Clausen
2011-11-16 17:12 ` Mark Brown
2011-11-16 17:15 ` Lars-Peter Clausen
2011-11-16 17:22 ` Mark Brown
2011-11-16 15:28 ` [PATCH 6/7] regmap: Add support for 10/14 register formating Lars-Peter Clausen
2011-11-16 17:37 ` Mark Brown
2011-11-16 15:28 ` [PATCH 7/7] staging:iio:dac: Add AD5380 driver Lars-Peter Clausen
2011-11-16 16:56 ` Lars-Peter Clausen
2011-11-17 20:24 ` Jonathan Cameron
2011-11-18 9:08 ` Lars-Peter Clausen
2011-11-18 9:51 ` J.I. Cameron
2011-11-16 17:35 ` [PATCH 1/7] regmap: Move initialization of regcache related fields to regcache_init Mark Brown
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=1321457302-8724-2-git-send-email-lars@metafoo.de \
--to=lars@metafoo.de \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=device-drivers-devel@blackfin.uclinux.org \
--cc=dp@opensource.wolfsonmicro.com \
--cc=drivers@analog.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.hennerich@analog.com \
/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;
as well as URLs for NNTP newsgroup(s).