diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2014-04-10 09:08:59 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-04-23 10:32:22 -0400 |
commit | f5d65070d49f707a06bf00c147f02848659a6a0b (patch) | |
tree | 3d5cc544d99dcc8719c3a89b1eb52c0faa53d0cd | |
parent | 6f7481b6685daf693e995e8653f6c8d27cfe5bfc (diff) |
[media] smiapp: Define macros for obtaining properties of register definitions
The register address, width and flags are encoded as a 32-bit value. Add
macros for obtaining these separately. Use the macros in register access
functions.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r-- | drivers/media/i2c/smiapp/smiapp-regs.c | 13 | ||||
-rw-r--r-- | drivers/media/i2c/smiapp/smiapp-regs.h | 4 |
2 files changed, 11 insertions, 6 deletions
diff --git a/drivers/media/i2c/smiapp/smiapp-regs.c b/drivers/media/i2c/smiapp/smiapp-regs.c index eb5146af9c30..a2098007fb70 100644 --- a/drivers/media/i2c/smiapp/smiapp-regs.c +++ b/drivers/media/i2c/smiapp/smiapp-regs.c | |||
@@ -165,7 +165,7 @@ static int __smiapp_read(struct smiapp_sensor *sensor, u32 reg, u32 *val, | |||
165 | bool only8) | 165 | bool only8) |
166 | { | 166 | { |
167 | struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); | 167 | struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); |
168 | unsigned int len = (u8)(reg >> 16); | 168 | u8 len = SMIAPP_REG_WIDTH(reg); |
169 | int rval; | 169 | int rval; |
170 | 170 | ||
171 | if (len != SMIAPP_REG_8BIT && len != SMIAPP_REG_16BIT | 171 | if (len != SMIAPP_REG_8BIT && len != SMIAPP_REG_16BIT |
@@ -173,9 +173,10 @@ static int __smiapp_read(struct smiapp_sensor *sensor, u32 reg, u32 *val, | |||
173 | return -EINVAL; | 173 | return -EINVAL; |
174 | 174 | ||
175 | if (len == SMIAPP_REG_8BIT || !only8) | 175 | if (len == SMIAPP_REG_8BIT || !only8) |
176 | rval = ____smiapp_read(sensor, (u16)reg, len, val); | 176 | rval = ____smiapp_read(sensor, SMIAPP_REG_ADDR(reg), len, val); |
177 | else | 177 | else |
178 | rval = ____smiapp_read_8only(sensor, (u16)reg, len, val); | 178 | rval = ____smiapp_read_8only(sensor, SMIAPP_REG_ADDR(reg), len, |
179 | val); | ||
179 | if (rval < 0) | 180 | if (rval < 0) |
180 | return rval; | 181 | return rval; |
181 | 182 | ||
@@ -227,9 +228,9 @@ int smiapp_write_no_quirk(struct smiapp_sensor *sensor, u32 reg, u32 val) | |||
227 | struct i2c_msg msg; | 228 | struct i2c_msg msg; |
228 | unsigned char data[6]; | 229 | unsigned char data[6]; |
229 | unsigned int retries; | 230 | unsigned int retries; |
230 | unsigned int flags = reg >> 24; | 231 | u8 flags = SMIAPP_REG_FLAGS(reg); |
231 | unsigned int len = (u8)(reg >> 16); | 232 | u8 len = SMIAPP_REG_WIDTH(reg); |
232 | u16 offset = reg; | 233 | u16 offset = SMIAPP_REG_ADDR(reg); |
233 | int r; | 234 | int r; |
234 | 235 | ||
235 | if ((len != SMIAPP_REG_8BIT && len != SMIAPP_REG_16BIT && | 236 | if ((len != SMIAPP_REG_8BIT && len != SMIAPP_REG_16BIT && |
diff --git a/drivers/media/i2c/smiapp/smiapp-regs.h b/drivers/media/i2c/smiapp/smiapp-regs.h index 81957cbf6a13..35521125a2cc 100644 --- a/drivers/media/i2c/smiapp/smiapp-regs.h +++ b/drivers/media/i2c/smiapp/smiapp-regs.h | |||
@@ -28,6 +28,10 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | 30 | ||
31 | #define SMIAPP_REG_ADDR(reg) ((u16)reg) | ||
32 | #define SMIAPP_REG_WIDTH(reg) ((u8)(reg >> 16)) | ||
33 | #define SMIAPP_REG_FLAGS(reg) ((u8)(reg >> 24)) | ||
34 | |||
31 | /* Use upper 8 bits of the type field for flags */ | 35 | /* Use upper 8 bits of the type field for flags */ |
32 | #define SMIAPP_REG_FLAG_FLOAT (1 << 24) | 36 | #define SMIAPP_REG_FLAG_FLOAT (1 << 24) |
33 | 37 | ||