Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5569640ybp; Tue, 8 Oct 2019 05:08:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTHNefhqRomK+ivRC3QtrlbLMy0mAK3k+meMY/uwdbyMViB3zjxx5GqbcudmQmNMYHZk17 X-Received: by 2002:a05:6402:164d:: with SMTP id s13mr19669296edx.263.1570536529129; Tue, 08 Oct 2019 05:08:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570536529; cv=none; d=google.com; s=arc-20160816; b=aTb/191bvFAVEYSklgiq+dfh3KxNWm1AWlFO2347AT5+sP7jAMTZEFZE5OtjJ55G9S ejiMUVR7dqZ37VaUcNrMVpycmLelPjZNlv1KVvNN3+nihSM3pUuFx0KJL4Z23HJz0Yym QaA0Af53duGBTuVQ7aVgyR9M0ecT6g1+qF5VsI+8gMejNZHXT8g1MUzQ+f2ifaKsfFyK xpaBnJSEPtY/ccG4PzHtdyhC2DvVxao9wtQt1LBFeth8E20NI2MAbyzVJExk0hLGVMFD W4ZTjp7yzjIrgjL27xFGvCOzT2pQ9rqEhB//694mglwfZdnuqJ46qR8YvKBwAuI5nMpE X5uw== 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=GHqEF0WPzWee4xQdmsltBE/DbSJ8wdizxOO3R+g9Qfw=; b=eXroh1+EXd+kmBLGFJkNxwGJNws5EjCBfzN2dVSChgHGR7VD1EFPyuV9b7nBqp3LTc hTo7tGKof2/sqFMPHDpJF4yeWnEnbJLvZ35xt1SfHxt7ypT3RYhR2N7kM2MCmGkinpGX +SPMLG+IHFWutUZ71TQL2Oeva9ZR6FE/jxZeaqvUVx7Ef0no/Yt2/tZTERENoVTz5uUx F1ZjryB/KbMAvHSwOGvzRr89hxUqrhv3+GZsg9jgkV9La5FAyKEPSdElFIV+i5Yi/BtC wYMQnekCVw2Z/YIlWn3kLOcHsjCLiAYaPzlaPvbvTudnbaTajmrSJIyUtaLLMRBYS2dr a9DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=iHfqd7In; 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 c14si8665376eda.8.2019.10.08.05.08.25; Tue, 08 Oct 2019 05:08:49 -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=iHfqd7In; 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 S1730933AbfJHMF2 (ORCPT + 99 others); Tue, 8 Oct 2019 08:05:28 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:44907 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730922AbfJHMF1 (ORCPT ); Tue, 8 Oct 2019 08:05:27 -0400 Received: by mail-lf1-f65.google.com with SMTP id q12so6781842lfc.11 for ; Tue, 08 Oct 2019 05:05:25 -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=GHqEF0WPzWee4xQdmsltBE/DbSJ8wdizxOO3R+g9Qfw=; b=iHfqd7InHpWSp9HtncYc/nGuUN2SQLNPz6EP4Z7c0utpCDEfBTHo79qRfdGdqnHjDc mUERS8N/Ezm1xJivvlU2FPSjziBCWfbM0Mp19xZKJ+DciElb5UKCU0Vr/UJTOEN7Raiq 9nMDdC6cEjkuK79xMF6I9qmtVilDUGJ2/wvCs= 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=GHqEF0WPzWee4xQdmsltBE/DbSJ8wdizxOO3R+g9Qfw=; b=Ax41lVmKGy0Ed1e5TvcQG7Z9m3rBabPiBrvmmUYdSDUyGIBU/aOACLSeyOan5rVD+f CA8J62Ntm8nH/C9aWiYXNuJmbYSC2zIZk6rYxVTAUuhrOER0K5uOlCx21hKpRJbDoOEx aP4rMmAy7nejZiTt/C+C8Due27zsY0f4j4Scilsc46yuPBi/+VPYA4iCLMPmDp8aZl/Y e+5BD6VhwMuMeUMQawd94L82OO3LIO5mP8aiEmn0TmNnnv9yr5yQLeyblE+7TF5egGal ZPjtl2KCQ9d62T+mDwK29IwESrs08szmFr151av5+0wSdPh6HyiHlzIX8eb+Rq/qASXr 3QYQ== X-Gm-Message-State: APjAAAUsbJisZyhQZWKuADcEDIVzprU0hWk2++UP5Ol1Two1JHQ8Tsoj QW9BXzlNnpXRznzv4jKJXS8Tfg== X-Received: by 2002:a19:90:: with SMTP id 138mr19176383lfa.111.1570536324544; Tue, 08 Oct 2019 05:05:24 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2019 05:05:22 -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 3/4] backlight: pwm_bl: drop use of int_pow() Date: Tue, 8 Oct 2019 14:03:26 +0200 Message-Id: <20191008120327.24208-4-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 For a fixed small exponent of 3, it is more efficient to simply use two explicit multiplications rather than calling the int_pow() library function: Aside from the function call overhead, its implementation using repeated squaring means it ends up doing four 64x64 multiplications. Reviewed-by: Daniel Thompson Signed-off-by: Rasmus Villemoes --- drivers/video/backlight/pwm_bl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 672c5e7cfcd1..273d3fb628a0 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -179,7 +179,8 @@ static u64 cie1931(unsigned int lightness, unsigned int scale) if (lightness <= (8 * scale)) { retval = DIV_ROUND_CLOSEST(lightness * 10, 9033); } else { - retval = int_pow((lightness + (16 * scale)) / 116, 3); + retval = (lightness + (16 * scale)) / 116; + retval *= retval * retval; retval = DIV_ROUND_CLOSEST_ULL(retval, (scale * scale)); } -- 2.20.1