Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1328048ybe; Thu, 5 Sep 2019 13:52:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBCVaUttTjiGyvbRh4IjHh+zW/q37AVWNMtv91kyTSzoDhxxmD+LQ6iZY2RcpUhtkquIaZ X-Received: by 2002:a17:90a:6788:: with SMTP id o8mr6066046pjj.19.1567716726837; Thu, 05 Sep 2019 13:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567716726; cv=none; d=google.com; s=arc-20160816; b=jkxQcuF9w9+BQaxuiNaROM1MLaRRvGnU46qJrSZWuhW/GA9K5iH06RFGAz09G7pAik 7IKSjFiV61nVcgFio+N3vYd2HN4P+4vsnLdJKlY0rrtT3wnJx3+Zfq3AjQngnIr0TuWG rBlYu26cCJcXRt2Y0fTRhVP/+7iCQpbFRieA2+bV2WnP05AHXx6SZY8pNP5g7GbEIdJv X/zWyMjfayB5mgH7tB2+Aswl6IxJso263gdJITqzQOzFxYCOHZzD2FdFFPmc9k77MJlg emxQNU6lkzS3kfNU3CcEuakvrloHEHD4p9CPdmwVcK7j+qtXc1yJAhGI1Pth3uxC9Y0O NCmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Dmcihu0D9PCcuESr9qYMPojVDSC/Xab2NYYuRpmZZN0=; b=H8z3pOiP6slQgoG1uDdUt2rXOJq7oBHCjgHLQuj1kN2hn4Nu9jS31LP55f+GozvSk2 MSu4CldcvQH3dX8RbVghecn0vAPJaYo+S+Lda5DKp3MBhd8NSlwcIKUrN7xfa36gIIyq D7xjkEHVE+NSjdL3in9UL6+c/3VmwpfXkbgNqzKe8xzIV90AmJSBacXTZsFUpH1YVDby 3WYLXyazuPq0jfx40fzHtyUMLvkZgL6ZLPFl9T3zUFX3/bJWM9QeZwtuL8mOWe7UhJdO mhsCL/WnVj7F6l8VOWOdwu/KlF2KnS+1k1QPNWNkFs8LsjTyQU52/3IVMr0aNPQC6hUf pF1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g23si3190538pfo.259.2019.09.05.13.51.51; Thu, 05 Sep 2019 13:52:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388068AbfIEQSK (ORCPT + 99 others); Thu, 5 Sep 2019 12:18:10 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6688 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387697AbfIEQSJ (ORCPT ); Thu, 5 Sep 2019 12:18:09 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id BB640AF43E2DBB16F63A; Fri, 6 Sep 2019 00:18:00 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Fri, 6 Sep 2019 00:18:39 +0800 From: zhong jiang To: CC: , , , , Subject: [PATCH 3/4] media: uvcvideo: Use DIV_ROUND_CLOSEST directly to make it readable Date: Fri, 6 Sep 2019 00:14:51 +0800 Message-ID: <1567700092-27769-4-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1567700092-27769-1-git-send-email-zhongjiang@huawei.com> References: <1567700092-27769-1-git-send-email-zhongjiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel.h macro DIV_ROUND_CLOSEST performs the computation (x + d/2)/d but is perhaps more readable. Signed-off-by: zhong jiang --- drivers/media/usb/uvc/uvc_ctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index e399b9f..9f3697161 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -1604,8 +1604,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 -- 1.7.12.4