Messages in this thread Patch in this message | | | Subject | Re: [PATCH] regmap: don't corrupt work buffer in _regmap_raw_write() | From | Paul Bolle <> | Date | Mon, 08 Apr 2013 12:24:22 +0200 |
| |
On Thu, 2013-03-21 at 20:09 +0100, Mark Brown wrote: > On Wed, Mar 20, 2013 at 05:02:02PM -0600, Stephen Warren wrote: > > _regmap_raw_write() contains code to call regcache_write() to write > > values to the cache. That code calls memcpy() to copy the value data to > > the start of the work_buf. However, at least when _regmap_raw_write() is > > Applied, thanks.
0) This patch ended up as mainline commit bc8ce4afd7ee7e1421c935d24b1f879f82afdd4e, which is part of v3.9-rc6.
1) Building regmap.o now triggers this warning: drivers/base/regmap/regmap.c: In function ‘_regmap_raw_write’: drivers/base/regmap/regmap.c:946:4: warning: passing argument 1 of ‘map->format.parse_val’ discards ‘const’ qualifier from pointer target type [enabled by default] drivers/base/regmap/regmap.c:946:4: note: expected ‘void *’ but argument is of type ‘const void *’
2) The following (draft) patch silences this warning. I'm a bit uncertain what the regmap_parse_*() functions are meant to do. So I'd like to first ask whether something along these lines is acceptable.
Paul Bolle
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h index 5a22bd3..35877b7 100644 --- a/drivers/base/regmap/internal.h +++ b/drivers/base/regmap/internal.h @@ -38,7 +38,7 @@ struct regmap_format { unsigned int reg, unsigned int val); void (*format_reg)(void *buf, unsigned int reg, unsigned int shift); void (*format_val)(void *buf, unsigned int val, unsigned int shift); - unsigned int (*parse_val)(void *buf); + unsigned int (*parse_val)(const void *buf); }; struct regmap_async { diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index d34adef..2ca90a6 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -228,30 +228,28 @@ static void regmap_format_32_native(void *buf, unsigned int val, *(u32 *)buf = val << shift; } -static unsigned int regmap_parse_8(void *buf) +static unsigned int regmap_parse_8(const void *buf) { - u8 *b = buf; + const u8 *b = buf; return b[0]; } -static unsigned int regmap_parse_16_be(void *buf) +static unsigned int regmap_parse_16_be(const void *buf) { - __be16 *b = buf; + const __be16 *b = buf; - b[0] = be16_to_cpu(b[0]); - - return b[0]; + return be16_to_cpu(b[0]); } -static unsigned int regmap_parse_16_native(void *buf) +static unsigned int regmap_parse_16_native(const void *buf) { return *(u16 *)buf; } -static unsigned int regmap_parse_24(void *buf) +static unsigned int regmap_parse_24(const void *buf) { - u8 *b = buf; + const u8 *b = buf; unsigned int ret = b[2]; ret |= ((unsigned int)b[1]) << 8; ret |= ((unsigned int)b[0]) << 16; @@ -259,16 +257,14 @@ static unsigned int regmap_parse_24(void *buf) return ret; } -static unsigned int regmap_parse_32_be(void *buf) +static unsigned int regmap_parse_32_be(const void *buf) { - __be32 *b = buf; + const __be32 *b = buf; - b[0] = be32_to_cpu(b[0]); - - return b[0]; + return be32_to_cpu(b[0]); } -static unsigned int regmap_parse_32_native(void *buf) +static unsigned int regmap_parse_32_native(const void *buf) { return *(u32 *)buf; }
-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |