* [PATCH 0/6] media: Use str_enable_disable-like helpers
@ 2025-01-14 19:46 Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 1/6] " Krzysztof Kozlowski
` (5 more replies)
0 siblings, 6 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-14 19:46 UTC (permalink / raw)
To: Hans Verkuil, Mauro Carvalho Chehab, Tomasz Figa,
Marek Szyprowski, Maxim Levitsky, Sean Young, Olli Salonen,
Abylay Ospan, Jemma Denson, Patrick Boettcher, Jacopo Mondi,
Kieran Bingham, Laurent Pinchart, Niklas Söderlund,
Tim Harvey, Andy Walls, Sakari Ailus, Bingbu Cao
Cc: linux-media, linux-kernel, Krzysztof Kozlowski
Simple refactoring to replace ternary operator for string pairs like
"enable/disable".
Best regards,
Krzysztof
---
Krzysztof Kozlowski (6):
media: Use str_enable_disable-like helpers
media: dvb: Use str_enable_disable-like helpers
media: i2c: Use str_enable_disable-like helpers
media: pci: Use str_enable_disable-like helpers
media: platform: Use str_enable_disable-like helpers
media: usb: Use str_enable_disable-like helpers
drivers/media/cec/platform/cec-gpio/cec-gpio.c | 5 ++-
drivers/media/cec/usb/pulse8/pulse8-cec.c | 5 ++-
drivers/media/common/b2c2/flexcop-hw-filter.c | 5 ++-
drivers/media/common/siano/sms-cards.c | 3 +-
drivers/media/common/videobuf2/videobuf2-core.c | 6 ++-
drivers/media/dvb-frontends/ascot2e.c | 3 +-
drivers/media/dvb-frontends/cx24120.c | 5 ++-
drivers/media/dvb-frontends/cxd2841er.c | 3 +-
drivers/media/dvb-frontends/drxk_hard.c | 5 ++-
drivers/media/dvb-frontends/helene.c | 3 +-
drivers/media/dvb-frontends/horus3a.c | 3 +-
drivers/media/dvb-frontends/sp2.c | 3 +-
drivers/media/i2c/adv7511-v4l2.c | 10 ++---
drivers/media/i2c/adv7604.c | 43 ++++++++++----------
drivers/media/i2c/adv7842.c | 46 ++++++++++------------
drivers/media/i2c/cx25840/cx25840-core.c | 5 ++-
drivers/media/i2c/cx25840/cx25840-ir.c | 35 ++++++++--------
drivers/media/i2c/max9286.c | 3 +-
drivers/media/i2c/msp3400-driver.c | 5 ++-
drivers/media/i2c/saa7110.c | 3 +-
drivers/media/i2c/saa7115.c | 4 +-
drivers/media/i2c/saa7127.c | 13 +++---
drivers/media/i2c/saa717x.c | 3 +-
drivers/media/i2c/tc358743.c | 43 +++++++++-----------
drivers/media/i2c/tda1997x.c | 7 ++--
drivers/media/i2c/ths7303.c | 3 +-
drivers/media/i2c/ths8200.c | 9 +++--
drivers/media/i2c/tvp7002.c | 4 +-
drivers/media/i2c/vpx3220.c | 3 +-
drivers/media/pci/bt8xx/bttv-cards.c | 17 ++++----
drivers/media/pci/bt8xx/bttv-driver.c | 7 ++--
drivers/media/pci/cobalt/cobalt-driver.c | 3 +-
drivers/media/pci/cx18/cx18-av-core.c | 5 ++-
drivers/media/pci/cx23885/altera-ci.c | 3 +-
drivers/media/pci/cx23885/cimax2.c | 3 +-
drivers/media/pci/cx23885/cx23888-ir.c | 37 ++++++++---------
drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c | 3 +-
drivers/media/pci/ivtv/ivtv-ioctl.c | 3 +-
drivers/media/pci/saa7134/saa7134-cards.c | 4 +-
drivers/media/pci/saa7134/saa7134-dvb.c | 3 +-
drivers/media/pci/saa7134/saa7134-input.c | 7 ++--
drivers/media/pci/saa7134/saa7134-video.c | 3 +-
drivers/media/platform/amphion/venc.c | 3 +-
drivers/media/platform/amphion/vpu_dbg.c | 3 +-
drivers/media/platform/aspeed/aspeed-video.c | 5 ++-
drivers/media/platform/chips-media/coda/coda-bit.c | 3 +-
drivers/media/platform/chips-media/coda/imx-vdoa.c | 3 +-
drivers/media/platform/st/sti/hva/hva-debugfs.c | 7 ++--
drivers/media/platform/ti/cal/cal-camerarx.c | 3 +-
drivers/media/platform/ti/omap3isp/ispstat.c | 3 +-
drivers/media/platform/xilinx/xilinx-csi2rxss.c | 19 ++++-----
drivers/media/rc/ene_ir.c | 3 +-
drivers/media/rc/mceusb.c | 3 +-
drivers/media/rc/serial_ir.c | 5 ++-
drivers/media/tuners/tda18250.c | 3 +-
drivers/media/tuners/tda9887.c | 11 +++---
drivers/media/usb/cx231xx/cx231xx-i2c.c | 5 ++-
drivers/media/usb/cx231xx/cx231xx-video.c | 5 ++-
drivers/media/usb/dvb-usb-v2/az6007.c | 5 ++-
drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 5 ++-
drivers/media/usb/dvb-usb/af9005-fe.c | 5 ++-
drivers/media/usb/dvb-usb/dvb-usb-dvb.c | 7 ++--
drivers/media/usb/dvb-usb/opera1.c | 9 +++--
drivers/media/usb/em28xx/em28xx-i2c.c | 5 ++-
drivers/media/usb/em28xx/em28xx-video.c | 5 ++-
drivers/media/usb/pvrusb2/pvrusb2-ctrl.c | 3 +-
drivers/media/usb/pvrusb2/pvrusb2-debugifc.c | 3 +-
drivers/media/usb/pvrusb2/pvrusb2-encoder.c | 6 +--
drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 7 ++--
drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c | 4 +-
70 files changed, 291 insertions(+), 243 deletions(-)
---
base-commit: e2911fda9771c7af657331e8073b112bdb56f0f7
change-id: 20250114-str-enable-disable-media-da9eb4e0dfef
Best regards,
--
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/6] media: Use str_enable_disable-like helpers
2025-01-14 19:46 [PATCH 0/6] media: Use str_enable_disable-like helpers Krzysztof Kozlowski
@ 2025-01-14 19:46 ` Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 2/6] media: dvb: " Krzysztof Kozlowski
` (4 subsequent siblings)
5 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-14 19:46 UTC (permalink / raw)
To: Hans Verkuil, Mauro Carvalho Chehab, Tomasz Figa,
Marek Szyprowski, Maxim Levitsky, Sean Young, Olli Salonen,
Abylay Ospan, Jemma Denson, Patrick Boettcher, Jacopo Mondi,
Kieran Bingham, Laurent Pinchart, Niklas Söderlund,
Tim Harvey, Andy Walls, Sakari Ailus, Bingbu Cao
Cc: linux-media, linux-kernel, Krzysztof Kozlowski
Replace ternary (condition ? "enable" : "disable") syntax with helpers
from string_choices.h because:
1. Simple function call with one argument is easier to read. Ternary
operator has three arguments and with wrapping might lead to quite
long code.
2. Is slightly shorter thus also easier to read.
3. It brings uniformity in the text - same string.
4. Allows deduping by the linker, which results in a smaller binary
file.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/media/cec/platform/cec-gpio/cec-gpio.c | 5 +++--
drivers/media/cec/usb/pulse8/pulse8-cec.c | 5 +++--
drivers/media/common/b2c2/flexcop-hw-filter.c | 5 +++--
drivers/media/common/siano/sms-cards.c | 3 ++-
drivers/media/common/videobuf2/videobuf2-core.c | 6 ++++--
drivers/media/rc/ene_ir.c | 3 ++-
drivers/media/rc/mceusb.c | 3 ++-
drivers/media/rc/serial_ir.c | 5 +++--
drivers/media/tuners/tda18250.c | 3 ++-
drivers/media/tuners/tda9887.c | 11 ++++++-----
10 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/drivers/media/cec/platform/cec-gpio/cec-gpio.c b/drivers/media/cec/platform/cec-gpio/cec-gpio.c
index 50cdc557c9430a2625ae615a1f469d2b2b02e6be..c75c48c07b7fb42254ba82abaab5f3602ef6cd97 100644
--- a/drivers/media/cec/platform/cec-gpio/cec-gpio.c
+++ b/drivers/media/cec/platform/cec-gpio/cec-gpio.c
@@ -9,6 +9,7 @@
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/seq_file.h>
+#include <linux/string_choices.h>
#include <media/cec-notifier.h>
#include <media/cec-pin.h>
@@ -136,10 +137,10 @@ static void cec_gpio_status(struct cec_adapter *adap, struct seq_file *file)
seq_printf(file, "using irq: %d\n", cec->cec_irq);
if (cec->hpd_gpio)
seq_printf(file, "hpd: %s\n",
- cec->hpd_is_high ? "high" : "low");
+ str_high_low(cec->hpd_is_high));
if (cec->v5_gpio)
seq_printf(file, "5V: %s\n",
- cec->v5_is_high ? "high" : "low");
+ str_high_low(cec->v5_is_high));
}
static int cec_gpio_read_hpd(struct cec_adapter *adap)
diff --git a/drivers/media/cec/usb/pulse8/pulse8-cec.c b/drivers/media/cec/usb/pulse8/pulse8-cec.c
index 171366fe35443b19f4791ffada46c83ed5e4fe06..c0b48b526cd7c86d046386184a036fbadde51306 100644
--- a/drivers/media/cec/usb/pulse8/pulse8-cec.c
+++ b/drivers/media/cec/usb/pulse8/pulse8-cec.c
@@ -36,6 +36,7 @@
#include <linux/workqueue.h>
#include <linux/serio.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <linux/time.h>
#include <linux/delay.h>
@@ -695,14 +696,14 @@ static int pulse8_setup(struct pulse8 *pulse8, struct serio *serio,
return err;
pulse8->autonomous = data[0];
dev_dbg(pulse8->dev, "Autonomous mode: %s",
- data[0] ? "on" : "off");
+ str_on_off(data[0]));
if (pulse8->vers >= 10) {
cmd[0] = MSGCODE_GET_AUTO_POWER_ON;
err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 1);
if (!err)
dev_dbg(pulse8->dev, "Auto Power On: %s",
- data[0] ? "on" : "off");
+ str_on_off(data[0]));
}
cmd[0] = MSGCODE_GET_DEVICE_TYPE;
diff --git a/drivers/media/common/b2c2/flexcop-hw-filter.c b/drivers/media/common/b2c2/flexcop-hw-filter.c
index c5a3345c99e9ee4b39dfe453eeaa5f59eae93cfa..f0969af79311181404811857bf209a45b9014cd5 100644
--- a/drivers/media/common/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/common/b2c2/flexcop-hw-filter.c
@@ -5,11 +5,12 @@
* see flexcop.c for copyright information
*/
#include "flexcop.h"
+#include <linux/string_choices.h>
static void flexcop_rcv_data_ctrl(struct flexcop_device *fc, int onoff)
{
flexcop_set_ibi_value(ctrl_208, Rcv_Data_sig, onoff);
- deb_ts("rcv_data is now: '%s'\n", onoff ? "on" : "off");
+ deb_ts("rcv_data is now: '%s'\n", str_on_off(onoff));
}
void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff)
@@ -116,7 +117,7 @@ static void flexcop_pid_control(struct flexcop_device *fc,
return;
deb_ts("setting pid: %5d %04x at index %d '%s'\n",
- pid, pid, index, onoff ? "on" : "off");
+ pid, pid, index, str_on_off(onoff));
/* First 6 can be buggy - skip over them if option set */
if (fc->skip_6_hw_pid_filter)
diff --git a/drivers/media/common/siano/sms-cards.c b/drivers/media/common/siano/sms-cards.c
index d4a116ab6c888609800aeedf9a6c4e268205f3a3..e9aa95233ff178c126cc1e621ab2e096637cb27c 100644
--- a/drivers/media/common/siano/sms-cards.c
+++ b/drivers/media/common/siano/sms-cards.c
@@ -8,6 +8,7 @@
#include "sms-cards.h"
#include "smsir.h"
#include <linux/module.h>
+#include <linux/string_choices.h>
static struct sms_board sms_boards[] = {
[SMS_BOARD_UNKNOWN] = {
@@ -326,7 +327,7 @@ int sms_board_lna_control(struct smscore_device_t *coredev, int onoff)
int board_id = smscore_get_board_id(coredev);
struct sms_board *board = sms_get_board(board_id);
- pr_debug("%s: LNA %s\n", __func__, onoff ? "enabled" : "disabled");
+ pr_debug("%s: LNA %s\n", __func__, str_enabled_disabled(onoff));
switch (board_id) {
case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index 2df566f409b65eb99fa7fbe308b8e3afe1bdcbca..19fa5c133c28db9c3766aded8e123a621a34ff88 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -23,6 +23,7 @@
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/sched.h>
+#include <linux/string_choices.h>
#include <linux/freezer.h>
#include <linux/kthread.h>
@@ -2874,7 +2875,8 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
return -EBUSY;
dprintk(q, 3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n",
- (read) ? "read" : "write", q->min_reqbufs_allocation, q->fileio_read_once,
+ str_read_write(read), q->min_reqbufs_allocation,
+ q->fileio_read_once,
q->fileio_write_immediately);
fileio = kzalloc(sizeof(*fileio), GFP_KERNEL);
@@ -3022,7 +3024,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
int ret;
dprintk(q, 3, "mode %s, offset %ld, count %zd, %sblocking\n",
- read ? "read" : "write", (long)*ppos, count,
+ str_read_write(read), (long)*ppos, count,
nonblock ? "non" : "");
if (!data)
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index 67722e2e47ff78e504c55054480f0619e050f093..90bee860a8a13dda52e1efebfa42a30a26fb93fe 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -24,6 +24,7 @@
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <media/rc-core.h>
#include "ene_ir.h"
@@ -1118,7 +1119,7 @@ static void ene_remove(struct pnp_dev *pnp_dev)
/* enable wake on IR (wakes on specific button on original remote) */
static void ene_enable_wake(struct ene_device *dev, bool enable)
{
- dbg("wake on IR %s", enable ? "enabled" : "disabled");
+ dbg("wake on IR %s", str_enabled_disabled(enable));
ene_set_clear_reg_mask(dev, ENE_FW1, ENE_FW1_WAKE, enable);
}
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 044767eb3a38c9354bdf4185bfb16521ddfceb91..fcf9e1559aea8b890e33ae6c9cdd951642ccdd44 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -25,6 +25,7 @@
#include <linux/device.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <linux/workqueue.h>
#include <linux/usb.h>
#include <linux/usb/input.h>
@@ -1126,7 +1127,7 @@ static int mceusb_set_rx_carrier_report(struct rc_dev *dev, int enable)
MCE_CMD_SETIRRXPORTEN, 0x00 };
dev_dbg(ir->dev, "%s short-range receiver carrier reporting",
- enable ? "enable" : "disable");
+ str_enable_disable(enable));
if (enable) {
ir->carrier_report_enabled = true;
if (!ir->learning_active) {
diff --git a/drivers/media/rc/serial_ir.c b/drivers/media/rc/serial_ir.c
index fc5fd39271772013c78c466a5c322b4a04ec8d69..f9ec2f043529cbed1e3f4dfd805c3d27919954d4 100644
--- a/drivers/media/rc/serial_ir.c
+++ b/drivers/media/rc/serial_ir.c
@@ -25,6 +25,7 @@
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>
+#include <linux/string_choices.h>
#include <media/rc-core.h>
struct serial_ir_hw {
@@ -588,10 +589,10 @@ static int serial_ir_probe(struct platform_device *dev)
}
sense = nlow >= nhigh ? 1 : 0;
dev_info(&dev->dev, "auto-detected active %s receiver\n",
- sense ? "low" : "high");
+ str_low_high(sense));
} else
dev_info(&dev->dev, "Manually using active %s receiver\n",
- sense ? "low" : "high");
+ str_low_high(sense));
dev_dbg(&dev->dev, "Interrupt %d, port %04x obtained\n", irq, io);
diff --git a/drivers/media/tuners/tda18250.c b/drivers/media/tuners/tda18250.c
index 68d0275f29e1b789ca1687283996c43ea3bacafc..1cfc0e3bfab455faee1da44de0ac5a473c68edc5 100644
--- a/drivers/media/tuners/tda18250.c
+++ b/drivers/media/tuners/tda18250.c
@@ -7,6 +7,7 @@
#include "tda18250_priv.h"
#include <linux/regmap.h>
+#include <linux/string_choices.h>
static const struct dvb_tuner_ops tda18250_ops;
@@ -107,7 +108,7 @@ static int tda18250_wait_for_irq(struct dvb_frontend *fe,
dev_dbg(&client->dev, "waited IRQ (0x%02x) %d ms, triggered: %s", irq,
jiffies_to_msecs(jiffies) -
(jiffies_to_msecs(timeout) - maxwait),
- triggered ? "true" : "false");
+ str_true_false(triggered));
if (!triggered)
return -ETIMEDOUT;
diff --git a/drivers/media/tuners/tda9887.c b/drivers/media/tuners/tda9887.c
index b2f7054c1832cef3610f38f2ff1421b01e7892c7..d1f9ef30782b5244083a1345def8cb8c2f343f44 100644
--- a/drivers/media/tuners/tda9887.c
+++ b/drivers/media/tuners/tda9887.c
@@ -6,6 +6,7 @@
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/delay.h>
+#include <linux/string_choices.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
#include <media/tuner.h>
@@ -291,11 +292,11 @@ static void dump_read_message(struct dvb_frontend *fe, unsigned char *buf)
"+ 12.5 kHz",
};
tuner_info("read: 0x%2x\n", buf[0]);
- tuner_info(" after power on : %s\n", (buf[0] & 0x01) ? "yes" : "no");
+ tuner_info(" after power on : %s\n", str_yes_no(buf[0] & 0x01));
tuner_info(" afc : %s\n", afc[(buf[0] >> 1) & 0x0f]);
- tuner_info(" fmif level : %s\n", (buf[0] & 0x20) ? "high" : "low");
+ tuner_info(" fmif level : %s\n", str_high_low(buf[0] & 0x20));
tuner_info(" afc window : %s\n", (buf[0] & 0x40) ? "in" : "out");
- tuner_info(" vfi level : %s\n", (buf[0] & 0x80) ? "high" : "low");
+ tuner_info(" vfi level : %s\n", str_high_low(buf[0] & 0x80));
}
static void dump_write_message(struct dvb_frontend *fe, unsigned char *buf)
@@ -344,13 +345,13 @@ static void dump_write_message(struct dvb_frontend *fe, unsigned char *buf)
tuner_info(" B0 video mode : %s\n",
(buf[1] & 0x01) ? "video trap" : "sound trap");
tuner_info(" B1 auto mute fm : %s\n",
- (buf[1] & 0x02) ? "yes" : "no");
+ str_yes_no(buf[1] & 0x02));
tuner_info(" B2 carrier mode : %s\n",
(buf[1] & 0x04) ? "QSS" : "Intercarrier");
tuner_info(" B3-4 tv sound/radio : %s\n",
sound[(buf[1] & 0x18) >> 3]);
tuner_info(" B5 force mute audio: %s\n",
- (buf[1] & 0x20) ? "yes" : "no");
+ str_yes_no(buf[1] & 0x20));
tuner_info(" B6 output port 1 : %s\n",
(buf[1] & 0x40) ? "high (inactive)" : "low (active)");
tuner_info(" B7 output port 2 : %s\n",
--
2.43.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/6] media: dvb: Use str_enable_disable-like helpers
2025-01-14 19:46 [PATCH 0/6] media: Use str_enable_disable-like helpers Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 1/6] " Krzysztof Kozlowski
@ 2025-01-14 19:46 ` Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 3/6] media: i2c: " Krzysztof Kozlowski
` (3 subsequent siblings)
5 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-14 19:46 UTC (permalink / raw)
To: Hans Verkuil, Mauro Carvalho Chehab, Tomasz Figa,
Marek Szyprowski, Maxim Levitsky, Sean Young, Olli Salonen,
Abylay Ospan, Jemma Denson, Patrick Boettcher, Jacopo Mondi,
Kieran Bingham, Laurent Pinchart, Niklas Söderlund,
Tim Harvey, Andy Walls, Sakari Ailus, Bingbu Cao
Cc: linux-media, linux-kernel, Krzysztof Kozlowski
Replace ternary (condition ? "enable" : "disable") syntax with helpers
from string_choices.h because:
1. Simple function call with one argument is easier to read. Ternary
operator has three arguments and with wrapping might lead to quite
long code.
2. Is slightly shorter thus also easier to read.
3. It brings uniformity in the text - same string.
4. Allows deduping by the linker, which results in a smaller binary
file.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/media/dvb-frontends/ascot2e.c | 3 ++-
drivers/media/dvb-frontends/cx24120.c | 5 +++--
drivers/media/dvb-frontends/cxd2841er.c | 3 ++-
drivers/media/dvb-frontends/drxk_hard.c | 5 +++--
drivers/media/dvb-frontends/helene.c | 3 ++-
drivers/media/dvb-frontends/horus3a.c | 3 ++-
drivers/media/dvb-frontends/sp2.c | 3 ++-
7 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/drivers/media/dvb-frontends/ascot2e.c b/drivers/media/dvb-frontends/ascot2e.c
index cf8e5f1bd10181a65376660bfa4648c0e536fd25..15a33dac3af95dbd6368b83eff7c49f5ae3187ed 100644
--- a/drivers/media/dvb-frontends/ascot2e.c
+++ b/drivers/media/dvb-frontends/ascot2e.c
@@ -13,6 +13,7 @@
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/dvb/frontend.h>
+#include <linux/string_choices.h>
#include <linux/types.h>
#include "ascot2e.h"
#include <media/dvb_frontend.h>
@@ -104,7 +105,7 @@ static void ascot2e_i2c_debug(struct ascot2e_priv *priv,
u8 reg, u8 write, const u8 *data, u32 len)
{
dev_dbg(&priv->i2c->dev, "ascot2e: I2C %s reg 0x%02x size %d\n",
- (write == 0 ? "read" : "write"), reg, len);
+ str_read_write(write == 0), reg, len);
print_hex_dump_bytes("ascot2e: I2C data: ",
DUMP_PREFIX_OFFSET, data, len);
}
diff --git a/drivers/media/dvb-frontends/cx24120.c b/drivers/media/dvb-frontends/cx24120.c
index 44515fdbe91d4f5eb23fb13dfc571507255655cb..2e4097a6043d05938c192a404099615cec5c8edb 100644
--- a/drivers/media/dvb-frontends/cx24120.c
+++ b/drivers/media/dvb-frontends/cx24120.c
@@ -21,6 +21,7 @@
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/firmware.h>
+#include <linux/string_choices.h>
#include <media/dvb_frontend.h>
#include "cx24120.h"
@@ -453,13 +454,13 @@ static int cx24120_msg_mpeg_output_global_config(struct cx24120_state *state,
ret = cx24120_message_send(state, &cmd);
if (ret != 0) {
dev_dbg(&state->i2c->dev, "failed to %s MPEG output\n",
- enable ? "enable" : "disable");
+ str_enable_disable(enable));
return ret;
}
state->mpeg_enabled = enable;
dev_dbg(&state->i2c->dev, "MPEG output %s\n",
- enable ? "enabled" : "disabled");
+ str_enabled_disabled(enable));
return 0;
}
diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c
index 415f1f91cc30724a77b6bb417e33f25aacf5a909..a4ec529b5ba547e866b9694527af0dad171eb318 100644
--- a/drivers/media/dvb-frontends/cxd2841er.c
+++ b/drivers/media/dvb-frontends/cxd2841er.c
@@ -15,6 +15,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/string.h>
+#include <linux/string_choices.h>
#include <linux/slab.h>
#include <linux/bitops.h>
#include <linux/math64.h>
@@ -206,7 +207,7 @@ static void cxd2841er_i2c_debug(struct cxd2841er_priv *priv,
{
dev_dbg(&priv->i2c->dev,
"cxd2841er: I2C %s addr %02x reg 0x%02x size %d data %*ph\n",
- (write == 0 ? "read" : "write"), addr, reg, len, len, data);
+ str_read_write(write == 0), addr, reg, len, len, data);
}
static int cxd2841er_write_regs(struct cxd2841er_priv *priv,
diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index 87f3d4f0eb8c484ddee4104162679ddeb88f6d73..b7d93119dcaa60eb4f774b77d53163da368fab13 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -15,6 +15,7 @@
#include <linux/firmware.h>
#include <linux/i2c.h>
#include <linux/hardirq.h>
+#include <linux/string_choices.h>
#include <asm/div64.h>
#include <media/dvb_frontend.h>
@@ -1068,7 +1069,7 @@ static int mpegts_configure_pins(struct drxk_state *state, bool mpeg_enable)
u16 err_cfg = 0;
dprintk(1, ": mpeg %s, %s mode\n",
- mpeg_enable ? "enable" : "disable",
+ str_enable_disable(mpeg_enable),
state->m_enable_parallel ? "parallel" : "serial");
/* stop lock indicator process */
@@ -6279,7 +6280,7 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
{
struct drxk_state *state = fe->demodulator_priv;
- dprintk(1, ": %s\n", enable ? "enable" : "disable");
+ dprintk(1, ": %s\n", str_enable_disable(enable));
if (state->m_drxk_state == DRXK_NO_DEV)
return -ENODEV;
diff --git a/drivers/media/dvb-frontends/helene.c b/drivers/media/dvb-frontends/helene.c
index f127adee3ebb7d041f0b85607a49aa1ec45b53e2..ae2a696a777050b6b0849481f9262893e34e7061 100644
--- a/drivers/media/dvb-frontends/helene.c
+++ b/drivers/media/dvb-frontends/helene.c
@@ -12,6 +12,7 @@
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/dvb/frontend.h>
+#include <linux/string_choices.h>
#include <linux/types.h>
#include "helene.h"
#include <media/dvb_frontend.h>
@@ -279,7 +280,7 @@ static void helene_i2c_debug(struct helene_priv *priv,
u8 reg, u8 write, const u8 *data, u32 len)
{
dev_dbg(&priv->i2c->dev, "helene: I2C %s reg 0x%02x size %d\n",
- (write == 0 ? "read" : "write"), reg, len);
+ str_read_write(write == 0), reg, len);
print_hex_dump_bytes("helene: I2C data: ",
DUMP_PREFIX_OFFSET, data, len);
}
diff --git a/drivers/media/dvb-frontends/horus3a.c b/drivers/media/dvb-frontends/horus3a.c
index 0330b78a5b3f29a88e65dcc228a6f09a2125434a..0c3280d4f4989ad37970107712884c3dece55ee7 100644
--- a/drivers/media/dvb-frontends/horus3a.c
+++ b/drivers/media/dvb-frontends/horus3a.c
@@ -13,6 +13,7 @@
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/dvb/frontend.h>
+#include <linux/string_choices.h>
#include <linux/types.h>
#include "horus3a.h"
#include <media/dvb_frontend.h>
@@ -38,7 +39,7 @@ static void horus3a_i2c_debug(struct horus3a_priv *priv,
u8 reg, u8 write, const u8 *data, u32 len)
{
dev_dbg(&priv->i2c->dev, "horus3a: I2C %s reg 0x%02x size %d\n",
- (write == 0 ? "read" : "write"), reg, len);
+ str_read_write(write == 0), reg, len);
print_hex_dump_bytes("horus3a: I2C data: ",
DUMP_PREFIX_OFFSET, data, len);
}
diff --git a/drivers/media/dvb-frontends/sp2.c b/drivers/media/dvb-frontends/sp2.c
index 75adf2a4589fd058d8c07621c9ae00d64177c3c1..2865d52a88a1e9b949dcca1c6ba3dd8803cc9bf7 100644
--- a/drivers/media/dvb-frontends/sp2.c
+++ b/drivers/media/dvb-frontends/sp2.c
@@ -12,6 +12,7 @@
* Copyright (C) 2009 Abylay Ospan <aospan@netup.ru>
*/
+#include <linux/string_choices.h>
#include "sp2_priv.h"
static int sp2_read_i2c(struct sp2 *s, u8 reg, u8 *buf, int len)
@@ -132,7 +133,7 @@ static int sp2_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot, u8 acs,
return ret;
dev_dbg(&s->client->dev, "%s: slot=%d, addr=0x%04x, %s, data=%x",
- (read) ? "read" : "write", slot, addr,
+ str_read_write(read), slot, addr,
(acs == SP2_CI_ATTR_ACS) ? "attr" : "io",
(read) ? mem : data);
--
2.43.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/6] media: i2c: Use str_enable_disable-like helpers
2025-01-14 19:46 [PATCH 0/6] media: Use str_enable_disable-like helpers Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 1/6] " Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 2/6] media: dvb: " Krzysztof Kozlowski
@ 2025-01-14 19:46 ` Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 4/6] media: pci: " Krzysztof Kozlowski
` (2 subsequent siblings)
5 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-14 19:46 UTC (permalink / raw)
To: Hans Verkuil, Mauro Carvalho Chehab, Tomasz Figa,
Marek Szyprowski, Maxim Levitsky, Sean Young, Olli Salonen,
Abylay Ospan, Jemma Denson, Patrick Boettcher, Jacopo Mondi,
Kieran Bingham, Laurent Pinchart, Niklas Söderlund,
Tim Harvey, Andy Walls, Sakari Ailus, Bingbu Cao
Cc: linux-media, linux-kernel, Krzysztof Kozlowski
Replace ternary (condition ? "enable" : "disable") syntax with helpers
from string_choices.h because:
1. Simple function call with one argument is easier to read. Ternary
operator has three arguments and with wrapping might lead to quite
long code.
2. Is slightly shorter thus also easier to read.
3. It brings uniformity in the text - same string.
4. Allows deduping by the linker, which results in a smaller binary
file.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/media/i2c/adv7511-v4l2.c | 10 +++----
drivers/media/i2c/adv7604.c | 43 +++++++++++++++--------------
drivers/media/i2c/adv7842.c | 46 +++++++++++++++-----------------
drivers/media/i2c/cx25840/cx25840-core.c | 5 ++--
drivers/media/i2c/cx25840/cx25840-ir.c | 35 ++++++++++++------------
drivers/media/i2c/max9286.c | 3 ++-
drivers/media/i2c/msp3400-driver.c | 5 ++--
drivers/media/i2c/saa7110.c | 3 ++-
drivers/media/i2c/saa7115.c | 4 +--
drivers/media/i2c/saa7127.c | 13 ++++-----
drivers/media/i2c/saa717x.c | 3 ++-
drivers/media/i2c/tc358743.c | 43 +++++++++++++----------------
drivers/media/i2c/tda1997x.c | 7 ++---
drivers/media/i2c/ths7303.c | 3 ++-
drivers/media/i2c/ths8200.c | 9 ++++---
drivers/media/i2c/tvp7002.c | 4 +--
drivers/media/i2c/vpx3220.c | 3 ++-
17 files changed, 119 insertions(+), 120 deletions(-)
diff --git a/drivers/media/i2c/adv7511-v4l2.c b/drivers/media/i2c/adv7511-v4l2.c
index 4036972af3a6628b72de0c770b13ba829742ff2f..3589a99d1ad7b859c9b3ef59891b02ed732a1081 100644
--- a/drivers/media/i2c/adv7511-v4l2.c
+++ b/drivers/media/i2c/adv7511-v4l2.c
@@ -16,6 +16,7 @@
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/delay.h>
+#include <linux/string_choices.h>
#include <linux/videodev2.h>
#include <linux/workqueue.h>
#include <linux/hdmi.h>
@@ -583,7 +584,7 @@ static int adv7511_log_status(struct v4l2_subdev *sd)
"9", "A", "B", "C", "D", "E", "F"
};
- v4l2_info(sd, "power %s\n", state->power_on ? "on" : "off");
+ v4l2_info(sd, "power %s\n", str_on_off(state->power_on));
v4l2_info(sd, "%s hotplug, %s Rx Sense, %s EDID (%d block(s))\n",
(adv7511_rd(sd, 0x42) & MASK_ADV7511_HPD_DETECT) ? "detected" : "no",
(adv7511_rd(sd, 0x42) & MASK_ADV7511_MSEN_DETECT) ? "detected" : "no",
@@ -635,8 +636,7 @@ static int adv7511_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "i2c cec addr: 0x%x\n", state->i2c_cec_addr);
- v4l2_info(sd, "CEC: %s\n", state->cec_enabled_adap ?
- "enabled" : "disabled");
+ v4l2_info(sd, "CEC: %s\n", str_enabled_disabled(state->cec_enabled_adap));
if (state->cec_enabled_adap) {
for (i = 0; i < ADV7511_MAX_ADDRS; i++) {
bool is_valid = state->cec_valid_addrs & (1 << i);
@@ -657,7 +657,7 @@ static int adv7511_s_power(struct v4l2_subdev *sd, int on)
const int retries = 20;
int i;
- v4l2_dbg(1, debug, sd, "%s: power %s\n", __func__, on ? "on" : "off");
+ v4l2_dbg(1, debug, sd, "%s: power %s\n", __func__, str_on_off(on));
state->power_on = on;
@@ -888,7 +888,7 @@ static void adv7511_set_isr(struct v4l2_subdev *sd, bool enable)
u8 irqs_rd;
int retries = 100;
- v4l2_dbg(2, debug, sd, "%s: %s\n", __func__, enable ? "enable" : "disable");
+ v4l2_dbg(2, debug, sd, "%s: %s\n", __func__, str_enable_disable(enable));
if (state->enabled_irq == enable)
return;
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index e271782b7b70bd15beff57aa5436d453e4d8ebab..87709bba78948915635e2fa85c7b27f72045e7fb 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -23,6 +23,7 @@
#include <linux/module.h>
#include <linux/of_graph.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <linux/v4l2-dv-timings.h>
#include <linux/videodev2.h>
#include <linux/workqueue.h>
@@ -2563,15 +2564,14 @@ static int adv76xx_log_status(struct v4l2_subdev *sd)
};
v4l2_info(sd, "-----Chip status-----\n");
- v4l2_info(sd, "Chip power: %s\n", no_power(sd) ? "off" : "on");
+ v4l2_info(sd, "Chip power: %s\n", str_off_on(no_power(sd)));
edid_enabled = rep_read(sd, info->edid_status_reg);
v4l2_info(sd, "EDID enabled port A: %s, B: %s, C: %s, D: %s\n",
- ((edid_enabled & 0x01) ? "Yes" : "No"),
- ((edid_enabled & 0x02) ? "Yes" : "No"),
- ((edid_enabled & 0x04) ? "Yes" : "No"),
- ((edid_enabled & 0x08) ? "Yes" : "No"));
- v4l2_info(sd, "CEC: %s\n", state->cec_enabled_adap ?
- "enabled" : "disabled");
+ str_yes_no(edid_enabled & 0x01),
+ str_yes_no(edid_enabled & 0x02),
+ str_yes_no(edid_enabled & 0x04),
+ str_yes_no(edid_enabled & 0x08));
+ v4l2_info(sd, "CEC: %s\n", str_enabled_disabled(state->cec_enabled_adap));
if (state->cec_enabled_adap) {
int i;
@@ -2587,19 +2587,18 @@ static int adv76xx_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "-----Signal status-----\n");
cable_det = info->read_cable_det(sd);
v4l2_info(sd, "Cable detected (+5V power) port A: %s, B: %s, C: %s, D: %s\n",
- ((cable_det & 0x01) ? "Yes" : "No"),
- ((cable_det & 0x02) ? "Yes" : "No"),
- ((cable_det & 0x04) ? "Yes" : "No"),
- ((cable_det & 0x08) ? "Yes" : "No"));
+ str_yes_no(cable_det & 0x01),
+ str_yes_no(cable_det & 0x02),
+ str_yes_no(cable_det & 0x04),
+ str_yes_no(cable_det & 0x08));
v4l2_info(sd, "TMDS signal detected: %s\n",
- no_signal_tmds(sd) ? "false" : "true");
+ str_false_true(no_signal_tmds(sd)));
v4l2_info(sd, "TMDS signal locked: %s\n",
- no_lock_tmds(sd) ? "false" : "true");
- v4l2_info(sd, "SSPD locked: %s\n", no_lock_sspd(sd) ? "false" : "true");
- v4l2_info(sd, "STDI locked: %s\n", no_lock_stdi(sd) ? "false" : "true");
- v4l2_info(sd, "CP locked: %s\n", no_lock_cp(sd) ? "false" : "true");
- v4l2_info(sd, "CP free run: %s\n",
- (in_free_run(sd)) ? "on" : "off");
+ str_false_true(no_lock_tmds(sd)));
+ v4l2_info(sd, "SSPD locked: %s\n", str_false_true(no_lock_sspd(sd)));
+ v4l2_info(sd, "STDI locked: %s\n", str_false_true(no_lock_stdi(sd)));
+ v4l2_info(sd, "CP locked: %s\n", str_false_true(no_lock_cp(sd)));
+ v4l2_info(sd, "CP free run: %s\n", str_on_off(in_free_run(sd)));
v4l2_info(sd, "Prim-mode = 0x%x, video std = 0x%x, v_freq = 0x%x\n",
io_read(sd, 0x01) & 0x0f, io_read(sd, 0x00) & 0x3f,
(io_read(sd, 0x01) & 0x70) >> 4);
@@ -2639,7 +2638,7 @@ static int adv76xx_log_status(struct v4l2_subdev *sd)
(reg_io_0x02 & 0x02) ? "RGB" : "YCbCr",
(((reg_io_0x02 >> 2) & 0x01) ^ (reg_io_0x02 & 0x01)) ?
"(16-235)" : "(0-255)",
- (reg_io_0x02 & 0x08) ? "enabled" : "disabled");
+ str_enabled_disabled(reg_io_0x02 & 0x08));
}
v4l2_info(sd, "Color space conversion: %s\n",
csc_coeff_sel_rb[cp_read(sd, info->cp_csc) >> 4]);
@@ -2651,9 +2650,9 @@ static int adv76xx_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "Digital video port selected: %c\n",
(hdmi_read(sd, 0x00) & 0x03) + 'A');
v4l2_info(sd, "HDCP encrypted content: %s\n",
- (hdmi_read(sd, 0x05) & 0x40) ? "true" : "false");
+ str_true_false(hdmi_read(sd, 0x05) & 0x40));
v4l2_info(sd, "HDCP keys read: %s%s\n",
- (hdmi_read(sd, 0x04) & 0x20) ? "yes" : "no",
+ str_yes_no(hdmi_read(sd, 0x04) & 0x20),
(hdmi_read(sd, 0x04) & 0x10) ? "ERROR" : "");
if (is_hdmi(sd)) {
bool audio_pll_locked = hdmi_read(sd, 0x04) & 0x01;
@@ -2674,7 +2673,7 @@ static int adv76xx_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "Audio N: %u\n", ((hdmi_read(sd, 0x5d) & 0x0f) << 16) +
(hdmi_read(sd, 0x5e) << 8) +
hdmi_read(sd, 0x5f));
- v4l2_info(sd, "AV Mute: %s\n", (hdmi_read(sd, 0x04) & 0x40) ? "on" : "off");
+ v4l2_info(sd, "AV Mute: %s\n", str_on_off(hdmi_read(sd, 0x04) & 0x40));
v4l2_info(sd, "Deep color mode: %s\n", deep_color_mode_txt[(hdmi_read(sd, 0x0b) & 0x60) >> 5]);
v4l2_info(sd, "HDMI colorspace: %s\n", hdmi_color_space_txt[hdmi_read(sd, 0x53) & 0xf]);
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 5545cd23e113d5c81d916eb764afb6f6612edc96..17055684f45b5b79cc8c5f09591d4d35653e8ff9 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -22,6 +22,7 @@
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/delay.h>
+#include <linux/string_choices.h>
#include <linux/videodev2.h>
#include <linux/workqueue.h>
#include <linux/v4l2-dv-timings.h>
@@ -2657,12 +2658,12 @@ static int adv7842_sdp_log_status(struct v4l2_subdev *sd)
/* SDP (Standard definition processor) block */
u8 sdp_signal_detected = sdp_read(sd, 0x5A) & 0x01;
- v4l2_info(sd, "Chip powered %s\n", no_power(sd) ? "off" : "on");
+ v4l2_info(sd, "Chip powered %s\n", str_on_off(no_power(sd)));
v4l2_info(sd, "Prim-mode = 0x%x, video std = 0x%x\n",
io_read(sd, 0x01) & 0x0f, io_read(sd, 0x00) & 0x3f);
v4l2_info(sd, "SDP: free run: %s\n",
- (sdp_read(sd, 0x56) & 0x01) ? "on" : "off");
+ str_on_off(sdp_read(sd, 0x56) & 0x01));
v4l2_info(sd, "SDP: %s\n", sdp_signal_detected ?
"valid SD/PR signal detected" : "invalid/no signal");
if (sdp_signal_detected) {
@@ -2687,7 +2688,7 @@ static int adv7842_sdp_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "SDP: %s\n",
(sdp_read(sd, 0x57) & 0x08) ? "Interlaced" : "Progressive");
v4l2_info(sd, "SDP: deinterlacer %s\n",
- (sdp_read(sd, 0x12) & 0x08) ? "enabled" : "disabled");
+ str_enabled_disabled(sdp_read(sd, 0x12) & 0x08));
v4l2_info(sd, "SDP: csc %s mode\n",
(sdp_io_read(sd, 0xe0) & 0x40) ? "auto" : "manual");
}
@@ -2734,19 +2735,16 @@ static int adv7842_cp_log_status(struct v4l2_subdev *sd)
};
v4l2_info(sd, "-----Chip status-----\n");
- v4l2_info(sd, "Chip power: %s\n", no_power(sd) ? "off" : "on");
+ v4l2_info(sd, "Chip power: %s\n", str_on_off(no_power(sd)));
v4l2_info(sd, "HDMI/DVI-D port selected: %s\n",
state->hdmi_port_a ? "A" : "B");
v4l2_info(sd, "EDID A %s, B %s\n",
- ((reg_rep_0x7d & 0x04) && (reg_rep_0x77 & 0x04)) ?
- "enabled" : "disabled",
- ((reg_rep_0x7d & 0x08) && (reg_rep_0x77 & 0x08)) ?
- "enabled" : "disabled");
+ str_enabled_disabled((reg_rep_0x7d & 0x04) && (reg_rep_0x77 & 0x04)),
+ str_enabled_disabled((reg_rep_0x7d & 0x08) && (reg_rep_0x77 & 0x08)));
v4l2_info(sd, "HPD A %s, B %s\n",
- reg_io_0x21 & 0x02 ? "enabled" : "disabled",
- reg_io_0x21 & 0x01 ? "enabled" : "disabled");
- v4l2_info(sd, "CEC: %s\n", state->cec_enabled_adap ?
- "enabled" : "disabled");
+ str_enabled_disabled(reg_io_0x21 & 0x02),
+ str_enabled_disabled(reg_io_0x21 & 0x01));
+ v4l2_info(sd, "CEC: %s\n", str_enabled_disabled(state->cec_enabled_adap));
if (state->cec_enabled_adap) {
int i;
@@ -2762,21 +2760,20 @@ static int adv7842_cp_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "-----Signal status-----\n");
if (state->hdmi_port_a) {
v4l2_info(sd, "Cable detected (+5V power): %s\n",
- io_read(sd, 0x6f) & 0x02 ? "true" : "false");
+ str_true_false(io_read(sd, 0x6f) & 0x02));
v4l2_info(sd, "TMDS signal detected: %s\n",
- (io_read(sd, 0x6a) & 0x02) ? "true" : "false");
+ str_true_false(io_read(sd, 0x6a) & 0x02));
v4l2_info(sd, "TMDS signal locked: %s\n",
- (io_read(sd, 0x6a) & 0x20) ? "true" : "false");
+ str_true_false(io_read(sd, 0x6a) & 0x20));
} else {
v4l2_info(sd, "Cable detected (+5V power):%s\n",
- io_read(sd, 0x6f) & 0x01 ? "true" : "false");
+ str_true_false(io_read(sd, 0x6f) & 0x01));
v4l2_info(sd, "TMDS signal detected: %s\n",
- (io_read(sd, 0x6a) & 0x01) ? "true" : "false");
+ str_true_false(io_read(sd, 0x6a) & 0x01));
v4l2_info(sd, "TMDS signal locked: %s\n",
- (io_read(sd, 0x6a) & 0x10) ? "true" : "false");
+ str_true_false(io_read(sd, 0x6a) & 0x10));
}
- v4l2_info(sd, "CP free run: %s\n",
- (!!(cp_read(sd, 0xff) & 0x10) ? "on" : "off"));
+ v4l2_info(sd, "CP free run: %s\n", str_on_off(!!(cp_read(sd, 0xff) & 0x10)));
v4l2_info(sd, "Prim-mode = 0x%x, video std = 0x%x, v_freq = 0x%x\n",
io_read(sd, 0x01) & 0x0f, io_read(sd, 0x00) & 0x3f,
(io_read(sd, 0x01) & 0x70) >> 4);
@@ -2820,7 +2817,7 @@ static int adv7842_cp_log_status(struct v4l2_subdev *sd)
(reg_io_0x02 & 0x02) ? "RGB" : "YCbCr",
(((reg_io_0x02 >> 2) & 0x01) ^ (reg_io_0x02 & 0x01)) ?
"(16-235)" : "(0-255)",
- (reg_io_0x02 & 0x08) ? "enabled" : "disabled");
+ str_enabled_disabled(reg_io_0x02 & 0x08));
v4l2_info(sd, "Color space conversion: %s\n",
csc_coeff_sel_rb[cp_read(sd, 0xf4) >> 4]);
@@ -2829,9 +2826,9 @@ static int adv7842_cp_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "-----%s status-----\n", is_hdmi(sd) ? "HDMI" : "DVI-D");
v4l2_info(sd, "HDCP encrypted content: %s\n",
- (hdmi_read(sd, 0x05) & 0x40) ? "true" : "false");
+ str_true_false(hdmi_read(sd, 0x05) & 0x40));
v4l2_info(sd, "HDCP keys read: %s%s\n",
- (hdmi_read(sd, 0x04) & 0x20) ? "yes" : "no",
+ str_yes_no(hdmi_read(sd, 0x04) & 0x20),
(hdmi_read(sd, 0x04) & 0x10) ? "ERROR" : "");
if (!is_hdmi(sd))
return 0;
@@ -2850,8 +2847,7 @@ static int adv7842_cp_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "Audio N: %u\n", ((hdmi_read(sd, 0x5d) & 0x0f) << 16) +
(hdmi_read(sd, 0x5e) << 8) +
hdmi_read(sd, 0x5f));
- v4l2_info(sd, "AV Mute: %s\n",
- (hdmi_read(sd, 0x04) & 0x40) ? "on" : "off");
+ v4l2_info(sd, "AV Mute: %s\n", str_on_off(hdmi_read(sd, 0x04) & 0x40));
v4l2_info(sd, "Deep color mode: %s\n",
deep_color_mode_txt[hdmi_read(sd, 0x0b) >> 6]);
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index a90a9e5705a03088d844e1d1a9e894e73a5402d3..e0abee073b58931ed5940e18c6aac9ae2fd74e2e 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -33,6 +33,7 @@
#include <linux/i2c.h>
#include <linux/delay.h>
#include <linux/math64.h>
+#include <linux/string_choices.h>
#include <media/v4l2-common.h>
#include <media/drv-intf/cx25840.h>
@@ -2366,7 +2367,7 @@ static int cx25840_s_audio_stream(struct v4l2_subdev *sd, int enable)
return 0;
v4l_dbg(1, cx25840_debug, client, "%s audio output\n",
- enable ? "enable" : "disable");
+ str_enable_disable(enable));
if (enable) {
v = cx25840_read(client, 0x115) | 0x80;
@@ -2389,7 +2390,7 @@ static int cx25840_s_stream(struct v4l2_subdev *sd, int enable)
u8 v;
v4l_dbg(1, cx25840_debug, client, "%s video output\n",
- enable ? "enable" : "disable");
+ str_enable_disable(enable));
/*
* It's not clear what should be done for these devices.
diff --git a/drivers/media/i2c/cx25840/cx25840-ir.c b/drivers/media/i2c/cx25840/cx25840-ir.c
index 8cef9656c61224861f1b0027be5e67fdec18cacd..5ae6568b79b1563c1c386d8684533c3add5d7708 100644
--- a/drivers/media/i2c/cx25840/cx25840-ir.c
+++ b/drivers/media/i2c/cx25840/cx25840-ir.c
@@ -10,6 +10,7 @@
#include <linux/slab.h>
#include <linux/kfifo.h>
#include <linux/module.h>
+#include <linux/string_choices.h>
#include <media/drv-intf/cx25840.h>
#include <media/rc-core.h>
@@ -1023,11 +1024,11 @@ int cx25840_ir_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "IR Receiver:\n");
v4l2_info(sd, "\tEnabled: %s\n",
- cntrl & CNTRL_RXE ? "yes" : "no");
+ str_yes_no(cntrl & CNTRL_RXE));
v4l2_info(sd, "\tDemodulation from a carrier: %s\n",
- cntrl & CNTRL_DMD ? "enabled" : "disabled");
+ str_enabled_disabled(cntrl & CNTRL_DMD));
v4l2_info(sd, "\tFIFO: %s\n",
- cntrl & CNTRL_RFE ? "enabled" : "disabled");
+ str_enabled_disabled(cntrl & CNTRL_RFE));
switch (cntrl & CNTRL_EDG) {
case CNTRL_EDG_NONE:
s = "disabled";
@@ -1086,33 +1087,33 @@ int cx25840_ir_log_status(struct v4l2_subdev *sd)
pulse_width_count_to_us(FIFO_RXTX, rxclk),
pulse_width_count_to_ns(FIFO_RXTX, rxclk));
v4l2_info(sd, "\tLow pass filter: %s\n",
- filtr ? "enabled" : "disabled");
+ str_enabled_disabled(filtr));
if (filtr)
v4l2_info(sd, "\tMin acceptable pulse width (LPF): %u us, %u ns\n",
lpf_count_to_us(filtr),
lpf_count_to_ns(filtr));
v4l2_info(sd, "\tPulse width timer timed-out: %s\n",
- stats & STATS_RTO ? "yes" : "no");
+ str_yes_no(stats & STATS_RTO));
v4l2_info(sd, "\tPulse width timer time-out intr: %s\n",
- irqen & IRQEN_RTE ? "enabled" : "disabled");
+ str_enabled_disabled(irqen & IRQEN_RTE));
v4l2_info(sd, "\tFIFO overrun: %s\n",
- stats & STATS_ROR ? "yes" : "no");
+ str_yes_no(stats & STATS_ROR));
v4l2_info(sd, "\tFIFO overrun interrupt: %s\n",
- irqen & IRQEN_ROE ? "enabled" : "disabled");
+ str_enabled_disabled(irqen & IRQEN_ROE));
v4l2_info(sd, "\tBusy: %s\n",
- stats & STATS_RBY ? "yes" : "no");
+ str_yes_no(stats & STATS_RBY));
v4l2_info(sd, "\tFIFO service requested: %s\n",
- stats & STATS_RSR ? "yes" : "no");
+ str_yes_no(stats & STATS_RSR));
v4l2_info(sd, "\tFIFO service request interrupt: %s\n",
- irqen & IRQEN_RSE ? "enabled" : "disabled");
+ str_enabled_disabled(irqen & IRQEN_RSE));
v4l2_info(sd, "IR Transmitter:\n");
v4l2_info(sd, "\tEnabled: %s\n",
- cntrl & CNTRL_TXE ? "yes" : "no");
+ str_yes_no(cntrl & CNTRL_TXE));
v4l2_info(sd, "\tModulation onto a carrier: %s\n",
- cntrl & CNTRL_MOD ? "enabled" : "disabled");
+ str_enabled_disabled(cntrl & CNTRL_MOD));
v4l2_info(sd, "\tFIFO: %s\n",
- cntrl & CNTRL_TFE ? "enabled" : "disabled");
+ str_enabled_disabled(cntrl & CNTRL_TFE));
v4l2_info(sd, "\tFIFO interrupt watermark: %s\n",
cntrl & CNTRL_TIC ? "not empty" : "half full or less");
v4l2_info(sd, "\tCarrier polarity: %s\n",
@@ -1128,11 +1129,11 @@ int cx25840_ir_log_status(struct v4l2_subdev *sd)
pulse_width_count_to_us(FIFO_RXTX, txclk),
pulse_width_count_to_ns(FIFO_RXTX, txclk));
v4l2_info(sd, "\tBusy: %s\n",
- stats & STATS_TBY ? "yes" : "no");
+ str_yes_no(stats & STATS_TBY));
v4l2_info(sd, "\tFIFO service requested: %s\n",
- stats & STATS_TSR ? "yes" : "no");
+ str_yes_no(stats & STATS_TSR));
v4l2_info(sd, "\tFIFO service request interrupt: %s\n",
- irqen & IRQEN_TSE ? "enabled" : "disabled");
+ str_enabled_disabled(irqen & IRQEN_TSE));
return 0;
}
diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index 9fc4e130a273f8547d7e7ec194cade5b5e9c8df2..fb893b9855f323b5e4cc7b11acb44b72c2f52342 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -22,6 +22,7 @@
#include <linux/of_graph.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <media/v4l2-async.h>
#include <media/v4l2-ctrls.h>
@@ -1330,7 +1331,7 @@ static int max9286_poc_enable(struct max9286_priv *priv, bool enable)
if (ret < 0)
dev_err(&priv->client->dev, "Unable to turn power %s\n",
- enable ? "on" : "off");
+ str_on_off(enable));
return ret;
}
diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c
index 4c0b0ad68c084e7a5d46fa08b4f182fe28805b01..3707b9f487674f08e383b509421d0f4d7538f659 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -39,6 +39,7 @@
#include <linux/i2c.h>
#include <linux/kthread.h>
#include <linux/freezer.h>
+#include <linux/string_choices.h>
#include <linux/videodev2.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
@@ -338,8 +339,8 @@ static int msp_s_ctrl(struct v4l2_ctrl *ctrl)
val = (val * 0x7f / 65535) << 8;
dev_dbg_lvl(&client->dev, 1, msp_debug, "mute=%s scanning=%s volume=%d\n",
- state->muted->val ? "on" : "off",
- state->scan_in_progress ? "yes" : "no",
+ str_on_off(state->muted->val),
+ str_yes_no(state->scan_in_progress),
state->volume->val);
msp_write_dsp(client, 0x0000, val);
diff --git a/drivers/media/i2c/saa7110.c b/drivers/media/i2c/saa7110.c
index 942aeeb40c524f47aa2fab6bda76d7bca5f0e2b2..7a96cefdb251938eaa54e314800ae68e4f24d2c2 100644
--- a/drivers/media/i2c/saa7110.c
+++ b/drivers/media/i2c/saa7110.c
@@ -17,6 +17,7 @@
#include <linux/types.h>
#include <linux/delay.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <linux/wait.h>
#include <linux/uaccess.h>
#include <linux/i2c.h>
@@ -310,7 +311,7 @@ static int saa7110_s_stream(struct v4l2_subdev *sd, int enable)
if (decoder->enable != enable) {
decoder->enable = enable;
saa7110_write(sd, 0x0E, enable ? 0x18 : 0x80);
- v4l2_dbg(1, debug, sd, "YUV %s\n", enable ? "on" : "off");
+ v4l2_dbg(1, debug, sd, "YUV %s\n", str_on_off(enable));
}
return 0;
}
diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index a1c71187e773ffd74cb0c0cf57247d65352d507f..7317414b64024d37dd899236e6eacbc768acd446 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -29,6 +29,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/i2c.h>
+#include <linux/string_choices.h>
#include <linux/videodev2.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ctrls.h>
@@ -1362,8 +1363,7 @@ static int saa711x_s_stream(struct v4l2_subdev *sd, int enable)
{
struct saa711x_state *state = to_state(sd);
- v4l2_dbg(1, debug, sd, "%s output\n",
- enable ? "enable" : "disable");
+ v4l2_dbg(1, debug, sd, "%s output\n", str_enable_disable(enable));
if (state->enable == enable)
return 0;
diff --git a/drivers/media/i2c/saa7127.c b/drivers/media/i2c/saa7127.c
index 818ed19cf37b540895b591f3f59ac94947b8d569..771dfb5a6766fcba0e967e99ed0998ce7c010d02 100644
--- a/drivers/media/i2c/saa7127.c
+++ b/drivers/media/i2c/saa7127.c
@@ -39,6 +39,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/i2c.h>
+#include <linux/string_choices.h>
#include <linux/videodev2.h>
#include <media/v4l2-device.h>
#include <media/i2c/saa7127.h>
@@ -343,7 +344,7 @@ static int saa7127_set_vps(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_
if (enable && (data->field != 0 || data->line != 16))
return -EINVAL;
if (state->vps_enable != enable) {
- v4l2_dbg(1, debug, sd, "Turn VPS Signal %s\n", enable ? "on" : "off");
+ v4l2_dbg(1, debug, sd, "Turn VPS Signal %s\n", str_on_off(enable));
saa7127_write(sd, 0x54, enable << 7);
state->vps_enable = enable;
}
@@ -376,7 +377,7 @@ static int saa7127_set_cc(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_d
return -EINVAL;
if (state->cc_enable != enable) {
v4l2_dbg(1, debug, sd,
- "Turn CC %s\n", enable ? "on" : "off");
+ "Turn CC %s\n", str_on_off(enable));
saa7127_write(sd, SAA7127_REG_CLOSED_CAPTION,
(state->xds_enable << 7) | (enable << 6) | 0x11);
state->cc_enable = enable;
@@ -402,7 +403,7 @@ static int saa7127_set_xds(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_
if (enable && (data->field != 1 || data->line != 21))
return -EINVAL;
if (state->xds_enable != enable) {
- v4l2_dbg(1, debug, sd, "Turn XDS %s\n", enable ? "on" : "off");
+ v4l2_dbg(1, debug, sd, "Turn XDS %s\n", str_on_off(enable));
saa7127_write(sd, SAA7127_REG_CLOSED_CAPTION,
(enable << 7) | (state->cc_enable << 6) | 0x11);
state->xds_enable = enable;
@@ -427,7 +428,7 @@ static int saa7127_set_wss(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_
if (enable && (data->field != 0 || data->line != 23))
return -EINVAL;
if (state->wss_enable != enable) {
- v4l2_dbg(1, debug, sd, "Turn WSS %s\n", enable ? "on" : "off");
+ v4l2_dbg(1, debug, sd, "Turn WSS %s\n", str_on_off(enable));
saa7127_write(sd, 0x27, enable << 7);
state->wss_enable = enable;
}
@@ -674,8 +675,8 @@ static int saa7127_log_status(struct v4l2_subdev *sd)
output_strs[state->output_type] : "disabled");
v4l2_info(sd, "WSS: %s\n", state->wss_enable ?
wss_strs[state->wss_mode] : "disabled");
- v4l2_info(sd, "VPS: %s\n", state->vps_enable ? "enabled" : "disabled");
- v4l2_info(sd, "CC: %s\n", state->cc_enable ? "enabled" : "disabled");
+ v4l2_info(sd, "VPS: %s\n", str_enabled_disabled(state->vps_enable));
+ v4l2_info(sd, "CC: %s\n", str_enabled_disabled(state->cc_enable));
return 0;
}
diff --git a/drivers/media/i2c/saa717x.c b/drivers/media/i2c/saa717x.c
index b0793bb0c02a443f7cad2e12e6fe20b4abd0241e..f2a342a6d7c95d1777471e032cf25ed1e94ea644 100644
--- a/drivers/media/i2c/saa717x.c
+++ b/drivers/media/i2c/saa717x.c
@@ -21,6 +21,7 @@
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/sched.h>
+#include <linux/string_choices.h>
#include <linux/videodev2.h>
#include <linux/i2c.h>
@@ -1088,7 +1089,7 @@ static int saa717x_s_stream(struct v4l2_subdev *sd, int enable)
struct saa717x_state *decoder = to_state(sd);
v4l2_dbg(1, debug, sd, "decoder %s output\n",
- enable ? "enable" : "disable");
+ str_enable_disable(enable));
decoder->enable = enable;
saa717x_write(sd, 0x193, enable ? 0xa6 : 0x26);
return 0;
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index c50d4e85dfd144bd6a8aee8622d59dbd03a143b0..828e575a4cf2705260351dac99b58e7fceecbd1d 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -22,6 +22,7 @@
#include <linux/interrupt.h>
#include <linux/timer.h>
#include <linux/of_graph.h>
+#include <linux/string_choices.h>
#include <linux/videodev2.h>
#include <linux/workqueue.h>
#include <linux/v4l2-dv-timings.h>
@@ -371,8 +372,7 @@ static void tc358743_delayed_work_enable_hotplug(struct work_struct *work)
static void tc358743_set_hdmi_hdcp(struct v4l2_subdev *sd, bool enable)
{
- v4l2_dbg(2, debug, sd, "%s: %s\n", __func__, enable ?
- "enable" : "disable");
+ v4l2_dbg(2, debug, sd, "%s: %s\n", __func__, str_enable_disable(enable));
if (enable) {
i2c_wr8_and_or(sd, HDCP_REG3, ~KEY_RD_CMD, KEY_RD_CMD);
@@ -1211,7 +1211,7 @@ static void tc358743_hdmi_sys_int_handler(struct v4l2_subdev *sd, bool *handled)
bool tx_5v = tx_5v_power_present(sd);
v4l2_dbg(1, debug, sd, "%s: Tx 5V power present: %s\n",
- __func__, tx_5v ? "yes" : "no");
+ __func__, str_yes_no(tx_5v));
if (tx_5v) {
tc358743_enable_edid(sd);
@@ -1288,26 +1288,24 @@ static int tc358743_log_status(struct v4l2_subdev *sd)
!!(sysctl & MASK_CECRST),
!!(sysctl & MASK_CTXRST),
!!(sysctl & MASK_HDMIRST));
- v4l2_info(sd, "Sleep mode: %s\n", sysctl & MASK_SLEEP ? "on" : "off");
+ v4l2_info(sd, "Sleep mode: %s\n", str_on_off(sysctl & MASK_SLEEP));
v4l2_info(sd, "Cable detected (+5V power): %s\n",
- hdmi_sys_status & MASK_S_DDC5V ? "yes" : "no");
+ str_yes_no(hdmi_sys_status & MASK_S_DDC5V));
v4l2_info(sd, "DDC lines enabled: %s\n",
- (i2c_rd8(sd, EDID_MODE) & MASK_EDID_MODE_E_DDC) ?
- "yes" : "no");
+ str_yes_no(i2c_rd8(sd, EDID_MODE) & MASK_EDID_MODE_E_DDC));
v4l2_info(sd, "Hotplug enabled: %s\n",
- (i2c_rd8(sd, HPD_CTL) & MASK_HPD_OUT0) ?
- "yes" : "no");
+ str_yes_no(i2c_rd8(sd, HPD_CTL) & MASK_HPD_OUT0));
v4l2_info(sd, "CEC enabled: %s\n",
- (i2c_rd16(sd, CECEN) & MASK_CECEN) ? "yes" : "no");
+ str_yes_no(i2c_rd16(sd, CECEN) & MASK_CECEN));
v4l2_info(sd, "-----Signal status-----\n");
v4l2_info(sd, "TMDS signal detected: %s\n",
- hdmi_sys_status & MASK_S_TMDS ? "yes" : "no");
+ str_yes_no(hdmi_sys_status & MASK_S_TMDS));
v4l2_info(sd, "Stable sync signal: %s\n",
- hdmi_sys_status & MASK_S_SYNC ? "yes" : "no");
+ str_yes_no(hdmi_sys_status & MASK_S_SYNC));
v4l2_info(sd, "PHY PLL locked: %s\n",
- hdmi_sys_status & MASK_S_PHY_PLL ? "yes" : "no");
+ str_yes_no(hdmi_sys_status & MASK_S_PHY_PLL));
v4l2_info(sd, "PHY DE detected: %s\n",
- hdmi_sys_status & MASK_S_PHY_SCDT ? "yes" : "no");
+ str_yes_no(hdmi_sys_status & MASK_S_PHY_SCDT));
if (tc358743_get_detected_timings(sd, &timings)) {
v4l2_info(sd, "No video detected\n");
@@ -1324,17 +1322,13 @@ static int tc358743_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "Lanes in use: %d\n",
state->csi_lanes_in_use);
v4l2_info(sd, "Waiting for particular sync signal: %s\n",
- (i2c_rd16(sd, CSI_STATUS) & MASK_S_WSYNC) ?
- "yes" : "no");
+ str_yes_no(i2c_rd16(sd, CSI_STATUS) & MASK_S_WSYNC));
v4l2_info(sd, "Transmit mode: %s\n",
- (i2c_rd16(sd, CSI_STATUS) & MASK_S_TXACT) ?
- "yes" : "no");
+ str_yes_no(i2c_rd16(sd, CSI_STATUS) & MASK_S_TXACT));
v4l2_info(sd, "Receive mode: %s\n",
- (i2c_rd16(sd, CSI_STATUS) & MASK_S_RXACT) ?
- "yes" : "no");
+ str_yes_no(i2c_rd16(sd, CSI_STATUS) & MASK_S_RXACT));
v4l2_info(sd, "Stopped: %s\n",
- (i2c_rd16(sd, CSI_STATUS) & MASK_S_HLT) ?
- "yes" : "no");
+ str_yes_no(i2c_rd16(sd, CSI_STATUS) & MASK_S_HLT));
v4l2_info(sd, "Color space: %s\n",
state->mbus_fmt_code == MEDIA_BUS_FMT_UYVY8_1X16 ?
"YCbCr 422 16-bit" :
@@ -1343,14 +1337,13 @@ static int tc358743_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "-----%s status-----\n", is_hdmi(sd) ? "HDMI" : "DVI-D");
v4l2_info(sd, "HDCP encrypted content: %s\n",
- hdmi_sys_status & MASK_S_HDCP ? "yes" : "no");
+ str_yes_no(hdmi_sys_status & MASK_S_HDCP));
v4l2_info(sd, "Input color space: %s %s range\n",
input_color_space[(vi_status3 & MASK_S_V_COLOR) >> 1],
(vi_status3 & MASK_LIMITED) ? "limited" : "full");
if (!is_hdmi(sd))
return 0;
- v4l2_info(sd, "AV Mute: %s\n", hdmi_sys_status & MASK_S_AVMUTE ? "on" :
- "off");
+ v4l2_info(sd, "AV Mute: %s\n", str_on_off(hdmi_sys_status & MASK_S_AVMUTE));
v4l2_info(sd, "Deep color mode: %d-bits per channel\n",
deep_color_mode[(i2c_rd8(sd, VI_STATUS1) &
MASK_S_DEEPCOLOR) >> 2]);
diff --git a/drivers/media/i2c/tda1997x.c b/drivers/media/i2c/tda1997x.c
index 3b7e5ff5b010b5525dcc784c92dd0d5b7b544f64..ca4992b07f57a1f5c4603d67b44c190253ec81bd 100644
--- a/drivers/media/i2c/tda1997x.c
+++ b/drivers/media/i2c/tda1997x.c
@@ -12,6 +12,7 @@
#include <linux/of_graph.h>
#include <linux/platform_device.h>
#include <linux/regulator/consumer.h>
+#include <linux/string_choices.h>
#include <linux/types.h>
#include <linux/v4l2-dv-timings.h>
#include <linux/videodev2.h>
@@ -1969,13 +1970,13 @@ static int tda1997x_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "-----Chip status-----\n");
v4l2_info(sd, "Chip: %s N%d\n", state->info->name,
state->chip_revision + 1);
- v4l2_info(sd, "EDID Enabled: %s\n", state->edid.present ? "yes" : "no");
+ v4l2_info(sd, "EDID Enabled: %s\n", str_yes_no(state->edid.present));
v4l2_info(sd, "-----Signal status-----\n");
v4l2_info(sd, "Cable detected (+5V power): %s\n",
- tda1997x_detect_tx_5v(sd) ? "yes" : "no");
+ str_yes_no(tda1997x_detect_tx_5v(sd)));
v4l2_info(sd, "HPD detected: %s\n",
- tda1997x_detect_tx_hpd(sd) ? "yes" : "no");
+ str_yes_no(tda1997x_detect_tx_hpd(sd)));
v4l2_info(sd, "-----Video Timings-----\n");
switch (tda1997x_detect_std(state, &timings)) {
diff --git a/drivers/media/i2c/ths7303.c b/drivers/media/i2c/ths7303.c
index b7cedc5b3e8ef4d992dd2bf8248f52be1f3ffaa2..8c3053251d92c655b4defc5bc6fe20ba47638fec 100644
--- a/drivers/media/i2c/ths7303.c
+++ b/drivers/media/i2c/ths7303.c
@@ -24,6 +24,7 @@
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <media/i2c/ths7303.h>
#include <media/v4l2-device.h>
@@ -281,7 +282,7 @@ static int ths7303_log_status(struct v4l2_subdev *sd)
{
struct ths7303_state *state = to_state(sd);
- v4l2_info(sd, "stream %s\n", state->stream_on ? "On" : "Off");
+ v4l2_info(sd, "stream %s\n", str_on_off(state->stream_on));
if (state->bt.pixelclock) {
struct v4l2_bt_timings *bt = &state->bt;
diff --git a/drivers/media/i2c/ths8200.c b/drivers/media/i2c/ths8200.c
index 686f10641c7a6a028abfb8579df8c34478d08089..12f6c54c14fd6ceb53423895a6f14f4cfbe8b555 100644
--- a/drivers/media/i2c/ths8200.c
+++ b/drivers/media/i2c/ths8200.c
@@ -20,6 +20,7 @@
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/string_choices.h>
#include <linux/v4l2-dv-timings.h>
#include <media/v4l2-dv-timings.h>
@@ -127,10 +128,10 @@ static int ths8200_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "----- Chip status -----\n");
v4l2_info(sd, "version: %u\n", state->chip_version);
- v4l2_info(sd, "power: %s\n", (reg_03 & 0x0c) ? "off" : "on");
- v4l2_info(sd, "reset: %s\n", (reg_03 & 0x01) ? "off" : "on");
+ v4l2_info(sd, "power: %s\n", str_off_on(reg_03 & 0x0c));
+ v4l2_info(sd, "reset: %s\n", str_off_on(reg_03 & 0x01));
v4l2_info(sd, "test pattern: %s\n",
- (reg_03 & 0x20) ? "enabled" : "disabled");
+ str_enabled_disabled(reg_03 & 0x20));
v4l2_info(sd, "format: %ux%u\n",
ths8200_read(sd, THS8200_DTG2_PIXEL_CNT_MSB) * 256 +
ths8200_read(sd, THS8200_DTG2_PIXEL_CNT_LSB),
@@ -146,7 +147,7 @@ static int ths8200_s_power(struct v4l2_subdev *sd, int on)
{
struct ths8200_state *state = to_state(sd);
- v4l2_dbg(1, debug, sd, "%s: power %s\n", __func__, on ? "on" : "off");
+ v4l2_dbg(1, debug, sd, "%s: power %s\n", __func__, str_on_off(on));
state->power_on = on;
diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index c09a5bd71fd0bb4d2e7d5d26f6c3be74de1b7efa..753ae187dea2f90088caab873453fd8f24872101 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -18,6 +18,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_graph.h>
+#include <linux/string_choices.h>
#include <linux/v4l2-dv-timings.h>
#include <media/i2c/tvp7002.h>
#include <media/v4l2-async.h>
@@ -771,8 +772,7 @@ static int tvp7002_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "Detected DV Timings: %ux%u\n",
bt->width, bt->height);
}
- v4l2_info(sd, "Streaming enabled: %s\n",
- device->streaming ? "yes" : "no");
+ v4l2_info(sd, "Streaming enabled: %s\n", str_yes_no(device->streaming));
/* Print the current value of the gain control */
v4l2_ctrl_handler_log_status(&device->hdl, sd->name);
diff --git a/drivers/media/i2c/vpx3220.c b/drivers/media/i2c/vpx3220.c
index 5f1a22284168d4256e5fcd236f7a446505ca74ea..63a2b6444bd09b5bcfd72aa6212160e748cea10a 100644
--- a/drivers/media/i2c/vpx3220.c
+++ b/drivers/media/i2c/vpx3220.c
@@ -10,6 +10,7 @@
#include <linux/delay.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <linux/uaccess.h>
#include <linux/i2c.h>
#include <linux/videodev2.h>
@@ -401,7 +402,7 @@ static int vpx3220_s_routing(struct v4l2_subdev *sd,
static int vpx3220_s_stream(struct v4l2_subdev *sd, int enable)
{
- v4l2_dbg(1, debug, sd, "s_stream %s\n", enable ? "on" : "off");
+ v4l2_dbg(1, debug, sd, "s_stream %s\n", str_on_off(enable));
vpx3220_write(sd, 0xf2, (enable ? 0x1b : 0x00));
return 0;
--
2.43.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 4/6] media: pci: Use str_enable_disable-like helpers
2025-01-14 19:46 [PATCH 0/6] media: Use str_enable_disable-like helpers Krzysztof Kozlowski
` (2 preceding siblings ...)
2025-01-14 19:46 ` [PATCH 3/6] media: i2c: " Krzysztof Kozlowski
@ 2025-01-14 19:46 ` Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 5/6] media: platform: " Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 6/6] media: usb: " Krzysztof Kozlowski
5 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-14 19:46 UTC (permalink / raw)
To: Hans Verkuil, Mauro Carvalho Chehab, Tomasz Figa,
Marek Szyprowski, Maxim Levitsky, Sean Young, Olli Salonen,
Abylay Ospan, Jemma Denson, Patrick Boettcher, Jacopo Mondi,
Kieran Bingham, Laurent Pinchart, Niklas Söderlund,
Tim Harvey, Andy Walls, Sakari Ailus, Bingbu Cao
Cc: linux-media, linux-kernel, Krzysztof Kozlowski
Replace ternary (condition ? "enable" : "disable") syntax with helpers
from string_choices.h because:
1. Simple function call with one argument is easier to read. Ternary
operator has three arguments and with wrapping might lead to quite
long code.
2. Is slightly shorter thus also easier to read.
3. It brings uniformity in the text - same string.
4. Allows deduping by the linker, which results in a smaller binary
file.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/media/pci/bt8xx/bttv-cards.c | 17 ++++++------
drivers/media/pci/bt8xx/bttv-driver.c | 7 +++--
drivers/media/pci/cobalt/cobalt-driver.c | 3 ++-
drivers/media/pci/cx18/cx18-av-core.c | 5 ++--
drivers/media/pci/cx23885/altera-ci.c | 3 ++-
drivers/media/pci/cx23885/cimax2.c | 3 ++-
drivers/media/pci/cx23885/cx23888-ir.c | 37 ++++++++++++++-------------
drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c | 3 ++-
drivers/media/pci/ivtv/ivtv-ioctl.c | 3 ++-
drivers/media/pci/saa7134/saa7134-cards.c | 4 +--
drivers/media/pci/saa7134/saa7134-dvb.c | 3 ++-
drivers/media/pci/saa7134/saa7134-input.c | 7 ++---
drivers/media/pci/saa7134/saa7134-video.c | 3 ++-
13 files changed, 54 insertions(+), 44 deletions(-)
diff --git a/drivers/media/pci/bt8xx/bttv-cards.c b/drivers/media/pci/bt8xx/bttv-cards.c
index 365b04e5ae4d27e7f7b092ce69575d938381570c..5d1b08aae077090221d7a284a3614c12db9dc495 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -20,6 +20,7 @@
#include <linux/kmod.h>
#include <linux/init.h>
#include <linux/pci.h>
+#include <linux/string_choices.h>
#include <linux/vmalloc.h>
#include <linux/firmware.h>
#include <net/checksum.h>
@@ -3036,12 +3037,12 @@ static void flyvideo_gpio(struct bttv *btv)
tuner_type = TUNER_ABSENT; /* No tuner present */
pr_info("%d: FlyVideo Radio=%s RemoteControl=%s Tuner=%d gpio=0x%06x\n",
- btv->c.nr, has_radio ? "yes" : "no",
- has_remote ? "yes" : "no", tuner_type, gpio);
+ btv->c.nr, str_yes_no(has_radio),
+ str_yes_no(has_remote), tuner_type, gpio);
pr_info("%d: FlyVideo LR90=%s tda9821/tda9820=%s capture_only=%s\n",
- btv->c.nr, is_lr90 ? "yes" : "no",
- has_tda9820_tda9821 ? "yes" : "no",
- is_capture_only ? "yes" : "no");
+ btv->c.nr, str_yes_no(is_lr90),
+ str_yes_no(has_tda9820_tda9821),
+ str_yes_no(is_capture_only));
if (tuner_type != UNSET) /* only set if known tuner autodetected, else let insmod option through */
btv->tuner_type = tuner_type;
@@ -3137,7 +3138,7 @@ static void miro_pinnacle_gpio(struct bttv *btv)
if (-1 != msp)
btv->c.type = BTTV_BOARD_PINNACLEPRO;
pr_info("%d: pinnacle/mt: id=%d info=\"%s\" radio=%s\n",
- btv->c.nr, id, info, btv->has_radio ? "yes" : "no");
+ btv->c.nr, id, info, str_yes_no(btv->has_radio));
btv->tuner_type = TUNER_MT2032;
}
}
@@ -4077,8 +4078,8 @@ static void avermedia_eeprom(struct bttv *btv)
} else
pr_cont("Unknown type");
pr_cont(" radio:%s remote control:%s\n",
- tuner_tv_fm ? "yes" : "no",
- btv->has_remote ? "yes" : "no");
+ str_yes_no(tuner_tv_fm),
+ str_yes_no(btv->has_remote));
}
/*
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 2782832f5eb8f272cf9acf29d7b4c31620c99227..33921a636b86d9eccf5fbd9792e3fe716de5c65a 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -32,6 +32,7 @@
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/sched.h>
+#include <linux/string_choices.h>
#include <linux/interrupt.h>
#include <linux/kdev_t.h>
#include "bttvp.h"
@@ -2983,12 +2984,10 @@ static irqreturn_t bttv_irq(int irq, void *dev_id)
bttv_print_irqbits(stat,astat);
if (stat & BT848_INT_HLOCK)
pr_cont(" HLOC => %s",
- dstat & BT848_DSTATUS_HLOC
- ? "yes" : "no");
+ str_yes_no(dstat & BT848_DSTATUS_HLOC));
if (stat & BT848_INT_VPRES)
pr_cont(" PRES => %s",
- dstat & BT848_DSTATUS_PRES
- ? "yes" : "no");
+ str_yes_no(dstat & BT848_DSTATUS_PRES));
if (stat & BT848_INT_FMTCHG)
pr_cont(" NUML => %s",
dstat & BT848_DSTATUS_NUML
diff --git a/drivers/media/pci/cobalt/cobalt-driver.c b/drivers/media/pci/cobalt/cobalt-driver.c
index 39e25cc53edb976795319c63c91164bca31edc6f..7fadf588a20c033e80686d02ca79b8b6a16713aa 100644
--- a/drivers/media/pci/cobalt/cobalt-driver.c
+++ b/drivers/media/pci/cobalt/cobalt-driver.c
@@ -10,6 +10,7 @@
#include <linux/bitfield.h>
#include <linux/delay.h>
+#include <linux/string_choices.h>
#include <media/i2c/adv7604.h>
#include <media/i2c/adv7842.h>
#include <media/i2c/adv7511.h>
@@ -260,7 +261,7 @@ static void msi_config_show(struct cobalt *cobalt, struct pci_dev *pci_dev)
u32 adrs_l, adrs_h;
pci_read_config_word(pci_dev, 0x52, &ctrl);
- cobalt_info("MSI %s\n", ctrl & 1 ? "enable" : "disable");
+ cobalt_info("MSI %s\n", str_enable_disable(ctrl & 1));
cobalt_info("MSI multiple message: Capable %u. Enable %u\n",
(1 << ((ctrl >> 1) & 7)), (1 << ((ctrl >> 4) & 7)));
if (ctrl & 0x80)
diff --git a/drivers/media/pci/cx18/cx18-av-core.c b/drivers/media/pci/cx18/cx18-av-core.c
index ee6e71157786ed04ddc5228dac1608bfdf56a7da..ad7bb4d9a8fa78d726f9892bf94be4c56747cc82 100644
--- a/drivers/media/pci/cx18/cx18-av-core.c
+++ b/drivers/media/pci/cx18/cx18-av-core.c
@@ -8,6 +8,7 @@
* Copyright (C) 2008 Andy Walls <awalls@md.metrocast.net>
*/
+#include <linux/string_choices.h>
#include "cx18-driver.h"
#include "cx18-io.h"
#include "cx18-cards.h"
@@ -1010,7 +1011,7 @@ static int cx18_av_s_stream(struct v4l2_subdev *sd, int enable)
{
struct cx18 *cx = v4l2_get_subdevdata(sd);
- CX18_DEBUG_INFO_DEV(sd, "%s output\n", enable ? "enable" : "disable");
+ CX18_DEBUG_INFO_DEV(sd, "%s output\n", str_enable_disable(enable));
if (enable) {
cx18_av_write(cx, 0x115, 0x8c);
cx18_av_write(cx, 0x116, 0x07);
@@ -1115,7 +1116,7 @@ static void log_audio_status(struct cx18 *cx)
}
CX18_INFO_DEV(sd, "Detected audio standard: %s\n", p);
CX18_INFO_DEV(sd, "Audio muted: %s\n",
- (mute_ctl & 0x2) ? "yes" : "no");
+ str_yes_no(mute_ctl & 0x2));
CX18_INFO_DEV(sd, "Audio microcontroller: %s\n",
(download_ctl & 0x10) ? "running" : "stopped");
diff --git a/drivers/media/pci/cx23885/altera-ci.c b/drivers/media/pci/cx23885/altera-ci.c
index 0dc348215b72d0666fd43ddc87629441784484ab..cf490d2bd476e641a163ca5c079112f90f4ee916 100644
--- a/drivers/media/pci/cx23885/altera-ci.c
+++ b/drivers/media/pci/cx23885/altera-ci.c
@@ -41,6 +41,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <linux/string_choices.h>
#include <media/dvb_demux.h>
#include <media/dvb_frontend.h>
#include "altera-ci.h"
@@ -282,7 +283,7 @@ static int altera_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot,
mutex_unlock(&inter->fpga_mutex);
ci_dbg_print("%s: %s: addr=[0x%02x], %s=%x\n", __func__,
- (read) ? "read" : "write", addr,
+ str_read_write(read), addr,
(flag == NETUP_CI_FLG_CTL) ? "ctl" : "mem",
(read) ? mem : val);
diff --git a/drivers/media/pci/cx23885/cimax2.c b/drivers/media/pci/cx23885/cimax2.c
index 06e41f92092dd0283bc04aeef58a207a18c962bc..8d76b436dea2f598a48c166bfadbaa3bb604c30f 100644
--- a/drivers/media/pci/cx23885/cimax2.c
+++ b/drivers/media/pci/cx23885/cimax2.c
@@ -11,6 +11,7 @@
#include "cx23885.h"
#include "cimax2.h"
+#include <linux/string_choices.h>
#include <media/dvb_ca_en50221.h>
/* Max transfer size done by I2C transfer functions */
@@ -224,7 +225,7 @@ static int netup_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot,
return -EREMOTEIO;
ci_dbg_print("%s: %s: chipaddr=[0x%x] addr=[0x%02x], %s=%x\n", __func__,
- (read) ? "read" : "write", state->ci_i2c_addr, addr,
+ str_read_write(read), state->ci_i2c_addr, addr,
(flag == NETUP_CI_CTL) ? "ctl" : "mem",
(read) ? mem : data);
diff --git a/drivers/media/pci/cx23885/cx23888-ir.c b/drivers/media/pci/cx23885/cx23888-ir.c
index 222d04421468e998dd02fdcf0784bce9fb7f2794..8d24f059cc8cc5f6dcebc229f0f76e9336ac6ff1 100644
--- a/drivers/media/pci/cx23885/cx23888-ir.c
+++ b/drivers/media/pci/cx23885/cx23888-ir.c
@@ -12,6 +12,7 @@
#include <linux/kfifo.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <media/v4l2-device.h>
#include <media/rc-core.h>
@@ -930,11 +931,11 @@ static int cx23888_ir_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "IR Receiver:\n");
v4l2_info(sd, "\tEnabled: %s\n",
- cntrl & CNTRL_RXE ? "yes" : "no");
+ str_yes_no(cntrl & CNTRL_RXE));
v4l2_info(sd, "\tDemodulation from a carrier: %s\n",
- cntrl & CNTRL_DMD ? "enabled" : "disabled");
+ str_enabled_disabled(cntrl & CNTRL_DMD));
v4l2_info(sd, "\tFIFO: %s\n",
- cntrl & CNTRL_RFE ? "enabled" : "disabled");
+ str_enabled_disabled(cntrl & CNTRL_RFE));
switch (cntrl & CNTRL_EDG) {
case CNTRL_EDG_NONE:
s = "disabled";
@@ -993,37 +994,37 @@ static int cx23888_ir_log_status(struct v4l2_subdev *sd)
pulse_width_count_to_us(FIFO_RXTX, rxclk),
pulse_width_count_to_ns(FIFO_RXTX, rxclk));
v4l2_info(sd, "\tLow pass filter: %s\n",
- filtr ? "enabled" : "disabled");
+ str_enabled_disabled(filtr));
if (filtr)
v4l2_info(sd, "\tMin acceptable pulse width (LPF): %u us, %u ns\n",
lpf_count_to_us(filtr),
lpf_count_to_ns(filtr));
v4l2_info(sd, "\tPulse width timer timed-out: %s\n",
- stats & STATS_RTO ? "yes" : "no");
+ str_yes_no(stats & STATS_RTO));
v4l2_info(sd, "\tPulse width timer time-out intr: %s\n",
- irqen & IRQEN_RTE ? "enabled" : "disabled");
+ str_enabled_disabled(irqen & IRQEN_RTE));
v4l2_info(sd, "\tFIFO overrun: %s\n",
- stats & STATS_ROR ? "yes" : "no");
+ str_yes_no(stats & STATS_ROR));
v4l2_info(sd, "\tFIFO overrun interrupt: %s\n",
- irqen & IRQEN_ROE ? "enabled" : "disabled");
+ str_enabled_disabled(irqen & IRQEN_ROE));
v4l2_info(sd, "\tBusy: %s\n",
- stats & STATS_RBY ? "yes" : "no");
+ str_yes_no(stats & STATS_RBY));
v4l2_info(sd, "\tFIFO service requested: %s\n",
- stats & STATS_RSR ? "yes" : "no");
+ str_yes_no(stats & STATS_RSR));
v4l2_info(sd, "\tFIFO service request interrupt: %s\n",
- irqen & IRQEN_RSE ? "enabled" : "disabled");
+ str_enabled_disabled(irqen & IRQEN_RSE));
v4l2_info(sd, "IR Transmitter:\n");
v4l2_info(sd, "\tEnabled: %s\n",
- cntrl & CNTRL_TXE ? "yes" : "no");
+ str_yes_no(cntrl & CNTRL_TXE));
v4l2_info(sd, "\tModulation onto a carrier: %s\n",
- cntrl & CNTRL_MOD ? "enabled" : "disabled");
+ str_enabled_disabled(cntrl & CNTRL_MOD));
v4l2_info(sd, "\tFIFO: %s\n",
- cntrl & CNTRL_TFE ? "enabled" : "disabled");
+ str_enabled_disabled(cntrl & CNTRL_TFE));
v4l2_info(sd, "\tFIFO interrupt watermark: %s\n",
cntrl & CNTRL_TIC ? "not empty" : "half full or less");
v4l2_info(sd, "\tOutput pin level inversion %s\n",
- cntrl & CNTRL_IVO ? "yes" : "no");
+ str_yes_no(cntrl & CNTRL_IVO));
v4l2_info(sd, "\tCarrier polarity: %s\n",
cntrl & CNTRL_CPL ? "space:burst mark:noburst"
: "space:noburst mark:burst");
@@ -1037,11 +1038,11 @@ static int cx23888_ir_log_status(struct v4l2_subdev *sd)
pulse_width_count_to_us(FIFO_RXTX, txclk),
pulse_width_count_to_ns(FIFO_RXTX, txclk));
v4l2_info(sd, "\tBusy: %s\n",
- stats & STATS_TBY ? "yes" : "no");
+ str_yes_no(stats & STATS_TBY));
v4l2_info(sd, "\tFIFO service requested: %s\n",
- stats & STATS_TSR ? "yes" : "no");
+ str_yes_no(stats & STATS_TSR));
v4l2_info(sd, "\tFIFO service request interrupt: %s\n",
- irqen & IRQEN_TSE ? "enabled" : "disabled");
+ str_enabled_disabled(irqen & IRQEN_TSE));
return 0;
}
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c b/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
index 051898ce53f439a68aff72c6c01978f7ce1de6fa..029561d84ad53c057c839f9cfaf0777f314c3738 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
@@ -12,6 +12,7 @@
#include <linux/io.h>
#include <linux/minmax.h>
#include <linux/sprintf.h>
+#include <linux/string_choices.h>
#include <media/media-entity.h>
#include <media/v4l2-ctrls.h>
@@ -244,7 +245,7 @@ static int ipu6_isys_csi2_set_stream(struct v4l2_subdev *sd,
u32 mask = 0;
u32 i;
- dev_dbg(dev, "stream %s CSI2-%u with %u lanes\n", enable ? "on" : "off",
+ dev_dbg(dev, "stream %s CSI2-%u with %u lanes\n", str_on_off(enable),
csi2->port, nlanes);
cfg.port = csi2->port;
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 7947dcd615e882da5240ed6b10dde8449036d019..ea8bb4f3669544780ad7b5502756ff382b27c8dd 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -20,6 +20,7 @@
#include "ivtv-gpio.h"
#include "ivtv-controls.h"
#include "ivtv-cards.h"
+#include <linux/string_choices.h>
#include <media/i2c/saa7127.h>
#include <media/tveeprom.h>
#include <media/v4l2-event.h>
@@ -1558,7 +1559,7 @@ static int ivtv_log_status(struct file *file, void *fh)
ivtv_vapi_result(itv, data, CX2341X_OSD_GET_STATE, 0);
data[0] |= (read_reg(0x2a00) >> 7) & 0x40;
IVTV_INFO("Overlay: %s, Alpha: %s, Pixel Format: %s\n",
- data[0] & 1 ? "On" : "Off",
+ str_on_off(data[0] & 1),
alpha_mode[(data[0] >> 1) & 0x3],
pixel_format[(data[0] >> 3) & 0xf]);
}
diff --git a/drivers/media/pci/saa7134/saa7134-cards.c b/drivers/media/pci/saa7134/saa7134-cards.c
index e80fb4ebfda61b614c73c5273b51acd4edf279bd..148cd43612a2df74135a2441a975c545ebdcc6ec 100644
--- a/drivers/media/pci/saa7134/saa7134-cards.c
+++ b/drivers/media/pci/saa7134/saa7134-cards.c
@@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/i2c-algo-bit.h>
+#include <linux/string_choices.h>
#include "xc2028.h"
#include <media/v4l2-common.h>
@@ -7980,8 +7981,7 @@ int saa7134_board_init2(struct saa7134_dev *dev)
msg.flags = I2C_M_RD;
rc = i2c_transfer(&dev->i2c_adap, &msg, 1);
pr_info("%s: probe IR chip @ i2c 0x%02x: %s\n",
- dev->name, msg.addr,
- (1 == rc) ? "yes" : "no");
+ dev->name, msg.addr, str_yes_no(rc == 1));
if (rc == 1)
dev->has_remote = SAA7134_REMOTE_I2C;
}
diff --git a/drivers/media/pci/saa7134/saa7134-dvb.c b/drivers/media/pci/saa7134/saa7134-dvb.c
index 6de8a02314af6a68e74c8c271e4d4e687a24576f..2827ae660632ed453d6bd556ceb3a32cf57e1d0a 100644
--- a/drivers/media/pci/saa7134/saa7134-dvb.c
+++ b/drivers/media/pci/saa7134/saa7134-dvb.c
@@ -16,6 +16,7 @@
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/kthread.h>
+#include <linux/string_choices.h>
#include <linux/suspend.h>
#include <media/v4l2-common.h>
@@ -90,7 +91,7 @@ static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
udelay(10);
ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
- pr_debug("%s %s\n", __func__, ok ? "on" : "off");
+ pr_debug("%s %s\n", __func__, str_on_off(ok));
if (!ok)
saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
diff --git a/drivers/media/pci/saa7134/saa7134-input.c b/drivers/media/pci/saa7134/saa7134-input.c
index 8610eb473b39e1e33e13abb21bcb985760f0221f..23c92a566a603ecb27397b01c184a418dd094849 100644
--- a/drivers/media/pci/saa7134/saa7134-input.c
+++ b/drivers/media/pci/saa7134/saa7134-input.c
@@ -12,6 +12,7 @@
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#define MODULE_NAME "saa7134"
@@ -895,7 +896,7 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);
input_dbg("probe 0x%02x @ %s: %s\n",
msg_msi.addr, dev->i2c_adap.name,
- (1 == rc) ? "yes" : "no");
+ str_yes_no(rc == 1));
break;
case SAA7134_BOARD_SNAZIO_TVPVR_PRO:
dev->init_data.name = "SnaZio* TVPVR PRO";
@@ -916,7 +917,7 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);
input_dbg("probe 0x%02x @ %s: %s\n",
msg_msi.addr, dev->i2c_adap.name,
- (rc == 1) ? "yes" : "no");
+ str_yes_no(rc == 1));
break;
case SAA7134_BOARD_KWORLD_PC150U:
/* copied and modified from MSI TV@nywhere Plus */
@@ -931,7 +932,7 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);
input_dbg("probe 0x%02x @ %s: %s\n",
msg_msi.addr, dev->i2c_adap.name,
- (1 == rc) ? "yes" : "no");
+ str_yes_no(rc == 1));
break;
case SAA7134_BOARD_HAUPPAUGE_HVR1110:
dev->init_data.name = saa7134_boards[dev->board].name;
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index 43e7b006eb596740771cf893d8fda39df0e4aff4..f36a666103b17d8c8b4d793c864d90fc003c17d0 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -16,6 +16,7 @@
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/sort.h>
+#include <linux/string_choices.h>
#include <media/v4l2-common.h>
#include <media/v4l2-event.h>
@@ -619,7 +620,7 @@ static int saa7134_enable_analog_tuner(struct saa7134_dev *dev)
if (ret) {
pr_err("Couldn't change link %s->%s to %s. Error %d\n",
source->name, sink->name,
- flags ? "enabled" : "disabled",
+ str_enabled_disabled(flags),
ret);
return ret;
}
--
2.43.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 5/6] media: platform: Use str_enable_disable-like helpers
2025-01-14 19:46 [PATCH 0/6] media: Use str_enable_disable-like helpers Krzysztof Kozlowski
` (3 preceding siblings ...)
2025-01-14 19:46 ` [PATCH 4/6] media: pci: " Krzysztof Kozlowski
@ 2025-01-14 19:46 ` Krzysztof Kozlowski
2025-01-14 20:42 ` Laurent Pinchart
2025-01-14 19:46 ` [PATCH 6/6] media: usb: " Krzysztof Kozlowski
5 siblings, 1 reply; 13+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-14 19:46 UTC (permalink / raw)
To: Hans Verkuil, Mauro Carvalho Chehab, Tomasz Figa,
Marek Szyprowski, Maxim Levitsky, Sean Young, Olli Salonen,
Abylay Ospan, Jemma Denson, Patrick Boettcher, Jacopo Mondi,
Kieran Bingham, Laurent Pinchart, Niklas Söderlund,
Tim Harvey, Andy Walls, Sakari Ailus, Bingbu Cao
Cc: linux-media, linux-kernel, Krzysztof Kozlowski
Replace ternary (condition ? "enable" : "disable") syntax with helpers
from string_choices.h because:
1. Simple function call with one argument is easier to read. Ternary
operator has three arguments and with wrapping might lead to quite
long code.
2. Is slightly shorter thus also easier to read.
3. It brings uniformity in the text - same string.
4. Allows deduping by the linker, which results in a smaller binary
file.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/media/platform/amphion/venc.c | 3 ++-
drivers/media/platform/amphion/vpu_dbg.c | 3 ++-
drivers/media/platform/aspeed/aspeed-video.c | 5 +++--
drivers/media/platform/chips-media/coda/coda-bit.c | 3 ++-
drivers/media/platform/chips-media/coda/imx-vdoa.c | 3 ++-
drivers/media/platform/st/sti/hva/hva-debugfs.c | 7 ++++---
drivers/media/platform/ti/cal/cal-camerarx.c | 3 ++-
drivers/media/platform/ti/omap3isp/ispstat.c | 3 ++-
drivers/media/platform/xilinx/xilinx-csi2rxss.c | 19 ++++++++++---------
9 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/drivers/media/platform/amphion/venc.c b/drivers/media/platform/amphion/venc.c
index c5c1f1fbaa80366d5b18b8f24699eb9c3a18ef92..65b1665eece8cd6efc535281b3be593abaf9ba64 100644
--- a/drivers/media/platform/amphion/venc.c
+++ b/drivers/media/platform/amphion/venc.c
@@ -13,6 +13,7 @@
#include <linux/videodev2.h>
#include <linux/ktime.h>
#include <linux/rational.h>
+#include <linux/string_choices.h>
#include <linux/vmalloc.h>
#include <media/v4l2-device.h>
#include <media/v4l2-event.h>
@@ -1215,7 +1216,7 @@ static int venc_get_debug_info(struct vpu_inst *inst, char *str, u32 size, u32 i
break;
case 8:
num = scnprintf(str, size, "rc: %s, mode = %d, bitrate = %d(%d), qp = %d\n",
- venc->params.rc_enable ? "enable" : "disable",
+ str_enable_disable(venc->params.rc_enable),
venc->params.rc_mode,
venc->params.bitrate,
venc->params.bitrate_max,
diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platform/amphion/vpu_dbg.c
index 940e5bda5fa391c47552c275bd1266f47d57f475..b726d884086d306cd4298dc46440a2235b311b86 100644
--- a/drivers/media/platform/amphion/vpu_dbg.c
+++ b/drivers/media/platform/amphion/vpu_dbg.c
@@ -11,6 +11,7 @@
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/pm_runtime.h>
+#include <linux/string_choices.h>
#include <media/v4l2-device.h>
#include <linux/debugfs.h>
#include "vpu.h"
@@ -256,7 +257,7 @@ static int vpu_dbg_core(struct seq_file *s, void *data)
return 0;
num = scnprintf(str, sizeof(str), "power %s\n",
- vpu_iface_get_power_state(core) ? "on" : "off");
+ str_on_off(vpu_iface_get_power_state(core)));
if (seq_write(s, str, num))
return 0;
num = scnprintf(str, sizeof(str), "state = %d\n", core->state);
diff --git a/drivers/media/platform/aspeed/aspeed-video.c b/drivers/media/platform/aspeed/aspeed-video.c
index 54cae0da9aca3fd74800b51f79136a261aec241a..d9cf12af05b75c76c506f6e7d72dfc41c9e05317 100644
--- a/drivers/media/platform/aspeed/aspeed-video.c
+++ b/drivers/media/platform/aspeed/aspeed-video.c
@@ -19,6 +19,7 @@
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/string.h>
+#include <linux/string_choices.h>
#include <linux/v4l2-controls.h>
#include <linux/videodev2.h>
#include <linux/wait.h>
@@ -1227,7 +1228,7 @@ static void aspeed_video_update_regs(struct aspeed_video *video)
v4l2_dbg(1, debug, &video->v4l2_dev, "compression quality(%d)\n",
video->jpeg_quality);
v4l2_dbg(1, debug, &video->v4l2_dev, "hq_mode(%s) hq_quality(%d)\n",
- video->hq_mode ? "on" : "off", video->jpeg_hq_quality);
+ str_on_off(video->hq_mode), video->jpeg_hq_quality);
if (video->format == VIDEO_FMT_ASPEED)
aspeed_video_update(video, VE_BCD_CTRL, 0, VE_BCD_CTRL_EN_BCD);
@@ -1939,7 +1940,7 @@ static int aspeed_video_debugfs_show(struct seq_file *s, void *data)
seq_printf(s, " %-20s:\t%d\n", "Quality", v->jpeg_quality);
if (v->format == VIDEO_FMT_ASPEED) {
seq_printf(s, " %-20s:\t%s\n", "HQ Mode",
- v->hq_mode ? "on" : "off");
+ str_on_off(v->hq_mode));
seq_printf(s, " %-20s:\t%d\n", "HQ Quality",
v->hq_mode ? v->jpeg_hq_quality : 0);
}
diff --git a/drivers/media/platform/chips-media/coda/coda-bit.c b/drivers/media/platform/chips-media/coda/coda-bit.c
index 84ded154adfe37147218d60278a1c1fac88ecadc..2cb0c04003da750f7108578e274da31778c3f2d2 100644
--- a/drivers/media/platform/chips-media/coda/coda-bit.c
+++ b/drivers/media/platform/chips-media/coda/coda-bit.c
@@ -16,6 +16,7 @@
#include <linux/ratelimit.h>
#include <linux/reset.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
@@ -1881,7 +1882,7 @@ static int __coda_decoder_seq_init(struct coda_ctx *ctx)
lockdep_assert_held(&dev->coda_mutex);
coda_dbg(1, ctx, "Video Data Order Adapter: %s\n",
- ctx->use_vdoa ? "Enabled" : "Disabled");
+ str_enabled_disabled(ctx->use_vdoa));
/* Start decoding */
q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
diff --git a/drivers/media/platform/chips-media/coda/imx-vdoa.c b/drivers/media/platform/chips-media/coda/imx-vdoa.c
index c3561fcecb98c7d3cd741c28afcb2a3854eaa0e7..abdff181d417788460b7f6230ea54789b242d436 100644
--- a/drivers/media/platform/chips-media/coda/imx-vdoa.c
+++ b/drivers/media/platform/chips-media/coda/imx-vdoa.c
@@ -15,6 +15,7 @@
#include <linux/platform_device.h>
#include <linux/videodev2.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include "imx-vdoa.h"
@@ -117,7 +118,7 @@ static irqreturn_t vdoa_irq_handler(int irq, void *data)
writel(val, vdoa->regs + VDOAIST);
if (val & VDOAIST_TERR) {
val = readl(vdoa->regs + VDOASR) & VDOASR_ERRW;
- dev_err(vdoa->dev, "AXI %s error\n", val ? "write" : "read");
+ dev_err(vdoa->dev, "AXI %s error\n", str_write_read(val));
} else if (!(val & VDOAIST_EOT)) {
dev_warn(vdoa->dev, "Spurious interrupt\n");
}
diff --git a/drivers/media/platform/st/sti/hva/hva-debugfs.c b/drivers/media/platform/st/sti/hva/hva-debugfs.c
index a86a07b6fbc792fc06db2dbbb3934694136a7813..1cb5bca44939606f39911a41e5f464be888848c2 100644
--- a/drivers/media/platform/st/sti/hva/hva-debugfs.c
+++ b/drivers/media/platform/st/sti/hva/hva-debugfs.c
@@ -6,6 +6,7 @@
*/
#include <linux/debugfs.h>
+#include <linux/string_choices.h>
#include "hva.h"
#include "hva-hw.h"
@@ -71,12 +72,12 @@ static void format_ctx(struct seq_file *s, struct hva_ctx *ctx)
" | |- SEI frame packing type=%s\n",
v4l2_ctrl_get_menu(entropy)[ctrls->entropy_mode],
ctrls->cpb_size,
- ctrls->dct8x8 ? "true" : "false",
+ str_true_false(ctrls->dct8x8),
ctrls->qpmin,
ctrls->qpmax,
- ctrls->vui_sar ? "true" : "false",
+ str_true_false(ctrls->vui_sar),
v4l2_ctrl_get_menu(vui_sar)[ctrls->vui_sar_idc],
- ctrls->sei_fp ? "true" : "false",
+ str_true_false(ctrls->sei_fp),
v4l2_ctrl_get_menu(sei_fp)[ctrls->sei_fp_type]);
}
diff --git a/drivers/media/platform/ti/cal/cal-camerarx.c b/drivers/media/platform/ti/cal/cal-camerarx.c
index 42dfe08b765f6bbdb0ab8cca0f7d6d87f2ff18eb..a70814cbada82654e926b12bcde73300107aaa8a 100644
--- a/drivers/media/platform/ti/cal/cal-camerarx.c
+++ b/drivers/media/platform/ti/cal/cal-camerarx.c
@@ -17,6 +17,7 @@
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-fwnode.h>
@@ -191,7 +192,7 @@ static void cal_camerarx_power(struct cal_camerarx *phy, bool enable)
if (i == 10)
phy_err(phy, "Failed to power %s complexio\n",
- enable ? "up" : "down");
+ str_up_down(enable));
}
static void cal_camerarx_wait_reset(struct cal_camerarx *phy)
diff --git a/drivers/media/platform/ti/omap3isp/ispstat.c b/drivers/media/platform/ti/omap3isp/ispstat.c
index 359a846205b0ffe9e736c7ed37c22677991cc9f2..f1293d412415d3fe36a87e7aa93a60e7daf693d8 100644
--- a/drivers/media/platform/ti/omap3isp/ispstat.c
+++ b/drivers/media/platform/ti/omap3isp/ispstat.c
@@ -14,6 +14,7 @@
#include <linux/dma-mapping.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <linux/timekeeping.h>
#include <linux/uaccess.h>
@@ -768,7 +769,7 @@ int omap3isp_stat_enable(struct ispstat *stat, u8 enable)
unsigned long irqflags;
dev_dbg(stat->isp->dev, "%s: user wants to %s module.\n",
- stat->subdev.name, enable ? "enable" : "disable");
+ stat->subdev.name, str_enable_disable(enable));
/* Prevent enabling while configuring */
mutex_lock(&stat->ioctl_lock);
diff --git a/drivers/media/platform/xilinx/xilinx-csi2rxss.c b/drivers/media/platform/xilinx/xilinx-csi2rxss.c
index 146131b8f37e5a30b168164d4eaedc9641d6af31..a5074f05cee50e117256fdb8496b977332757e27 100644
--- a/drivers/media/platform/xilinx/xilinx-csi2rxss.c
+++ b/drivers/media/platform/xilinx/xilinx-csi2rxss.c
@@ -16,6 +16,7 @@
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/platform_device.h>
+#include <linux/string_choices.h>
#include <linux/v4l2-subdev.h>
#include <media/media-entity.h>
#include <media/mipi-csi2.h>
@@ -400,19 +401,19 @@ static int xcsi2rxss_log_status(struct v4l2_subdev *sd)
dev_info(dev, "***** Core Status *****\n");
data = xcsi2rxss_read(xcsi2rxss, XCSI_CSR_OFFSET);
dev_info(dev, "Short Packet FIFO Full = %s\n",
- data & XCSI_CSR_SPFIFOFULL ? "true" : "false");
+ str_true_false(data & XCSI_CSR_SPFIFOFULL));
dev_info(dev, "Short Packet FIFO Not Empty = %s\n",
- data & XCSI_CSR_SPFIFONE ? "true" : "false");
+ str_true_false(data & XCSI_CSR_SPFIFONE));
dev_info(dev, "Stream line buffer full = %s\n",
- data & XCSI_CSR_SLBF ? "true" : "false");
+ str_true_false(data & XCSI_CSR_SLBF));
dev_info(dev, "Soft reset/Core disable in progress = %s\n",
- data & XCSI_CSR_RIPCD ? "true" : "false");
+ str_true_false(data & XCSI_CSR_RIPCD));
/* Clk & Lane Info */
dev_info(dev, "******** Clock Lane Info *********\n");
data = xcsi2rxss_read(xcsi2rxss, XCSI_CLKINFR_OFFSET);
dev_info(dev, "Clock Lane in Stop State = %s\n",
- data & XCSI_CLKINFR_STOP ? "true" : "false");
+ str_true_false(data & XCSI_CLKINFR_STOP));
dev_info(dev, "******** Data Lane Info *********\n");
dev_info(dev, "Lane\tSoT Error\tSoT Sync Error\tStop State\n");
@@ -421,9 +422,9 @@ static int xcsi2rxss_log_status(struct v4l2_subdev *sd)
data = xcsi2rxss_read(xcsi2rxss, reg);
dev_info(dev, "%d\t%s\t\t%s\t\t%s\n", i,
- data & XCSI_DLXINFR_SOTERR ? "true" : "false",
- data & XCSI_DLXINFR_SOTSYNCERR ? "true" : "false",
- data & XCSI_DLXINFR_STOP ? "true" : "false");
+ str_true_false(data & XCSI_DLXINFR_SOTERR),
+ str_true_false(data & XCSI_DLXINFR_SOTSYNCERR),
+ str_true_false(data & XCSI_DLXINFR_STOP));
reg += XCSI_NEXTREG_OFFSET;
}
@@ -889,7 +890,7 @@ static int xcsi2rxss_parse_of(struct xcsi2rxss_state *xcsi2rxss)
fwnode_handle_put(ep);
dev_dbg(dev, "vcx %s, %u data lanes (%s), data type 0x%02x\n",
- xcsi2rxss->en_vcx ? "enabled" : "disabled",
+ str_enabled_disabled(xcsi2rxss->en_vcx),
xcsi2rxss->max_num_lanes,
xcsi2rxss->enable_active_lanes ? "dynamic" : "static",
xcsi2rxss->datatype);
--
2.43.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 6/6] media: usb: Use str_enable_disable-like helpers
2025-01-14 19:46 [PATCH 0/6] media: Use str_enable_disable-like helpers Krzysztof Kozlowski
` (4 preceding siblings ...)
2025-01-14 19:46 ` [PATCH 5/6] media: platform: " Krzysztof Kozlowski
@ 2025-01-14 19:46 ` Krzysztof Kozlowski
5 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-14 19:46 UTC (permalink / raw)
To: Hans Verkuil, Mauro Carvalho Chehab, Tomasz Figa,
Marek Szyprowski, Maxim Levitsky, Sean Young, Olli Salonen,
Abylay Ospan, Jemma Denson, Patrick Boettcher, Jacopo Mondi,
Kieran Bingham, Laurent Pinchart, Niklas Söderlund,
Tim Harvey, Andy Walls, Sakari Ailus, Bingbu Cao
Cc: linux-media, linux-kernel, Krzysztof Kozlowski
Replace ternary (condition ? "enable" : "disable") syntax with helpers
from string_choices.h because:
1. Simple function call with one argument is easier to read. Ternary
operator has three arguments and with wrapping might lead to quite
long code.
2. Is slightly shorter thus also easier to read.
3. It brings uniformity in the text - same string.
4. Allows deduping by the linker, which results in a smaller binary
file.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/media/usb/cx231xx/cx231xx-i2c.c | 5 +++--
drivers/media/usb/cx231xx/cx231xx-video.c | 5 +++--
drivers/media/usb/dvb-usb-v2/az6007.c | 5 +++--
drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 5 +++--
drivers/media/usb/dvb-usb/af9005-fe.c | 5 +++--
drivers/media/usb/dvb-usb/dvb-usb-dvb.c | 7 ++++---
drivers/media/usb/dvb-usb/opera1.c | 9 +++++----
drivers/media/usb/em28xx/em28xx-i2c.c | 5 +++--
drivers/media/usb/em28xx/em28xx-video.c | 5 +++--
drivers/media/usb/pvrusb2/pvrusb2-ctrl.c | 3 ++-
drivers/media/usb/pvrusb2/pvrusb2-debugifc.c | 3 ++-
drivers/media/usb/pvrusb2/pvrusb2-encoder.c | 6 +++---
drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 7 ++++---
drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c | 4 ++--
14 files changed, 43 insertions(+), 31 deletions(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
index 6da8e7943d94a38a8d38ec3944d80fedfb44f76b..abace421612c6d40a28ce4120a8fd03b2b024565 100644
--- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/i2c.h>
#include <linux/i2c-mux.h>
+#include <linux/string_choices.h>
#include <media/v4l2-common.h>
#include <media/tuner.h>
@@ -370,7 +371,7 @@ static int cx231xx_i2c_xfer(struct i2c_adapter *i2c_adap,
addr = msgs[i].addr;
dprintk2(2, "%s %s addr=0x%x len=%d:",
- (msgs[i].flags & I2C_M_RD) ? "read" : "write",
+ str_read_write(msgs[i].flags & I2C_M_RD),
i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len);
if (!msgs[i].len) {
/* no len: check only for device presence */
@@ -399,7 +400,7 @@ static int cx231xx_i2c_xfer(struct i2c_adapter *i2c_adap,
}
/* read bytes */
dprintk2(2, "plus %s %s addr=0x%x len=%d:",
- (msgs[i+1].flags & I2C_M_RD) ? "read" : "write",
+ str_read_write(msgs[i + 1].flags & I2C_M_RD),
i+1 == num - 1 ? "stop" : "nonstop", addr, msgs[i+1].len);
rc = cx231xx_i2c_recv_bytes_with_saddr(i2c_adap,
&msgs[i],
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index 2cd4e333bc4b012f97df98f8771f2508d81c3b3c..03a071834cb5b38fb6e0fbdac6825ebd3c03038d 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -20,6 +20,7 @@
#include <linux/mm.h>
#include <linux/mutex.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h>
@@ -141,14 +142,14 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
dev_err(dev->dev,
"Couldn't change link %s->%s to %s. Error %d\n",
source->name, sink->name,
- flags ? "enabled" : "disabled",
+ str_enabled_disabled(flags),
ret);
return ret;
} else
dev_dbg(dev->dev,
"link %s->%s was %s\n",
source->name, sink->name,
- flags ? "ENABLED" : "disabled");
+ str_enabled_disabled(flags));
}
#endif
return 0;
diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 2410054ddb2c345909fad792bd815e5a0584e7c3..53eadfb5bd49d58eaa331f49393107b8f4135990 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -15,6 +15,7 @@
#include "drxk.h"
#include "mt2063.h"
+#include <linux/string_choices.h>
#include <media/dvb_ca_en50221.h>
#include "dvb_usb.h"
#include "cypress_firmware.h"
@@ -79,7 +80,7 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
struct dvb_usb_adapter *adap = fe->sec_priv;
int status = 0;
- pr_debug("%s: %s\n", __func__, enable ? "enable" : "disable");
+ pr_debug("%s: %s\n", __func__, str_enable_disable(enable));
if (!adap || !st)
return -EINVAL;
@@ -189,7 +190,7 @@ static int az6007_streaming_ctrl(struct dvb_frontend *fe, int onoff)
{
struct dvb_usb_device *d = fe_to_d(fe);
- pr_debug("%s: %s\n", __func__, onoff ? "enable" : "disable");
+ pr_debug("%s: %s\n", __func__, str_enable_disable(onoff));
return az6007_write(d, 0xbc, onoff, 0, NULL, 0);
}
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
index f1c79f351ec8de1bb13fbecc110a33243161888d..1220283e59d3db25ec76a4a7ac5a5c32812e5947 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -7,6 +7,7 @@
*/
#include "dvb_usb_common.h"
+#include <linux/string_choices.h>
#include <media/media-device.h>
static int dvb_usbv2_disable_rc_polling;
@@ -247,7 +248,7 @@ static int dvb_usb_start_feed(struct dvb_demux_feed *dvbdmxfeed)
dev_dbg(&d->udev->dev,
"%s: adap=%d active_fe=%d feed_type=%d setting pid [%s]: %04x (%04d) at index %d\n",
__func__, adap->id, adap->active_fe, dvbdmxfeed->type,
- adap->pid_filtering ? "yes" : "no", dvbdmxfeed->pid,
+ str_yes_no(adap->pid_filtering), dvbdmxfeed->pid,
dvbdmxfeed->pid, dvbdmxfeed->index);
/* wait init is done */
@@ -334,7 +335,7 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
dev_dbg(&d->udev->dev,
"%s: adap=%d active_fe=%d feed_type=%d setting pid [%s]: %04x (%04d) at index %d\n",
__func__, adap->id, adap->active_fe, dvbdmxfeed->type,
- adap->pid_filtering ? "yes" : "no", dvbdmxfeed->pid,
+ str_yes_no(adap->pid_filtering), dvbdmxfeed->pid,
dvbdmxfeed->pid, dvbdmxfeed->index);
if (adap->active_fe == -1)
diff --git a/drivers/media/usb/dvb-usb/af9005-fe.c b/drivers/media/usb/dvb-usb/af9005-fe.c
index 404e56b32145f1e629b08809ed866371b6efb0fa..d742fde9c1259930382c3d4688a64454be4bf863 100644
--- a/drivers/media/usb/dvb-usb/af9005-fe.c
+++ b/drivers/media/usb/dvb-usb/af9005-fe.c
@@ -12,6 +12,7 @@
#include "af9005-script.h"
#include "mt2060.h"
#include "qt1010.h"
+#include <linux/string_choices.h>
#include <asm/div64.h>
struct af9005_fe_state {
@@ -787,7 +788,7 @@ static int af9005_fe_power(struct dvb_frontend *fe, int on)
struct af9005_fe_state *state = fe->demodulator_priv;
u8 temp = on;
int ret;
- deb_info("power %s tuner\n", on ? "on" : "off");
+ deb_info("power %s tuner\n", str_on_off(on));
ret = af9005_send_command(state->d, 0x03, &temp, 1, NULL, 0);
return ret;
}
@@ -1279,7 +1280,7 @@ static int af9005_fe_get_frontend(struct dvb_frontend *fe,
if (ret)
return ret;
/* if temp is set = high priority */
- deb_info("PRIORITY %s\n", temp ? "high" : "low");
+ deb_info("PRIORITY %s\n", str_high_low(temp));
/* high coderate */
ret =
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
index 0a7f8ba9099261d057064120901abd9ada8f1b32..5ff3f71503889f3873e9eedee9118477c2474034 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
@@ -8,6 +8,7 @@
* linux-dvb API.
*/
#include "dvb-usb-common.h"
+#include <linux/string_choices.h>
#include <media/media-device.h>
/* does the complete input transfer handling */
@@ -44,9 +45,9 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
/* activate the pid on the device specific pid_filter */
deb_ts("setting pid (%s): %5d %04x at index %d '%s'\n",
- adap->fe_adap[adap->active_fe].pid_filtering ?
- "yes" : "no", dvbdmxfeed->pid, dvbdmxfeed->pid,
- dvbdmxfeed->index, onoff ? "on" : "off");
+ str_yes_no(adap->fe_adap[adap->active_fe].pid_filtering),
+ dvbdmxfeed->pid, dvbdmxfeed->pid,
+ dvbdmxfeed->index, str_on_off(onoff));
if (adap->props.fe[adap->active_fe].caps & DVB_USB_ADAP_HAS_PID_FILTER &&
adap->fe_adap[adap->active_fe].pid_filtering &&
adap->props.fe[adap->active_fe].pid_filter != NULL)
diff --git a/drivers/media/usb/dvb-usb/opera1.c b/drivers/media/usb/dvb-usb/opera1.c
index 268f05fc8691bcaecc16e02596212191ff242c76..05539133fff0b13fbd69eda49a623fe76aeacb06 100644
--- a/drivers/media/usb/dvb-usb/opera1.c
+++ b/drivers/media/usb/dvb-usb/opera1.c
@@ -9,6 +9,7 @@
#define DVB_USB_LOG_PREFIX "opera"
+#include <linux/string_choices.h>
#include "dvb-usb.h"
#include "stv0299.h"
@@ -280,7 +281,7 @@ static int opera1_power_ctrl(struct dvb_usb_device *d, int onoff)
u8 val = onoff ? 0x01 : 0x00;
if (dvb_usb_opera1_debug)
- info("power %s", onoff ? "on" : "off");
+ info("power %s", str_on_off(onoff));
return opera1_xilinx_rw(d->udev, 0xb7, val,
&val, 1, OPERA_WRITE_MSG);
}
@@ -293,7 +294,7 @@ static int opera1_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
{.addr = ADDR_B1A6_STREAM_CTRL,.buf = onoff ? buf_start : buf_stop,.len = 2},
};
if (dvb_usb_opera1_debug)
- info("streaming %s", onoff ? "on" : "off");
+ info("streaming %s", str_on_off(onoff));
i2c_transfer(&adap->dev->i2c_adap, start_tuner, 1);
return 0;
}
@@ -307,7 +308,7 @@ static int opera1_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
};
if (dvb_usb_opera1_debug)
info("pidfilter index: %d pid: %d %s", index, pid,
- onoff ? "on" : "off");
+ str_on_off(onoff));
b_pid[0] = (2 * index) + 4;
b_pid[1] = onoff ? (pid & 0xff) : (0x00);
b_pid[2] = onoff ? ((pid >> 8) & 0xff) : (0x00);
@@ -323,7 +324,7 @@ static int opera1_pid_filter_control(struct dvb_usb_adapter *adap, int onoff)
{.addr = ADDR_B1A6_STREAM_CTRL,.buf = b_pid,.len = 3},
};
if (dvb_usb_opera1_debug)
- info("%s hw-pidfilter", onoff ? "enable" : "disable");
+ info("%s hw-pidfilter", str_enable_disable(onoff));
for (; u < 0x7e; u += 2) {
b_pid[0] = u;
b_pid[1] = 0;
diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c
index a7eb11f7fb349114172cba5e02d1553ecbede2b2..c4af40ebc885a910ba1a3c95e7e80b9c7726576d 100644
--- a/drivers/media/usb/em28xx/em28xx-i2c.c
+++ b/drivers/media/usb/em28xx/em28xx-i2c.c
@@ -15,6 +15,7 @@
#include <linux/usb.h>
#include <linux/i2c.h>
#include <linux/jiffies.h>
+#include <linux/string_choices.h>
#include "xc2028.h"
#include <media/v4l2-common.h>
@@ -576,7 +577,7 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap,
goto error;
dprintk(2, "%s %s addr=%02x len=%d: %*ph\n",
- (msgs[i].flags & I2C_M_RD) ? "read" : "write",
+ str_read_write(msgs[i].flags & I2C_M_RD),
i == num - 1 ? "stop" : "nonstop",
addr, msgs[i].len,
msgs[i].len, msgs[i].buf);
@@ -587,7 +588,7 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap,
error:
dprintk(2, "%s %s addr=%02x len=%d: %sERROR: %i\n",
- (msgs[i].flags & I2C_M_RD) ? "read" : "write",
+ str_read_write(msgs[i].flags & I2C_M_RD),
i == num - 1 ? "stop" : "nonstop",
addr, msgs[i].len,
(rc == -ENODEV) ? "no device " : "",
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 66c09bc6d59ed29328c081c03e0084877ea8d7d0..1d0bc7d7d96220abb21df54ac25f472d17826441 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -24,6 +24,7 @@
#include <linux/mm.h>
#include <linux/mutex.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include "em28xx-v4l.h"
#include <media/v4l2-common.h>
@@ -938,14 +939,14 @@ static int em28xx_enable_analog_tuner(struct em28xx *dev)
dev_err(&dev->intf->dev,
"Couldn't change link %s->%s to %s. Error %d\n",
source->name, sink->name,
- flags ? "enabled" : "disabled",
+ str_enabled_disabled(flags),
ret);
return ret;
}
em28xx_videodbg("link %s->%s was %s\n",
source->name, sink->name,
- flags ? "ENABLED" : "disabled");
+ str_enabled_disabled(flags));
}
#endif
return 0;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-ctrl.c b/drivers/media/usb/pvrusb2/pvrusb2-ctrl.c
index 8ae3ad80cccb6826c70baff6fbfca7e1ce027a1c..5ae285042752f4e99b1b7155f8ddabd195adb97c 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-ctrl.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-ctrl.c
@@ -8,6 +8,7 @@
#include "pvrusb2-hdw-internal.h"
#include <linux/errno.h>
#include <linux/string.h>
+#include <linux/string_choices.h>
#include <linux/mutex.h>
@@ -521,7 +522,7 @@ int pvr2_ctrl_value_to_sym_internal(struct pvr2_ctrl *cptr,
*len = scnprintf(buf,maxlen,"%d",val);
ret = 0;
} else if (cptr->info->type == pvr2_ctl_bool) {
- *len = scnprintf(buf,maxlen,"%s",val ? "true" : "false");
+ *len = scnprintf(buf, maxlen, "%s", str_true_false(val));
ret = 0;
} else if (cptr->info->type == pvr2_ctl_enum) {
const char * const *names;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-debugifc.c b/drivers/media/usb/pvrusb2/pvrusb2-debugifc.c
index 81d711269ab57308493f8bd22f2f88b8d80b606b..9e4eb03133c9dce6cfde3790f69d2fc0a0cbe10a 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-debugifc.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-debugifc.c
@@ -5,6 +5,7 @@
*/
#include <linux/string.h>
+#include <linux/string_choices.h>
#include "pvrusb2-debugifc.h"
#include "pvrusb2-hdw.h"
#include "pvrusb2-debug.h"
@@ -148,7 +149,7 @@ int pvr2_debugifc_print_status(struct pvr2_hdw *hdw,
bcnt += ccnt; acnt -= ccnt; buf += ccnt;
ccnt = scnprintf(buf,acnt,"Streaming is %s\n",
- pvr2_hdw_get_streaming(hdw) ? "on" : "off");
+ str_on_off(pvr2_hdw_get_streaming(hdw)));
bcnt += ccnt; acnt -= ccnt; buf += ccnt;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-encoder.c b/drivers/media/usb/pvrusb2/pvrusb2-encoder.c
index c8102772344b8ea24c292e6b33a1947828bdcf69..adf5fcbb291db86906157c1ddda4db5c886f5478 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-encoder.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-encoder.c
@@ -7,6 +7,7 @@
#include <linux/device.h> // for linux/firmware.h
#include <linux/firmware.h>
+#include <linux/string_choices.h>
#include "pvrusb2-util.h"
#include "pvrusb2-encoder.h"
#include "pvrusb2-hdw-internal.h"
@@ -262,14 +263,13 @@ rdData[0]);
pvr2_trace(PVR2_TRACE_STBITS,
"State bit %s <-- %s",
"state_encoder_ok",
- (hdw->state_encoder_ok ? "true" : "false"));
+ str_true_false(hdw->state_encoder_ok));
if (hdw->state_encoder_runok) {
hdw->state_encoder_runok = 0;
pvr2_trace(PVR2_TRACE_STBITS,
"State bit %s <-- %s",
"state_encoder_runok",
- (hdw->state_encoder_runok ?
- "true" : "false"));
+ str_true_false(hdw->state_encoder_runok));
}
pvr2_trace(
PVR2_TRACE_ERROR_LEGS,
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 29cc207194b9fa55d13ad5d25607c75432de7cdc..79d2665d174c74771627c44d182ed1b8492141e1 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -6,6 +6,7 @@
#include <linux/errno.h>
#include <linux/string.h>
+#include <linux/string_choices.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/firmware.h>
@@ -338,7 +339,7 @@ static void trace_stbit(const char *name,int val)
{
pvr2_trace(PVR2_TRACE_STBITS,
"State bit %s <-- %s",
- name,(val ? "true" : "false"));
+ name, str_true_false(val));
}
static int ctrl_channelfreq_get(struct pvr2_ctrl *cptr,int *vp)
@@ -1660,7 +1661,7 @@ static int pvr2_decoder_enable(struct pvr2_hdw *hdw,int enablefl)
anyway, just in case somebody else wants to hear the
command... */
pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 stream=%s",
- (enablefl ? "on" : "off"));
+ str_on_off(enablefl));
v4l2_device_call_all(&hdw->v4l2_dev, 0, video, s_stream, enablefl);
v4l2_device_call_all(&hdw->v4l2_dev, 0, audio, s_stream, enablefl);
if (hdw->decoder_client_id) {
@@ -1724,7 +1725,7 @@ int pvr2_hdw_set_streaming(struct pvr2_hdw *hdw,int enable_flag)
hdw->state_pipeline_req = enable_flag != 0;
pvr2_trace(PVR2_TRACE_START_STOP,
"/*--TRACE_STREAM--*/ %s",
- enable_flag ? "enable" : "disable");
+ str_enable_disable(enable_flag));
}
pvr2_hdw_state_sched(hdw);
LOCK_GIVE(hdw->big_lock);
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
index 63db04fe12d39d599861204d98fecc5b2fc3dd58..c50c6a7bffffe5e995926ecf35be9177f7179407 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
@@ -6,6 +6,7 @@
#include <linux/i2c.h>
#include <linux/module.h>
+#include <linux/string_choices.h>
#include <media/i2c/ir-kbd-i2c.h>
#include "pvrusb2-i2c-core.h"
#include "pvrusb2-hdw-internal.h"
@@ -472,8 +473,7 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
idx+1,num,
msgs[idx].addr,
cnt,
- (msgs[idx].flags & I2C_M_RD ?
- "read" : "write"));
+ str_read_write(msgs[idx].flags & I2C_M_RD));
if ((ret > 0) || !(msgs[idx].flags & I2C_M_RD)) {
if (cnt > 8) cnt = 8;
pr_cont(" [");
--
2.43.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 5/6] media: platform: Use str_enable_disable-like helpers
2025-01-14 19:46 ` [PATCH 5/6] media: platform: " Krzysztof Kozlowski
@ 2025-01-14 20:42 ` Laurent Pinchart
2025-01-14 21:06 ` Krzysztof Kozlowski
2025-01-15 7:39 ` Sakari Ailus
0 siblings, 2 replies; 13+ messages in thread
From: Laurent Pinchart @ 2025-01-14 20:42 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Hans Verkuil, Mauro Carvalho Chehab, Tomasz Figa,
Marek Szyprowski, Maxim Levitsky, Sean Young, Olli Salonen,
Abylay Ospan, Jemma Denson, Patrick Boettcher, Jacopo Mondi,
Kieran Bingham, Niklas Söderlund, Tim Harvey, Andy Walls,
Sakari Ailus, Bingbu Cao, linux-media, linux-kernel
Hi Krzysztof,
Thank you for the patch.
On Tue, Jan 14, 2025 at 08:46:21PM +0100, Krzysztof Kozlowski wrote:
> Replace ternary (condition ? "enable" : "disable") syntax with helpers
> from string_choices.h because:
> 1. Simple function call with one argument is easier to read. Ternary
> operator has three arguments and with wrapping might lead to quite
> long code.
It's more difficult to read for me.
> 2. Is slightly shorter thus also easier to read.
> 3. It brings uniformity in the text - same string.
> 4. Allows deduping by the linker, which results in a smaller binary
> file.
I don't see why the linker can't de-dup string in the current code.
I'm sorry, I just don't see the point in doing this. I'd like to avoid
those changes in the Linux media subsystem, or at the very least in
drivers I maintain.
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> drivers/media/platform/amphion/venc.c | 3 ++-
> drivers/media/platform/amphion/vpu_dbg.c | 3 ++-
> drivers/media/platform/aspeed/aspeed-video.c | 5 +++--
> drivers/media/platform/chips-media/coda/coda-bit.c | 3 ++-
> drivers/media/platform/chips-media/coda/imx-vdoa.c | 3 ++-
> drivers/media/platform/st/sti/hva/hva-debugfs.c | 7 ++++---
> drivers/media/platform/ti/cal/cal-camerarx.c | 3 ++-
> drivers/media/platform/ti/omap3isp/ispstat.c | 3 ++-
> drivers/media/platform/xilinx/xilinx-csi2rxss.c | 19 ++++++++++---------
> 9 files changed, 29 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/media/platform/amphion/venc.c b/drivers/media/platform/amphion/venc.c
> index c5c1f1fbaa80366d5b18b8f24699eb9c3a18ef92..65b1665eece8cd6efc535281b3be593abaf9ba64 100644
> --- a/drivers/media/platform/amphion/venc.c
> +++ b/drivers/media/platform/amphion/venc.c
> @@ -13,6 +13,7 @@
> #include <linux/videodev2.h>
> #include <linux/ktime.h>
> #include <linux/rational.h>
> +#include <linux/string_choices.h>
> #include <linux/vmalloc.h>
> #include <media/v4l2-device.h>
> #include <media/v4l2-event.h>
> @@ -1215,7 +1216,7 @@ static int venc_get_debug_info(struct vpu_inst *inst, char *str, u32 size, u32 i
> break;
> case 8:
> num = scnprintf(str, size, "rc: %s, mode = %d, bitrate = %d(%d), qp = %d\n",
> - venc->params.rc_enable ? "enable" : "disable",
> + str_enable_disable(venc->params.rc_enable),
> venc->params.rc_mode,
> venc->params.bitrate,
> venc->params.bitrate_max,
> diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platform/amphion/vpu_dbg.c
> index 940e5bda5fa391c47552c275bd1266f47d57f475..b726d884086d306cd4298dc46440a2235b311b86 100644
> --- a/drivers/media/platform/amphion/vpu_dbg.c
> +++ b/drivers/media/platform/amphion/vpu_dbg.c
> @@ -11,6 +11,7 @@
> #include <linux/kernel.h>
> #include <linux/types.h>
> #include <linux/pm_runtime.h>
> +#include <linux/string_choices.h>
> #include <media/v4l2-device.h>
> #include <linux/debugfs.h>
> #include "vpu.h"
> @@ -256,7 +257,7 @@ static int vpu_dbg_core(struct seq_file *s, void *data)
> return 0;
>
> num = scnprintf(str, sizeof(str), "power %s\n",
> - vpu_iface_get_power_state(core) ? "on" : "off");
> + str_on_off(vpu_iface_get_power_state(core)));
> if (seq_write(s, str, num))
> return 0;
> num = scnprintf(str, sizeof(str), "state = %d\n", core->state);
> diff --git a/drivers/media/platform/aspeed/aspeed-video.c b/drivers/media/platform/aspeed/aspeed-video.c
> index 54cae0da9aca3fd74800b51f79136a261aec241a..d9cf12af05b75c76c506f6e7d72dfc41c9e05317 100644
> --- a/drivers/media/platform/aspeed/aspeed-video.c
> +++ b/drivers/media/platform/aspeed/aspeed-video.c
> @@ -19,6 +19,7 @@
> #include <linux/sched.h>
> #include <linux/spinlock.h>
> #include <linux/string.h>
> +#include <linux/string_choices.h>
> #include <linux/v4l2-controls.h>
> #include <linux/videodev2.h>
> #include <linux/wait.h>
> @@ -1227,7 +1228,7 @@ static void aspeed_video_update_regs(struct aspeed_video *video)
> v4l2_dbg(1, debug, &video->v4l2_dev, "compression quality(%d)\n",
> video->jpeg_quality);
> v4l2_dbg(1, debug, &video->v4l2_dev, "hq_mode(%s) hq_quality(%d)\n",
> - video->hq_mode ? "on" : "off", video->jpeg_hq_quality);
> + str_on_off(video->hq_mode), video->jpeg_hq_quality);
>
> if (video->format == VIDEO_FMT_ASPEED)
> aspeed_video_update(video, VE_BCD_CTRL, 0, VE_BCD_CTRL_EN_BCD);
> @@ -1939,7 +1940,7 @@ static int aspeed_video_debugfs_show(struct seq_file *s, void *data)
> seq_printf(s, " %-20s:\t%d\n", "Quality", v->jpeg_quality);
> if (v->format == VIDEO_FMT_ASPEED) {
> seq_printf(s, " %-20s:\t%s\n", "HQ Mode",
> - v->hq_mode ? "on" : "off");
> + str_on_off(v->hq_mode));
> seq_printf(s, " %-20s:\t%d\n", "HQ Quality",
> v->hq_mode ? v->jpeg_hq_quality : 0);
> }
> diff --git a/drivers/media/platform/chips-media/coda/coda-bit.c b/drivers/media/platform/chips-media/coda/coda-bit.c
> index 84ded154adfe37147218d60278a1c1fac88ecadc..2cb0c04003da750f7108578e274da31778c3f2d2 100644
> --- a/drivers/media/platform/chips-media/coda/coda-bit.c
> +++ b/drivers/media/platform/chips-media/coda/coda-bit.c
> @@ -16,6 +16,7 @@
> #include <linux/ratelimit.h>
> #include <linux/reset.h>
> #include <linux/slab.h>
> +#include <linux/string_choices.h>
> #include <linux/videodev2.h>
>
> #include <media/v4l2-common.h>
> @@ -1881,7 +1882,7 @@ static int __coda_decoder_seq_init(struct coda_ctx *ctx)
> lockdep_assert_held(&dev->coda_mutex);
>
> coda_dbg(1, ctx, "Video Data Order Adapter: %s\n",
> - ctx->use_vdoa ? "Enabled" : "Disabled");
> + str_enabled_disabled(ctx->use_vdoa));
>
> /* Start decoding */
> q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
> diff --git a/drivers/media/platform/chips-media/coda/imx-vdoa.c b/drivers/media/platform/chips-media/coda/imx-vdoa.c
> index c3561fcecb98c7d3cd741c28afcb2a3854eaa0e7..abdff181d417788460b7f6230ea54789b242d436 100644
> --- a/drivers/media/platform/chips-media/coda/imx-vdoa.c
> +++ b/drivers/media/platform/chips-media/coda/imx-vdoa.c
> @@ -15,6 +15,7 @@
> #include <linux/platform_device.h>
> #include <linux/videodev2.h>
> #include <linux/slab.h>
> +#include <linux/string_choices.h>
>
> #include "imx-vdoa.h"
>
> @@ -117,7 +118,7 @@ static irqreturn_t vdoa_irq_handler(int irq, void *data)
> writel(val, vdoa->regs + VDOAIST);
> if (val & VDOAIST_TERR) {
> val = readl(vdoa->regs + VDOASR) & VDOASR_ERRW;
> - dev_err(vdoa->dev, "AXI %s error\n", val ? "write" : "read");
> + dev_err(vdoa->dev, "AXI %s error\n", str_write_read(val));
> } else if (!(val & VDOAIST_EOT)) {
> dev_warn(vdoa->dev, "Spurious interrupt\n");
> }
> diff --git a/drivers/media/platform/st/sti/hva/hva-debugfs.c b/drivers/media/platform/st/sti/hva/hva-debugfs.c
> index a86a07b6fbc792fc06db2dbbb3934694136a7813..1cb5bca44939606f39911a41e5f464be888848c2 100644
> --- a/drivers/media/platform/st/sti/hva/hva-debugfs.c
> +++ b/drivers/media/platform/st/sti/hva/hva-debugfs.c
> @@ -6,6 +6,7 @@
> */
>
> #include <linux/debugfs.h>
> +#include <linux/string_choices.h>
>
> #include "hva.h"
> #include "hva-hw.h"
> @@ -71,12 +72,12 @@ static void format_ctx(struct seq_file *s, struct hva_ctx *ctx)
> " | |- SEI frame packing type=%s\n",
> v4l2_ctrl_get_menu(entropy)[ctrls->entropy_mode],
> ctrls->cpb_size,
> - ctrls->dct8x8 ? "true" : "false",
> + str_true_false(ctrls->dct8x8),
> ctrls->qpmin,
> ctrls->qpmax,
> - ctrls->vui_sar ? "true" : "false",
> + str_true_false(ctrls->vui_sar),
> v4l2_ctrl_get_menu(vui_sar)[ctrls->vui_sar_idc],
> - ctrls->sei_fp ? "true" : "false",
> + str_true_false(ctrls->sei_fp),
> v4l2_ctrl_get_menu(sei_fp)[ctrls->sei_fp_type]);
> }
>
> diff --git a/drivers/media/platform/ti/cal/cal-camerarx.c b/drivers/media/platform/ti/cal/cal-camerarx.c
> index 42dfe08b765f6bbdb0ab8cca0f7d6d87f2ff18eb..a70814cbada82654e926b12bcde73300107aaa8a 100644
> --- a/drivers/media/platform/ti/cal/cal-camerarx.c
> +++ b/drivers/media/platform/ti/cal/cal-camerarx.c
> @@ -17,6 +17,7 @@
> #include <linux/platform_device.h>
> #include <linux/regmap.h>
> #include <linux/slab.h>
> +#include <linux/string_choices.h>
>
> #include <media/v4l2-ctrls.h>
> #include <media/v4l2-fwnode.h>
> @@ -191,7 +192,7 @@ static void cal_camerarx_power(struct cal_camerarx *phy, bool enable)
>
> if (i == 10)
> phy_err(phy, "Failed to power %s complexio\n",
> - enable ? "up" : "down");
> + str_up_down(enable));
> }
>
> static void cal_camerarx_wait_reset(struct cal_camerarx *phy)
> diff --git a/drivers/media/platform/ti/omap3isp/ispstat.c b/drivers/media/platform/ti/omap3isp/ispstat.c
> index 359a846205b0ffe9e736c7ed37c22677991cc9f2..f1293d412415d3fe36a87e7aa93a60e7daf693d8 100644
> --- a/drivers/media/platform/ti/omap3isp/ispstat.c
> +++ b/drivers/media/platform/ti/omap3isp/ispstat.c
> @@ -14,6 +14,7 @@
>
> #include <linux/dma-mapping.h>
> #include <linux/slab.h>
> +#include <linux/string_choices.h>
> #include <linux/timekeeping.h>
> #include <linux/uaccess.h>
>
> @@ -768,7 +769,7 @@ int omap3isp_stat_enable(struct ispstat *stat, u8 enable)
> unsigned long irqflags;
>
> dev_dbg(stat->isp->dev, "%s: user wants to %s module.\n",
> - stat->subdev.name, enable ? "enable" : "disable");
> + stat->subdev.name, str_enable_disable(enable));
>
> /* Prevent enabling while configuring */
> mutex_lock(&stat->ioctl_lock);
> diff --git a/drivers/media/platform/xilinx/xilinx-csi2rxss.c b/drivers/media/platform/xilinx/xilinx-csi2rxss.c
> index 146131b8f37e5a30b168164d4eaedc9641d6af31..a5074f05cee50e117256fdb8496b977332757e27 100644
> --- a/drivers/media/platform/xilinx/xilinx-csi2rxss.c
> +++ b/drivers/media/platform/xilinx/xilinx-csi2rxss.c
> @@ -16,6 +16,7 @@
> #include <linux/of.h>
> #include <linux/of_irq.h>
> #include <linux/platform_device.h>
> +#include <linux/string_choices.h>
> #include <linux/v4l2-subdev.h>
> #include <media/media-entity.h>
> #include <media/mipi-csi2.h>
> @@ -400,19 +401,19 @@ static int xcsi2rxss_log_status(struct v4l2_subdev *sd)
> dev_info(dev, "***** Core Status *****\n");
> data = xcsi2rxss_read(xcsi2rxss, XCSI_CSR_OFFSET);
> dev_info(dev, "Short Packet FIFO Full = %s\n",
> - data & XCSI_CSR_SPFIFOFULL ? "true" : "false");
> + str_true_false(data & XCSI_CSR_SPFIFOFULL));
> dev_info(dev, "Short Packet FIFO Not Empty = %s\n",
> - data & XCSI_CSR_SPFIFONE ? "true" : "false");
> + str_true_false(data & XCSI_CSR_SPFIFONE));
> dev_info(dev, "Stream line buffer full = %s\n",
> - data & XCSI_CSR_SLBF ? "true" : "false");
> + str_true_false(data & XCSI_CSR_SLBF));
> dev_info(dev, "Soft reset/Core disable in progress = %s\n",
> - data & XCSI_CSR_RIPCD ? "true" : "false");
> + str_true_false(data & XCSI_CSR_RIPCD));
>
> /* Clk & Lane Info */
> dev_info(dev, "******** Clock Lane Info *********\n");
> data = xcsi2rxss_read(xcsi2rxss, XCSI_CLKINFR_OFFSET);
> dev_info(dev, "Clock Lane in Stop State = %s\n",
> - data & XCSI_CLKINFR_STOP ? "true" : "false");
> + str_true_false(data & XCSI_CLKINFR_STOP));
>
> dev_info(dev, "******** Data Lane Info *********\n");
> dev_info(dev, "Lane\tSoT Error\tSoT Sync Error\tStop State\n");
> @@ -421,9 +422,9 @@ static int xcsi2rxss_log_status(struct v4l2_subdev *sd)
> data = xcsi2rxss_read(xcsi2rxss, reg);
>
> dev_info(dev, "%d\t%s\t\t%s\t\t%s\n", i,
> - data & XCSI_DLXINFR_SOTERR ? "true" : "false",
> - data & XCSI_DLXINFR_SOTSYNCERR ? "true" : "false",
> - data & XCSI_DLXINFR_STOP ? "true" : "false");
> + str_true_false(data & XCSI_DLXINFR_SOTERR),
> + str_true_false(data & XCSI_DLXINFR_SOTSYNCERR),
> + str_true_false(data & XCSI_DLXINFR_STOP));
>
> reg += XCSI_NEXTREG_OFFSET;
> }
> @@ -889,7 +890,7 @@ static int xcsi2rxss_parse_of(struct xcsi2rxss_state *xcsi2rxss)
> fwnode_handle_put(ep);
>
> dev_dbg(dev, "vcx %s, %u data lanes (%s), data type 0x%02x\n",
> - xcsi2rxss->en_vcx ? "enabled" : "disabled",
> + str_enabled_disabled(xcsi2rxss->en_vcx),
> xcsi2rxss->max_num_lanes,
> xcsi2rxss->enable_active_lanes ? "dynamic" : "static",
> xcsi2rxss->datatype);
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 5/6] media: platform: Use str_enable_disable-like helpers
2025-01-14 20:42 ` Laurent Pinchart
@ 2025-01-14 21:06 ` Krzysztof Kozlowski
2025-01-15 7:44 ` Laurent Pinchart
2025-01-15 7:39 ` Sakari Ailus
1 sibling, 1 reply; 13+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-14 21:06 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Hans Verkuil, Mauro Carvalho Chehab, Tomasz Figa,
Marek Szyprowski, Maxim Levitsky, Sean Young, Olli Salonen,
Abylay Ospan, Jemma Denson, Patrick Boettcher, Jacopo Mondi,
Kieran Bingham, Niklas Söderlund, Tim Harvey, Andy Walls,
Sakari Ailus, Bingbu Cao, linux-media, linux-kernel
On 14/01/2025 21:42, Laurent Pinchart wrote:
> Hi Krzysztof,
>
> Thank you for the patch.
>
> On Tue, Jan 14, 2025 at 08:46:21PM +0100, Krzysztof Kozlowski wrote:
>> Replace ternary (condition ? "enable" : "disable") syntax with helpers
>> from string_choices.h because:
>> 1. Simple function call with one argument is easier to read. Ternary
>> operator has three arguments and with wrapping might lead to quite
>> long code.
>
> It's more difficult to read for me.
That's obviously subjective, but I am surprised that such stuff is
readable for you:
data & XCSI_DLXINFR_SOTERR ? "true" : "false",
video->hq_mode ? "on" : "off", video->jpeg_hq_quality);
or from PCI parts of this set, note that's ternary is split here:
dstat & BT848_DSTATUS_HLOC
? "yes" : "no");
>
>> 2. Is slightly shorter thus also easier to read.
>> 3. It brings uniformity in the text - same string.
>> 4. Allows deduping by the linker, which results in a smaller binary
>> file.
>
> I don't see why the linker can't de-dup string in the current code.
>
> I'm sorry, I just don't see the point in doing this. I'd like to avoid
> those changes in the Linux media subsystem, or at the very least in
> drivers I maintain.
Ack.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 5/6] media: platform: Use str_enable_disable-like helpers
2025-01-14 20:42 ` Laurent Pinchart
2025-01-14 21:06 ` Krzysztof Kozlowski
@ 2025-01-15 7:39 ` Sakari Ailus
2025-01-15 7:47 ` Tomasz Figa
1 sibling, 1 reply; 13+ messages in thread
From: Sakari Ailus @ 2025-01-15 7:39 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Krzysztof Kozlowski, Hans Verkuil, Mauro Carvalho Chehab,
Tomasz Figa, Marek Szyprowski, Maxim Levitsky, Sean Young,
Olli Salonen, Abylay Ospan, Jemma Denson, Patrick Boettcher,
Jacopo Mondi, Kieran Bingham, Niklas Söderlund, Tim Harvey,
Andy Walls, Bingbu Cao, linux-media, linux-kernel
Hi Laurent,
On Tue, Jan 14, 2025 at 10:42:40PM +0200, Laurent Pinchart wrote:
> Hi Krzysztof,
>
> Thank you for the patch.
>
> On Tue, Jan 14, 2025 at 08:46:21PM +0100, Krzysztof Kozlowski wrote:
> > Replace ternary (condition ? "enable" : "disable") syntax with helpers
> > from string_choices.h because:
> > 1. Simple function call with one argument is easier to read. Ternary
> > operator has three arguments and with wrapping might lead to quite
> > long code.
>
> It's more difficult to read for me.
I don't have any issue in using the ternary operator either. Using these
helpers makes the lines generally 3 characters shorter.
>
> > 2. Is slightly shorter thus also easier to read.
> > 3. It brings uniformity in the text - same string.
> > 4. Allows deduping by the linker, which results in a smaller binary
> > file.
>
> I don't see why the linker can't de-dup string in the current code.
In fact the functions are static inline so from that point of view I don't
think there's any difference.
>
> I'm sorry, I just don't see the point in doing this. I'd like to avoid
> those changes in the Linux media subsystem, or at the very least in
> drivers I maintain.
I don't have much of an opinion, perhaps I slightly prefer using these as
the rest of the kernel does, too. Yet if we choose not to use these
helpers, we continue to be occasional targets of largish patchsets "fixing"
this.
--
Kind regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 5/6] media: platform: Use str_enable_disable-like helpers
2025-01-14 21:06 ` Krzysztof Kozlowski
@ 2025-01-15 7:44 ` Laurent Pinchart
0 siblings, 0 replies; 13+ messages in thread
From: Laurent Pinchart @ 2025-01-15 7:44 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Hans Verkuil, Mauro Carvalho Chehab, Tomasz Figa,
Marek Szyprowski, Maxim Levitsky, Sean Young, Olli Salonen,
Abylay Ospan, Jemma Denson, Patrick Boettcher, Jacopo Mondi,
Kieran Bingham, Niklas Söderlund, Tim Harvey, Andy Walls,
Sakari Ailus, Bingbu Cao, linux-media, linux-kernel
On Tue, Jan 14, 2025 at 10:06:15PM +0100, Krzysztof Kozlowski wrote:
> On 14/01/2025 21:42, Laurent Pinchart wrote:
> > Hi Krzysztof,
> >
> > Thank you for the patch.
> >
> > On Tue, Jan 14, 2025 at 08:46:21PM +0100, Krzysztof Kozlowski wrote:
> >> Replace ternary (condition ? "enable" : "disable") syntax with helpers
> >> from string_choices.h because:
> >> 1. Simple function call with one argument is easier to read. Ternary
> >> operator has three arguments and with wrapping might lead to quite
> >> long code.
> >
> > It's more difficult to read for me.
>
> That's obviously subjective, but I am surprised that such stuff is
> readable for you:
>
> data & XCSI_DLXINFR_SOTERR ? "true" : "false",
> video->hq_mode ? "on" : "off", video->jpeg_hq_quality);
>
> or from PCI parts of this set, note that's ternary is split here:
>
> dstat & BT848_DSTATUS_HLOC
> ? "yes" : "no");
That's likely due to being used to reading those constructs, and is
certainly subjective. I can't tell what option would objectively be
best, but I have a feeling there's actually no objective best.
> >> 2. Is slightly shorter thus also easier to read.
> >> 3. It brings uniformity in the text - same string.
> >> 4. Allows deduping by the linker, which results in a smaller binary
> >> file.
> >
> > I don't see why the linker can't de-dup string in the current code.
> >
> > I'm sorry, I just don't see the point in doing this. I'd like to avoid
> > those changes in the Linux media subsystem, or at the very least in
> > drivers I maintain.
>
> Ack.
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 5/6] media: platform: Use str_enable_disable-like helpers
2025-01-15 7:39 ` Sakari Ailus
@ 2025-01-15 7:47 ` Tomasz Figa
2025-02-20 13:51 ` Hans Verkuil
0 siblings, 1 reply; 13+ messages in thread
From: Tomasz Figa @ 2025-01-15 7:47 UTC (permalink / raw)
To: Sakari Ailus
Cc: Laurent Pinchart, Krzysztof Kozlowski, Hans Verkuil,
Mauro Carvalho Chehab, Marek Szyprowski, Maxim Levitsky,
Sean Young, Olli Salonen, Abylay Ospan, Jemma Denson,
Patrick Boettcher, Jacopo Mondi, Kieran Bingham,
Niklas Söderlund, Tim Harvey, Andy Walls, Bingbu Cao,
linux-media, linux-kernel
On Wed, Jan 15, 2025 at 4:39 PM Sakari Ailus
<sakari.ailus@linux.intel.com> wrote:
>
> Hi Laurent,
>
> On Tue, Jan 14, 2025 at 10:42:40PM +0200, Laurent Pinchart wrote:
> > Hi Krzysztof,
> >
> > Thank you for the patch.
> >
> > On Tue, Jan 14, 2025 at 08:46:21PM +0100, Krzysztof Kozlowski wrote:
> > > Replace ternary (condition ? "enable" : "disable") syntax with helpers
> > > from string_choices.h because:
> > > 1. Simple function call with one argument is easier to read. Ternary
> > > operator has three arguments and with wrapping might lead to quite
> > > long code.
> >
> > It's more difficult to read for me.
>
> I don't have any issue in using the ternary operator either. Using these
> helpers makes the lines generally 3 characters shorter.
>
> >
> > > 2. Is slightly shorter thus also easier to read.
> > > 3. It brings uniformity in the text - same string.
> > > 4. Allows deduping by the linker, which results in a smaller binary
> > > file.
> >
> > I don't see why the linker can't de-dup string in the current code.
>
> In fact the functions are static inline so from that point of view I don't
> think there's any difference.
>
> >
> > I'm sorry, I just don't see the point in doing this. I'd like to avoid
> > those changes in the Linux media subsystem, or at the very least in
> > drivers I maintain.
>
> I don't have much of an opinion, perhaps I slightly prefer using these as
> the rest of the kernel does, too. Yet if we choose not to use these
> helpers, we continue to be occasional targets of largish patchsets "fixing"
> this.
To put one more aspect on the scales:
These kinds of patches actually make it more difficult to backport
changes (e.g. fixes) to stable kernels, so my preference would be to
only use the new helpers in new drivers.
Best regards,
Tomasz
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 5/6] media: platform: Use str_enable_disable-like helpers
2025-01-15 7:47 ` Tomasz Figa
@ 2025-02-20 13:51 ` Hans Verkuil
0 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2025-02-20 13:51 UTC (permalink / raw)
To: Tomasz Figa, Sakari Ailus
Cc: Laurent Pinchart, Krzysztof Kozlowski, Mauro Carvalho Chehab,
Marek Szyprowski, Maxim Levitsky, Sean Young, Olli Salonen,
Abylay Ospan, Jemma Denson, Patrick Boettcher, Jacopo Mondi,
Kieran Bingham, Niklas Söderlund, Tim Harvey, Andy Walls,
Bingbu Cao, linux-media, linux-kernel
On 1/15/25 08:47, Tomasz Figa wrote:
> On Wed, Jan 15, 2025 at 4:39 PM Sakari Ailus
> <sakari.ailus@linux.intel.com> wrote:
>>
>> Hi Laurent,
>>
>> On Tue, Jan 14, 2025 at 10:42:40PM +0200, Laurent Pinchart wrote:
>>> Hi Krzysztof,
>>>
>>> Thank you for the patch.
>>>
>>> On Tue, Jan 14, 2025 at 08:46:21PM +0100, Krzysztof Kozlowski wrote:
>>>> Replace ternary (condition ? "enable" : "disable") syntax with helpers
>>>> from string_choices.h because:
>>>> 1. Simple function call with one argument is easier to read. Ternary
>>>> operator has three arguments and with wrapping might lead to quite
>>>> long code.
>>>
>>> It's more difficult to read for me.
>>
>> I don't have any issue in using the ternary operator either. Using these
>> helpers makes the lines generally 3 characters shorter.
>>
>>>
>>>> 2. Is slightly shorter thus also easier to read.
>>>> 3. It brings uniformity in the text - same string.
>>>> 4. Allows deduping by the linker, which results in a smaller binary
>>>> file.
>>>
>>> I don't see why the linker can't de-dup string in the current code.
>>
>> In fact the functions are static inline so from that point of view I don't
>> think there's any difference.
>>
>>>
>>> I'm sorry, I just don't see the point in doing this. I'd like to avoid
>>> those changes in the Linux media subsystem, or at the very least in
>>> drivers I maintain.
>>
>> I don't have much of an opinion, perhaps I slightly prefer using these as
>> the rest of the kernel does, too. Yet if we choose not to use these
>> helpers, we continue to be occasional targets of largish patchsets "fixing"
>> this.
>
> To put one more aspect on the scales:
>
> These kinds of patches actually make it more difficult to backport
> changes (e.g. fixes) to stable kernels, so my preference would be to
> only use the new helpers in new drivers.
I agree with Tomasz. Now, if the whole kernel is converting to these
new functions, then I guess we should follow, but from what I can tell
that doesn't appear to be the case.
I'll reject this series. It can always be resurrected if there is
sufficient demand for this.
Regards,
Hans
>
> Best regards,
> Tomasz
>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-02-20 13:51 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-14 19:46 [PATCH 0/6] media: Use str_enable_disable-like helpers Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 1/6] " Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 2/6] media: dvb: " Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 3/6] media: i2c: " Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 4/6] media: pci: " Krzysztof Kozlowski
2025-01-14 19:46 ` [PATCH 5/6] media: platform: " Krzysztof Kozlowski
2025-01-14 20:42 ` Laurent Pinchart
2025-01-14 21:06 ` Krzysztof Kozlowski
2025-01-15 7:44 ` Laurent Pinchart
2025-01-15 7:39 ` Sakari Ailus
2025-01-15 7:47 ` Tomasz Figa
2025-02-20 13:51 ` Hans Verkuil
2025-01-14 19:46 ` [PATCH 6/6] media: usb: " Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®