mbox series

[v3,0/3] Use void pointers instead of char in I2C transfer APIs

Message ID 20191112203132.163306-1-dmitry.torokhov@gmail.com
Headers show
Series Use void pointers instead of char in I2C transfer APIs | expand

Message

Dmitry Torokhov Nov. 12, 2019, 8:31 p.m. UTC
While we indeed often deal with a stream of bytes when executing a
transfer, at the higher layers we usually work with more structured
data, and there is not really a reason to require casts to u8 * form the
callers. These series change I2C APIs to accept [const] void pointers,
and also adjust SMBUS implementation to use get/put_unaligned_16() and
memcpy() for moving data around.

Changes in v3:
- addressed Luca's comments
- added Jonathan's Acked-by
- split put_unaligned_le16 into a separate patch
- more call sites converted to get/put_unaligned_le16
- new patch using memcpy() for moving data around

Changes in v2:
- adjusted max1363 to the new i2c_master_send/recv signatures

Dmitry Torokhov (3):
  i2c: use void pointers for supplying data for reads and writes
  i2c: smbus: use get/put_unaligned_le16 when working with word data
  i2c: smbus: switch from loops to memcpy

 drivers/i2c/i2c-core-base.c  |  2 +-
 drivers/i2c/i2c-core-smbus.c | 40 +++++++++++++++---------------------
 drivers/iio/adc/max1363.c    | 14 +++++++------
 include/linux/i2c.h          | 28 +++++++++++++------------
 4 files changed, 41 insertions(+), 43 deletions(-)

Comments

Wolfram Sang Jan. 11, 2021, 9:01 p.m. UTC | #1
On Tue, Nov 12, 2019 at 12:31:29PM -0800, Dmitry Torokhov wrote:
> While we indeed often deal with a stream of bytes when executing a
> transfer, at the higher layers we usually work with more structured
> data, and there is not really a reason to require casts to u8 * form the
> callers. These series change I2C APIs to accept [const] void pointers,
> and also adjust SMBUS implementation to use get/put_unaligned_16() and
> memcpy() for moving data around.

I just started to work on something SMBus, so I rediscovered this series
and will comment now.