Skip to contentSkip to conversation

Several static analizer fixes

PATCH In review Mauro Carvalho Chehab 8 participants 61 messages Sep 3, 2014 – Sep 5, 2014

Subsystems (24)
lore
Share & tools
lore
#0 lore raw

cover Several static analizer fixes

There are several small issues reported by static analyzers. Let's fix some of them on this patch series. One of this patch is a real bug (dmxdev one, at patch 01/46).

The other ones are just code cleanups.

The main goal is to be able to run a static analyzer test more frequently, so we want to have a cleaner report.

Mauro Carvalho Chehab (46):
[media] dmxdev: don't use before checking file->private_data [media] marvel-ccic: don't initialize static vars with 0 [media] soc_camera: use kmemdup()
[media] vivid-vid-out: use memdup_user()
[media] s5k5baf: remove an uneeded semicolon [media] bttv-driver: remove an uneeded semicolon [media] soc_camera: remove uneeded semicolons [media] stv0900_core: don't allocate a temporary var [media] em28xx: use true/false for boolean vars [media] tuner-core: use true/false for boolean vars [media] af9013: use true/false for boolean vars [media] cxd2820r: use true/false for boolean vars [media] m88ds3103: use true/false for boolean vars [media] af9013: use true/false for boolean vars [media] tda10071: use true/false for boolean vars [media] smiapp-core: use true/false for boolean vars [media] ov9740: use true/false for boolean vars [media] omap3isp: use true/false for boolean vars [media] ti-vpe: use true/false for boolean vars [media] vivid-tpg: use true/false for boolean vars [media] radio: use true/false for boolean vars [media] ene_ir: use true/false for boolean vars [media] au0828-dvb: use true/false for boolean vars [media] lmedm04: use true/false for boolean vars [media] af9005: use true/false for boolean vars [media] msi2500: simplify boolean tests
[media] drxk_hard: simplify test logic
[media] lm3560: simplify boolean tests
[media] lm3560: simplify a boolean test
[media] omap: simplify test logic
[media] via-camera: simplify boolean tests
[media] e4000: simplify boolean tests
[media] s5p-tv: Simplify the return logic
[media] siano: just return 0 instead of using a var [media] stv0367: just return 0 instead of using a var [media] media-devnode: just return 0 instead of using a var [media] bt8xx: just return 0 instead of using a var [media] saa7164: just return 0 instead of using a var [media] davinci: just return 0 instead of using a var [media] marvel-ccic: just return 0 instead of using a var [media] fintek-cir: just return 0 instead of using a var [media] ite-cir: just return 0 instead of using a var [media] nuvoton-cir: just return 0 instead of using a var [media] mt2060: just return 0 instead of using a var [media] mxl5005s: just return 0 instead of using a var [media] cx231xx: just return 0 instead of using a var

 drivers/media/common/siano/smscoreapi.c            |  4 +--
 drivers/media/dvb-core/dmxdev.c                    |  3 +-
 drivers/media/dvb-frontends/af9013.c               | 24 +++++++--------
 drivers/media/dvb-frontends/cxd2820r_c.c           |  4 +--
 drivers/media/dvb-frontends/cxd2820r_core.c        |  4 +--
 drivers/media/dvb-frontends/cxd2820r_t.c           |  4 +--
 drivers/media/dvb-frontends/drxk_hard.c            | 34 +++++++++++-----------
 drivers/media/dvb-frontends/m88ds3103.c            | 12 ++++----
 drivers/media/dvb-frontends/rtl2832.c              |  2 +-
 drivers/media/dvb-frontends/rtl2832_sdr.c          |  2 +-
 drivers/media/dvb-frontends/stv0367.c              |  4 +--
 drivers/media/dvb-frontends/stv0900_core.c         |  7 ++---
 drivers/media/dvb-frontends/tda10071.c             |  2 +-
 drivers/media/i2c/lm3560.c                         |  4 +--
 drivers/media/i2c/s5k5baf.c                        |  2 +-
 drivers/media/i2c/smiapp/smiapp-core.c             |  8 ++---
 drivers/media/i2c/soc_camera/ov9740.c              |  4 +--
 drivers/media/media-devnode.c                      |  3 +-
 drivers/media/pci/bt8xx/bttv-driver.c              |  5 ++--
 drivers/media/pci/bt8xx/dst_ca.c                   |  4 +--
 drivers/media/pci/saa7164/saa7164-api.c            |  3 +-
 drivers/media/pci/zoran/zoran_device.c             |  2 +-
 drivers/media/platform/davinci/vpfe_capture.c      |  3 +-
 drivers/media/platform/exynos4-is/fimc-isp-video.c |  3 +-
 drivers/media/platform/marvell-ccic/mcam-core.c    |  2 +-
 drivers/media/platform/omap/omap_vout.c            |  8 ++---
 drivers/media/platform/omap/omap_vout_vrfb.c       | 10 +++----
 drivers/media/platform/omap3isp/ispccdc.c          |  2 +-
 drivers/media/platform/s5p-tv/hdmi_drv.c           |  2 +-
 drivers/media/platform/s5p-tv/sdo_drv.c            |  2 +-
 drivers/media/platform/s5p-tv/sii9234_drv.c        |  2 +-
 drivers/media/platform/soc_camera/pxa_camera.c     |  2 +-
 drivers/media/platform/soc_camera/rcar_vin.c       |  2 +-
 drivers/media/platform/soc_camera/soc_camera.c     |  4 +--
 drivers/media/platform/ti-vpe/vpe.c                |  4 +--
 drivers/media/platform/via-camera.c                |  2 +-
 drivers/media/platform/vivid/vivid-tpg.c           |  4 +--
 drivers/media/platform/vivid/vivid-vid-out.c       | 10 ++-----
 drivers/media/radio/radio-gemtek.c                 |  2 +-
 drivers/media/radio/radio-sf16fmi.c                |  4 +--
 drivers/media/radio/si470x/radio-si470x-common.c   |  4 +--
 drivers/media/rc/ene_ir.c                          |  2 +-
 drivers/media/rc/fintek-cir.c                      |  6 ++--
 drivers/media/rc/ite-cir.c                         |  3 +-
 drivers/media/rc/nuvoton-cir.c                     |  6 ++--
 drivers/media/tuners/e4000.c                       |  4 +--
 drivers/media/tuners/mt2060.c                      |  3 +-
 drivers/media/tuners/mxl5005s.c                    |  3 +-
 drivers/media/usb/au0828/au0828-dvb.c              |  2 +-
 drivers/media/usb/cx231xx/cx231xx-dvb.c            |  4 +--
 drivers/media/usb/dvb-usb-v2/lmedm04.c             |  2 +-
 drivers/media/usb/dvb-usb/af9005.c                 |  2 +-
 drivers/media/usb/em28xx/em28xx-input.c            |  6 ++--
 drivers/media/usb/em28xx/em28xx-video.c            |  4 +--
 drivers/media/usb/msi2500/msi2500.c                |  2 +-
 drivers/media/v4l2-core/tuner-core.c               |  2 +-
 56 files changed, 117 insertions(+), 147 deletions(-)
Signature · 1 line
1.9.3
#1 lore raw

PATCH 1/46 dmxdev: don't use before checking file->private_data

As reported by smatch:
drivers/media/dvb-core/dmxdev.c:1091 dvb_demux_poll() warn: variable dereferenced before check 'dmxdevfilter' (see line 1088)

This was introduced by changeset d102cac8097c.

We need to test if dmxdevfilter exists before using it.

