Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6509400ybe; Wed, 18 Sep 2019 04:51:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwu+o+Il6wVFfOD1QYc9jkaJms0ExiGdtioxxP17KnkIplvJCPwNZ/xDwCvmwdc33yH1WHV X-Received: by 2002:a17:906:e2d8:: with SMTP id gr24mr8807245ejb.55.1568807491144; Wed, 18 Sep 2019 04:51:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568807491; cv=none; d=google.com; s=arc-20160816; b=Quk1BHsb0i3T7I8X49kNJ28dNwHrlU8zVJnVWpWsjwzGkyUHmklIUlDrw/ZmugITlA /V4pfwDdBs6fJ3NuzB3d03EQyJUK+mrrUHM4Owm4wBjxFn/eITmwxhApEIDMmqGQrJcd cQoCDhrkBFzPKIkrsM7iJOPAgspXV56o9LWUYrtSQffgg4Uz5F7ERuLmgD8ORGvMrT7a bzqJ4XpLOtlWmH4c9SHbHyxCV5kUtdbQyOP+PC35+ZM7K7jiJg8iDqnOOADNMyOXLTAZ BQ/e9SUQaXCacaT9S+krfl79p+KdlCXo/JqFE8TlWQCIOOkcsQUhW6U4TaAO4iTx+Emt uYMg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=SnfA/z7sYmS4p90KugFRDGYAqrClHJ5yHTUJ5IzMHDY=; b=ke/t2axZozE3vgCZ8evY23QDWf7rY/dfK8shuTZVki34GR6+1x7Wefn7gmEwwS8fJT 4p09HfNxNru3PPzZXlcuJnGjvY8oRNQyj6cubzTUwJXJ4oU68cT2kGd8zniuflQusZiM MjZXXTMNNzUXwDa9NsHQ/Dn/IsH0CgsVfbq5oE/WjWFb2dgtzE3jXHdaXO8GwVt37BJ7 +jw/E4tF+1ERR8/v7CJiSVLdJk6CPbcHKYboXpq6WEkYfLxU1x7DFrLF8CG2LI3i/2J7 USQfqc1aVZtaxoCyxPq0FChUOF0tT4QTawZShc3fnaunpFXWx9e19bEvBXPHZmyUvpBM AB1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=0xf9mIzB; 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 i6si2469009ejc.380.2019.09.18.04.51.07; Wed, 18 Sep 2019 04:51:31 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=0xf9mIzB; 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 S1727497AbfIRHgo (ORCPT + 99 others); Wed, 18 Sep 2019 03:36:44 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:33342 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726296AbfIRHgo (ORCPT ); Wed, 18 Sep 2019 03:36:44 -0400 Received: by mail-oi1-f194.google.com with SMTP id e18so5192130oii.0 for ; Wed, 18 Sep 2019 00:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=SnfA/z7sYmS4p90KugFRDGYAqrClHJ5yHTUJ5IzMHDY=; b=0xf9mIzBD0QKbX2cTIovmV63drg+4bFZ2C0WEIGQX/8kD+lr9PORvLVtvWmqVnY2Hx uw6DicmbP6IePdEL+n95cmQOhIk9nc9GgRhtNYYJFFx8kR2SMvvfw+iR+wMyZPY2QiZM md2HIIXPM/RJGfNbpnUv1aW3b9YljxNxM2NMjyzQBN+kSUwhhZXHtxxKAStdhjx5QFD8 3KvY9Szt5E08abh4wEt9bmoKmO/hkpkb7RvSD+/em/plmFxXU63xHCMO8Mr5AC43Sh/k ZcIkXW27Uor7Z0rF/d/YLluWqH4CrJj/sIPPcJOZIGn5/c/qjkI6XwbN6/QEUjRJmGoM qgBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=SnfA/z7sYmS4p90KugFRDGYAqrClHJ5yHTUJ5IzMHDY=; b=BHJ8viC9NodpgDJijhu3VewpeqWoH8P+a62zImu+fhl7rLLyCGcqSwLyAHtU0Y9jr8 gMGdz+w58/2GnEtq4UuFVFrW5ER9AxVzC4DoWrTf4G8RNi/pmB8hsoaovXobIlrf+a2P qUf9uLwfVrWmQSrQjA47Bj5tQekIBWnHPUNdDHb/yiudc2E+WylzSlXAQAi/mXZzdJos Ht9z5I1lGmJgd94X4Ryde1Z1Z7Fb70DAaeQ3fEOBzwd88PMtZQ0yNa91g4Lp4D6Yc/Yg jFsTwoggp+WhkLVawZ8SvL+/jTVfd4MAn8Fa7YyI1VhMFUchTDODyv/K3jutNotQ8Qg8 H42g== X-Gm-Message-State: APjAAAVsPM0Zkz5DSyZ+c5FDkGUdKSnsXgjqW4OCh5UeruvYFFZTt+J5 AMZLO48qGOxdML4Qx6VEWAUrtzdSsIOdEeyK5qiuCw== X-Received: by 2002:aca:ad09:: with SMTP id w9mr1346998oie.114.1568792202394; Wed, 18 Sep 2019 00:36:42 -0700 (PDT) MIME-Version: 1.0 References: <20190916055817.43425-1-hui.song_1@nxp.com> In-Reply-To: <20190916055817.43425-1-hui.song_1@nxp.com> From: Bartosz Golaszewski Date: Wed, 18 Sep 2019 09:36:31 +0200 Message-ID: Subject: Re: [PATCH v5] gpio/mpc8xxx: change irq handler from chained to normal To: Hui Song Cc: Shawn Guo , Li Yang , Rob Herring , Mark Rutland , Linus Walleij , arm-soc , linux-devicetree , LKML , linux-gpio Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pon., 16 wrz 2019 o 08:08 Hui Song napisa=C5=82(a): > > From: Song Hui > > More than one gpio controllers can share one interrupt, change the > driver to request shared irq. > > Signed-off-by: Laurentiu Tudor > Signed-off-by: Alex Marginean > Signed-off-by: Song Hui > --- > Changes in v5: > - add traverse every bit function. > Changes in v4: > - convert 'pr_err' to 'dev_err'. > Changes in v3: > - update the patch description. > Changes in v2: > - delete the compatible of ls1088a. > drivers/gpio/gpio-mpc8xxx.c | 30 +++++++++++++++++++----------- > 1 file changed, 19 insertions(+), 11 deletions(-) > > diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c > index 16a47de..3a06ca9 100644 > --- a/drivers/gpio/gpio-mpc8xxx.c > +++ b/drivers/gpio/gpio-mpc8xxx.c > @@ -22,6 +22,7 @@ > #include > #include > #include > +#include > > #define MPC8XXX_GPIO_PINS 32 > > @@ -127,20 +128,20 @@ static int mpc8xxx_gpio_to_irq(struct gpio_chip *gc= , unsigned offset) > return -ENXIO; > } > > -static void mpc8xxx_gpio_irq_cascade(struct irq_desc *desc) > +static irqreturn_t mpc8xxx_gpio_irq_cascade(int irq, void *data) > { > - struct mpc8xxx_gpio_chip *mpc8xxx_gc =3D irq_desc_get_handler_dat= a(desc); > - struct irq_chip *chip =3D irq_desc_get_chip(desc); > + struct mpc8xxx_gpio_chip *mpc8xxx_gc =3D (struct mpc8xxx_gpio_chi= p *)data; There's no need to cast void pointers. > struct gpio_chip *gc =3D &mpc8xxx_gc->gc; > unsigned int mask; > + int i; > > mask =3D gc->read_reg(mpc8xxx_gc->regs + GPIO_IER) > & gc->read_reg(mpc8xxx_gc->regs + GPIO_IMR); > - if (mask) > + for_each_set_bit(i, &mask, 32) > generic_handle_irq(irq_linear_revmap(mpc8xxx_gc->irq, > - 32 - ffs(mask))); > - if (chip->irq_eoi) > - chip->irq_eoi(&desc->irq_data); > + 31 - i)); > + > + return IRQ_HANDLED; > } > > static void mpc8xxx_irq_unmask(struct irq_data *d) > @@ -388,8 +389,8 @@ static int mpc8xxx_probe(struct platform_device *pdev= ) > > ret =3D gpiochip_add_data(gc, mpc8xxx_gc); > if (ret) { > - pr_err("%pOF: GPIO chip registration failed with status %= d\n", > - np, ret); > + dev_err(&pdev->dev, "%pOF: GPIO chip registration failed = with status %d\n", > + np, ret); > goto err; > } > > @@ -409,8 +410,15 @@ static int mpc8xxx_probe(struct platform_device *pde= v) > if (devtype->gpio_dir_in_init) > devtype->gpio_dir_in_init(gc); > > - irq_set_chained_handler_and_data(mpc8xxx_gc->irqn, > - mpc8xxx_gpio_irq_cascade, mpc8xx= x_gc); > + ret =3D request_irq(mpc8xxx_gc->irqn, mpc8xxx_gpio_irq_cascade, > + IRQF_NO_THREAD | IRQF_SHARED, "gpio-cascade", > + mpc8xxx_gc); You never free this irq. Maybe use devm_request_irq()? Bart > + if (ret) { > + dev_err(&pdev->dev, "%s: failed to request_irq(%d), ret = =3D %d\n", > + np->full_name, mpc8xxx_gc->irqn, ret); > + goto err; > + } > + > return 0; > err: > iounmap(mpc8xxx_gc->regs); > -- > 2.9.5 >