Received: by 10.223.176.5 with SMTP id f5csp394728wra; Wed, 7 Feb 2018 00:52:59 -0800 (PST) X-Google-Smtp-Source: AH8x226NH/lr9WIvJxMFsHP/LuCRMac+dpXaTOwrujwM4bWuwzVvQla8EQtat8vFN6aQb1199w97 X-Received: by 2002:a17:902:1665:: with SMTP id g92-v6mr5281958plg.245.1517993579721; Wed, 07 Feb 2018 00:52:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517993579; cv=none; d=google.com; s=arc-20160816; b=v5gFceIf79v9wRBbKrhALwSLt46aWqGetC1MPIBh3B0zgmZYqSspOF8LKCxhBhxjVX /+ANnvmqfdPXTi07w+4F1vvk4qKl5tAG4Tv6t7f2kShqCHY3DH62/KXlKRKZ7HeH/TMX xg25CtOYWRg+9HKL5sK/zGvBYbg7kHG1Moy5gPmuGnRxWqJjFqijy2Lrxf96Xp927P5G 57dQMltpmmmvlvs0RH2AsA3go32w1pp8qO59LFhEkd/xWcTyGkFkVJCk/P2CwOEy9H7G OxFbVJLa2vyJ6PPKsqoedzeq4ak4U+ySYZAQFpNO9+jUdTTUiPD2YZwR8re+Xz6BbGYi IBFA== 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=tbf8uWbPWpSMk3T1ca0Rie3F2yi1HmyRFQ9MXD8h3SM=; b=JQITHSijchu9nFaX15xpcmKmB1ndtH2Ka0c3bf1CkEBA49F9C6sXNUEXIbdjYMXUME d5eGi/T2jY6ODsWJ5lsuoxPu2fllskS2/CFxtbfZwe5drGZVg90uLSpMZmogH04Vag+R 9utxKmJ2E6W0/NnuZFQ3EQy73pX0GCwDVhy9NTE3WuDlob5DxnmwQLv426fzzz9FnLF6 rNwY8L5ZePsCHpa+mL/sfo7eWe9UQ5vaHmcXTHzDVEWweZU3oo5bAv6X3NJnHu15CeGk Cfdr+kmeHNNriIvLQNjXIvtwYmLvnThDYG9GaOEOk+NKLqhYZw8Fj0Xhy962XB5d8tGj osfw== 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 f5si652502pgt.833.2018.02.07.00.52.45; Wed, 07 Feb 2018 00:52:59 -0800 (PST) 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 S1753483AbeBGIwA (ORCPT + 99 others); Wed, 7 Feb 2018 03:52:00 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:42642 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753117AbeBGIv6 (ORCPT ); Wed, 7 Feb 2018 03:51:58 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 812C62039F; Wed, 7 Feb 2018 09:51:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 4A43A20381; Wed, 7 Feb 2018 09:51:46 +0100 (CET) Date: Wed, 7 Feb 2018 09:51:46 +0100 From: Maxime Ripard To: Icenowy Zheng Cc: Rob Herring , Chen-Yu Tsai , Linus Walleij , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-sunxi@googlegroups.com Subject: Re: [PATCH v2 1/6] pinctrl: sunxi: support pin controllers with holes among IRQ banks Message-ID: <20180207085146.dvgwkdjq7ybhohwh@flea> References: <20180203154942.63566-1-icenowy@aosc.io> <20180203154942.63566-2-icenowy@aosc.io> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ux2zf7yiedaeoze7" Content-Disposition: inline In-Reply-To: <20180203154942.63566-2-icenowy@aosc.io> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ux2zf7yiedaeoze7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Sat, Feb 03, 2018 at 11:49:37PM +0800, Icenowy Zheng wrote: > diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.h b/drivers/pinctrl/sunx= i/pinctrl-sunxi.h > index 11b128f54ed2..fae732c8c548 100644 > --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.h > +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.h > @@ -110,7 +110,7 @@ struct sunxi_pinctrl_desc { > int npins; > unsigned pin_base; > unsigned irq_banks; > - unsigned irq_bank_base; > + const unsigned int *irq_bank_map; > bool irq_read_needs_mux; > bool disable_strict_mode; > }; > @@ -263,12 +263,21 @@ static inline u32 sunxi_pull_offset(u16 pin) > return pin_num * PULL_PINS_BITS; > } > =20 > -static inline u32 sunxi_irq_cfg_reg(u16 irq, unsigned bank_base) > +static inline u32 sunxi_irq_hw_bank_num(u8 bank, const unsigned int *ban= k_map) > +{ > + if (!bank_map) > + return bank; > + else > + return bank_map[bank]; > +} =46rom a function API PoV, I guess it would make more sense and be cleaner to simply pass the sunxi_pinctrl_desc structure (as the first argument) and have the function there read that structure and act upon it. Giving it just a blank pointer, without any size indication, and either dereferencing it without any boundary check, or changing the behaviour based on whether it's null or not seems pretty fragile. I guess you could do it in two patches. One to change the function prototypes to call the sunxi_irq_cfg_reg function (and all its caller) to have the prototype (struct sunxi_pinctrl_desc *desc, u16 irq). And then in a later patch change the behaviour to introduce the map. Thanks! Maxime --=20 Maxime Ripard, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering http://bootlin.com --ux2zf7yiedaeoze7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE0VqZU19dR2zEVaqr0rTAlCFNr3QFAlp6viEACgkQ0rTAlCFN r3QE9g//ca+2HfiXxwPgoIsFYBi5mDXgmveHQPbG+0OGbEA9sJFInAqTTlEbyfdS bzoSBq8YM/TybROB+0TWDu/WIdF51XIuHRFHXUyLbGziqYql9zcWg4vgLpirtgTj Yg2LsMLjyOSOmYB+WlDMg0PejNmopPYCmlHj5cw9Scm7wnbdrKO3DQH+QRev/IsW YCgdc7pCFpmUvbBDprO0AVfFyBTqXJfVaHdkE8X++JdJ22YvhjA4yN2VKNLUUdK9 2AuXN8JIzJr/QZS5ihjlmvTyRx+s064is2L+2SuezEuZuOyXxI+GSTfLgmoqQDxV udp1rBSXTOtKudBwOSukjIVZT8Dro+h+S9vD0wN6n46fCHxc8XecEUHxwu3JRgOK lmzd3tcEItrbrZ+yP8XwHdDKNQIduHjnPCGbsuu+WuEGV2+ZhgHUbcJtk8HrJm+g /jQUiqNuqck1pLnfvJ/AhMQCR5bm+0PXGlBzxdfARbJjocAO7//kx80PS9sQRnx6 eXyZLq+vrEB9Zp9BfCO/2FT4iZ1oe3HL5+OW1yzlXFVjQHqyMz2YWGnGHveg0evQ FMAj4/fe3Zf505eWZWb67YkBOujRpzKbT2f8hzvgV2hcUNEu0h52i0f0DGpWO9Ik Aatui+23xqmOvt6clPDRWSoxcWUFdvUGz6UXwyX6ThsEEEhz8a0= =z/dS -----END PGP SIGNATURE----- --ux2zf7yiedaeoze7--