drivers/media/dvb-core/dmxdev.c +1 -2
index 42b5e70d5ca7..abff803ad69a 100644
@@ -1085,10 +1085,9 @@ static long dvb_demux_ioctl(struct file *file, unsigned int cmd,
 static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
 {
 	struct dmxdev_filter *dmxdevfilter = file->private_data;
-	struct dmxdev *dmxdev = dmxdevfilter->dev;
 	unsigned int mask = 0;
 
-	if ((!dmxdevfilter) || (dmxdev->exit))
+	if ((!dmxdevfilter) || dmxdevfilter->dev->exit)
 		return POLLERR;
 
 	poll_wait(file, &dmxdevfilter->buffer.queue, wait);
Signature · 1 line
1.9.3
#2 lore raw

PATCH 2/46 marvel-ccic: don't initialize static vars with 0

In reply to Mauro Carvalho Chehab

alloc_bufs_at_read is static. No need to initialize with zero, as the Kernel will cleanup the data memory already.

drivers/media/platform/marvell-ccic/mcam-core.c +1 -1
index be4b51212106..7a86c77bffa0 100644
@@ -67,7 +67,7 @@ MODULE_PARM_DESC(dma_buf_size,
 		"parameters require larger buffers, an attempt to reallocate "
 		"will be made.");
 #else /* MCAM_MODE_VMALLOC */
-static const bool alloc_bufs_at_read = 0;
+static const bool alloc_bufs_at_read;
 static const int n_dma_bufs = 3;  /* Used by S/G_PARM */
 #endif /* MCAM_MODE_VMALLOC */
 
Signature · 1 line
1.9.3
#3 lore raw

PATCH 3/46 soc_camera: use kmemdup()

In reply to Mauro Carvalho Chehab

Instead of calling kzalloc and then copying, use kmemdup(). That avoids zeroing the data structure before copying.

Found by coccinelle.

drivers/media/platform/soc_camera/soc_camera.c +1 -3
index f4308fed5431..ee8cdc95a9f9 100644
@@ -1347,13 +1347,11 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
 		return -ENODEV;
 	}
 
-	ssdd = kzalloc(sizeof(*ssdd), GFP_KERNEL);
+	ssdd = kmemdup(&sdesc->subdev_desc, sizeof(*ssdd), GFP_KERNEL);
 	if (!ssdd) {
 		ret = -ENOMEM;
 		goto ealloc;
 	}
-
-	memcpy(ssdd, &sdesc->subdev_desc, sizeof(*ssdd));
 	/*
 	 * In synchronous case we request regulators ourselves in
 	 * soc_camera_pdrv_probe(), make sure the subdevice driver doesn't try
Signature · 1 line
1.9.3
Acked-by on v1 3/46
#4 lore raw

Re: [PATCH 03/46] [media] soc_camera: use kmemdup()

Hi Mauro,

Quoted 13 lines · Mauro Carvalho Chehab

Instead of calling kzalloc and then copying, use kmemdup(). That avoids zeroing the data structure before copying.

Found by coccinelle.

drivers/media/platform/soc_camera/soc_camera.c +0 -0
index f4308fed5431..ee8cdc95a9f9 100644
@@ -1347,13 +1347,11 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
 		return -ENODEV;

drivers/media/platform/soc_camera/soc_camera.c static int soc_camera_i2c_init(struct soc_camera_device *icd, · line 1356

Quoted 10 lines
drivers/media/platform/soc_camera/soc_camera.c +1 -3
 	}
 
-	ssdd = kzalloc(sizeof(*ssdd), GFP_KERNEL);
+	ssdd = kmemdup(&sdesc->subdev_desc, sizeof(*ssdd), GFP_KERNEL);
 	if (!ssdd) {
 		ret = -ENOMEM;
 		goto ealloc;
 	}
-
-	memcpy(ssdd, &sdesc->subdev_desc, sizeof(*ssdd));

Hm, wow... that seems to be a particularly silly one... Even if not memdup, why did I use kZalloc() to immediately overwrite it completely?.. Thanks for catching! This and the other two (so far) patches - would you like me to pull-push them or just use my

for all 3 of them?

Thanks
Guennadi

Quoted 6 lines
drivers/media/platform/soc_camera/soc_camera.c +0 -0
 	/*
 	 * In synchronous case we request regulators ourselves in
 	 * soc_camera_pdrv_probe(), make sure the subdevice driver doesn't try
Signature · 1 line
1.9.3
#5 lore raw

Re: [PATCH 03/46] [media] soc_camera: use kmemdup()

Em Wed, 3 Sep 2014 22:44:02 +0200 (CEST) Guennadi Liakhovetski <[email protected]> escreveu:

Quoted 19 lines

Hi Mauro,

Quoted 15 lines · Mauro Carvalho Chehab

Instead of calling kzalloc and then copying, use kmemdup(). That avoids zeroing the data structure before copying.

Found by coccinelle.

drivers/media/platform/soc_camera/soc_camera.c +0 -0
index f4308fed5431..ee8cdc95a9f9 100644
@@ -1347,13 +1347,11 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
 		return -ENODEV;
 	}
 
Quoted 11 lines

drivers/media/platform/soc_camera/soc_camera.c static int soc_camera_i2c_init(struct soc_camera_device *icd, · line 1356

Quoted 8 lines
drivers/media/platform/soc_camera/soc_camera.c +1 -3
-	ssdd = kzalloc(sizeof(*ssdd), GFP_KERNEL);
+	ssdd = kmemdup(&sdesc->subdev_desc, sizeof(*ssdd), GFP_KERNEL);
 	if (!ssdd) {
 		ret = -ENOMEM;
 		goto ealloc;
 	}
-
-	memcpy(ssdd, &sdesc->subdev_desc, sizeof(*ssdd));

Hm, wow... that seems to be a particularly silly one... Even if not memdup, why did I use kZalloc() to immediately overwrite it completely?..

Maybe this pattern happened due to some incremental change.

Quoted 6 lines

Thanks for catching! This and the other two (so far) patches - would you like me to pull-push them or just use my

for all 3 of them?

Just the acked-by is enough.

Thanks!
Mauro

Quoted 10 lines

Thanks
Guennadi

Quoted 6 lines
drivers/media/platform/soc_camera/soc_camera.c +0 -0
 	/*
 	 * In synchronous case we request regulators ourselves in
 	 * soc_camera_pdrv_probe(), make sure the subdevice driver doesn't try
Signature · 1 line
1.9.3
#6 lore raw

PATCH 4/46 vivid-vid-out: use memdup_user()

In reply to Mauro Carvalho Chehab

Instead of allocating and coping from __user, do it using one atomic call. That makes the code simpler. Also,

Found by coccinelle.

drivers/media/platform/vivid/vivid-vid-out.c +3 -7
index c983461f29d5..8ed9f6d9f505 100644
@@ -897,14 +897,10 @@ int vidioc_s_fmt_vid_out_overlay(struct file *file, void *priv,
 		return ret;
 
 	if (win->bitmap) {
-		new_bitmap = kzalloc(bitmap_size, GFP_KERNEL);
+		new_bitmap = memdup_user(win->bitmap, bitmap_size);
 
-		if (new_bitmap == NULL)
-			return -ENOMEM;
-		if (copy_from_user(new_bitmap, win->bitmap, bitmap_size)) {
-			kfree(new_bitmap);
-			return -EFAULT;
-		}
+		if (IS_ERR(new_bitmap))
+			return PTR_ERR(new_bitmap);
 	}
 
 	dev->overlay_out_top = win->w.top;
Signature · 1 line
1.9.3
Acked-by on v1 4/46
#7 lore raw

Re: [PATCH 04/46] [media] vivid-vid-out: use memdup_user()

Quoted 2 lines · Mauro Carvalho Chehab

Instead of allocating and coping from __user, do it using one atomic call. That makes the code simpler. Also,

Also what?

Anyway, looks good to me:

Regards,

Hans

Quoted 28 lines

Found by coccinelle.

drivers/media/platform/vivid/vivid-vid-out.c +3 -7
index c983461f29d5..8ed9f6d9f505 100644
@@ -897,14 +897,10 @@ int vidioc_s_fmt_vid_out_overlay(struct file *file, void *priv,
 		return ret;
 
 	if (win->bitmap) {
-		new_bitmap = kzalloc(bitmap_size, GFP_KERNEL);
+		new_bitmap = memdup_user(win->bitmap, bitmap_size);
 
-		if (new_bitmap == NULL)
-			return -ENOMEM;
-		if (copy_from_user(new_bitmap, win->bitmap, bitmap_size)) {
-			kfree(new_bitmap);
-			return -EFAULT;
-		}
+		if (IS_ERR(new_bitmap))
+			return PTR_ERR(new_bitmap);
 	}
 
 	dev->overlay_out_top = win->w.top;
#8 lore raw

Re: [PATCH 04/46] [media] vivid-vid-out: use memdup_user()

Em Wed, 03 Sep 2014 22:49:47 +0200
Hans Verkuil <[email protected]> escreveu:

Quoted 5 lines · Mauro Carvalho Chehab
Quoted 2 lines

Instead of allocating and coping from __user, do it using one atomic call. That makes the code simpler. Also,

Also what?

I added a comment about IS_ERR(new_bitmap), and returning the error, but then I realized that the above is good enough, but I forgot the "Also, " at the above line. Thanks for pointing it.

Quoted 4 lines

Anyway, looks good to me:

Thanks!
Mauro

Quoted 34 lines

Regards,

Hans

Quoted 28 lines

Found by coccinelle.

drivers/media/platform/vivid/vivid-vid-out.c +3 -7
index c983461f29d5..8ed9f6d9f505 100644
@@ -897,14 +897,10 @@ int vidioc_s_fmt_vid_out_overlay(struct file *file, void *priv,
 		return ret;
 
 	if (win->bitmap) {
-		new_bitmap = kzalloc(bitmap_size, GFP_KERNEL);
+		new_bitmap = memdup_user(win->bitmap, bitmap_size);
 
-		if (new_bitmap == NULL)
-			return -ENOMEM;
-		if (copy_from_user(new_bitmap, win->bitmap, bitmap_size)) {
-			kfree(new_bitmap);
-			return -EFAULT;
-		}
+		if (IS_ERR(new_bitmap))
+			return PTR_ERR(new_bitmap);
 	}
 
 	dev->overlay_out_top = win->w.top;
#9 lore raw

PATCH 5/46 s5k5baf: remove an uneeded semicolon

In reply to Mauro Carvalho Chehab

We don't use semicolons after curly braces in the middle of the code.

drivers/media/i2c/s5k5baf.c +1 -1
index 564f05f2c9ef..0e461a6fd065 100644
@@ -816,7 +816,7 @@ static void s5k5baf_hw_find_min_fiv(struct s5k5baf *state)
 				 "error setting frame interval: %d\n", err);
 			state->error = -EINVAL;
 		}
-	};
+	}
 	v4l2_err(&state->sd, "cannot find correct frame interval\n");
 	state->error = -ERANGE;
 }
Signature · 1 line
1.9.3
#10 lore raw

PATCH 6/46 bttv-driver: remove an uneeded semicolon

In reply to Mauro Carvalho Chehab

We don't use semicolons after curly braces in the middle of the code.

drivers/media/pci/bt8xx/bttv-driver.c +1 -1
index 970e542d3a51..750bdab8aacb 100644
@@ -3856,7 +3856,7 @@ static irqreturn_t bttv_irq(int irq, void *dev_id)
 
 				btwrite(btread(BT848_INT_MASK) & (-1 ^ BT848_INT_GPINT),
 						BT848_INT_MASK);
-			};
+			}
 
 			bttv_print_irqbits(stat,astat);
 
Signature · 1 line
1.9.3
#11 lore raw

PATCH 7/46 soc_camera: remove uneeded semicolons

In reply to Mauro Carvalho Chehab

We don't use semicolons after curly braces in the middle of the code.

drivers/media/platform/soc_camera/pxa_camera.c +1 -1
index 64dc80ccd6f9..66178fc9f9eb 100644
@@ -1694,7 +1694,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
 		break;
 	default:
 		break;
-	};
+	}
 
 	if (ep.bus.parallel.flags & V4L2_MBUS_MASTER)
 		pcdev->platform_flags |= PXA_CAMERA_MASTER;
drivers/media/platform/soc_camera/rcar_vin.c +1 -1
index 85d579f65f52..b122c2cf5b85 100644
@@ -1502,7 +1502,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
 	} else {
 		priv->ici.nr = of_alias_get_id(pdev->dev.of_node, "vin");
 		priv->chip = (enum chip_id)match->data;
-	};
+	}
 
 	spin_lock_init(&priv->lock);
 	INIT_LIST_HEAD(&priv->capture);
Signature · 1 line
1.9.3
#12 lore raw

PATCH 8/46 stv0900_core: don't allocate a temporary var

In reply to Mauro Carvalho Chehab

The error return code STV0900_NO_ERROR happens only once, at the end of the functions. So, just return it directly.

This driver should actually be fixed to return standard Linux error codes, instead of its own macros, but this should be done on a separate patchset.

drivers/media/dvb-frontends/stv0900_core.c +2 -5
index e5a87b57d855..2c88abfab531 100644
@@ -1270,7 +1270,6 @@ enum fe_stv0900_error stv0900_st_dvbs2_single(struct stv0900_internal *intp,
 					enum fe_stv0900_demod_mode LDPC_Mode,
 					enum fe_stv0900_demod_num demod)
 {
-	enum fe_stv0900_error error = STV0900_NO_ERROR;
 	s32 reg_ind;
 
 	dprintk("%s\n", __func__);
@@ -1337,7 +1336,7 @@ enum fe_stv0900_error stv0900_st_dvbs2_single(struct stv0900_internal *intp,
 		break;
 	}
 
-	return error;
+	return STV0900_NO_ERROR;
 }
 
 static enum fe_stv0900_error stv0900_init_internal(struct dvb_frontend *fe,
@@ -1555,8 +1554,6 @@ static int stv0900_status(struct stv0900_internal *intp,
 static int stv0900_set_mis(struct stv0900_internal *intp,
 				enum fe_stv0900_demod_num demod, int mis)
 {
-	enum fe_stv0900_error error = STV0900_NO_ERROR;
-
 	dprintk("%s\n", __func__);
 
 	if (mis < 0 || mis > 255) {
@@ -1569,7 +1566,7 @@ static int stv0900_set_mis(struct stv0900_internal *intp,
 		stv0900_write_reg(intp, ISIBITENA, 0xff);
 	}
 
-	return error;
+	return STV0900_NO_ERROR;
 }
 
 
Signature · 1 line
1.9.3
#13 lore raw

PATCH 9/46 em28xx: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/usb/em28xx/em28xx-input.c +3 -3
index ed843bd221ea..e978a2ae6f21 100644
@@ -609,17 +609,17 @@ static int em28xx_register_snapshot_button(struct em28xx *dev)
 static void em28xx_init_buttons(struct em28xx *dev)
 {
 	u8  i = 0, j = 0;
-	bool addr_new = 0;
+	bool addr_new = false;
 
 	dev->button_polling_interval = EM28XX_BUTTONS_DEBOUNCED_QUERY_INTERVAL;
 	while (dev->board.buttons[i].role >= 0 &&
 			 dev->board.buttons[i].role < EM28XX_NUM_BUTTON_ROLES) {
 		struct em28xx_button *button = &dev->board.buttons[i];
 		/* Check if polling address is already on the list */
-		addr_new = 1;
+		addr_new = true;
 		for (j = 0; j < dev->num_button_polling_addresses; j++) {
 			if (button->reg_r == dev->button_polling_addresses[j]) {
-				addr_new = 0;
+				addr_new = false;
 				break;
 			}
 		}
drivers/media/usb/em28xx/em28xx-video.c +2 -2
index f6cf99fa30b2..3642438bc7d4 100644
@@ -721,7 +721,7 @@ static inline void process_frame_data_em25xx(struct em28xx *dev,
 	struct em28xx_buffer    *buf = dev->usb_ctl.vid_buf;
 	struct em28xx_dmaqueue  *dmaq = &dev->vidq;
 	struct em28xx_v4l2      *v4l2 = dev->v4l2;
-	bool frame_end = 0;
+	bool frame_end = false;
 
 	/* Check for header */
 	/* NOTE: at least with bulk transfers, only the first packet
@@ -2308,7 +2308,7 @@ static int em28xx_v4l2_init(struct em28xx *dev)
 	v4l2->v4l2_dev.ctrl_handler = hdl;
 
 	if (dev->board.is_webcam)
-		v4l2->progressive = 1;
+		v4l2->progressive = true;
 
 	/*
 	 * Default format, used for tvp5150 or saa711x output formats
Signature · 1 line
1.9.3
#14 lore raw

PATCH 10/46 tuner-core: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/v4l2-core/tuner-core.c +1 -1
index 177023200737..559f8372e2eb 100644
@@ -601,7 +601,7 @@ static int tuner_probe(struct i2c_client *client,
 	t->name = "(tuner unset)";
 	t->type = UNSET;
 	t->audmode = V4L2_TUNER_MODE_STEREO;
-	t->standby = 1;
+	t->standby = true;
 	t->radio_freq = 87.5 * 16000;	/* Initial freq range */
 	t->tv_freq = 400 * 16; /* Sets freq to VHF High - needed for some PLL's to properly start */
 
Signature · 1 line
1.9.3
#15 lore raw

PATCH 11/46 af9013: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/dvb-frontends/af9013.c +12 -12
index ecf6388d2200..8001690d7576 100644
@@ -683,7 +683,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 
 	switch (c->transmission_mode) {
 	case TRANSMISSION_MODE_AUTO:
-		auto_mode = 1;
+		auto_mode = true;
 		break;
 	case TRANSMISSION_MODE_2K:
 		break;
@@ -693,12 +693,12 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 	default:
 		dev_dbg(&state->i2c->dev, "%s: invalid transmission_mode\n",
 				__func__);
-		auto_mode = 1;
+		auto_mode = true;
 	}
 
 	switch (c->guard_interval) {
 	case GUARD_INTERVAL_AUTO:
-		auto_mode = 1;
+		auto_mode = true;
 		break;
 	case GUARD_INTERVAL_1_32:
 		break;
@@ -714,12 +714,12 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 	default:
 		dev_dbg(&state->i2c->dev, "%s: invalid guard_interval\n",
 				__func__);
-		auto_mode = 1;
+		auto_mode = true;
 	}
 
 	switch (c->hierarchy) {
 	case HIERARCHY_AUTO:
-		auto_mode = 1;
+		auto_mode = true;
 		break;
 	case HIERARCHY_NONE:
 		break;
@@ -734,12 +734,12 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 		break;
 	default:
 		dev_dbg(&state->i2c->dev, "%s: invalid hierarchy\n", __func__);
-		auto_mode = 1;
+		auto_mode = true;
 	}
 
 	switch (c->modulation) {
 	case QAM_AUTO:
-		auto_mode = 1;
+		auto_mode = true;
 		break;
 	case QPSK:
 		break;
@@ -751,7 +751,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 		break;
 	default:
 		dev_dbg(&state->i2c->dev, "%s: invalid modulation\n", __func__);
-		auto_mode = 1;
+		auto_mode = true;
 	}
 
 	/* Use HP. How and which case we can switch to LP? */
@@ -759,7 +759,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 
 	switch (c->code_rate_HP) {
 	case FEC_AUTO:
-		auto_mode = 1;
+		auto_mode = true;
 		break;
 	case FEC_1_2:
 		break;
@@ -778,12 +778,12 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 	default:
 		dev_dbg(&state->i2c->dev, "%s: invalid code_rate_HP\n",
 				__func__);
-		auto_mode = 1;
+		auto_mode = true;
 	}
 
 	switch (c->code_rate_LP) {
 	case FEC_AUTO:
-		auto_mode = 1;
+		auto_mode = true;
 		break;
 	case FEC_1_2:
 		break;
@@ -804,7 +804,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 	default:
 		dev_dbg(&state->i2c->dev, "%s: invalid code_rate_LP\n",
 				__func__);
-		auto_mode = 1;
+		auto_mode = true;
 	}
 
 	switch (c->bandwidth_hz) {
Signature · 1 line
1.9.3
#16 lore raw

PATCH 12/46 cxd2820r: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/dvb-frontends/cxd2820r_c.c +2 -2
index 0f4657e01cde..149fdca3fb44 100644
@@ -65,7 +65,7 @@ int cxd2820r_set_frontend_c(struct dvb_frontend *fe)
 	}
 
 	priv->delivery_system = SYS_DVBC_ANNEX_A;
-	priv->ber_running = 0; /* tune stops BER counter */
+	priv->ber_running = false; /* tune stops BER counter */
 
 	/* program IF frequency */
 	if (fe->ops.tuner_ops.get_if_frequency) {
@@ -168,7 +168,7 @@ int cxd2820r_read_ber_c(struct dvb_frontend *fe, u32 *ber)
 			start_ber = 1;
 		}
 	} else {
-		priv->ber_running = 1;
+		priv->ber_running = true;
 		start_ber = 1;
 	}
 
drivers/media/dvb-frontends/cxd2820r_core.c +2 -2
index 03930d5e9fea..cd2af3edbd04 100644
@@ -564,10 +564,10 @@ static enum dvbfe_search cxd2820r_search(struct dvb_frontend *fe)
 
 	/* check if we have a valid signal */
 	if (status & FE_HAS_LOCK) {
-		priv->last_tune_failed = 0;
+		priv->last_tune_failed = false;
 		return DVBFE_ALGO_SEARCH_SUCCESS;
 	} else {
-		priv->last_tune_failed = 1;
+		priv->last_tune_failed = true;
 		return DVBFE_ALGO_SEARCH_AGAIN;
 	}
 
drivers/media/dvb-frontends/cxd2820r_t.c +2 -2
index 9b5a45b907bc..51401d036530 100644
@@ -89,7 +89,7 @@ int cxd2820r_set_frontend_t(struct dvb_frontend *fe)
 	}
 
 	priv->delivery_system = SYS_DVBT;
