All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: Use u8 type in i2c transfer calls
@ 2022-07-18 15:34 Jason Gerecke
  2022-08-03 14:59 ` [PATCH v2] " Jason Gerecke
  0 siblings, 1 reply; 9+ messages in thread
From: Jason Gerecke @ 2022-07-18 15:34 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang
  Cc: Ping Cheng, Tobita, Tatsunosuke, Jason Gerecke, Ping Cheng

The 'i2c_transfer_buffer_flags' function (and related inlines) defines its
'buf' argument to be of type 'char*'. This is a poor choice of type given
that most callers actually pass a 'u8*' and that the function itself ends
up just storing the variable to a 'u8*'-typed member of 'struct i2c_msg'
anyway.

Changing the type of the 'buf' argument to 'u8*' vastly reduces the number
of (admittedly usually-silent) Wpointer-sign warnings that are generated
as the types get needlessly juggled back and forth.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
---
 drivers/i2c/i2c-core-base.c |  2 +-
 include/linux/i2c.h         | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 10f35f942066..2925507e8626 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -2184,7 +2184,7 @@ EXPORT_SYMBOL(i2c_transfer);
  *
  * Returns negative errno, or else the number of bytes transferred.
  */
-int i2c_transfer_buffer_flags(const struct i2c_client *client, char *buf,
+int i2c_transfer_buffer_flags(const struct i2c_client *client, u8 *buf,
 			      int count, u16 flags)
 {
 	int ret;
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index fbda5ada2afc..65c46df51c51 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -64,7 +64,7 @@ const char *i2c_freq_mode_string(u32 bus_freq_hz);
  * @count must be less than 64k since msg.len is u16.
  */
 int i2c_transfer_buffer_flags(const struct i2c_client *client,
-			      char *buf, int count, u16 flags);
+			      u8 *buf, int count, u16 flags);
 
 /**
  * i2c_master_recv - issue a single I2C message in master receive mode
@@ -75,7 +75,7 @@ int i2c_transfer_buffer_flags(const struct i2c_client *client,
  * Returns negative errno, or else the number of bytes read.
  */
 static inline int i2c_master_recv(const struct i2c_client *client,
-				  char *buf, int count)
+				  u8 *buf, int count)
 {
 	return i2c_transfer_buffer_flags(client, buf, count, I2C_M_RD);
 };
@@ -90,7 +90,7 @@ static inline int i2c_master_recv(const struct i2c_client *client,
  * Returns negative errno, or else the number of bytes read.
  */
 static inline int i2c_master_recv_dmasafe(const struct i2c_client *client,
-					  char *buf, int count)
+					  u8 *buf, int count)
 {
 	return i2c_transfer_buffer_flags(client, buf, count,
 					 I2C_M_RD | I2C_M_DMA_SAFE);
@@ -105,9 +105,9 @@ static inline int i2c_master_recv_dmasafe(const struct i2c_client *client,
  * Returns negative errno, or else the number of bytes written.
  */
 static inline int i2c_master_send(const struct i2c_client *client,
-				  const char *buf, int count)
+				  const u8 *buf, int count)
 {
-	return i2c_transfer_buffer_flags(client, (char *)buf, count, 0);
+	return i2c_transfer_buffer_flags(client, (u8 *)buf, count, 0);
 };
 
 /**
@@ -120,9 +120,9 @@ static inline int i2c_master_send(const struct i2c_client *client,
  * Returns negative errno, or else the number of bytes written.
  */
 static inline int i2c_master_send_dmasafe(const struct i2c_client *client,
-					  const char *buf, int count)
+					  const u8 *buf, int count)
 {
-	return i2c_transfer_buffer_flags(client, (char *)buf, count,
+	return i2c_transfer_buffer_flags(client, (u8 *)buf, count,
 					 I2C_M_DMA_SAFE);
 };
 
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-10-20 10:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-18 15:34 [PATCH] i2c: Use u8 type in i2c transfer calls Jason Gerecke
2022-08-03 14:59 ` [PATCH v2] " Jason Gerecke
2022-08-03 16:46   ` Andy Shevchenko
2022-08-03 18:06     ` Jason Gerecke
2022-10-19 20:11       ` Wolfram Sang
2022-10-19 20:48         ` Jason Gerecke
2022-10-19 21:37           ` Wolfram Sang
2022-10-20 10:35             ` Jonathan Cameron
2022-08-06 14:44   ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.