@@ -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],
@@ -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;
@@ -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);
}
@@ -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)
@@ -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 =
@@ -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)
@@ -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;
@@ -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 " : "",
@@ -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;
@@ -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;
@@ -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;
@@ -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,
@@ -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);
@@ -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(" [");
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(-)