From: zhong jiang Date: Wed, 9 Oct 2019 14:55:24 +0000 (+0200) Subject: media: uvcvideo: Use DIV_ROUND_CLOSEST directly to make it readable X-Git-Tag: accepted/tizen/unified/20230118.172025~8355^2~228 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ae53081901b52cebfdd5b39b373abaac5d1d4ef;p=platform%2Fkernel%2Flinux-rpi.git 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 Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index f479d89..011e694 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