Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7269721ybi; Thu, 1 Aug 2019 05:49:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqybvf1IYykDox6uMjfCDUDV5u41ZdEo/hIOS/ztucmQEpZPXqryVmR/GVbrsw76rI+QOOAn X-Received: by 2002:a62:7994:: with SMTP id u142mr54055925pfc.39.1564663749372; Thu, 01 Aug 2019 05:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564663749; cv=none; d=google.com; s=arc-20160816; b=lasM/I3weWmz0UVtRygKuYXsjrc5e5JdcHc53TkOBaWPnzJC8XmTk07hGVTS5k2tyY xEx7WT/X/Gjda7n4EE7P3NFVCEEJWjkB2++UEdTrWCb0X8SlOSRhpzPAlIprF9cxUz2e 7Vljfcp2qTCtk8RJI5lc+0H8LFOKOArDS2NkAQFoFxZ9CaLp7peGC4WUD46SmxOMSTnx Mm0DqYPb0yaR129DHSIwus7DVczJwtBwyNXb2IiKCRW0YRmHOBbktC0R4YmKBTwQET9m nJPoTNcfY4Ga58JYlk7cqNiZE1zvT+LJLJgV/xzwgciccApazpFogveN3v8MGsM4JFZH 9SMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=rMK1RllfV4P2xpiqt8mefRXJslT0LkY2QSCEOeW9PVM=; b=TP8RnUE18vo0SohcrIycBipWySQDjEsb+hYqGOhRd19v9sSCZyghHFE/V3l8kmGMuJ 64V00IwSSNyztOd9HT0HZTwUyL+oDjCK3603w2SRKlbQ/KUzoxhHpVIaQZk6tHBVYnf0 OOpd8NU0QwfP8Zh0P0BYAsmU8ZU+NEDEGequgUsk02rnjYe2KZGS0McOgeAg8i6h+8dY yTs0TQXVEzqohS5yKDGs8I1CQkPPeCRCYMj9KLTZ4LuIL3eW0E/zvJ7NXzXMj535ZIhy gUqBc9NI7nxoBWvBPy0UArn9g0XaF4VYchWEBPOhtLokVcC9oxYm/jV+75ASmc0Hk8QJ buSQ== ARC-Authentication-Results: i=1; mx.google.com; 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 o63si4053245pjo.94.2019.08.01.05.48.53; Thu, 01 Aug 2019 05:49:09 -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; 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 S1731519AbfHAMrK convert rfc822-to-8bit (ORCPT + 99 others); Thu, 1 Aug 2019 08:47:10 -0400 Received: from skedge04.snt-world.com ([91.208.41.69]:41592 "EHLO skedge04.snt-world.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731511AbfHAMrI (ORCPT ); Thu, 1 Aug 2019 08:47:08 -0400 Received: from sntmail10s.snt-is.com (unknown [10.203.32.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by skedge04.snt-world.com (Postfix) with ESMTPS id 56C7667A6F0; Thu, 1 Aug 2019 14:46:43 +0200 (CEST) Received: from sntmail12r.snt-is.com (10.203.32.182) by sntmail10s.snt-is.com (10.203.32.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 1 Aug 2019 14:46:42 +0200 Received: from sntmail12r.snt-is.com ([fe80::e551:8750:7bba:3305]) by sntmail12r.snt-is.com ([fe80::e551:8750:7bba:3305%3]) with mapi id 15.01.1713.004; Thu, 1 Aug 2019 14:46:42 +0200 From: Schrempf Frieder To: "u.kleine-koenig@pengutronix.de" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , "linux-imx@nxp.com" , Greg Kroah-Hartman CC: "linux-arm-kernel@lists.infradead.org" , Schrempf Frieder , Jiri Slaby , "linux-serial@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] serial: mctrl_gpio: Avoid probe failures in case of missing gpiolib Thread-Topic: [PATCH] serial: mctrl_gpio: Avoid probe failures in case of missing gpiolib Thread-Index: AQHVSGcrNWPx0fgcHUyq9EomzdiefQ== Date: Thu, 1 Aug 2019 12:46:42 +0000 Message-ID: <20190801124446.15703-1-frieder.schrempf@kontron.de> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-originating-ip: [172.25.9.193] x-c2processedorg: 51b406b7-48a2-4d03-b652-521f56ac89f3 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-SnT-MailScanner-Information: Please contact the ISP for more information X-SnT-MailScanner-ID: 56C7667A6F0.AF21B X-SnT-MailScanner: Not scanned: please contact your Internet E-Mail Service Provider for details X-SnT-MailScanner-SpamCheck: X-SnT-MailScanner-From: frieder.schrempf@kontron.de X-SnT-MailScanner-To: festevam@gmail.com, gregkh@linuxfoundation.org, jslaby@suse.com, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org, u.kleine-koenig@pengutronix.de X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Frieder Schrempf If CONFIG_GPIOLIB is not enabled, mctrl_gpio_init() and mctrl_gpio_init_noauto() will currently return an error pointer with -ENOSYS. As the mctrl GPIOs are usually optional, drivers need to check for this condition to allow continue probing. To avoid the need for this check in each driver, we return NULL instead, as all the mctrl_gpio_*() functions are skipped anyway. We also adapt mctrl_gpio_to_gpiod() to be in line with this change. Signed-off-by: Frieder Schrempf --- drivers/tty/serial/serial_mctrl_gpio.c | 3 +++ drivers/tty/serial/serial_mctrl_gpio.h | 6 +++--- drivers/tty/serial/sh-sci.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/serial_mctrl_gpio.c b/drivers/tty/serial/serial_mctrl_gpio.c index 2b400189be91..54c43e02e375 100644 --- a/drivers/tty/serial/serial_mctrl_gpio.c +++ b/drivers/tty/serial/serial_mctrl_gpio.c @@ -61,6 +61,9 @@ EXPORT_SYMBOL_GPL(mctrl_gpio_set); struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios, enum mctrl_gpio_idx gidx) { + if (gpios == NULL) + return NULL; + return gpios->gpio[gidx]; } EXPORT_SYMBOL_GPL(mctrl_gpio_to_gpiod); diff --git a/drivers/tty/serial/serial_mctrl_gpio.h b/drivers/tty/serial/serial_mctrl_gpio.h index b7d3cca48ede..1b2ff503b2c2 100644 --- a/drivers/tty/serial/serial_mctrl_gpio.h +++ b/drivers/tty/serial/serial_mctrl_gpio.h @@ -114,19 +114,19 @@ static inline struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios, enum mctrl_gpio_idx gidx) { - return ERR_PTR(-ENOSYS); + return NULL; } static inline struct mctrl_gpios *mctrl_gpio_init(struct uart_port *port, unsigned int idx) { - return ERR_PTR(-ENOSYS); + return NULL; } static inline struct mctrl_gpios *mctrl_gpio_init_noauto(struct device *dev, unsigned int idx) { - return ERR_PTR(-ENOSYS); + return NULL; } static inline diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index d18c680aa64b..249325b65ee0 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -3287,7 +3287,7 @@ static int sci_probe_single(struct platform_device *dev, return ret; sciport->gpios = mctrl_gpio_init(&sciport->port, 0); - if (IS_ERR(sciport->gpios) && PTR_ERR(sciport->gpios) != -ENOSYS) + if (IS_ERR(sciport->gpios)) return PTR_ERR(sciport->gpios); if (sciport->has_rtscts) { -- 2.17.1