Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5569356ybp; Tue, 8 Oct 2019 05:08:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBLJFOOjRMt425p1kio9LanjY58Z3luxyLFrMtNRnhv6TEbVG4/J4+55Ypgc1j3rp2yPvW X-Received: by 2002:a17:906:7e56:: with SMTP id z22mr28019760ejr.294.1570536513416; Tue, 08 Oct 2019 05:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570536513; cv=none; d=google.com; s=arc-20160816; b=ruU/U394iJC9yzvhhASUu8kG0vnTM52dKme07KuPoTRigI7uvM0mcFlbnEu16yzFHJ ZfioPWzf5rH5QqN/1uqN7wiAQO17NldFgn0Yv0W86WJ7+EOD0+NI3AZwooY5J7Wz0GkR DfdQpa/BVBZ20NUPv3GhZ9hGBcL8bmrqqlFCvmBEocts0hNJpr4NcR1+oqm7r+URAdQb F8H0DgWp/YvwhQiZvWmubU1M1lHJ6I8axMo/tV2K1C+keWcj+oIitpF31f97Rz9dbGZh 48NUcQZdbZeweL7ZJXEbQdgJ21+RQ8Yhz2TtAbTsNxB0IXzwYoek+fLrO3iO4cu9DvQf WKWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t1XvNBeL5bYKnc6NbbptU+vm2vXQBBrTO687+/k8huo=; b=JvvJ1NSVosrZJ9eF6Rnbp/QVMohqbVfAKgYetpg/SftZsywqDZW9/ewd3rgs5C3lFz U+iN2Vz+YahJbMDkANKLKRLJks37jLoUNmjlY5K68Uopb/XdhNw56p12pgtDezZI2vnv hJZirgj/y/jCZY6KywAfXPLyRqyvWlX1W3rFEBkaf0GyJw9YusVZnBUakx58eFwQxmi+ EGTiI6eVTJECVS+nO+YBugZL+YTC7Xxwjoin6/lvOuzH6MyP6bKle1fgOULfP7dvhlGV Kv0o8gQufkeU5L5eb+c59AwujKelDKwTqZtK+LeKPcsBnfpB2SOEo4Psfee1ALTYqK1I TQ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=ELuDRuvE; 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 w20si10750612edc.202.2019.10.08.05.08.10; Tue, 08 Oct 2019 05:08:33 -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; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=ELuDRuvE; 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 S1730914AbfJHMFY (ORCPT + 99 others); Tue, 8 Oct 2019 08:05:24 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:44890 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730904AbfJHMFY (ORCPT ); Tue, 8 Oct 2019 08:05:24 -0400 Received: by mail-lj1-f196.google.com with SMTP id m13so17191546ljj.11 for ; Tue, 08 Oct 2019 05:05:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t1XvNBeL5bYKnc6NbbptU+vm2vXQBBrTO687+/k8huo=; b=ELuDRuvEPbxHn+tPF2h2RxCruUdG8zM+LbvVMlIluH8Z/3Nz3rM48QruNf6Jjzt6Qx s+T3vGwTXw/HUazqjiUT8y6NaXwohlIowNQCdfwlwMsrwKqKmMOt9HlxSOwPJeCD4YOl uaNX5F5hIsDxJs3FYKG+NK0+p/NucTLWFjocY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t1XvNBeL5bYKnc6NbbptU+vm2vXQBBrTO687+/k8huo=; b=DKFlYMgYXFDrgLvgHa24PcuxeqVfHUfPSiPer6LVsq8D2xF+c/08sgeAWarrpq5JFM 96pTm2xmpo4nUAwuB7xW/ECpf3pDzmczdNUo36cQWn58tVRk1V/3SxH211ZapQquYZGA OoH8pX7wK5bhhWcG0gZj2uTfAA1KJLjbdaZs8+Bd6q9xzohJ1ChqWQolEhnLb8LvFK07 HyQ0tvMRvlE2m/2NQghDvrt1O6HQ0eK77LkbLg3ne1ielc8HoKFEIa2FEliapFGawqlH tHMJtyleFs7alCAegkmJsbZurLJbuxlxKfBzXw+4bdJ8j9rWQOQePkisU9WSJ2N/J366 /t5g== X-Gm-Message-State: APjAAAVWZKwV+O+TVGp2JE1esOZiBVrHukC09fK3ki4EQU2vJZaeTLE0 9Y2+tyPUO+L5F5i6is1c6CaNFw== X-Received: by 2002:a2e:9d16:: with SMTP id t22mr19624221lji.207.1570536321581; Tue, 08 Oct 2019 05:05:21 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id z18sm3918033ljh.17.2019.10.08.05.05.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2019 05:05:19 -0700 (PDT) From: Rasmus Villemoes To: Thierry Reding , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz Cc: Rasmus Villemoes , linux-pwm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] backlight: pwm_bl: eliminate a 64/32 division Date: Tue, 8 Oct 2019 14:03:25 +0200 Message-Id: <20191008120327.24208-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191008120327.24208-1-linux@rasmusvillemoes.dk> References: <20191008120327.24208-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org lightness*1000 is nowhere near overflowing 32 bits, so we can just use an ordinary 32/32 division, which is much cheaper than the 64/32 done via do_div(). Reviewed-by: Daniel Thompson Signed-off-by: Rasmus Villemoes --- drivers/video/backlight/pwm_bl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index cc44a02e95c7..672c5e7cfcd1 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -177,7 +177,7 @@ static u64 cie1931(unsigned int lightness, unsigned int scale) */ lightness *= 100; if (lightness <= (8 * scale)) { - retval = DIV_ROUND_CLOSEST_ULL(lightness * 10, 9033); + retval = DIV_ROUND_CLOSEST(lightness * 10, 9033); } else { retval = int_pow((lightness + (16 * scale)) / 116, 3); retval = DIV_ROUND_CLOSEST_ULL(retval, (scale * scale)); -- 2.20.1