-	priv->ber_running = 0; /* tune stops BER counter */
+	priv->ber_running = false; /* tune stops BER counter */
 
 	/* program IF frequency */
 	if (fe->ops.tuner_ops.get_if_frequency) {
@@ -272,7 +272,7 @@ int cxd2820r_read_ber_t(struct dvb_frontend *fe, u32 *ber)
 			start_ber = 1;
 		}
 	} else {
-		priv->ber_running = 1;
+		priv->ber_running = true;
 		start_ber = 1;
 	}
 
Signature · 1 line
1.9.3
#17 lore raw

PATCH 13/46 m88ds3103: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/dvb-frontends/m88ds3103.c +6 -6
index 6eae2c619843..81657e94c5a4 100644
@@ -1063,16 +1063,16 @@ static int m88ds3103_set_voltage(struct dvb_frontend *fe,
 
 	switch (fe_sec_voltage) {
 	case SEC_VOLTAGE_18:
-		voltage_sel = 1;
-		voltage_dis = 0;
+		voltage_sel = true;
+		voltage_dis = false;
 		break;
 	case SEC_VOLTAGE_13:
-		voltage_sel = 0;
-		voltage_dis = 0;
+		voltage_sel = false;
+		voltage_dis = false;
 		break;
 	case SEC_VOLTAGE_OFF:
-		voltage_sel = 0;
-		voltage_dis = 1;
+		voltage_sel = false;
+		voltage_dis = true;
 		break;
 	default:
 		dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_voltage\n",
Signature · 1 line
1.9.3
#18 lore raw

PATCH 14/46 af9013: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

Also, instead of testing foo == false, just use the simplified notation if(!foo).

drivers/media/dvb-frontends/rtl2832.c +1 -1
index fdbed35c87fa..eb737cf29a36 100644
@@ -936,7 +936,7 @@ static void rtl2832_i2c_gate_work(struct work_struct *work)
 	if (ret != 1)
 		goto err;
 
-	priv->i2c_gate_state = 0;
+	priv->i2c_gate_state = false;
 
 	return;
 err:
drivers/media/dvb-frontends/rtl2832_sdr.c +1 -1
index 023e0f49c786..5bcf48bb4a71 100644
@@ -1432,7 +1432,7 @@ struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
 	s->pixelformat = formats[0].pixelformat;
 	s->buffersize = formats[0].buffersize;
 	s->num_formats = NUM_FORMATS;
-	if (rtl2832_sdr_emulated_fmt == false)
+	if (!rtl2832_sdr_emulated_fmt)
 		s->num_formats -= 1;
 
 	mutex_init(&s->v4l2_lock);
Signature · 1 line
1.9.3
#19 lore raw

PATCH 15/46 tda10071: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/dvb-frontends/tda10071.c +1 -1
index 9619be5d4827..4a19b85995f1 100644
@@ -1037,7 +1037,7 @@ static int tda10071_init(struct dvb_frontend *fe)
 			ret = -EFAULT;
 			goto error;
 		} else {
-			priv->warm = 1;
+			priv->warm = true;
 		}
 
 		cmd.args[0] = CMD_GET_FW_VERSION;
Signature · 1 line
1.9.3
#20 lore raw

PATCH 16/46 smiapp-core: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/i2c/smiapp/smiapp-core.c +4 -4
index c4cc5de3ae59..d312932bc56e 100644
@@ -1312,7 +1312,7 @@ static void smiapp_power_off(struct smiapp_sensor *sensor)
 		clk_disable_unprepare(sensor->ext_clk);
 	usleep_range(5000, 5000);
 	regulator_disable(sensor->vana);
-	sensor->streaming = 0;
+	sensor->streaming = false;
 }
 
 static int smiapp_set_power(struct v4l2_subdev *subdev, int on)
