From patchwork Thu Sep 19 14:06:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 11153921 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54A151747 for ; Fri, 20 Sep 2019 07:53:21 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3CCCF21D81 for ; Fri, 20 Sep 2019 07:53:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CCCF21D81 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rasmusvillemoes.dk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D08E46F730; Fri, 20 Sep 2019 07:53:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id D801B6F860 for ; Thu, 19 Sep 2019 14:06:31 +0000 (UTC) Received: by mail-lj1-x241.google.com with SMTP id y23so3741534ljn.5 for ; Thu, 19 Sep 2019 07:06:31 -0700 (PDT) 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=zBTcMpOyl2bLXBXPvlZrHA8WBZZACi7gNqiyseLnytg=; b=tEWo6Qx7zZ7kkaruD+ymilqF3r1k+Qj6EWfAJYOBAmyNG8bNUTTSXq1rKRbUTncoGv vXsEqhMJ1yWCsJrA/WTYaXk0EsX1bzDQEEfwEi/4dI54nVH6pU20ppxjG75dxXTscbHW nKT/gzpymVVShSZsKJgf2gPAIAgSKVQSAOttCe4q62uEGndSC6f5xox/n2rsO3EOnAiM cu/P+uLT6G2mLae3CggYQDixaRfWfLkjnsLRnDgYjTmFO2Ev5RWgrKvW+c/5G7CYvoug KKluvMTD87U6xrXy/sBY4ghJSlPESkna4bTFZVLD4Bu60kOEkeZfNB9QXHdj3efMUFn5 docQ== X-Gm-Message-State: APjAAAW+Kpxj0n3EFq6A/zhSW+RkymhT1OlJhftnH/n53aLHADRuwDhu Zt3mrEBmzsK3A3oxp3OHBIZvfw== X-Google-Smtp-Source: APXvYqz80XnBinuoIhjkWosIvpazzODW2CaBBl25zB2SkJzfe+uW+0Y8qIL/RSBMCTZSD3oY/92ueA== X-Received: by 2002:a2e:6e18:: with SMTP id j24mr5534397ljc.158.1568901990286; Thu, 19 Sep 2019 07:06:30 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id h3sm1687886ljf.12.2019.09.19.07.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 07:06:29 -0700 (PDT) From: Rasmus Villemoes To: Thierry Reding , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz Subject: [PATCH 2/5] backlight: pwm_bl: eliminate a 64/32 division Date: Thu, 19 Sep 2019 16:06:17 +0200 Message-Id: <20190919140620.32407-2-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190919140620.32407-1-linux@rasmusvillemoes.dk> References: <20190919140620.32407-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 20 Sep 2019 07:51:39 +0000 X-Mailman-Original-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=zBTcMpOyl2bLXBXPvlZrHA8WBZZACi7gNqiyseLnytg=; b=A48WL858gPJVbFagBB2BTpTgHdTGMt1R9BC01trDu5z3ENfmhWS7RiqjnfWx20RoUY E0iQrrx0deYrkinYfpODZNFzuVCQBajUDYXy09Qkmb+GV1iPmOdfGkZktLbOEyqsuOiz 8Rwokwielo8W6w7zis9sx6uJ5V5kHfsVwrS8I= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-fbdev@vger.kernel.org, Rasmus Villemoes , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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(). Signed-off-by: Rasmus Villemoes Reviewed-by: Daniel Thompson --- 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 be36be1cacb7..9252d51f31b9 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));