diff mbox series

[RFC,1/3] media: i2c: adv7842: remove open coded version of SMBus block write

Message ID 20210112164130.47895-2-wsa+renesas@sang-engineering.com
State New
Headers show
Series treewide: remove open coded SMBus block transfers | expand

Commit Message

Wolfram Sang Jan. 12, 2021, 4:41 p.m. UTC
The version here is identical to the one in the I2C core, so use a
define to keep the original name within the driver but call the I2C core
function instead.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/i2c/adv7842.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

Comments

Hans Verkuil Jan. 18, 2021, 9:24 a.m. UTC | #1
On 12/01/2021 17:41, Wolfram Sang wrote:
> The version here is identical to the one in the I2C core, so use a
> define to keep the original name within the driver but call the I2C core
> function instead.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>  drivers/media/i2c/adv7842.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
> index 0855f648416d..6ed6bcd1d64d 100644
> --- a/drivers/media/i2c/adv7842.c
> +++ b/drivers/media/i2c/adv7842.c
> @@ -343,19 +343,7 @@ static void adv_smbus_write_byte_no_check(struct i2c_client *client,
>  		       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);
> -}
> +#define adv_smbus_write_i2c_block_data i2c_smbus_write_i2c_block_data

I would prefer it if the driver just uses i2c_smbus_write_i2c_block_data
directly instead of relying on this define. It's used only 5 times, so
it should be a trivial change.

Regards,

	Hans

>  
>  /* ----------------------------------------------------------------------- */
>  
>
Wolfram Sang Jan. 18, 2021, 9:32 a.m. UTC | #2
> > +#define adv_smbus_write_i2c_block_data i2c_smbus_write_i2c_block_data
> 
> I would prefer it if the driver just uses i2c_smbus_write_i2c_block_data
> directly instead of relying on this define. It's used only 5 times, so
> it should be a trivial change.

Okay, will change it!
diff mbox series

Patch

diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 0855f648416d..6ed6bcd1d64d 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -343,19 +343,7 @@  static void adv_smbus_write_byte_no_check(struct i2c_client *client,
 		       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);
-}
+#define adv_smbus_write_i2c_block_data i2c_smbus_write_i2c_block_data
 
 /* ----------------------------------------------------------------------- */