@@ -1509,13 +1509,13 @@ static int smiapp_set_stream(struct v4l2_subdev *subdev, int enable)
 		return 0;
 
 	if (enable) {
-		sensor->streaming = 1;
+		sensor->streaming = true;
 		rval = smiapp_start_streaming(sensor);
 		if (rval < 0)
-			sensor->streaming = 0;
+			sensor->streaming = false;
 	} else {
 		rval = smiapp_stop_streaming(sensor);
-		sensor->streaming = 0;
+		sensor->streaming = false;
 	}
 
 	return rval;
Signature · 1 line
1.9.3
Acked-by on v1 16/46
#21 lore raw

Re: [PATCH 16/46] [media] smiapp-core: use true/false for boolean vars

Quoted 4 lines · Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

Thanks!

Would you like me to pick this patch to my tree, or would you like to apply it directly? I'm fine with either.

Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]
#22 lore raw

Re: [PATCH 16/46] [media] smiapp-core: use true/false for boolean vars

Em Thu, 04 Sep 2014 10:03:40 +0300
Sakari Ailus <[email protected]> escreveu:

Quoted 12 lines · Mauro Carvalho Chehab
Quoted 4 lines

Instead of using 0 or 1 for boolean, use the true/false defines.

Thanks!

Would you like me to pick this patch to my tree, or would you like to apply it directly? I'm fine with either.

I'll pick it myself.

Regards,
Mauro

#23 lore raw

PATCH 17/46 ov9740: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/i2c/soc_camera/ov9740.c +2 -2
index ea76863dfdb4..ee9eb635d540 100644
@@ -564,13 +564,13 @@ static int ov9740_set_res(struct i2c_client *client, u32 width, u32 height)
 	u32 y_start;
 	u32 x_end;
 	u32 y_end;
-	bool scaling = 0;
+	bool scaling = false;
 	u32 scale_input_x;
 	u32 scale_input_y;
 	int ret;
 
 	if ((width != OV9740_MAX_WIDTH) || (height != OV9740_MAX_HEIGHT))
-		scaling = 1;
+		scaling = true;
 
 	/*
 	 * Try to use as much of the sensor area as possible when supporting
Signature · 1 line
1.9.3
#24 lore raw

PATCH 18/46 omap3isp: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/platform/omap3isp/ispccdc.c +1 -1
index cabf46b4b645..81a9dc053d58 100644
@@ -1806,7 +1806,7 @@ static int ccdc_video_queue(struct isp_video *video, struct isp_buffer *buffer)
 	spin_lock_irqsave(&ccdc->lock, flags);
 	if (ccdc->state == ISP_PIPELINE_STREAM_CONTINUOUS && !ccdc->running &&
 	    ccdc->bt656)
-		restart = 1;
+		restart = true;
 	else
 		ccdc->underrun = 1;
 	spin_unlock_irqrestore(&ccdc->lock, flags);
Signature · 1 line
1.9.3
Acked-by on v1 18/46
#25 lore raw

Re: [PATCH 18/46] [media] omap3isp: use true/false for boolean vars

Hi Mauro,

Thank you for the patch.

Quoted 4 lines · On Wednesday 03 September 2014 17:32:50 Mauro Carvalho Chehab wrote:

Instead of using 0 or 1 for boolean, use the true/false defines.

Quoted 14 lines
(quoted diff) +0 -0

b/drivers/media/platform/omap3isp/ispccdc.c index
cabf46b4b645..81a9dc053d58 100644

drivers/media/platform/omap3isp/ispccdc.c +1 -1
@@ -1806,7 +1806,7 @@ static int ccdc_video_queue(struct isp_video *video,
 struct isp_buffer *buffer) spin_lock_irqsave(&ccdc->lock, flags);
 	if (ccdc->state == ISP_PIPELINE_STREAM_CONTINUOUS && !ccdc->running &&
 	    ccdc->bt656)
-		restart = 1;
+		restart = true;
 	else
 		ccdc->underrun = 1;
 	spin_unlock_irqrestore(&ccdc->lock, flags);
Signature · 3 lines
Regards,

Laurent Pinchart
#26 lore raw

PATCH 19/46 ti-vpe: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/platform/ti-vpe/vpe.c +2 -2
index 773b1fbf3269..febeca70211b 100644
@@ -835,10 +835,10 @@ static int set_srcdst_params(struct vpe_ctx *ctx)
 					VPDMA_STRIDE_ALIGN);
 		mv_buf_size = bytes_per_line * s_q_data->height;
 
-		ctx->deinterlacing = 1;
+		ctx->deinterlacing = true;
 		src_h <<= 1;
 	} else {
-		ctx->deinterlacing = 0;
+		ctx->deinterlacing = false;
 		mv_buf_size = 0;
 	}
 
Signature · 1 line
1.9.3
#27 lore raw

PATCH 20/46 vivid-tpg: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/platform/vivid/vivid-tpg.c +2 -2
index 8576b2c1d4a1..57ff428c897e 100644
@@ -183,7 +183,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
 	case V4L2_PIX_FMT_XBGR32:
 	case V4L2_PIX_FMT_ARGB32:
 	case V4L2_PIX_FMT_ABGR32:
-		tpg->is_yuv = 0;
+		tpg->is_yuv = false;
 		break;
 	case V4L2_PIX_FMT_NV16M:
 	case V4L2_PIX_FMT_NV61M:
@@ -193,7 +193,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
 	case V4L2_PIX_FMT_UYVY:
 	case V4L2_PIX_FMT_YVYU:
 	case V4L2_PIX_FMT_VYUY:
-		tpg->is_yuv = 1;
+		tpg->is_yuv = true;
 		break;
 	default:
 		return false;
Signature · 1 line
1.9.3
#28 lore raw

PATCH 21/46 radio: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/radio/radio-gemtek.c +1 -1
index 235c0e349820..cff1eb144a5c 100644
@@ -332,7 +332,7 @@ static int __init gemtek_init(void)
 
 static void __exit gemtek_exit(void)
 {
-	hardmute = 1;	/* Turn off PLL */
+	hardmute = true;	/* Turn off PLL */
 #ifdef CONFIG_PNP
 	pnp_unregister_driver(&gemtek_driver.pnp_driver);
 #endif
drivers/media/radio/radio-sf16fmi.c +2 -2
index d7ce8fe6b5ae..bcd0946c84a5 100644
@@ -285,7 +285,7 @@ static int __init fmi_init(void)
 				io = isapnp_fmi_probe();
 				if (io < 0)
 					continue;
