From patchwork Fri Apr 29 07:24:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 8977991 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4BA0BBF29F for ; Fri, 29 Apr 2016 07:24:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A8B712021A for ; Fri, 29 Apr 2016 07:24:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E19720219 for ; Fri, 29 Apr 2016 07:24:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751427AbcD2HYn (ORCPT ); Fri, 29 Apr 2016 03:24:43 -0400 Received: from michel.telenet-ops.be ([195.130.137.88]:43322 "EHLO michel.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750752AbcD2HYm (ORCPT ); Fri, 29 Apr 2016 03:24:42 -0400 Received: from ayla.of.borg ([84.195.109.243]) by michel.telenet-ops.be with bizsmtp id o7Qg1s00W5F7gFG067Qgd0; Fri, 29 Apr 2016 09:24:40 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1aw2n2-0000zf-3z; Fri, 29 Apr 2016 09:24:40 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1aw2n3-0006UC-O0; Fri, 29 Apr 2016 09:24:41 +0200 From: Geert Uytterhoeven To: Linus Walleij , Laurent Pinchart Cc: linux-gpio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] pinctrl: sh-pfc: Let gpio_chip.to_irq() return -ENXIO on error Date: Fri, 29 Apr 2016 09:24:37 +0200 Message-Id: <1461914677-24899-1-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currrently the gpio_chip.to_irq() callback returns -ENOSYS on error, which causes bad interactions with the serial_mctrl_gpio helpers. mctrl_gpio_init() returns -ENOSYS if GPIOLIB is not enabled, which is intended to be ignored by its callers. However, ignoring -ENOSYS when it was caused by a gpiod_to_irq() failure will lead to a crash later: Unable to handle kernel paging request at virtual address ffffffde ... PC is at mctrl_gpio_set+0x14/0x78 Fix this by returning -ENXIO instead. Signed-off-by: Geert Uytterhoeven --- Is -ENXIO the right error code? - Most drivers seem to return -ENXIO on failure, just like gpiod_to_irq() does when no .to_irq() callback is provided by the driver, - Some drivers use -EINVAL, - Drivers that call irq_find_mapping(), irq_create_mapping(), or irq_create_fwspec_mapping() return zero! This also applies to the core helper gpiochip_to_irq(). --- drivers/pinctrl/sh-pfc/gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c index a6681b8b17c3b30c..2fffb9c32231adb3 100644 --- a/drivers/pinctrl/sh-pfc/gpio.c +++ b/drivers/pinctrl/sh-pfc/gpio.c @@ -212,7 +212,7 @@ static int gpio_pin_to_irq(struct gpio_chip *gc, unsigned offset) } } - return -ENOSYS; + return -ENXIO; found: return pfc->irqs[i];