]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
i2c: Use str_read_write() helper
authorYumeng Fang <fang.yumeng@zte.com.cn>
Fri, 23 May 2025 08:54:45 +0000 (16:54 +0800)
committerWolfram Sang <wsa+renesas@sang-engineering.com>
Fri, 23 May 2025 15:28:07 +0000 (17:28 +0200)
Remove hard-coded strings by using the str_read_write() helper.

Signed-off-by: Yumeng Fang <fang.yumeng@zte.com.cn>
Signed-off-by: Yunjian Long <long.yunjian@zte.com.cn>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
drivers/i2c/algos/i2c-algo-pcf.c
drivers/i2c/busses/i2c-at91-master.c
drivers/i2c/busses/i2c-sh_mobile.c
drivers/i2c/busses/i2c-tiny-usb.c
drivers/i2c/busses/i2c-viperboard.c
drivers/i2c/i2c-core-base.c
drivers/i2c/i2c-core-smbus.c

index 7a01f2687b4cc716830b2a1753a142db6aa5d588..740066ceaea37598e60090d471af4d148e68bd1d 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/errno.h>
 #include <linux/i2c.h>
 #include <linux/i2c-algo-pcf.h>
+#include <linux/string_choices.h>
 #include "i2c-algo-pcf.h"
 
 
@@ -316,7 +317,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
                pmsg = &msgs[i];
 
                DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
-                    pmsg->flags & I2C_M_RD ? "read" : "write",
+                    str_read_write(pmsg->flags & I2C_M_RD),
                     pmsg->len, pmsg->addr, i + 1, num);)
 
                ret = pcf_doAddress(adap, pmsg);
index ee3b469ddfb98d64d2f40b30885b2836663f3262..374fc50bb205fb1b9baa9c052faacd281413bcdf 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/string_choices.h>
 
 #include "i2c-at91.h"
 
@@ -523,7 +524,7 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
         */
 
        dev_dbg(dev->dev, "transfer: %s %zu bytes.\n",
-               (dev->msg->flags & I2C_M_RD) ? "read" : "write", dev->buf_len);
+               str_read_write(dev->msg->flags & I2C_M_RD), dev->buf_len);
 
        reinit_completion(&dev->cmd_complete);
        dev->transfer_status = 0;
index efe29621b8d7c17995e8339af767dc6207d4134c..adfcee6c9fdccac0c0e576462302596646375200 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 
 /* Transmit operation:                                                      */
 /*                                                                          */
@@ -409,7 +410,7 @@ static irqreturn_t sh_mobile_i2c_isr(int irq, void *dev_id)
        pd->sr |= sr; /* remember state */
 
        dev_dbg(pd->dev, "i2c_isr 0x%02x 0x%02x %s %d %d!\n", sr, pd->sr,
-              (pd->msg->flags & I2C_M_RD) ? "read" : "write",
+              str_read_write(pd->msg->flags & I2C_M_RD),
               pd->pos, pd->msg->len);
 
        /* Kick off TxDMA after preface was done */
index 0f2ed181b2665ce9cc5f22d73007639bb358547d..a18eab0992a1ddc335cad808ca1e5beb8a3396a7 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 #include <linux/types.h>
 
 /* include interfaces to usb layer */
@@ -71,7 +72,7 @@ static int usb_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)
 
                dev_dbg(&adapter->dev,
                        "  %d: %s (flags %d) %d bytes to 0x%02x\n",
-                       i, pmsg->flags & I2C_M_RD ? "read" : "write",
+                       i, str_read_write(pmsg->flags & I2C_M_RD),
                        pmsg->flags, pmsg->len, pmsg->addr);
 
                /* and directly send the message */
index 7523e7c02271071e239e97575e6bbf4139bf3385..1bd602852e35c1d82f9476f7c837be8cb9a78ee4 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 #include <linux/types.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
@@ -278,7 +279,7 @@ static int vprbrd_i2c_xfer(struct i2c_adapter *i2c, struct i2c_msg *msgs,
 
                dev_dbg(&i2c->dev,
                        "  %d: %s (flags %d) %d bytes to 0x%02x\n",
-                       i, pmsg->flags & I2C_M_RD ? "read" : "write",
+                       i, str_read_write(pmsg->flags & I2C_M_RD),
                        pmsg->flags, pmsg->len, pmsg->addr);
 
                mutex_lock(&vb->lock);
index 5f6ff35a27071f2660a0c9ba413305a4b9b6c612..2ad2b1838f0f41c83362743c72a3c491f630f294 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/property.h>
 #include <linux/rwsem.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 
 #include "i2c-core.h"
 
@@ -2144,7 +2145,7 @@ static int i2c_quirk_error(struct i2c_adapter *adap, struct i2c_msg *msg, char *
 {
        dev_err_ratelimited(&adap->dev, "adapter quirk: %s (addr 0x%04x, size %u, %s)\n",
                            err_msg, msg->addr, msg->len,
-                           msg->flags & I2C_M_RD ? "read" : "write");
+                           str_read_write(msg->flags & I2C_M_RD));
        return -EOPNOTSUPP;
 }
 
index e73afbefe2225f9669cbc67168219a038c453245..71eb1ef56f0c34cda3e14472f988cf9db2ef9b0e 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/i2c-smbus.h>
 #include <linux/property.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 
 #include "i2c-core.h"
 
@@ -433,7 +434,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
        case I2C_SMBUS_I2C_BLOCK_DATA:
                if (data->block[0] > I2C_SMBUS_BLOCK_MAX) {
                        dev_err(&adapter->dev, "Invalid block %s size %d\n",
-                               read_write == I2C_SMBUS_READ ? "read" : "write",
+                               str_read_write(read_write == I2C_SMBUS_READ),
                                data->block[0]);
                        return -EINVAL;
                }