Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp9540pja; Fri, 22 Nov 2019 02:44:58 -0800 (PST) X-Google-Smtp-Source: APXvYqwBfL0d4WM8upuDcz/p21zFxFjepOb2sFPp1HJ0+CmkeAV3TPMAET54sfOeFp7eGUQlI676 X-Received: by 2002:a17:906:1fd5:: with SMTP id e21mr20528614ejt.320.1574419498480; Fri, 22 Nov 2019 02:44:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574419498; cv=none; d=google.com; s=arc-20160816; b=dXZ/IAbGtUS56pal4OJeP2m8nto8MrLkvJxASWtqEE9lDg0n/vXlvOFrVkPW/m4N2m OVofq6BYrmfDAmYdEzQmPoeg00nd8SKvcuQQicvYcbN6GKyLvi9OLGcF4cn6eb6B0lxW Jh7FSuFQKwpfkj54FZ0NZ2EbhGE/rnpDshETyzOOSLxT6g4IrT4sX+sbUqZkzNMP0ZCC Az1T2swccEB8qVvEh+5M+hvkCjzRi7bap0+ciLJQ7for+jHSs0OYXy9i1rqXNpG24lsU YGK/UOb7badzthp9QBU8zxGw/2bBtdf3YbITSeWjvFfe2AGZ5PdBCtECJLlEKp5OYs94 Fb3g== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=X2OU5KNudgIUoiiwDb3hDI2qc9SjXZDnCEzH7Vzs6gw=; b=oFyUtjHAAYumWPTtYiS+3GwZzh9PtmYOUME4hM4n35kViGDwH27yTdIT+mdC3j9CCk pTWP2MqFuNVQGxYsMWX6zDkEUc5p41XO1Y8j1fzh7zkDQcJZs5B710TtSjZVeP8PPn+y zDlTGRj1jMYdzwxaZVABtRXnvrC+D12Gr494cruYN81u8NkMnWvTZAnF6nIxqI9ayom0 1R2IoDuiZpR98dRuxwHtk9KS9VbkLHGB8MWbmPzrd/ScCJxFFQ3enaeIq6FhWIr8dxSV Jr8yXG9TdQg9cCE/lVkIxLzFrwr/ETT37QnuKVtkt4VYsmLS2ouZZANGzxxAP7Sb5pES /ITw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GrP8JGjj; 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 f7si4628529edy.92.2019.11.22.02.44.34; Fri, 22 Nov 2019 02:44:58 -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; dkim=pass header.i=@kernel.org header.s=default header.b=GrP8JGjj; 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 S1729099AbfKVKmW (ORCPT + 99 others); Fri, 22 Nov 2019 05:42:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:47250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728657AbfKVKmR (ORCPT ); Fri, 22 Nov 2019 05:42:17 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9804920637; Fri, 22 Nov 2019 10:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574419336; bh=8jmJ15RKMd00vSediAxz+/eJNibhGO3eYbxiobdn/8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GrP8JGjj8mNrNYRjUo8+kI2SDemyktHCkvlX44e1e9dI7nObgteLgQGjYR+Hd4PY2 syxiDfQkoiPVhm72BRDAkN5Tb5B95M8YzNvOQMnGZL31CsfIofOsuqDoqBr1ctfAwe f++WE63CsKZZj1ZSMy3gMkURFUWkKand/uIX/xsA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ludovic Desroches , Linus Walleij , Sasha Levin Subject: [PATCH 4.9 070/222] pinctrl: at91: dont use the same irqchip with multiple gpiochips Date: Fri, 22 Nov 2019 11:26:50 +0100 Message-Id: <20191122100905.868383436@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100830.874290814@linuxfoundation.org> References: <20191122100830.874290814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ludovic Desroches [ Upstream commit 0c3dfa176912b5f87732545598200fb55e9c1978 ] Sharing the same irqchip with multiple gpiochips is not a good practice. For instance, when installing hooks, we change the state of the irqchip. The initial state of the irqchip for the second gpiochip to register is then disrupted. Signed-off-by: Ludovic Desroches Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/pinctrl/pinctrl-at91.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 9f09041859099..9401a0630e80b 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -1545,16 +1545,6 @@ void at91_pinctrl_gpio_resume(void) #define gpio_irq_set_wake NULL #endif /* CONFIG_PM */ -static struct irq_chip gpio_irqchip = { - .name = "GPIO", - .irq_ack = gpio_irq_ack, - .irq_disable = gpio_irq_mask, - .irq_mask = gpio_irq_mask, - .irq_unmask = gpio_irq_unmask, - /* .irq_set_type is set dynamically */ - .irq_set_wake = gpio_irq_set_wake, -}; - static void gpio_irq_handler(struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); @@ -1595,12 +1585,22 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev, struct gpio_chip *gpiochip_prev = NULL; struct at91_gpio_chip *prev = NULL; struct irq_data *d = irq_get_irq_data(at91_gpio->pioc_virq); + struct irq_chip *gpio_irqchip; int ret, i; + gpio_irqchip = devm_kzalloc(&pdev->dev, sizeof(*gpio_irqchip), GFP_KERNEL); + if (!gpio_irqchip) + return -ENOMEM; + at91_gpio->pioc_hwirq = irqd_to_hwirq(d); - /* Setup proper .irq_set_type function */ - gpio_irqchip.irq_set_type = at91_gpio->ops->irq_type; + gpio_irqchip->name = "GPIO"; + gpio_irqchip->irq_ack = gpio_irq_ack; + gpio_irqchip->irq_disable = gpio_irq_mask; + gpio_irqchip->irq_mask = gpio_irq_mask; + gpio_irqchip->irq_unmask = gpio_irq_unmask; + gpio_irqchip->irq_set_wake = gpio_irq_set_wake, + gpio_irqchip->irq_set_type = at91_gpio->ops->irq_type; /* Disable irqs of this PIO controller */ writel_relaxed(~0, at91_gpio->regbase + PIO_IDR); @@ -1611,7 +1611,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev, * interrupt. */ ret = gpiochip_irqchip_add(&at91_gpio->chip, - &gpio_irqchip, + gpio_irqchip, 0, handle_edge_irq, IRQ_TYPE_NONE); @@ -1629,7 +1629,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev, if (!gpiochip_prev) { /* Then register the chain on the parent IRQ */ gpiochip_set_chained_irqchip(&at91_gpio->chip, - &gpio_irqchip, + gpio_irqchip, at91_gpio->pioc_virq, gpio_irq_handler); return 0; -- 2.20.1