Commit fe1fd842 authored by Wolfram Sang's avatar Wolfram Sang Committed by Mauro Carvalho Chehab

media: i2c: adv7842: remove open coded version of SMBus block write

The version here is identical to the one in the I2C core, so use the
latter version directly.
Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 0f02beec
...@@ -343,20 +343,6 @@ static void adv_smbus_write_byte_no_check(struct i2c_client *client, ...@@ -343,20 +343,6 @@ static void adv_smbus_write_byte_no_check(struct i2c_client *client,
I2C_SMBUS_BYTE_DATA, &data); I2C_SMBUS_BYTE_DATA, &data);
} }
static s32 adv_smbus_write_i2c_block_data(struct i2c_client *client,
u8 command, unsigned length, const u8 *values)
{
union i2c_smbus_data data;
if (length > I2C_SMBUS_BLOCK_MAX)
length = I2C_SMBUS_BLOCK_MAX;
data.block[0] = length;
memcpy(data.block + 1, values, length);
return i2c_smbus_xfer(client->adapter, client->addr, client->flags,
I2C_SMBUS_WRITE, command,
I2C_SMBUS_I2C_BLOCK_DATA, &data);
}
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static inline int io_read(struct v4l2_subdev *sd, u8 reg) static inline int io_read(struct v4l2_subdev *sd, u8 reg)
...@@ -741,8 +727,9 @@ static int edid_write_vga_segment(struct v4l2_subdev *sd) ...@@ -741,8 +727,9 @@ static int edid_write_vga_segment(struct v4l2_subdev *sd)
rep_write_and_or(sd, 0x77, 0xef, 0x10); rep_write_and_or(sd, 0x77, 0xef, 0x10);
for (i = 0; !err && i < 256; i += I2C_SMBUS_BLOCK_MAX) for (i = 0; !err && i < 256; i += I2C_SMBUS_BLOCK_MAX)
err = adv_smbus_write_i2c_block_data(state->i2c_edid, i, err = i2c_smbus_write_i2c_block_data(state->i2c_edid, i,
I2C_SMBUS_BLOCK_MAX, val + i); I2C_SMBUS_BLOCK_MAX,
val + i);
if (err) if (err)
return err; return err;
...@@ -807,7 +794,7 @@ static int edid_write_hdmi_segment(struct v4l2_subdev *sd, u8 port) ...@@ -807,7 +794,7 @@ static int edid_write_hdmi_segment(struct v4l2_subdev *sd, u8 port)
rep_write_and_or(sd, 0x77, 0xef, 0x00); rep_write_and_or(sd, 0x77, 0xef, 0x00);
for (i = 0; !err && i < 256; i += I2C_SMBUS_BLOCK_MAX) for (i = 0; !err && i < 256; i += I2C_SMBUS_BLOCK_MAX)
err = adv_smbus_write_i2c_block_data(state->i2c_edid, i, err = i2c_smbus_write_i2c_block_data(state->i2c_edid, i,
I2C_SMBUS_BLOCK_MAX, edid + i); I2C_SMBUS_BLOCK_MAX, edid + i);
if (err) if (err)
return err; return err;
...@@ -1079,7 +1066,7 @@ static void configure_custom_video_timings(struct v4l2_subdev *sd, ...@@ -1079,7 +1066,7 @@ static void configure_custom_video_timings(struct v4l2_subdev *sd,
/* Should only be set in auto-graphics mode [REF_02, p. 91-92] */ /* Should only be set in auto-graphics mode [REF_02, p. 91-92] */
/* setup PLL_DIV_MAN_EN and PLL_DIV_RATIO */ /* setup PLL_DIV_MAN_EN and PLL_DIV_RATIO */
/* IO-map reg. 0x16 and 0x17 should be written in sequence */ /* IO-map reg. 0x16 and 0x17 should be written in sequence */
if (adv_smbus_write_i2c_block_data(client, 0x16, 2, pll)) { if (i2c_smbus_write_i2c_block_data(client, 0x16, 2, pll)) {
v4l2_err(sd, "writing to reg 0x16 and 0x17 failed\n"); v4l2_err(sd, "writing to reg 0x16 and 0x17 failed\n");
break; break;
} }
...@@ -1135,7 +1122,7 @@ static void adv7842_set_offset(struct v4l2_subdev *sd, bool auto_offset, u16 off ...@@ -1135,7 +1122,7 @@ static void adv7842_set_offset(struct v4l2_subdev *sd, bool auto_offset, u16 off
offset_buf[3] = offset_c & 0x0ff; offset_buf[3] = offset_c & 0x0ff;
/* Registers must be written in this order with no i2c access in between */ /* Registers must be written in this order with no i2c access in between */
if (adv_smbus_write_i2c_block_data(state->i2c_cp, 0x77, 4, offset_buf)) if (i2c_smbus_write_i2c_block_data(state->i2c_cp, 0x77, 4, offset_buf))
v4l2_err(sd, "%s: i2c error writing to CP reg 0x77, 0x78, 0x79, 0x7a\n", __func__); v4l2_err(sd, "%s: i2c error writing to CP reg 0x77, 0x78, 0x79, 0x7a\n", __func__);
} }
...@@ -1164,7 +1151,7 @@ static void adv7842_set_gain(struct v4l2_subdev *sd, bool auto_gain, u16 gain_a, ...@@ -1164,7 +1151,7 @@ static void adv7842_set_gain(struct v4l2_subdev *sd, bool auto_gain, u16 gain_a,
gain_buf[3] = ((gain_c & 0x0ff)); gain_buf[3] = ((gain_c & 0x0ff));
/* Registers must be written in this order with no i2c access in between */ /* Registers must be written in this order with no i2c access in between */
if (adv_smbus_write_i2c_block_data(state->i2c_cp, 0x73, 4, gain_buf)) if (i2c_smbus_write_i2c_block_data(state->i2c_cp, 0x73, 4, gain_buf))
v4l2_err(sd, "%s: i2c error writing to CP reg 0x73, 0x74, 0x75, 0x76\n", __func__); v4l2_err(sd, "%s: i2c error writing to CP reg 0x73, 0x74, 0x75, 0x76\n", __func__);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment