Skip to content

Commit 17b7d78

Browse files
Yumeng FangWolfram Sang
authored andcommitted
i2c: Use str_read_write() helper
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>
1 parent 9c7dcf4 commit 17b7d78

File tree

7 files changed

+14
-7
lines changed

7 files changed

+14
-7
lines changed

drivers/i2c/algos/i2c-algo-pcf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/errno.h>
2020
#include <linux/i2c.h>
2121
#include <linux/i2c-algo-pcf.h>
22+
#include <linux/string_choices.h>
2223
#include "i2c-algo-pcf.h"
2324

2425

@@ -316,7 +317,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
316317
pmsg = &msgs[i];
317318

318319
DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
319-
pmsg->flags & I2C_M_RD ? "read" : "write",
320+
str_read_write(pmsg->flags & I2C_M_RD),
320321
pmsg->len, pmsg->addr, i + 1, num);)
321322

322323
ret = pcf_doAddress(adap, pmsg);

drivers/i2c/busses/i2c-at91-master.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/pinctrl/consumer.h>
2727
#include <linux/platform_device.h>
2828
#include <linux/pm_runtime.h>
29+
#include <linux/string_choices.h>
2930

3031
#include "i2c-at91.h"
3132

@@ -523,7 +524,7 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
523524
*/
524525

525526
dev_dbg(dev->dev, "transfer: %s %zu bytes.\n",
526-
(dev->msg->flags & I2C_M_RD) ? "read" : "write", dev->buf_len);
527+
str_read_write(dev->msg->flags & I2C_M_RD), dev->buf_len);
527528

528529
reinit_completion(&dev->cmd_complete);
529530
dev->transfer_status = 0;

drivers/i2c/busses/i2c-sh_mobile.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/platform_device.h>
2525
#include <linux/pm_runtime.h>
2626
#include <linux/slab.h>
27+
#include <linux/string_choices.h>
2728

2829
/* Transmit operation: */
2930
/* */
@@ -409,7 +410,7 @@ static irqreturn_t sh_mobile_i2c_isr(int irq, void *dev_id)
409410
pd->sr |= sr; /* remember state */
410411

411412
dev_dbg(pd->dev, "i2c_isr 0x%02x 0x%02x %s %d %d!\n", sr, pd->sr,
412-
(pd->msg->flags & I2C_M_RD) ? "read" : "write",
413+
str_read_write(pd->msg->flags & I2C_M_RD),
413414
pd->pos, pd->msg->len);
414415

415416
/* Kick off TxDMA after preface was done */

drivers/i2c/busses/i2c-tiny-usb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/errno.h>
1111
#include <linux/module.h>
1212
#include <linux/slab.h>
13+
#include <linux/string_choices.h>
1314
#include <linux/types.h>
1415

1516
/* include interfaces to usb layer */
@@ -71,7 +72,7 @@ static int usb_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)
7172

7273
dev_dbg(&adapter->dev,
7374
" %d: %s (flags %d) %d bytes to 0x%02x\n",
74-
i, pmsg->flags & I2C_M_RD ? "read" : "write",
75+
i, str_read_write(pmsg->flags & I2C_M_RD),
7576
pmsg->flags, pmsg->len, pmsg->addr);
7677

7778
/* and directly send the message */

drivers/i2c/busses/i2c-viperboard.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/errno.h>
1212
#include <linux/module.h>
1313
#include <linux/slab.h>
14+
#include <linux/string_choices.h>
1415
#include <linux/types.h>
1516
#include <linux/mutex.h>
1617
#include <linux/platform_device.h>
@@ -278,7 +279,7 @@ static int vprbrd_i2c_xfer(struct i2c_adapter *i2c, struct i2c_msg *msgs,
278279

279280
dev_dbg(&i2c->dev,
280281
" %d: %s (flags %d) %d bytes to 0x%02x\n",
281-
i, pmsg->flags & I2C_M_RD ? "read" : "write",
282+
i, str_read_write(pmsg->flags & I2C_M_RD),
282283
pmsg->flags, pmsg->len, pmsg->addr);
283284

284285
mutex_lock(&vb->lock);

drivers/i2c/i2c-core-base.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <linux/property.h>
4242
#include <linux/rwsem.h>
4343
#include <linux/slab.h>
44+
#include <linux/string_choices.h>
4445

4546
#include "i2c-core.h"
4647

@@ -2144,7 +2145,7 @@ static int i2c_quirk_error(struct i2c_adapter *adap, struct i2c_msg *msg, char *
21442145
{
21452146
dev_err_ratelimited(&adap->dev, "adapter quirk: %s (addr 0x%04x, size %u, %s)\n",
21462147
err_msg, msg->addr, msg->len,
2147-
msg->flags & I2C_M_RD ? "read" : "write");
2148+
str_read_write(msg->flags & I2C_M_RD));
21482149
return -EOPNOTSUPP;
21492150
}
21502151

drivers/i2c/i2c-core-smbus.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/i2c-smbus.h>
1717
#include <linux/property.h>
1818
#include <linux/slab.h>
19+
#include <linux/string_choices.h>
1920

2021
#include "i2c-core.h"
2122

@@ -433,7 +434,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
433434
case I2C_SMBUS_I2C_BLOCK_DATA:
434435
if (data->block[0] > I2C_SMBUS_BLOCK_MAX) {
435436
dev_err(&adapter->dev, "Invalid block %s size %d\n",
436-
read_write == I2C_SMBUS_READ ? "read" : "write",
437+
str_read_write(read_write == I2C_SMBUS_READ),
437438
data->block[0]);
438439
return -EINVAL;
439440
}

0 commit comments

Comments
 (0)