[PATCH] regmap: Add 24 bits support

Subsystems: driver core, kobjects, debugfs and sysfs, register map abstraction, the rest

STALE5242d

3 messages, 2 authors, 2012-03-26 · open the first message on its own page

[PATCH] regmap: Add 24 bits support

From: Alex Gershgorin <hidden>
Date: 2012-03-26 14:47:16

This patch adds support for PMIC who use regmap and 24 bit registers
For example MC13892, the patch was tested on i.MX35-PDK

Signed-off-by: Alex Gershgorin <redacted>
---
 drivers/base/regmap/internal.h |    1 +
 drivers/base/regmap/regmap.c   |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 1a02b75..3c5d204 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -122,5 +122,6 @@ int regcache_lookup_reg(struct regmap *map, unsigned int reg);
 
 extern struct regcache_ops regcache_rbtree_ops;
 extern struct regcache_ops regcache_lzo_ops;
+typedef struct { __u8 b[3]; } __be24;
 
 #endif
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 6555803..499ee6a 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -114,6 +114,13 @@ static void regmap_format_16(void *buf, unsigned int val)
 	b[0] = cpu_to_be16(val);
 }
 
+static void regmap_format_24(void *buf, unsigned int val)
+{
+	__be24 *b = buf;
+
+	b[0] = (__be24){ {(val >> 16) & 0xff, (val >> 8) & 0xff, val & 0xff } };
+}
+
 static unsigned int regmap_parse_8(void *buf)
 {
 	u8 *b = buf;
@@ -130,6 +137,13 @@ static unsigned int regmap_parse_16(void *buf)
 	return b[0];
 }
 
+static unsigned int regmap_parse_24(void *buf)
+{
+	__be24 *b = buf;
+
+	return (b->b[0] << 16) | (b->b[1] << 8) | (b->b[2]);
+}
+
 /**
  * regmap_init(): Initialise register map
  *
@@ -229,6 +243,10 @@ struct regmap *regmap_init(struct device *dev,
 		map->format.format_val = regmap_format_16;
 		map->format.parse_val = regmap_parse_16;
 		break;
+	case 24:
+		map->format.format_val = regmap_format_24;
+		map->format.parse_val = regmap_parse_24;
+		break;
 	}
 
 	if (!map->format.format_write &&
-- 
1.7.0.4

Re: [PATCH] regmap: Add 24 bits support

From: Mark Brown <hidden>
Date: 2012-03-26 14:51:01

On Mon, Mar 26, 2012 at 04:40:08PM +0200, Alex Gershgorin wrote:
This patch adds support for PMIC who use regmap and 24 bit registers
For example MC13892, the patch was tested on i.MX35-PDK
A similar patch from Marc Reilly has already been applied.  You don't
have his signoff here but then...
+typedef struct { __u8 b[3]; } __be24;
...you're adding stuff like this to the regmap headers which *clearly*
isn't regmap specific so this looks like a separate development.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120326/29610d5f/attachment.sig>

RE: [PATCH] regmap: Add 24 bits support

From: Alex Gershgorin <hidden>
Date: 2012-03-26 17:30:33

 
Subject: Re: [PATCH] regmap: Add 24 bits support
On Mon, Mar 26, 2012 at 04:40:08PM +0200, Alex Gershgorin wrote:
This patch adds support for PMIC who use regmap and 24 bit registers
For example MC13892, the patch was tested on i.MX35-PDK
quoted
A similar patch from Marc Reilly has already been applied.  You don't
have his signoff here but then...
Sorry Marc, I missed the patch 
+typedef struct { __u8 b[3]; } __be24;
quoted
...you're adding stuff like this to the regmap headers which *clearly*
isn't regmap specific so this looks like a separate development.
You right,

I think it makes no sense to fix it,
why do we need two similar patches

Thanks  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help