aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeungJun, Kim <riverful.kim@samsung.com>2011-06-07 00:59:44 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-06-11 08:45:55 -0400
commita6354d2e5da646926ce492b66b527a1efc39cd27 (patch)
tree1f4f18c5a1a1979775316e37624e8ad4a866f1c0
parent57644f56234a154afffd0f4d53becf8ff4a55b41 (diff)
[media] m5mols: remove union in the m5mols_get_version(), and VERSION_SIZE
Remove union version in the m5mols_get_version(), and read version information directly. Also remove VERSION_SIZE. Signed-off-by: HeungJun, Kim <riverful.kim@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/m5mols/m5mols.h1
-rw-r--r--drivers/media/video/m5mols/m5mols_core.c50
-rw-r--r--drivers/media/video/m5mols/m5mols_reg.h13
3 files changed, 37 insertions, 27 deletions
diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h
index dbe8928855de..9ae170935871 100644
--- a/drivers/media/video/m5mols/m5mols.h
+++ b/drivers/media/video/m5mols/m5mols.h
@@ -154,7 +154,6 @@ struct m5mols_version {
154 u8 str[VERSION_STRING_SIZE]; 154 u8 str[VERSION_STRING_SIZE];
155 u8 af; 155 u8 af;
156}; 156};
157#define VERSION_SIZE sizeof(struct m5mols_version)
158 157
159/** 158/**
160 * struct m5mols_info - M-5MOLS driver data structure 159 * struct m5mols_info - M-5MOLS driver data structure
diff --git a/drivers/media/video/m5mols/m5mols_core.c b/drivers/media/video/m5mols/m5mols_core.c
index 2b1f23f8d063..9815f2c75e83 100644
--- a/drivers/media/video/m5mols/m5mols_core.c
+++ b/drivers/media/video/m5mols/m5mols_core.c
@@ -386,37 +386,37 @@ int m5mols_mode(struct m5mols_info *info, u8 mode)
386static int m5mols_get_version(struct v4l2_subdev *sd) 386static int m5mols_get_version(struct v4l2_subdev *sd)
387{ 387{
388 struct m5mols_info *info = to_m5mols(sd); 388 struct m5mols_info *info = to_m5mols(sd);
389 union { 389 struct m5mols_version *ver = &info->ver;
390 struct m5mols_version ver; 390 u8 *str = ver->str;
391 u8 bytes[VERSION_SIZE]; 391 int i;
392 } version;
393 u8 cmd = CAT0_VER_CUSTOMER;
394 int ret; 392 int ret;
395 393
396 do { 394 ret = m5mols_read_u8(sd, SYSTEM_VER_CUSTOMER, &ver->customer);
397 ret = m5mols_read_u8(sd, SYSTEM_CMD(cmd), &version.bytes[cmd]); 395 if (!ret)
398 if (ret) 396 ret = m5mols_read_u8(sd, SYSTEM_VER_PROJECT, &ver->project);
399 return ret; 397 if (!ret)
400 } while (cmd++ != CAT0_VER_AWB); 398 ret = m5mols_read_u16(sd, SYSTEM_VER_FIRMWARE, &ver->fw);
399 if (!ret)
400 ret = m5mols_read_u16(sd, SYSTEM_VER_HARDWARE, &ver->hw);
401 if (!ret)
402 ret = m5mols_read_u16(sd, SYSTEM_VER_PARAMETER, &ver->param);
403 if (!ret)
404 ret = m5mols_read_u16(sd, SYSTEM_VER_AWB, &ver->awb);
405 if (!ret)
406 ret = m5mols_read_u8(sd, AF_VERSION, &ver->af);
407 if (ret)
408 return ret;
401 409
402 do { 410 for (i = 0; i < VERSION_STRING_SIZE; i++) {
403 ret = m5mols_read_u8(sd, SYSTEM_VER_STRING, &version.bytes[cmd]); 411 ret = m5mols_read_u8(sd, SYSTEM_VER_STRING, &str[i]);
404 if (ret) 412 if (ret)
405 return ret; 413 return ret;
406 if (cmd >= VERSION_SIZE - 1) 414 }
407 return -EINVAL;
408 } while (version.bytes[cmd++]);
409
410 ret = m5mols_read_u8(sd, AF_VERSION, &version.bytes[cmd]);
411 if (ret)
412 return ret;
413 415
414 /* store version information swapped for being readable */ 416 ver->fw = be16_to_cpu(ver->fw);
415 info->ver = version.ver; 417 ver->hw = be16_to_cpu(ver->hw);
416 info->ver.fw = be16_to_cpu(info->ver.fw); 418 ver->param = be16_to_cpu(ver->param);
417 info->ver.hw = be16_to_cpu(info->ver.hw); 419 ver->awb = be16_to_cpu(ver->awb);
418 info->ver.param = be16_to_cpu(info->ver.param);
419 info->ver.awb = be16_to_cpu(info->ver.awb);
420 420
421 v4l2_info(sd, "Manufacturer\t[%s]\n", 421 v4l2_info(sd, "Manufacturer\t[%s]\n",
422 is_manufacturer(info, REG_SAMSUNG_ELECTRO) ? 422 is_manufacturer(info, REG_SAMSUNG_ELECTRO) ?
diff --git a/drivers/media/video/m5mols/m5mols_reg.h b/drivers/media/video/m5mols/m5mols_reg.h
index 8260f5030c7e..5f5bdcf608b6 100644
--- a/drivers/media/video/m5mols/m5mols_reg.h
+++ b/drivers/media/video/m5mols/m5mols_reg.h
@@ -56,13 +56,24 @@
56 * more specific contents, see definition if file m5mols.h. 56 * more specific contents, see definition if file m5mols.h.
57 */ 57 */
58#define CAT0_VER_CUSTOMER 0x00 /* customer version */ 58#define CAT0_VER_CUSTOMER 0x00 /* customer version */
59#define CAT0_VER_AWB 0x09 /* Auto WB version */ 59#define CAT0_VER_PROJECT 0x01 /* project version */
60#define CAT0_VER_FIRMWARE 0x02 /* Firmware version */
61#define CAT0_VER_HARDWARE 0x04 /* Hardware version */
62#define CAT0_VER_PARAMETER 0x06 /* Parameter version */
63#define CAT0_VER_AWB 0x08 /* Auto WB version */
60#define CAT0_VER_STRING 0x0a /* string including M-5MOLS */ 64#define CAT0_VER_STRING 0x0a /* string including M-5MOLS */
61#define CAT0_SYSMODE 0x0b /* SYSTEM mode register */ 65#define CAT0_SYSMODE 0x0b /* SYSTEM mode register */
62#define CAT0_STATUS 0x0c /* SYSTEM mode status register */ 66#define CAT0_STATUS 0x0c /* SYSTEM mode status register */
63#define CAT0_INT_FACTOR 0x10 /* interrupt pending register */ 67#define CAT0_INT_FACTOR 0x10 /* interrupt pending register */
64#define CAT0_INT_ENABLE 0x11 /* interrupt enable register */ 68#define CAT0_INT_ENABLE 0x11 /* interrupt enable register */
65 69
70#define SYSTEM_VER_CUSTOMER I2C_REG(CAT_SYSTEM, CAT0_VER_CUSTOMER, 1)
71#define SYSTEM_VER_PROJECT I2C_REG(CAT_SYSTEM, CAT0_VER_PROJECT, 1)
72#define SYSTEM_VER_FIRMWARE I2C_REG(CAT_SYSTEM, CAT0_VER_FIRMWARE, 2)
73#define SYSTEM_VER_HARDWARE I2C_REG(CAT_SYSTEM, CAT0_VER_HARDWARE, 2)
74#define SYSTEM_VER_PARAMETER I2C_REG(CAT_SYSTEM, CAT0_VER_PARAMETER, 2)
75#define SYSTEM_VER_AWB I2C_REG(CAT_SYSTEM, CAT0_VER_AWB, 2)
76
66#define SYSTEM_SYSMODE I2C_REG(CAT_SYSTEM, CAT0_SYSMODE, 1) 77#define SYSTEM_SYSMODE I2C_REG(CAT_SYSTEM, CAT0_SYSMODE, 1)
67#define REG_SYSINIT 0x00 /* SYSTEM mode */ 78#define REG_SYSINIT 0x00 /* SYSTEM mode */
68#define REG_PARAMETER 0x01 /* PARAMETER mode */ 79#define REG_PARAMETER 0x01 /* PARAMETER mode */