Skip to content

Commit

Permalink
[media] m5mols: Simplify the I2C registers definition
Browse files Browse the repository at this point in the history
The redundant definitions of the m5mols I2C register addresses within
the pages (categories) are removed. In place of symbolic definitions
plain numbers are used which simplifies the code and eases identifying
the registers in the documentation.

Also make the m5mols_busy() function accept I2C_REG() value as a register
address, like all other functions, rather than using the category and
command values.

Acked-by: HeungJun Kim <riverful.kim@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Sylwester Nawrocki authored and Mauro Carvalho Chehab committed Dec 30, 2011
1 parent dafb9c7 commit 69eb180
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 153 deletions.
2 changes: 1 addition & 1 deletion drivers/media/video/m5mols/m5mols.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ int m5mols_read_u8(struct v4l2_subdev *sd, u32 reg_comb, u8 *val);
int m5mols_read_u16(struct v4l2_subdev *sd, u32 reg_comb, u16 *val);
int m5mols_read_u32(struct v4l2_subdev *sd, u32 reg_comb, u32 *val);
int m5mols_write(struct v4l2_subdev *sd, u32 reg_comb, u32 val);
int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u8 value);
int m5mols_busy(struct v4l2_subdev *sd, u32 reg, u8 value);

/*
* Mode operation of the M-5MOLS
Expand Down
9 changes: 4 additions & 5 deletions drivers/media/video/m5mols/m5mols_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,14 @@ int m5mols_write(struct v4l2_subdev *sd, u32 reg, u32 val)
return 0;
}

int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u8 mask)
int m5mols_busy(struct v4l2_subdev *sd, u32 reg, u8 mask)
{
u8 busy;
int i;
int ret;

for (i = 0; i < M5MOLS_I2C_CHECK_RETRY; i++) {
ret = m5mols_read_u8(sd, I2C_REG(category, cmd, 1), &busy);
ret = m5mols_read_u8(sd, reg, &busy);
if (ret < 0)
return ret;
if ((busy & mask) == mask)
Expand Down Expand Up @@ -317,7 +317,7 @@ static int m5mols_reg_mode(struct v4l2_subdev *sd, u8 mode)
{
int ret = m5mols_write(sd, SYSTEM_SYSMODE, mode);

return ret ? ret : m5mols_busy(sd, CAT_SYSTEM, CAT0_SYSMODE, mode);
return ret ? ret : m5mols_busy(sd, mode, SYSTEM_SYSMODE);
}

/**
Expand Down Expand Up @@ -829,8 +829,7 @@ static int m5mols_s_power(struct v4l2_subdev *sd, int on)
if (!ret)
ret = m5mols_write(sd, AF_MODE, REG_AF_POWEROFF);
if (!ret)
ret = m5mols_busy(sd, CAT_SYSTEM, CAT0_STATUS,
REG_AF_IDLE);
ret = m5mols_busy(sd, SYSTEM_STATUS, REG_AF_IDLE);
if (!ret)
v4l2_info(sd, "Success soft-landing lens\n");
}
Expand Down
Loading

0 comments on commit 69eb180

Please sign in to comment.