aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/media/usb/uvc/uvc_ctrl.c
diff options
context:
space:
mode:
authorzhong jiang <zhongjiang@huawei.com>2019-10-09 16:55:24 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-11-27 10:19:29 +0100
commit7ae53081901b52cebfdd5b39b373abaac5d1d4ef (patch)
tree780c82cd89af1b34bbbd05443067b483d5816304 /drivers/media/usb/uvc/uvc_ctrl.c
parentmedia: imx214: Fix stop streaming (diff)
downloadwireguard-linux-7ae53081901b52cebfdd5b39b373abaac5d1d4ef.tar.xz
wireguard-linux-7ae53081901b52cebfdd5b39b373abaac5d1d4ef.zip
media: uvcvideo: Use DIV_ROUND_CLOSEST directly to make it readable
The kernel.h macro DIV_ROUND_CLOSEST performs the computation (x + d/2)/d but is perhaps more readable. Signed-off-by: zhong jiang <zhongjiang@huawei.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/usb/uvc/uvc_ctrl.c')
-rw-r--r--drivers/media/usb/uvc/uvc_ctrl.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index f479d8971dfb..011e69427b7c 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1608,8 +1608,8 @@ int uvc_ctrl_set(struct uvc_fh *handle,
if (step == 0)
step = 1;
- xctrl->value = min + ((u32)(xctrl->value - min) + step / 2)
- / step * step;
+ xctrl->value = min + DIV_ROUND_CLOSEST((u32)(xctrl->value - min),
+ step) * step;
if (mapping->data_type == UVC_CTRL_DATA_TYPE_SIGNED)
xctrl->value = clamp(xctrl->value, min, max);
else