From patchwork Fri Nov 2 19:10:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 992516 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42ms9V2g9jzB4Ns for ; Sat, 3 Nov 2018 06:10:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727145AbeKCETM (ORCPT ); Sat, 3 Nov 2018 00:19:12 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:12601 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728497AbeKCETM (ORCPT ); Sat, 3 Nov 2018 00:19:12 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie3.idc.renesas.com with ESMTP; 03 Nov 2018 04:10:49 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id A3B044EB7C; Sat, 3 Nov 2018 04:10:49 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.54,456,1534777200"; d="scan'208";a="295067054" Received: from unknown (HELO fabrizio-dev.ree.adwin.renesas.com) ([10.226.36.250]) by relmlii1.idc.renesas.com with ESMTP; 03 Nov 2018 04:10:47 +0900 From: Fabrizio Castro To: Linus Walleij , Geert Uytterhoeven , Simon Horman Cc: Fabrizio Castro , linux-gpio@vger.kernel.org, Chris Paterson , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH] gpio: rcar: Request GPIO while enabling interrupt Date: Fri, 2 Nov 2018 19:10:43 +0000 Message-Id: <1541185843-32732-1-git-send-email-fabrizio.castro@bp.renesas.com> X-Mailer: git-send-email 2.7.4 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org There are cases when the bootloader configures a pin to work as a function rather than GPIO, and other cases when the pin is configured as a function at POR. This commit makes sure the pin is configured as a GPIO the moment we need it to work as an interrupt. Signed-off-by: Fabrizio Castro --- RFC->PATCH: * Moved gc->request to the bottom of gpio_rcar_irq_set_type drivers/gpio/gpio-rcar.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 3c82bb3..5b96ee3 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -147,6 +147,7 @@ static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type) struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_rcar_priv *p = gpiochip_get_data(gc); unsigned int hwirq = irqd_to_hwirq(d); + int err; dev_dbg(&p->pdev->dev, "sense irq = %d, type = %d\n", hwirq, type); @@ -176,6 +177,13 @@ static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type) default: return -EINVAL; } + + err = gc->request(gc, hwirq); + if (err) { + dev_err(&p->pdev->dev, "Can't request GPIO %d from %s\n", hwirq, + gc->label); + return err; + } return 0; }