Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp928333ybp; Fri, 4 Oct 2019 07:09:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhTyN2PaDITqcXytrgsPD7m5sbU3GRWml6g/qNLoC8YlLj6m00SBlE3rtoUu2uopTPvr96 X-Received: by 2002:a05:6402:1246:: with SMTP id l6mr15151152edw.213.1570198197018; Fri, 04 Oct 2019 07:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570198197; cv=none; d=google.com; s=arc-20160816; b=gkemNnNB0vqriF+kYIXveXS2mNjqdBKLHYneBkhL0XjiZyBbs4NHmRlhBg/ONlOMLj zH+TwW71YFnrNmhYAcPiyH9lawOI8PP5Rn5YVenHCgdbe2zjm6UIBAi6xSn6YBD0OLSy W3gyYpaDBUsUwPNYdtMDR+Hhfp1aBq0JbiMW/mo/r9z0b+CBQjFj8tXK9WijfYzzEGwM 2Bay8hSAj3IT94MaS+/K4zvZlSuX5Q6HJHeDCH4zF8YDwDXR5uqSEEdnmUmpAPFYNTzw LQMSxcksKlBhIUxPzKk/wJXLOV52smgf7/tPJkiGLbkIhNhqWOIQKgy4hs43iSA1rxOb hVWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=yN1VFtmie0YX+cjo+NeKDtxzC96O9Jg4YaTS/CTg7KA=; b=o5MlhvRXGC5P3Tc9UxIhgiZG1wQhAfNuTQZKwVLAEfc6HXwkWDywkECzdUuNN4t3l8 gbqwXkaYACY0wZpARH7Lmiiu5HJkON+sGatuE8HqmAOm7FHqHPKRV1WuO+b85kS0PlrX ueWp9rKMkEfUR3i6kVcDJkqmENR0Yl3Mfvz1+ZPrxSjUqDbN/QQR+vgFMOGgncWnsJ2a dLYzCCIArhIqYtvavpxcpoF/HJVWWH6jdtUnADnKmwGAEwaBGTxlQAgB2R3oSQQwboSE UydcXAYRsMwm+pzgZ1ALA+0nbZ17nbTABWey3aUpnFU+jsvPwbazi13ZNKGnoN+d/IVY YhOQ== 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 w11si2945350eji.160.2019.10.04.07.09.32; Fri, 04 Oct 2019 07:09:57 -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 S2388994AbfJDOIn (ORCPT + 99 others); Fri, 4 Oct 2019 10:08:43 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:35359 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387917AbfJDOIm (ORCPT ); Fri, 4 Oct 2019 10:08:42 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iGOG3-00077c-5N; Fri, 04 Oct 2019 16:08:35 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iGOG2-0004Pi-Oo; Fri, 04 Oct 2019 16:08:34 +0200 Date: Fri, 4 Oct 2019 16:08:34 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Rasmus Villemoes Cc: Thierry Reding , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devicetree@vger.kernel.org, Rob Herring , linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 5/6] pwm: mxs: avoid a division in mxs_pwm_apply() Message-ID: <20191004140834.4idddyohf52ha4ao@pengutronix.de> References: <20191004133207.6663-1-linux@rasmusvillemoes.dk> <20191004133207.6663-6-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191004133207.6663-6-linux@rasmusvillemoes.dk> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 04, 2019 at 03:32:06PM +0200, Rasmus Villemoes wrote: > Since the divisor is not a compile-time constant (unless gcc somehow > decided to unroll the loop PERIOD_CDIV_MAX times), this does a > somewhat expensive 32/32 division. Replace that with a right shift. > > We still have a 64/32 division just below, but at least in that > case the divisor is compile-time constant. > > Signed-off-by: Rasmus Villemoes > --- > drivers/pwm/pwm-mxs.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c > index 57562221c439..f2e57fcf8f8b 100644 > --- a/drivers/pwm/pwm-mxs.c > +++ b/drivers/pwm/pwm-mxs.c > @@ -33,8 +33,8 @@ > #define PERIOD_CDIV(div) (((div) & 0x7) << 20) > #define PERIOD_CDIV_MAX 8 > > -static const unsigned int cdiv[PERIOD_CDIV_MAX] = { > - 1, 2, 4, 8, 16, 64, 256, 1024 > +static const u8 cdiv_shift[PERIOD_CDIV_MAX] = { > + 0, 1, 2, 3, 4, 6, 8, 10 One small nitpick: I would like to see this name have a mxs_pwm_ prefix. But even without this change: Reviewed-by: Uwe Kleine-K?nig Thanks Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |