| Message ID | 20260929203634.32998-1-pmazzini@gmail.com (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-26405-sunxi=pue.re@lists.linux.dev>
X-Original-To: noreply@patchwork.local
Delivered-To: noreply@patchwork.local
Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mxe881.netcup.net (Postfix) with ESMTPS id 427F41C1C76
for <noreply@patchwork.local>; Tue, 29 Sep 2026 22:37:40 +0200 (CEST)
Authentication-Results: mxe881;
dkim=pass header.d=gmail.com;
spf=pass (sender IP is 172.105.105.114)
smtp.mailfrom=linux-sunxi+bounces-26405-noreply=patchwork.local@lists.linux.dev
smtp.helo=tor.lore.kernel.org
Received-SPF: pass (mxe881: domain of lists.linux.dev designates
172.105.105.114 as permitted sender) client-ip=172.105.105.114;
envelope-from=linux-sunxi+bounces-26405-noreply=patchwork.local@lists.linux.dev;
helo=tor.lore.kernel.org;
Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org
[100.90.174.1])
by tor.lore.kernel.org (Postfix) with ESMTP id 0CC3A3B0DF
for <noreply@patchwork.local>; Tue, 29 Sep 2026 20:37:25 +0000 (UTC)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id B671D41C2E4;
Tue, 29 Sep 2026 20:37:24 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com
header.b="dmYFsz9W"
X-Original-To: linux-sunxi@lists.linux.dev
Received: from mail-wr2-f12.google.com (mail-wr2-f12.google.com
[74.125.225.76])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CA2148821D
for <linux-sunxi@lists.linux.dev>; Tue, 29 Sep 2026 20:37:23 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=none smtp.client-ip=74.125.225.76
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1790714244; cv=none;
b=LaCRs8u22kLcutJg7G605pb2HApx5/IEAqs4g8eCAxN6zYm/Zbf3fSSHLSL/v4pRIbcxMog80krlOBhaCM7Wbz4DhOB+Mdus5P+RKVrYTLpWcAZnaN3yTDfaFIt3NARte6bYAJ7fGOH6SUXSdmjwX7U35cnZbbyiBPm/COFo5U0=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1790714244; c=relaxed/simple;
bh=Gqvcy2MOOYrL8Gno0HNWN9hEb57iEhrmpV/Bp5STDho=;
h=From:To:Cc:Subject:Date:Message-ID:MIME-Version;
b=iNfvDnSv2pn+hI5Nmj+D9eDlHjUbct5sYDPtoid4DLRSzUO7VINFyjAUhcuNO2P8OYu6xN3DBG5yAj6XObyf5a8gBYbOO46g67EY+ZFvZ/VCKsnpr9NBtzXc0IoiH5iuW0qJKCR8/wetDvNuok/UP24FKlssLy5AiOAr1B/c+6Y=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass (p=none dis=none) header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com
header.b=dmYFsz9W; arc=none smtp.client-ip=74.125.225.76
Authentication-Results: smtp.subspace.kernel.org;
dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: smtp.subspace.kernel.org;
spf=pass smtp.mailfrom=gmail.com
Received: by mail-wr2-f12.google.com with SMTP id
ffacd0b85a97d-48434392b02so3987630f8f.3
for <linux-sunxi@lists.linux.dev>;
Tue, 29 Sep 2026 13:37:22 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1790714241; x=1791319041;
darn=lists.linux.dev;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=uc6m/QNpalNv4a9wmqg9O0BMMr47ojwjmucGyrpTpAA=;
b=dmYFsz9W5gkd5g00STEtVFF2TCYtu+zOZxdlKAhDG0Y5JP+yqPM2uHFrqn8DEjErtR
nxPbA1GORA3BxJe2nkyofrwXmB6rRA961Qdf62jGwTUjtMwmfidyHa8/grQjoTYkT5gq
w66ePRg3Vfr6SuBMTJb+7dJP9bFrIxcsCv/UeVIVivOdi+JvzF2453AMyX0IXmJCjad5
BQBAcNO+WG2JdRcWB2gwYKnLGY7DY+dXhmkNsfS4rOVPefTzzGnhfFKioYOkjZkqdM7X
Cb1b7JfG9vwrAH+ICUtFVdkB32deMtBDgM9aqLPW+CZTfNDac1vRVWPmuzvmL+ayc0k3
nVNA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1790714241; x=1791319041;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=uc6m/QNpalNv4a9wmqg9O0BMMr47ojwjmucGyrpTpAA=;
b=a3TsS0/bwt82QqyaKU7TfszxBqctmdYy1rOTHGyIcaLW4X5ppWuADqOc3VNFQ0uDw0
o6rQy6M/nKFxlSIInqJSZGO6WQa3kEsIJ2a+8bUpp5bil3mF6io9IhCLeiXvNsxT66GQ
SpZVNB2updzzMrl9/d7RjLTPd43DlwW+kBol6e50MXZPdwz4Wry5JxwkQ+3X5R0htTN3
3T519ErTIDzgJqzM8EHGwcDYsLsR7dEefSwm742WOhS566PeSEUJnYhlHJ5MDk4ecODo
If7QUYVCoHwIRvNhgAwmAIKxNznE2WVvZ1Y15mQ17k+JHtL7BQVytNRHQ1GJg6nU133H
vu2w==
X-Forwarded-Encrypted: i=1;
AKwUvByBicTTDaK74p14YzuNVH2eL+30udnzZw2fRgTAjY2iN73+fQyl04IQN6iCEqgETG9OVK50lD4xMREPHg==@lists.linux.dev
X-Gm-Message-State: AFq9FYJVAHNSm9BazaZnfrYRNgjsFZ4jiX+SIlkBBL68kJxhGXfslou2
WsS96Ff7uS4aJCZfbMFuadH/ZtTrSItEujj+xEVjTekveLkSu3Ubh3pu
X-Gm-Gg: AYBFou1dB8gCioBCX7bUIK+uvmbnDvgT750UV1qXAIOXwb/cludG2b7S5OFFZABEVUp
xjj9qJNCLqil6yfBRJjqLo0fw5qW7WjUSOddxLViiiuTptqEC5pfeRxnxZgLCgglR5vtk8Xzuke
zJQ/Nr9r7OESiE6F0CfQkC8YOnyFHh6Ps62LOvRGXlySCrD8aFg+B3rSnBY90zeAQufRFghNL5O
t62Pv/sFYq0XO8T73cGg+Mgiee4kGelmnYj0Sr8W//Lr619/a9jkJpPlfjoRDntXME0xe6bDZip
bSdR2g/mX4iov7pz4507m2UrIizDmWRa3QoqDF4hh2Fl10Vw2c3ZZKmmQ75cyvE5CxNRwppT3+q
M8gzDbAXR5kj5an0fPda8bCbKrjL7cQEtEwNWMTNV7QKb4oyhzVncrNrXx9MnhnI0nZQt5PZTer
REUilvvLP9xEMKJzBnSDUp0/sLu30ZCXid53o56pUD0WSoTwhxH/jd5jS991f21zswJlOvLxpSm
GSv9Jfu3lDPI49RZPW5DXNMNumWbc9j6SrPNB9drskl
X-Received: by 2002:a05:6000:381:b0:487:27f9:83d with SMTP id
ffacd0b85a97d-48afe782c3amr766701f8f.50.1790714241257;
Tue, 29 Sep 2026 13:37:21 -0700 (PDT)
Received: from debian (ip-78-137-176-146.broadband.digiweb.ie.
[78.137.176.146])
by smtp.gmail.com with ESMTPSA id
ffacd0b85a97d-48afe6a9624sm1237578f8f.24.2026.09.29.13.37.19
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 29 Sep 2026 13:37:20 -0700 (PDT)
From: Pablo Mazzini <pmazzini@gmail.com>
To: Linus Walleij <linusw@kernel.org>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Andre Przywara <andre.przywara@arm.com>
Cc: Pablo Mazzini <pmazzini@gmail.com>,
linux-gpio@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [PATCH] pinctrl: sunxi: dt: number the IRQ banks from the first one
that has IRQs
Date: Tue, 29 Sep 2026 21:36:34 +0100
Message-ID: <20260929203634.32998-1-pmazzini@gmail.com>
X-Mailer: git-send-email 2.53.0
Precedence: bulk
X-Mailing-List: linux-sunxi@lists.linux.dev
List-Id: <linux-sunxi.lists.linux.dev>
List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev>
List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Rspamd-Server: rspamd-worker-8404
X-Spamd-Result: default: False [5.84 / 15.00];
RBL_SENDERSCORE(2.00)[172.105.105.114:from];
SUSPICIOUS_RECIPS(1.50)[];
DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed),
No valid DKIM,none];
MID_CONTAINS_FROM(1.00)[];
R_MISSING_CHARSET(0.50)[];
MAILLIST(-0.15)[generic];
BAD_REP_POLICIES(0.10)[];
MIME_GOOD(-0.10)[text/plain];
HAS_LIST_UNSUB(-0.01)[];
FROM_HAS_DN(0.00)[];
FREEMAIL_CC(0.00)[gmail.com,vger.kernel.org,lists.infradead.org,lists.linux.dev];
RCVD_COUNT_FIVE(0.00)[6];
PRECEDENCE_BULK(0.00)[];
TAGGED_RCPT(0.00)[];
FORGED_SENDER_MAILLIST(0.00)[];
DBL_BLOCKED_OPENRESOLVER(0.00)[tor.lore.kernel.org:rdns,tor.lore.kernel.org:helo];
FROM_NEQ_ENVFROM(0.00)[pmazzini@gmail.com,linux-sunxi@lists.linux.dev];
ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1];
ASN(0.00)[asn:63949, ipnet:172.105.96.0/20, country:SG];
TO_DN_SOME(0.00)[];
FREEMAIL_FROM(0.00)[gmail.com];
RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.90.174.1:received,74.125.225.76:received,78.137.176.146:received];
RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.105.105.114:from];
TAGGED_FROM(0.00)[bounces-26405-noreply=patchwork.local];
R_SPF_ALLOW(0.00)[+ip4:172.105.105.114];
FREEMAIL_TO(0.00)[kernel.org,gmail.com,sholland.org,arm.com];
RCVD_TLS_LAST(0.00)[];
RCPT_COUNT_SEVEN(0.00)[10];
MIME_TRACE(0.00)[0:+];
FORGED_RECIPIENTS_MAILLIST(0.00)[];
RCVD_VIA_SMTP_AUTH(0.00)[]
X-Rspamd-Queue-Id: 427F41C1C76
X-MORS-Enabled: yes
X-MORS-DOMAIN: patchwork.local
X-MORS-HOSTING: hosting172546
X-MORS-USER: hosting172546
X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?=
|
| Series |
pinctrl: sunxi: dt: number the IRQ banks from the first one that has IRQs
|
|
Commit Message
Pablo Mazzini
Sept. 29, 2026, 8:36 p.m. UTC
prepare_function_table() assumes the first pin is in bank 0. On the
A523, which has no PA pins, every IRQ bank is numbered one too high:
the last bank writes past the end of irq_array, and interrupts are
looked up at the wrong offsets.
Count the IRQ banks from the first bank that has interrupts.
Fixes: f5e2cd34b12f ("pinctrl: sunxi: allow reading mux values from DT")
Signed-off-by: Pablo Mazzini <pmazzini@gmail.com>
---
drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
Comments
Hi Pablo, thanks for sending a patch! On 9/29/26 22:36, Pablo Mazzini wrote: > prepare_function_table() assumes the first pin is in bank 0. On the > A523, which has no PA pins, every IRQ bank is numbered one too high: > the last bank writes past the end of irq_array, and interrupts are > looked up at the wrong offsets. Yes, this is a known issue, and I already provided a quite different fix for this[1]: the A523 manual actually lists a PortA GPIO interrupt, even though this is pretty likely not functional. But specifying this IRQ in the DT fixes the problem as well. The DT binding does not say how the IRQs are assigned to the GPIO ports, so from that point of view my solution is similarly usable as yours - though admittedly yours looks a little better and more future proof. I guess we now need to figure out how we want to handle this in the future, and add an explanation to the binding. The A733 has a similar problem: PortA does not exist. This time the manual does not explicitly specify a GPIO IRQ, but conspicuously leaves a gap before the PortB GPIO IRQ, so we can use that as well. Linus, Chen-Yu, Jernej: what do you think? Cheers, Andre [1] https://lore.kernel.org/linux-sunxi/20260327113006.3135663-4-andre.przywara@arm.com/ > > Count the IRQ banks from the first bank that has interrupts. > > Fixes: f5e2cd34b12f ("pinctrl: sunxi: allow reading mux values from DT") > Signed-off-by: Pablo Mazzini <pmazzini@gmail.com> > --- > drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c b/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c > index 50a16f3bd131..9c5eb21a86a5 100644 > --- a/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c > +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c > @@ -208,7 +208,7 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode, > * The extra functions will be filled in later. > */ > irq_bank = 0; > - last_bank = 0; > + last_bank = -1; > for (i = 0; i < npins; i++) { > struct sunxi_desc_pin *pin = &pins[i]; > int bank = (pin->pin.number - pin_base) / PINS_PER_BANK; > @@ -221,16 +221,14 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode, > func[1].muxval = 1; > > if (irq_mux) { > - if (bank > last_bank) > + if (last_bank >= 0 && bank > last_bank) > irq_bank++; > func[lastfunc].muxval = irq_mux; > func[lastfunc].irqbank = irq_bank; > func[lastfunc].irqnum = pin->pin.number % PINS_PER_BANK; > func[lastfunc].name = "irq"; > - } > - > - if (bank > last_bank) > last_bank = bank; > + } > > pin->functions = func; >
On Tue, Sep 29, 2026 at 10:37 PM Pablo Mazzini <pmazzini@gmail.com> wrote: > prepare_function_table() assumes the first pin is in bank 0. On the > A523, which has no PA pins, every IRQ bank is numbered one too high: > the last bank writes past the end of irq_array, Why don't you add a patch to protect against that? Something like this (completely untested, not even compiled) diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index 31cd142ce0f7..c0c90d9e3215 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -1632,9 +1632,10 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev, else pctl->pow_mod_sel_offset = PIO_POW_MOD_SEL_REG; + pctl->irqs = IRQ_PER_BANK * pctl->desc->irq_banks; pctl->irq_array = devm_kcalloc(&pdev->dev, - IRQ_PER_BANK * pctl->desc->irq_banks, - sizeof(*pctl->irq_array), + pctl->irqs, + sizeof(unsigned int), GFP_KERNEL); if (!pctl->irq_array) return -ENOMEM; diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.h b/drivers/pinctrl/sunxi/pinctrl-sunxi.h index 8bd00c6ff628..9e0ed9c0c1ee 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.h +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.h @@ -176,7 +176,8 @@ struct sunxi_pinctrl { struct sunxi_pinctrl_group *groups; unsigned ngroups; int *irq; - unsigned *irq_array; + unsigned irq_array[] __counted_by(irqs); + unsigned irqs; raw_spinlock_t lock; /* * Output latch shadow, one word per bank. Seeded lockless at > and interrupts are > looked up at the wrong offsets. > > Count the IRQ banks from the first bank that has interrupts. (...) > irq_bank = 0; > - last_bank = 0; > + last_bank = -1; > for (i = 0; i < npins; i++) { > struct sunxi_desc_pin *pin = &pins[i]; > int bank = (pin->pin.number - pin_base) / PINS_PER_BANK; > @@ -221,16 +221,14 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode, > func[1].muxval = 1; > > if (irq_mux) { > - if (bank > last_bank) > + if (last_bank >= 0 && bank > last_bank) > irq_bank++; > func[lastfunc].muxval = irq_mux; > func[lastfunc].irqbank = irq_bank; > func[lastfunc].irqnum = pin->pin.number % PINS_PER_BANK; > func[lastfunc].name = "irq"; > - } > - > - if (bank > last_bank) > last_bank = bank; > + } This looks reasonable. Yours, Linus Walleij
On Wed, Sep 30, 2026 at 5:27 PM Andre Przywara <andre.przywara@arm.com> wrote: > Yes, this is a known issue, and I already provided a quite different fix > for this[1]: the A523 manual actually lists a PortA GPIO interrupt, even > though this is pretty likely not functional. But specifying this IRQ in > the DT fixes the problem as well. > The DT binding does not say how the IRQs are assigned to the GPIO ports, > so from that point of view my solution is similarly usable as yours - > though admittedly yours looks a little better and more future proof. > > I guess we now need to figure out how we want to handle this in the > future, and add an explanation to the binding. The A733 has a similar > problem: PortA does not exist. This time the manual does not explicitly > specify a GPIO IRQ, but conspicuously leaves a gap before the PortB GPIO > IRQ, so we can use that as well. > > Linus, Chen-Yu, Jernej: what do you think? Can't we do both patches? Maybe there is something I don't get with this code... Yours, Linus Walleij
Hi Linus, On 10/1/26 14:06, Linus Walleij wrote: > On Wed, Sep 30, 2026 at 5:27 PM Andre Przywara <andre.przywara@arm.com> wrote: > >> Yes, this is a known issue, and I already provided a quite different fix >> for this[1]: the A523 manual actually lists a PortA GPIO interrupt, even >> though this is pretty likely not functional. But specifying this IRQ in >> the DT fixes the problem as well. >> The DT binding does not say how the IRQs are assigned to the GPIO ports, >> so from that point of view my solution is similarly usable as yours - >> though admittedly yours looks a little better and more future proof. >> >> I guess we now need to figure out how we want to handle this in the >> future, and add an explanation to the binding. The A733 has a similar >> problem: PortA does not exist. This time the manual does not explicitly >> specify a GPIO IRQ, but conspicuously leaves a gap before the PortB GPIO >> IRQ, so we can use that as well. >> >> Linus, Chen-Yu, Jernej: what do you think? > > Can't we do both patches? Maybe there is something I don't get with this > code... Well, if we change the DT and the code, they fight each other, and would be off by one again. So we need to decide for one solution, and since this affects the DT, this has compatibility implications. At the moment the code assumes that GPIO IRQ counting starts with PortA, regardless of whether this implemented or not. That does not sound very future proof: while A523 specifies an IRQ for PortA (even though it's not implemented!), I am afraid future SoCs might not. So having Pablo's patch would make a lot of sense, but would break with the just changed DT for the A523. That former DT change was fine, since it never worked before, and the new v7.2 DT should work on older kernels even. So we could revert the DT patch, and take Pablo's code patch, with a Fixes: tag, but that would create some broken combinations meanwhile. And in any case we should add a word to the binding document, to pin down what's expected here. Cheers, Andre.
On Thu, Oct 1, 2026 at 2:31 PM Andre Przywara <andre.przywara@arm.com> wrote: > So we could revert the DT patch, and take Pablo's code patch, with a > Fixes: tag, but that would create some broken combinations meanwhile. I see it like this was a bug in the DTS file, so this if fine as-is. > And in any case we should add a word to the binding document, to pin > down what's expected here. Can we enforce it with YAML constraints or is it too open-ended? Yours, Linus Walleij
Hi Andre, Linus, The B288 only has IRQ banks for PB, PD, PF and PG (banks 0-3). With the current code it would need a made-up first interrupt; with this patch it doesn't. Which way would you prefer for B288? Thanks, Pablo On Thu, Oct 1, 2026 at 8:28 PM Linus Walleij <linusw@kernel.org> wrote: > > On Thu, Oct 1, 2026 at 2:31 PM Andre Przywara <andre.przywara@arm.com> wrote: > > > So we could revert the DT patch, and take Pablo's code patch, with a > > Fixes: tag, but that would create some broken combinations meanwhile. > > I see it like this was a bug in the DTS file, so this if fine as-is. > > > And in any case we should add a word to the binding document, to pin > > down what's expected here. > > Can we enforce it with YAML constraints or is it too open-ended? > > Yours, > Linus Walleij
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c b/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c index 50a16f3bd131..9c5eb21a86a5 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c @@ -208,7 +208,7 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode, * The extra functions will be filled in later. */ irq_bank = 0; - last_bank = 0; + last_bank = -1; for (i = 0; i < npins; i++) { struct sunxi_desc_pin *pin = &pins[i]; int bank = (pin->pin.number - pin_base) / PINS_PER_BANK; @@ -221,16 +221,14 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode, func[1].muxval = 1; if (irq_mux) { - if (bank > last_bank) + if (last_bank >= 0 && bank > last_bank) irq_bank++; func[lastfunc].muxval = irq_mux; func[lastfunc].irqbank = irq_bank; func[lastfunc].irqnum = pin->pin.number % PINS_PER_BANK; func[lastfunc].name = "irq"; - } - - if (bank > last_bank) last_bank = bank; + } pin->functions = func;