Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp889934imm; Wed, 23 May 2018 07:07:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrfxsv30fihmzA8YnC6zaYSq80Xs/UZaT1mW+6YH1j4wjHwGXG9izGQcXZ2j0rRGU6ay8j6 X-Received: by 2002:a17:902:14d:: with SMTP id 71-v6mr3123461plb.275.1527084467733; Wed, 23 May 2018 07:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527084467; cv=none; d=google.com; s=arc-20160816; b=DUSdeSIuKCzwfXrhx8bc4fKXzvBRBpydFpErEMjiQZf9yQxU1pzi6xlcizPdq4FxHR 05ZX63A7MZ8T/r24WWucvXc3/vvcHKhRyyr4vRcEadVbuLiw0roDG+9HCEXZU4q9BJ7O +1srgYm3+AHceRZ0MW0lduE2gVU88ixYjtqxUkkmIDnsBTVi9Pt2gs58gwnm1j85+TLv YELoPmnH1EyBJaNV/j98OMmrXxxfx/HCWFf2qD/2Cnyqnv7r1UwktGdS/ZyrjE3nYko+ ij2Jh9NR1xoTbwUJ9g9TkyfNkSjGa7Pk9orVgGY6sycCI8MCuby+dEb06BQbdTQMXlD7 uNYg== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=fs1ZT8K9rN0R+KKqVe8LUGIEZISpd7tglJw87WwNG8M=; b=W70CZo2vEaS5wEkPCnX24i0q1tdSZZRE/v9UVpgYgK0CJulBNm2bsUHrsMPmJOXRh/ xPoIb3PRokDVfYHi2jjXf6oE8jjPSAJy5yqwmZLWgemRUtuOdvKs2Ml0NJAgSxv9CfHh hDBhLXEdrsggu2pDzLyhWoxIBigRSMMkvjxI/NhXGcbZYthjDcYEPpCDrLaaHR26Dx/Q 6GHTAb+aWioXwnToeALIdUg1A38wtSGqfoLemaOdaoX9FYWybqlO0PV3aSRP4Ja6/1yd qZONQ+x4ZoWmry8rEJZ4a99wMS4ln3LC8HG7wSh4xTuuRzhRtbxce9SJbqzWB9OISlu1 GbqA== 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 z14-v6si14767531pgc.617.2018.05.23.07.07.32; Wed, 23 May 2018 07:07:47 -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 S933289AbeEWOGk (ORCPT + 99 others); Wed, 23 May 2018 10:06:40 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:43295 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933093AbeEWOGh (ORCPT ); Wed, 23 May 2018 10:06:37 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 64DC080558; Wed, 23 May 2018 16:06:36 +0200 (CEST) Date: Wed, 23 May 2018 16:06:36 +0200 From: Pavel Machek To: "H. Nikolaus Schaller" Cc: galak@codeaurora.org, andy.shevchenko@gmail.com, Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Linus Walleij , Alexandre Courbot , devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, letux-kernel@openphoenux.org, kernel@pyra-handheld.com Subject: Re: [PATCH v7 3/3] gpio: pca953x: fix address calculation for pcal6524 Message-ID: <20180523140635.GB27215@amd> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="WhfpMioaduB5tiZL" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --WhfpMioaduB5tiZL Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu 2018-05-17 06:59:49, H. Nikolaus Schaller wrote: > The register constants are so far defined in a way that they fit > for the pcal9555a when shifted by the number of banks, i.e. are > multiplied by 2 in the accessor function. >=20 > Now, the pcal6524 has 3 banks which means the relative offset > is multiplied by 4 for the standard registers. >=20 > Simply applying the bit shift to the extended registers gives > a wrong result, since the base offset is already included in > the offset. >=20 > Therefore, we have to add code to the 24 bit accessor functions > that=A0adjusts the register number for these exended registers. >=20 > The formula finally used was developed and proposed by > Andy Shevchenko . >=20 > Suggested-by: Andy Shevchenko > Signed-off-by: H. Nikolaus Schaller > --- > drivers/gpio/gpio-pca953x.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c > index c682921d7019..4ad553f4e41f 100644 > --- a/drivers/gpio/gpio-pca953x.c > +++ b/drivers/gpio/gpio-pca953x.c > @@ -222,9 +222,11 @@ static int pca957x_write_regs_16(struct pca953x_chip= *chip, int reg, u8 *val) > static int pca953x_write_regs_24(struct pca953x_chip *chip, int reg, u8 = *val) > { > int bank_shift =3D fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); > + int addr =3D (reg & PCAL_GPIO_MASK) << bank_shift; > + int pinctrl =3D (reg & PCAL_PINCTRL_MASK) << 1; Is this reasonable to do on each register access? Compiler will not be able to optimize out fls and shifts, right? Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --WhfpMioaduB5tiZL Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlsFdWsACgkQMOfwapXb+vITrwCcDj//GiI8j4gSWTwrTovWV1af B5QAniiu4Ct5Fy1mqITZSjntXGb4B+4F =uPYg -----END PGP SIGNATURE----- --WhfpMioaduB5tiZL--