aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/v4l1-compat.c
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2009-08-01 15:48:41 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-12 11:19:08 -0400
commit75b697f747b14b0c6afae48ee0f5e605abd2df4c (patch)
tree3812e853ff3d8758cded2fdfebb58bdec76babfc /drivers/media/video/v4l1-compat.c
parent166987c6987a25a95cef6889d24088f0eb2daa36 (diff)
V4L/DVB (12483): Use DIV_ROUND_CLOSEST
The kernel.h macro DIV_ROUND_CLOSEST performs the computation (x + d/2)/d but is perhaps more readable. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @haskernel@ @@ @depends on haskernel@ expression x,__divisor; @@ - (((x) + ((__divisor) / 2)) / (__divisor)) + DIV_ROUND_CLOSEST(x,__divisor) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/v4l1-compat.c')
-rw-r--r--drivers/media/video/v4l1-compat.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index 02f2a6d18b45..761fbd64db58 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -76,9 +76,8 @@ get_v4l_control(struct file *file,
76 dprintk("VIDIOC_G_CTRL: %d\n", err); 76 dprintk("VIDIOC_G_CTRL: %d\n", err);
77 return 0; 77 return 0;
78 } 78 }
79 return ((ctrl2.value - qctrl2.minimum) * 65535 79 return DIV_ROUND_CLOSEST((ctrl2.value-qctrl2.minimum) * 65535,
80 + (qctrl2.maximum - qctrl2.minimum) / 2) 80 qctrl2.maximum - qctrl2.minimum);
81 / (qctrl2.maximum - qctrl2.minimum);
82 } 81 }
83 return 0; 82 return 0;
84} 83}