-				pnp_attached = 1;
+				pnp_attached = true;
 			}
 			if (!request_region(io, 2, "radio-sf16fmi")) {
 				if (pnp_attached)
@@ -349,7 +349,7 @@ static int __init fmi_init(void)
 	mutex_init(&fmi->lock);
 
 	/* mute card and set default frequency */
-	fmi->mute = 1;
+	fmi->mute = true;
 	fmi->curfreq = RSF16_MINFREQ;
 	fmi_set_freq(fmi);
 
drivers/media/radio/si470x/radio-si470x-common.c +2 -2
index 0e750aef656a..909c3f92d839 100644
@@ -208,7 +208,7 @@ static int si470x_set_band(struct si470x_device *radio, int band)
 static int si470x_set_chan(struct si470x_device *radio, unsigned short chan)
 {
 	int retval;
-	bool timed_out = 0;
+	bool timed_out = false;
 
 	/* start tuning */
 	radio->registers[CHANNEL] &= ~CHANNEL_CHAN;
@@ -300,7 +300,7 @@ static int si470x_set_seek(struct si470x_device *radio,
 {
 	int band, retval;
 	unsigned int freq;
-	bool timed_out = 0;
+	bool timed_out = false;
 
 	/* set band */
 	if (seek->rangelow || seek->rangehigh) {
Signature · 1 line
1.9.3
#29 lore raw

PATCH 22/46 ene_ir: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/rc/ene_ir.c +1 -1
index d16d9b496b92..e80f2c6c5f1a 100644
@@ -979,7 +979,7 @@ static int ene_transmit(struct rc_dev *rdev, unsigned *buf, unsigned n)
 	dev->tx_reg = 0;
 	dev->tx_done = 0;
 	dev->tx_sample = 0;
-	dev->tx_sample_pulse = 0;
+	dev->tx_sample_pulse = false;
 
 	dbg("TX: %d samples", dev->tx_len);
 
Signature · 1 line
1.9.3
#30 lore raw

PATCH 23/46 au0828-dvb: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/usb/au0828/au0828-dvb.c +1 -1
index 4bd9d687d2d6..00ab1563d142 100644
@@ -630,7 +630,7 @@ void au0828_dvb_suspend(struct au0828_dev *dev)
 			stop_urb_transfer(dev);
 			au0828_stop_transport(dev, 1);
 			mutex_unlock(&dvb->lock);
-			dev->need_urb_start = 1;
+			dev->need_urb_start = true;
 		}
 		/* suspend frontend - does tuner and fe to sleep */
 		rc = dvb_frontend_suspend(dvb->frontend);
Signature · 1 line
1.9.3
#31 lore raw

PATCH 24/46 lmedm04: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/usb/dvb-usb-v2/lmedm04.c +1 -1
index e332af731187..9f2c5459b73a 100644
@@ -1252,7 +1252,7 @@ static int lme2510_get_stream_config(struct dvb_frontend *fe, u8 *ts_type,
 
 	/* Turn PID filter on the fly by module option */
 	if (pid_filter == 2) {
-		adap->pid_filtering  = 1;
+		adap->pid_filtering  = true;
 		adap->max_feed_count = 15;
 	}
 
Signature · 1 line
1.9.3
#32 lore raw

PATCH 25/46 af9005: use true/false for boolean vars

In reply to Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false defines.

drivers/media/usb/dvb-usb/af9005.c +1 -1
index af176b6ce738..3f4361e48a32 100644
@@ -30,7 +30,7 @@ MODULE_PARM_DESC(debug,
 		 "set debugging level (1=info,xfer=2,rc=4,reg=8,i2c=16,fw=32 (or-able))."
 		 DVB_USB_DEBUG_STATUS);
 /* enable obnoxious led */
-bool dvb_usb_af9005_led = 1;
+bool dvb_usb_af9005_led = true;
 module_param_named(led, dvb_usb_af9005_led, bool, 0644);
 MODULE_PARM_DESC(led, "enable led (default: 1).");
 
Signature · 1 line
1.9.3
#33 lore raw

PATCH 26/46 msi2500: simplify boolean tests

In reply to Mauro Carvalho Chehab

Instead of using if (foo == false), just use
if (!foo).

That allows a faster mental parsing when analyzing the code.

drivers/media/usb/msi2500/msi2500.c +1 -1
index 71e0960b46c0..e980aaa47b7c 100644
@@ -1212,7 +1212,7 @@ static int msi2500_probe(struct usb_interface *intf,
 	s->pixelformat = formats[0].pixelformat;
 	s->buffersize = formats[0].buffersize;
 	s->num_formats = NUM_FORMATS;
-	if (msi2500_emulated_fmt == false)
+	if (!msi2500_emulated_fmt)
 		s->num_formats -= 2;
 
 	/* Init videobuf2 queue structure */
Signature · 1 line
1.9.3
#34 lore raw

PATCH 27/46 drxk_hard: simplify test logic

In reply to Mauro Carvalho Chehab

instead of testing if it is false or true, just use if (!foo) or if (foo). That makes the code easier to read and shorter.

Also, properly initialize booleans with true or false.

drivers/media/dvb-frontends/drxk_hard.c +17 -17
index cce94a75b2e1..88182c18e186 100644
@@ -1028,7 +1028,7 @@ static int hi_command(struct drxk_state *state, u16 cmd, u16 *p_result)
 		    ((state->m_hi_cfg_ctrl) &
 		     SIO_HI_RA_RAM_PAR_5_CFG_SLEEP__M) ==
 		    SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ);
-	if (powerdown_cmd == false) {
+	if (!powerdown_cmd) {
 		/* Wait until command rdy */
 		u32 retry_count = 0;
 		u16 wait_cmd;
@@ -1129,7 +1129,7 @@ static int mpegts_configure_pins(struct drxk_state *state, bool mpeg_enable)
 	if (status < 0)
 		goto error;
 
-	if (mpeg_enable == false) {
+	if (!mpeg_enable) {
 		/*  Set MPEG TS pads to inputmode */
 		status = write16(state, SIO_PDR_MSTRT_CFG__A, 0x0000);
 		if (status < 0)
@@ -1190,7 +1190,7 @@ static int mpegts_configure_pins(struct drxk_state *state, bool mpeg_enable)
 		if (status < 0)
 			goto error;
 
-		if (state->m_enable_parallel == true) {
+		if (state->m_enable_parallel) {
 			/* parallel -> enable MD1 to MD7 */
 			status = write16(state, SIO_PDR_MD1_CFG__A,
 					 sio_pdr_mdx_cfg);
@@ -1392,7 +1392,7 @@ static int dvbt_enable_ofdm_token_ring(struct drxk_state *state, bool enable)
 
 	dprintk(1, "\n");
 
-	if (enable == false) {
+	if (!enable) {
 		desired_ctrl = SIO_OFDM_SH_OFDM_RING_ENABLE_OFF;
 		desired_status = SIO_OFDM_SH_OFDM_RING_STATUS_DOWN;
 	}
@@ -2012,7 +2012,7 @@ static int mpegts_dto_setup(struct drxk_state *state,
 		goto error;
 	fec_oc_reg_mode &= (~FEC_OC_MODE_PARITY__M);
 	fec_oc_reg_ipr_mode &= (~FEC_OC_IPR_MODE_MVAL_DIS_PAR__M);
-	if (state->m_insert_rs_byte == true) {
+	if (state->m_insert_rs_byte) {
 		/* enable parity symbol forward */
 		fec_oc_reg_mode |= FEC_OC_MODE_PARITY__M;
 		/* MVAL disable during parity bytes */
@@ -2023,7 +2023,7 @@ static int mpegts_dto_setup(struct drxk_state *state,
 
 	/* Check serial or parallel output */
 	fec_oc_reg_ipr_mode &= (~(FEC_OC_IPR_MODE_SERIAL__M));
-	if (state->m_enable_parallel == false) {
+	if (!state->m_enable_parallel) {
 		/* MPEG data output is serial -> set ipr_mode[0] */
 		fec_oc_reg_ipr_mode |= FEC_OC_IPR_MODE_SERIAL__M;
 	}
@@ -2136,19 +2136,19 @@ static int mpegts_configure_polarity(struct drxk_state *state)
 
 	/* Control selective inversion of output bits */
 	fec_oc_reg_ipr_invert &= (~(invert_data_mask));
-	if (state->m_invert_data == true)
+	if (state->m_invert_data)
 		fec_oc_reg_ipr_invert |= invert_data_mask;
 	fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MERR__M));
-	if (state->m_invert_err == true)
+	if (state->m_invert_err)
 		fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MERR__M;
 	fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MSTRT__M));
-	if (state->m_invert_str == true)
+	if (state->m_invert_str)
 		fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MSTRT__M;
 	fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MVAL__M));
-	if (state->m_invert_val == true)
+	if (state->m_invert_val)
 		fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MVAL__M;
 	fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MCLK__M));
-	if (state->m_invert_clk == true)
+	if (state->m_invert_clk)
 		fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MCLK__M;
 
 	return write16(state, FEC_OC_IPR_INVERT__A, fec_oc_reg_ipr_invert);
@@ -3352,7 +3352,7 @@ static int dvbt_ctrl_set_inc_enable(struct drxk_state *state, bool *enabled)
 	int status;
 
 	dprintk(1, "\n");
-	if (*enabled == true)
+	if (*enabled)
 		status = write16(state, IQM_CF_BYPASSDET__A, 0);
 	else
 		status = write16(state, IQM_CF_BYPASSDET__A, 1);
@@ -3368,7 +3368,7 @@ static int dvbt_ctrl_set_fr_enable(struct drxk_state *state, bool *enabled)
 	int status;
 
 	dprintk(1, "\n");
-	if (*enabled == true) {
+	if (*enabled) {
 		/* write mask to 1 */
 		status = write16(state, OFDM_SC_RA_RAM_FR_THRES_8K__A,
 				   DEFAULT_FR_THRES_8K);
@@ -6794,11 +6794,11 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config,
 	state->enable_merr_cfg = config->enable_merr_cfg;
 
 	if (config->dynamic_clk) {
-		state->m_dvbt_static_clk = 0;
-		state->m_dvbc_static_clk = 0;
+		state->m_dvbt_static_clk = false;
+		state->m_dvbc_static_clk = false;
 	} else {
-		state->m_dvbt_static_clk = 1;
-		state->m_dvbc_static_clk = 1;
+		state->m_dvbt_static_clk = true;
+		state->m_dvbc_static_clk = true;
 	}
 
 
Signature · 1 line
1.9.3
#35 lore raw

PATCH 28/46 lm3560: simplify boolean tests

In reply to Mauro Carvalho Chehab

Instead of using if (on == true), just use
if (on).

That allows a faster mental parsing when analyzing the code.

drivers/media/i2c/lm3560.c +2 -2
index c23de593c17d..d9ece4b2d047 100644
@@ -100,14 +100,14 @@ static int lm3560_enable_ctrl(struct lm3560_flash *flash,
 	int rval;
 
 	if (led_no == LM3560_LED0) {
-		if (on == true)
+		if (on)
 			rval = regmap_update_bits(flash->regmap,
 						  REG_ENABLE, 0x08, 0x08);
 		else
 			rval = regmap_update_bits(flash->regmap,
 						  REG_ENABLE, 0x08, 0x00);
 	} else {
-		if (on == true)
+		if (on)
 			rval = regmap_update_bits(flash->regmap,
 						  REG_ENABLE, 0x10, 0x10);
 		else
Signature · 1 line
1.9.3
#38 lore raw

PATCH 29/46 lm3560: simplify a boolean test

In reply to Mauro Carvalho Chehab

lml33dpatch is boolean. So, the possible values are true or false.

Instead of using if (lml33dpath), just use
if (!lml33dpath).

That allows a faster mental parsing when analyzing the code.

drivers/media/pci/zoran/zoran_device.c +1 -1
index bf34b93f23ee..b6801e035ea4 100644
@@ -682,7 +682,7 @@ set_videobus_dir (struct zoran *zr,
 	switch (zr->card.type) {
 	case LML33:
 	case LML33R10:
-		if (lml33dpath == 0)
+		if (!lml33dpath)
 			GPIO(zr, 5, val);
 		else
 			GPIO(zr, 5, 1);
Signature · 1 line
1.9.3
#39 lore raw

PATCH 30/46 omap: simplify test logic

In reply to Mauro Carvalho Chehab

instead of testing bools if they are false or true, just use if (!foo) or if (foo). That makes the code easier to read and shorter.

Also, properly initialize booleans with true or false.

drivers/media/platform/omap/omap_vout.c +4 -4
index d9258f3d0f8e..64ab6fb06b9c 100644
@@ -989,7 +989,7 @@ static int omap_vout_release(struct file *file)
 		mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN |
 			DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_VSYNC2;
 		omap_dispc_unregister_isr(omap_vout_isr, vout, mask);
-		vout->streaming = 0;
+		vout->streaming = false;
 
 		videobuf_streamoff(q);
 		videobuf_queue_cancel(q);
@@ -1644,7 +1644,7 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
 	vout->field_id = 0;
 
 	/* set flag here. Next QBUF will start DMA */
-	vout->streaming = 1;
+	vout->streaming = true;
 
 	vout->first_int = 1;
 
@@ -1704,7 +1704,7 @@ static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
 	if (!vout->streaming)
 		return -EINVAL;
 
-	vout->streaming = 0;
+	vout->streaming = false;
 	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN | DISPC_IRQ_EVSYNC_ODD
 		| DISPC_IRQ_VSYNC2;
 
@@ -1912,7 +1912,7 @@ static int __init omap_vout_setup_video_data(struct omap_vout_device *vout)
 	control[0].id = V4L2_CID_ROTATE;
 	control[0].value = 0;
 	vout->rotation = 0;
-	vout->mirror = 0;
+	vout->mirror = false;
 	vout->control[2].id = V4L2_CID_HFLIP;
 	vout->control[2].value = 0;
 	if (vout->vid_info.rotation_type == VOUT_ROT_VRFB)
drivers/media/platform/omap/omap_vout_vrfb.c +5 -5
index 62e7e5783ce8..aa39306afc73 100644
@@ -148,7 +148,7 @@ int omap_vout_setup_vrfb_bufs(struct platform_device *pdev, int vid_num,
 			ret =  -ENOMEM;
 			goto release_vrfb_ctx;
 		}
-		vout->vrfb_static_allocation = 1;
+		vout->vrfb_static_allocation = true;
 	}
 	return 0;
 
@@ -336,7 +336,7 @@ void omap_vout_calculate_vrfb_offset(struct omap_vout_device *vout)
 		offset = vout->vrfb_context[0].yoffset *
 			vout->vrfb_context[0].bytespp;
 		temp_ps = ps / vr_ps;
-		if (mirroring == 0) {
+		if (!mirroring) {
 			*cropped_offset = offset + line_length *
 				temp_ps * cleft + crop->top * temp_ps;
 		} else {
@@ -350,7 +350,7 @@ void omap_vout_calculate_vrfb_offset(struct omap_vout_device *vout)
 			vout->vrfb_context[0].bytespp) +
 			(vout->vrfb_context[0].xoffset *
 			vout->vrfb_context[0].bytespp));
-		if (mirroring == 0) {
+		if (!mirroring) {
 			*cropped_offset = offset + (line_length * ps * ctop) +
 				(cleft / vr_ps) * ps;
 
@@ -364,7 +364,7 @@ void omap_vout_calculate_vrfb_offset(struct omap_vout_device *vout)
 		offset = MAX_PIXELS_PER_LINE * vout->vrfb_context[0].xoffset *
 			vout->vrfb_context[0].bytespp;
 		temp_ps = ps / vr_ps;
-		if (mirroring == 0) {
+		if (!mirroring) {
 			*cropped_offset = offset + line_length *
 			    temp_ps * crop->left + ctop * ps;
 		} else {
@@ -375,7 +375,7 @@ void omap_vout_calculate_vrfb_offset(struct omap_vout_device *vout)
 		}
 		break;
 	case dss_rotation_0_degree:
-		if (mirroring == 0) {
+		if (!mirroring) {
 			*cropped_offset = (line_length * ps) *
 				crop->top + (crop->left / vr_ps) * ps;
 		} else {
Signature · 1 line
1.9.3
#40 lore raw

PATCH 31/46 via-camera: simplify boolean tests

In reply to Mauro Carvalho Chehab

Instead of using if (foo == false), just use
if (!foo).

That allows a faster mental parsing when analyzing the code.

drivers/media/platform/via-camera.c +1 -1
index 00d431293190..ae6870cb8339 100644
@@ -1276,7 +1276,7 @@ static bool viacam_serial_is_enabled(void)
 			VIACAM_SERIAL_CREG, &cbyte);
 	if ((cbyte & VIACAM_SERIAL_BIT) == 0)
 		return false; /* Not enabled */
-	if (override_serial == 0) {
+	if (!override_serial) {
 		printk(KERN_NOTICE "Via camera: serial port is enabled, " \
 				"refusing to load.\n");
 		printk(KERN_NOTICE "Specify override_serial=1 to force " \
Signature · 1 line
1.9.3
#41 lore raw

PATCH 32/46 e4000: simplify boolean tests

In reply to Mauro Carvalho Chehab

Instead of using if (foo == false), just use
if (!foo).

That allows a faster mental parsing when analyzing the code.

drivers/media/tuners/e4000.c +2 -2
index 90d93348f20c..cd9cf643f602 100644
@@ -400,7 +400,7 @@ static int e4000_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
 	struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl);
 	int ret;
 
-	if (s->active == false)
+	if (!s->active)
 		return 0;
 
 	switch (ctrl->id) {
@@ -423,7 +423,7 @@ static int e4000_s_ctrl(struct v4l2_ctrl *ctrl)
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	int ret;
 
-	if (s->active == false)
+	if (!s->active)
 		return 0;
 
 	switch (ctrl->id) {
Signature · 1 line
1.9.3
#42 lore raw

Re: [PATCH 32/46] [media] e4000: simplify boolean tests

Which is static analyzer you are referring to fix these?

Using true/false for boolean datatype sounds OK, but personally I dislike use of negation operator. For my eyes (foo = 0) / (foo == false) is better and I have changed all the time negate operators to equal operators from my drivers.

regards
Antti

Quoted 31 lines · Mauro Carvalho Chehab

Instead of using if (foo == false), just use
if (!foo).

That allows a faster mental parsing when analyzing the code.

drivers/media/tuners/e4000.c +2 -2
index 90d93348f20c..cd9cf643f602 100644
@@ -400,7 +400,7 @@ static int e4000_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
  	struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl);
  	int ret;
 
-	if (s->active == false)
+	if (!s->active)
  		return 0;
 
  	switch (ctrl->id) {
@@ -423,7 +423,7 @@ static int e4000_s_ctrl(struct v4l2_ctrl *ctrl)
  	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  	int ret;
 
-	if (s->active == false)
+	if (!s->active)
  		return 0;
 
  	switch (ctrl->id) {
Signature · 1 line
http://palosaari.fi/
#43 lore raw

Re: [PATCH 32/46] [media] e4000: simplify boolean tests

Em Thu, 04 Sep 2014 02:56:19 +0300
Antti Palosaari <[email protected]> escreveu:

Quoted 1 line

Which is static analyzer you are referring to fix these?

Coccinelle. See: scripts/coccinelle/misc/boolinit.cocci

Quoted 4 lines

Using true/false for boolean datatype sounds OK, but personally I dislike use of negation operator. For my eyes (foo = 0) / (foo == false) is better and I have changed all the time negate operators to equal operators from my drivers.

The usage of the negation operator on such tests is there since the beginning of C.

By being shorter, a reviewer can read it faster and, at least for me, it is a non-brain to understand !foo. On the other hand, "false" is not part of standard C. So, it takes more time for my brain to parse it.

Anyway, from my side, the real reasone for using it is not due to that. It is that I (and other Kernel developers) run from time to time static analyzers like smatch and coccinelle, in order to identify real errors. Having a less-polluted log helps to identify the newer errors/warnings.

Regards,
Mauro

Quoted 37 lines

regards
Antti

Quoted 31 lines · Mauro Carvalho Chehab

Instead of using if (foo == false), just use
if (!foo).

That allows a faster mental parsing when analyzing the code.

drivers/media/tuners/e4000.c +2 -2
index 90d93348f20c..cd9cf643f602 100644
@@ -400,7 +400,7 @@ static int e4000_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
  	struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl);
  	int ret;
 
-	if (s->active == false)
+	if (!s->active)
  		return 0;
 
  	switch (ctrl->id) {
@@ -423,7 +423,7 @@ static int e4000_s_ctrl(struct v4l2_ctrl *ctrl)
  	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  	int ret;
 
-	if (s->active == false)
+	if (!s->active)
  		return 0;
 
  	switch (ctrl->id) {
#44 lore raw

Re: [PATCH 32/46] [media] e4000: simplify boolean tests

Quoted 7 lines · Mauro Carvalho Chehab

Em Thu, 04 Sep 2014 02:56:19 +0300
Antti Palosaari <[email protected]> escreveu:

Quoted 1 line

Which is static analyzer you are referring to fix these?

Coccinelle. See: scripts/coccinelle/misc/boolinit.cocci

Quoted 7 lines
Quoted 4 lines

Using true/false for boolean datatype sounds OK, but personally I dislike use of negation operator. For my eyes (foo = 0) / (foo == false) is better and I have changed all the time negate operators to equal operators from my drivers.

The usage of the negation operator on such tests is there since the beginning of C.

ugh! :(

Quoted 5 lines

By being shorter, a reviewer can read it faster and, at least for me, it is a non-brain to understand !foo. On the other hand, "false" is not part of standard C. So, it takes more time for my brain to parse it.

No, it just opposite for me and many others.

Quoted 6 lines

Anyway, from my side, the real reasone for using it is not due to that. It is that I (and other Kernel developers) run from time to time static analyzers like smatch and coccinelle, in order to identify real errors. Having a less-polluted log helps to identify the newer errors/warnings.

Have you ever looked Documentation/CodingStyle ?
How about that example, from CodingStyle:
int fun(int a)

{
	int result = 0;
	char *buffer = kmalloc(SIZE);

	if (buffer == NULL)
		return -ENOMEM;

	if (condition1) {
		while (loop1) {
			...
		}
		result = 1;
		goto out;
	}
	...
out:
	kfree(buffer);
	return result;
}

As it shows, it is (buffer == NULL) *not* (!buffer). And if you like to do it differently then update CodingStyle first! Add clear mention that it should be (!buffer) and change given example to match your style. Otherwise, I am happy to do as CodingStyle shows!

Antti

Quoted 40 lines

Regards,
Mauro

Quoted 37 lines

regards
Antti

Quoted 31 lines · Mauro Carvalho Chehab

Instead of using if (foo == false), just use
if (!foo).

That allows a faster mental parsing when analyzing the code.

drivers/media/tuners/e4000.c +2 -2
index 90d93348f20c..cd9cf643f602 100644
@@ -400,7 +400,7 @@ static int e4000_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
   	struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl);
   	int ret;
 
-	if (s->active == false)
+	if (!s->active)
   		return 0;
 
   	switch (ctrl->id) {
@@ -423,7 +423,7 @@ static int e4000_s_ctrl(struct v4l2_ctrl *ctrl)
   	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
   	int ret;
 
-	if (s->active == false)
+	if (!s->active)
   		return 0;
 
   	switch (ctrl->id) {
Signature · 1 line
http://palosaari.fi/
author Reviewed-by Rusty Russell
#45 lore raw

Re: [PATCH 32/46] [media] e4000: simplify boolean tests

Em Thu, 04 Sep 2014 04:27:57 +0300
Antti Palosaari <[email protected]> escreveu:

Quoted 6 lines
Quoted 4 lines

By being shorter, a reviewer can read it faster and, at least for me, it is a non-brain to understand !foo. On the other hand, "false" is not part of standard C. So, it takes more time for my brain to parse it.

No, it just opposite for me and many others.

Yeah, this is subjective, so different people have different views.

Yet, if you take a look on the numbers inside the Kernel, this is what we have:

$ git grep "== false" |wc -l
622
$ git grep "false ==" |wc -l
41
$ git grep 'if (!' |wc -l
153125

Being 249 occurrences inside Documentation:

$ git grep 'if (!' |grep Docum|wc -l
249
$ git grep "false ==" |grep Docum |wc -l
0
$ git grep "== false" |grep Docum |wc -l
1

Where the only Documentation with == false is this one (at Documentation/thermal/sysfs-api.txt):
.no_hwmon: a boolean to indicate if the thermal to hwmon sysfs interface
is required. when no_hwmon == false, a hwmon sysfs interface will be created. when no_hwmon == true, nothing will be done. In case the thermal_zone_params is NULL, the hwmon interface will be created (for backward compatibility).

Yet, at the only place where this is tested, the syntax is !foo:

drivers/thermal/thermal_core.c: if (!tz->tzp || !tz->tzp->no_hwmon) {

So, clearly, the vast majority of Kernel developers are using !foo.

Quoted 9 lines
Quoted 5 lines

Anyway, from my side, the real reasone for using it is not due to that. It is that I (and other Kernel developers) run from time to time static analyzers like smatch and coccinelle, in order to identify real errors. Having a less-polluted log helps to identify the newer errors/warnings.

Have you ever looked Documentation/CodingStyle ?
How about that example, from CodingStyle:
int fun(int a)

Quoted 6 lines
{
	int result = 0;
	char *buffer = kmalloc(SIZE);

	if (buffer == NULL)
		return -ENOMEM;

Well, buffer is not a boolean operator.

I would code myself with if (!buffer), but I accept patches with both ways, and I've seen a mix of both usages inside the Kernel.

Quoted 14 lines
	if (condition1) {
		while (loop1) {
			...
		}
		result = 1;
		goto out;
	}
	...
out:
	kfree(buffer);
	return result;
}
Quoted 4 lines

As it shows, it is (buffer == NULL) *not* (!buffer). And if you like to do it differently then update CodingStyle first! Add clear mention that it should be (!buffer) and change given example to match your style. Otherwise, I am happy to do as CodingStyle shows!

It is not me opting for it. Someone's else added the coccinelle patch upstream, and it got at least 2 different reviewers besides its author:

commit 8991058171f3536c0a8fbb50ad311689b8b74979

Author: Julia Lawall <[email protected]>
Date:   Fri Feb 10 22:05:18 2012 +0100

coccinelle: semantic patch for bool issues

Anyway, as I said, my main interest is to just shut up the in-Kernel tests, as this helps to better identify real problems.

I don't care if this is done by someone sending a patch to remove or modify the coccinelle script to accept both ways or to use the approach taken by this patch.

Quoted 44 lines

Antti

Quoted 40 lines

Regards,
Mauro

Quoted 37 lines

regards
Antti

Quoted 31 lines · Mauro Carvalho Chehab

Instead of using if (foo == false), just use
if (!foo).

That allows a faster mental parsing when analyzing the code.

drivers/media/tuners/e4000.c +2 -2
index 90d93348f20c..cd9cf643f602 100644
@@ -400,7 +400,7 @@ static int e4000_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
   	struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl);
   	int ret;
 
-	if (s->active == false)
+	if (!s->active)
   		return 0;
 
   	switch (ctrl->id) {
@@ -423,7 +423,7 @@ static int e4000_s_ctrl(struct v4l2_ctrl *ctrl)
   	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
   	int ret;
 
-	if (s->active == false)
+	if (!s->active)
   		return 0;
 
   	switch (ctrl->id) {
#46 lore raw

PATCH 33/46 s5p-tv: Simplify the return logic

In reply to Mauro Carvalho Chehab

Make sure pm_runtime_* calls does not use unnecessary IS_ERR_VALUE().

Reported by scripts/coccinelle/api/pm_runtime.cocci script.

drivers/media/platform/s5p-tv/hdmi_drv.c +1 -1
index 754740f4b671..37c8bd694c5f 100644
@@ -615,7 +615,7 @@ static int hdmi_s_power(struct v4l2_subdev *sd, int on)
 	else
 		ret = pm_runtime_put_sync(hdev->dev);
 	/* only values < 0 indicate errors */
-	return IS_ERR_VALUE(ret) ? ret : 0;
+	return ret < 0 ? ret : 0;
 }
 
 static int hdmi_s_dv_timings(struct v4l2_subdev *sd,
drivers/media/platform/s5p-tv/sdo_drv.c +1 -1
index 5a7c3796f22e..72cf892dd008 100644
@@ -190,7 +190,7 @@ static int sdo_s_power(struct v4l2_subdev *sd, int on)
 		ret = pm_runtime_put_sync(dev);
 
 	/* only values < 0 indicate errors */
-	return IS_ERR_VALUE(ret) ? ret : 0;
+	return ret < 0 ? ret : 0;
 }
 
 static int sdo_streamon(struct sdo_device *sdev)
drivers/media/platform/s5p-tv/sii9234_drv.c +1 -1
index 3dd762e5b67e..db8c17bb4aaa 100644
@@ -289,7 +289,7 @@ static int sii9234_s_power(struct v4l2_subdev *sd, int on)
 	else
 		ret = pm_runtime_put(&ctx->client->dev);
 	/* only values < 0 indicate errors */
-	return IS_ERR_VALUE(ret) ? ret : 0;
+	return ret < 0 ? ret : 0;
 }
 
 static int sii9234_s_stream(struct v4l2_subdev *sd, int enable)
Signature · 1 line
1.9.3
#47 lore raw

PATCH 34/46 siano: just return 0 instead of using a var

In reply to Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

drivers/media/common/siano/smscoreapi.c +1 -3
index 050984c5b1e3..a3677438205e 100644
@@ -2129,8 +2129,6 @@ int smscore_gpio_get_level(struct smscore_device_t *coredev, u8 pin_num,
 
 static int __init smscore_module_init(void)
 {
-	int rc = 0;
-
 	INIT_LIST_HEAD(&g_smscore_notifyees);
 	INIT_LIST_HEAD(&g_smscore_devices);
 	kmutex_init(&g_smscore_deviceslock);
@@ -2138,7 +2136,7 @@ static int __init smscore_module_init(void)
 	INIT_LIST_HEAD(&g_smscore_registry);
 	kmutex_init(&g_smscore_registrylock);
 
-	return rc;
+	return 0;
 }
 
 static void __exit smscore_module_exit(void)
Signature · 1 line
1.9.3
#48 lore raw

PATCH 35/46 stv0367: just return 0 instead of using a var

In reply to Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

drivers/media/dvb-frontends/stv0367.c +1 -3
index 764577218974..59f622ae80e8 100644
@@ -1935,8 +1935,6 @@ static int stv0367ter_get_frontend(struct dvb_frontend *fe)
 	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
 	struct stv0367_state *state = fe->demodulator_priv;
 	struct stv0367ter_state *ter_state = state->ter_state;
-
-	int error = 0;
 	enum stv0367_ter_mode mode;
 	int constell = 0,/* snr = 0,*/ Data = 0;
 
@@ -2020,7 +2018,7 @@ static int stv0367ter_get_frontend(struct dvb_frontend *fe)
 
 	p->guard_interval = stv0367_readbits(state, F367TER_SYR_GUARD);
 
-	return error;
+	return 0;
 }
 
 static int stv0367ter_read_snr(struct dvb_frontend *fe, u16 *snr)
Signature · 1 line
1.9.3
#49 lore raw

PATCH 36/46 media-devnode: just return 0 instead of using a var

In reply to Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

drivers/media/media-devnode.c +1 -2
index 7acd19c881de..ebf9626e5ae5 100644
@@ -192,7 +192,6 @@ static int media_open(struct inode *inode, struct file *filp)
 static int media_release(struct inode *inode, struct file *filp)
 {
 	struct media_devnode *mdev = media_devnode_data(filp);
-	int ret = 0;
 
 	if (mdev->fops->release)
 		mdev->fops->release(filp);
@@ -201,7 +200,7 @@ static int media_release(struct inode *inode, struct file *filp)
 	   return value is ignored. */
 	put_device(&mdev->dev);
 	filp->private_data = NULL;
-	return ret;
+	return 0;
 }
 
 static const struct file_operations media_devnode_fops = {
Signature · 1 line
1.9.3
#50 lore raw

PATCH 37/46 bt8xx: just return 0 instead of using a var

In reply to Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

drivers/media/pci/bt8xx/bttv-driver.c +1 -2
index 750bdab8aacb..4a8176c09fc9 100644
@@ -1531,7 +1531,6 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
 {
 	struct bttv_buffer *old;
 	unsigned long flags;
-	int retval = 0;
 
 	dprintk("switch_overlay: enter [new=%p]\n", new);
 	if (new)
@@ -1551,7 +1550,7 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
 	if (NULL == new)
 		free_btres_lock(btv,fh,RESOURCE_OVERLAY);
 	dprintk("switch_overlay: done\n");
-	return retval;
+	return 0;
 }
 
 /* ----------------------------------------------------------------------- */
drivers/media/pci/bt8xx/dst_ca.c +1 -3
index 0e788fca992c..c22c4ae06844 100644
@@ -674,11 +674,9 @@ static int dst_ca_release(struct inode *inode, struct file *file)
 
 static ssize_t dst_ca_read(struct file *file, char __user *buffer, size_t length, loff_t *offset)
 {
-	ssize_t bytes_read = 0;
-
 	dprintk(verbose, DST_CA_DEBUG, 1, " Device read.");
 
-	return bytes_read;
+	return 0;
 }
 
 static ssize_t dst_ca_write(struct file *file, const char __user *buffer, size_t length, loff_t *offset)
Signature · 1 line
1.9.3
#51 lore raw

PATCH 38/46 saa7164: just return 0 instead of using a var

In reply to Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

drivers/media/pci/saa7164/saa7164-api.c +1 -2
index e042963d377d..4f3b1dd18ba4 100644
@@ -680,7 +680,6 @@ static int saa7164_api_set_dif(struct saa7164_port *port, u8 reg, u8 val)
 int saa7164_api_configure_dif(struct saa7164_port *port, u32 std)
 {
 	struct saa7164_dev *dev = port->dev;
-	int ret = 0;
 	u8 agc_disable;
 
 	dprintk(DBGLVL_API, "%s(nr=%d, 0x%x)\n", __func__, port->nr, std);
@@ -733,7 +732,7 @@ int saa7164_api_configure_dif(struct saa7164_port *port, u32 std)
 	saa7164_api_set_dif(port, 0x04, 0x00); /* Active (again) */
 	msleep(100);
 
-	return ret;
+	return 0;
 }
 
 /* Ensure the dif is in the correct state for the operating mode
Signature · 1 line
1.9.3
#52 lore raw

PATCH 39/46 davinci: just return 0 instead of using a var

In reply to Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

drivers/media/platform/davinci/vpfe_capture.c +1 -2
index ed9dd27e3c63..c557eb5ebf6b 100644
@@ -943,12 +943,11 @@ static int vpfe_g_fmt_vid_cap(struct file *file, void *priv,
 				struct v4l2_format *fmt)
 {
 	struct vpfe_device *vpfe_dev = video_drvdata(file);
-	int ret = 0;
 
 	v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_fmt_vid_cap\n");
 	/* Fill in the information about format */
 	*fmt = vpfe_dev->fmt;
-	return ret;
+	return 0;
 }
 
 static int vpfe_enum_fmt_vid_cap(struct file *file, void  *priv,
Signature · 1 line
1.9.3
Acked-by on v1 39/46
#53 lore raw

Re: [PATCH 39/46] [media] davinci: just return 0 instead of using a var

Quoted 3 lines · Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

Regards,
--Prabhakar Lad

Quoted 23 lines
drivers/media/platform/davinci/vpfe_capture.c +1 -3
index ed9dd27e3c63..c557eb5ebf6b 100644
@@ -943,12 +943,11 @@ static int vpfe_g_fmt_vid_cap(struct file *file, void *priv,
                                struct v4l2_format *fmt)
 {
        struct vpfe_device *vpfe_dev = video_drvdata(file);
-       int ret = 0;
 
        v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_fmt_vid_cap\n");
        /* Fill in the information about format */
        *fmt = vpfe_dev->fmt;
-       return ret;
+       return 0;
 }
 
 static int vpfe_enum_fmt_vid_cap(struct file *file, void  *priv,
--

1.9.3

#54 lore raw

PATCH 40/46 marvel-ccic: just return 0 instead of using a var

In reply to Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

drivers/media/platform/exynos4-is/fimc-isp-video.c +1 -2
index 93f9cf2ebcd6..9d8d885558e5 100644
@@ -313,7 +313,6 @@ static int isp_video_release(struct file *file)
 	struct fimc_is_video *ivc = &isp->video_capture;
 	struct media_entity *entity = &ivc->ve.vdev.entity;
 	struct media_device *mdev = entity->parent;
-	int ret = 0;
 
 	mutex_lock(&isp->video_lock);
 
@@ -335,7 +334,7 @@ static int isp_video_release(struct file *file)
 	pm_runtime_put(&isp->pdev->dev);
 	mutex_unlock(&isp->video_lock);
 
-	return ret;
+	return 0;
 }
 
 static const struct v4l2_file_operations isp_video_fops = {
Signature · 1 line
1.9.3
#55 lore raw

PATCH 41/46 fintek-cir: just return 0 instead of using a var

In reply to Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

drivers/media/rc/fintek-cir.c +2 -4
index f0a1f7d31ee6..b5167573240e 100644
@@ -148,7 +148,6 @@ static int fintek_hw_detect(struct fintek_dev *fintek)
 	u8 vendor_major, vendor_minor;
 	u8 portsel, ir_class;
 	u16 vendor, chip;
-	int ret = 0;
 
 	fintek_config_mode_enable(fintek);
 
@@ -208,7 +207,7 @@ static int fintek_hw_detect(struct fintek_dev *fintek)
 
 	spin_unlock_irqrestore(&fintek->fintek_lock, flags);
 
-	return ret;
+	return 0;
 }
 
 static void fintek_cir_ldev_init(struct fintek_dev *fintek)
@@ -644,7 +643,6 @@ static int fintek_suspend(struct pnp_dev *pdev, pm_message_t state)
 
 static int fintek_resume(struct pnp_dev *pdev)
 {
-	int ret = 0;
 	struct fintek_dev *fintek = pnp_get_drvdata(pdev);
 
 	fit_dbg("%s called", __func__);
@@ -661,7 +659,7 @@ static int fintek_resume(struct pnp_dev *pdev)
 
 	fintek_cir_regs_init(fintek);
 
-	return ret;
+	return 0;
 }
 
 static void fintek_shutdown(struct pnp_dev *pdev)
Signature · 1 line
1.9.3
#56 lore raw

PATCH 42/46 ite-cir: just return 0 instead of using a var

In reply to Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

drivers/media/rc/ite-cir.c +1 -2
index 447fe35862dc..56abf9120cc2 100644
@@ -1666,7 +1666,6 @@ static int ite_suspend(struct pnp_dev *pdev, pm_message_t state)
 
 static int ite_resume(struct pnp_dev *pdev)
 {
-	int ret = 0;
 	struct ite_dev *dev = pnp_get_drvdata(pdev);
 	unsigned long flags;
 
@@ -1681,7 +1680,7 @@ static int ite_resume(struct pnp_dev *pdev)
 
 	spin_unlock_irqrestore(&dev->lock, flags);
 
-	return ret;
+	return 0;
 }
 
 static void ite_shutdown(struct pnp_dev *pdev)
Signature · 1 line
1.9.3
#57 lore raw

PATCH 43/46 nuvoton-cir: just return 0 instead of using a var

In reply to Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

drivers/media/rc/nuvoton-cir.c +2 -4
index 7f4fd859bba5..9c2c8635ff33 100644
@@ -229,7 +229,6 @@ static int nvt_hw_detect(struct nvt_dev *nvt)
 {
 	unsigned long flags;
 	u8 chip_major, chip_minor;
-	int ret = 0;
 	char chip_id[12];
 	bool chip_unknown = false;
 
@@ -285,7 +284,7 @@ static int nvt_hw_detect(struct nvt_dev *nvt)
 	nvt->chip_minor = chip_minor;
 	spin_unlock_irqrestore(&nvt->nvt_lock, flags);
 
-	return ret;
+	return 0;
 }
 
 static void nvt_cir_ldev_init(struct nvt_dev *nvt)
@@ -1177,7 +1176,6 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)
 
 static int nvt_resume(struct pnp_dev *pdev)
 {
-	int ret = 0;
 	struct nvt_dev *nvt = pnp_get_drvdata(pdev);
 
 	nvt_dbg("%s called", __func__);
@@ -1195,7 +1193,7 @@ static int nvt_resume(struct pnp_dev *pdev)
 	nvt_cir_regs_init(nvt);
 	nvt_cir_wake_regs_init(nvt);
 
-	return ret;
+	return 0;
 }
 
 static void nvt_shutdown(struct pnp_dev *pdev)
Signature · 1 line
1.9.3
#58 lore raw

PATCH 44/46 mt2060: just return 0 instead of using a var

In reply to Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

drivers/media/tuners/mt2060.c +1 -2
index 13381de58a84..b87b2549d58d 100644
@@ -157,7 +157,6 @@ static int mt2060_set_params(struct dvb_frontend *fe)
 {
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	struct mt2060_priv *priv;
-	int ret=0;
 	int i=0;
 	u32 freq;
 	u8  lnaband;
@@ -240,7 +239,7 @@ static int mt2060_set_params(struct dvb_frontend *fe)
 	if (fe->ops.i2c_gate_ctrl)
 		fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */
 
-	return ret;
+	return 0;
 }
 
 static void mt2060_calibrate(struct mt2060_priv *priv)
Signature · 1 line
1.9.3
#59 lore raw

PATCH 45/46 mxl5005s: just return 0 instead of using a var

In reply to Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

drivers/media/tuners/mxl5005s.c +1 -2
index b473b76cb278..92a3be4fde87 100644
@@ -1692,7 +1692,6 @@ static u16 MXL5005_TunerConfig(struct dvb_frontend *fe,
 	)
 {
 	struct mxl5005s_state *state = fe->tuner_priv;
-	u16 status = 0;
 
 	state->Mode = Mode;
 	state->IF_Mode = IF_mode;
@@ -1715,7 +1714,7 @@ static u16 MXL5005_TunerConfig(struct dvb_frontend *fe,
 	/* Synthesizer LO frequency calculation */
 	MXL_SynthIFLO_Calc(fe);
 
-	return status;
+	return 0;
 }
 
 static void MXL_SynthIFLO_Calc(struct dvb_frontend *fe)
Signature · 1 line
1.9.3
#60 lore raw

PATCH 46/46 cx231xx: just return 0 instead of using a var

In reply to Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it, change the code to return 0 directly.

drivers/media/usb/cx231xx/cx231xx-dvb.c +1 -3
index 2adfecf70236..6c7b5e250eed 100644
@@ -403,8 +403,6 @@ static int attach_xc5000(u8 addr, struct cx231xx *dev)
 
 int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq)
 {
-	int status = 0;
-
 	if ((dev->dvb != NULL) && (dev->dvb->frontend != NULL)) {
 
 		struct dvb_tuner_ops *dops = &dev->dvb->frontend->ops.tuner_ops;
@@ -423,7 +421,7 @@ int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq)
 
 	}
 
-	return status;
+	return 0;
 }
 
 int cx231xx_reset_analog_tuner(struct cx231xx *dev)
Signature · 1 line
1.9.3