Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7402369ybi; Thu, 1 Aug 2019 07:40:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqynNPKdnTju/gohPiQbM9nAzSTzhl3bwCb2kvEitwHpPT+pryGRMcogUf9gtPMpHZxRy9sS X-Received: by 2002:aa7:8ad0:: with SMTP id b16mr51956305pfd.45.1564670434207; Thu, 01 Aug 2019 07:40:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564670434; cv=none; d=google.com; s=arc-20160816; b=VahFaIzl1la/JG66Aek425pUXbePe8CG89+myh6FSVq2wV4Ag1d0UjnfCxncxcGxs2 m17FEmh+aNqYbJ9PPrakKtGmlxMmxF7CywEbgb/DI4hyAF/vIfKaH0Ime+Dg4EaoPwAB cuynGe3zh68DXa96nTDop/07wKBQZZRQvfLPjiok9QRRviwi15qDfNGPt58QRb9BSS2p Rj4jD1xmtEF65N7i9wlZB7tO2a0tE8kwQU5OsFy3EgjvNIsP5D+GqWdrcBGO4DhfinId hjfpCqRr4fhI3BCU6WHhr1QMOaMEdyKtDhiFA6KyENz/LS3ii45EbaqwL2uxw30xnqME tqUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=RC6wKO1Isy8ssplnFFBZCldnnaBxZKmxUbojPji9Nn8=; b=Rgu6zsLOYGkXrsiqhdfiAfDKoEWHOsbFqSaDec+fGm7a4OQsdM7SfqPHig/UBgxG/O ySpgOMbZIm43xYA7pofBBdBHpg3MJa5R2c8f03Xt1lFKJ6cAmyo7Asvlja5o6OeN0Ovm 4TJycILk1eyhNHaowOGnDiaif01coNpRanwLQwc9uLwq35QpTm5uwpKD+00h9djfQgbL 4uGaPe6UFIAQUj9QtgQN9BaxRZKx1AF7MmZGtsquVdGN7WPQHEHd+ODGSzRZMR4IrLcp A5WJ1F8J2YGVwJLJ0iLOX8hGyGvapzGYwqMrBpD7stw1mUxSOzcerztTFfL6/v8wTVNd lzrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KUu2NGVr; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h189si25867449pge.36.2019.08.01.07.40.18; Thu, 01 Aug 2019 07:40:34 -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=@gmail.com header.s=20161025 header.b=KUu2NGVr; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729674AbfHANTf (ORCPT + 99 others); Thu, 1 Aug 2019 09:19:35 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:39913 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728592AbfHANTf (ORCPT ); Thu, 1 Aug 2019 09:19:35 -0400 Received: by mail-lj1-f195.google.com with SMTP id v18so69309236ljh.6; Thu, 01 Aug 2019 06:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RC6wKO1Isy8ssplnFFBZCldnnaBxZKmxUbojPji9Nn8=; b=KUu2NGVrF3CsroBiTb6xu1ZVx93LkXrT1peKf0dykpEFlk4TXLXA7TsWvS53RT4lTo K4juM7BZMtb6SDbbYkdwqh1AgseBQOTuTLGUQqm1vROI5EC+TR9avlR+2A/5WE/Qx8Qb XWc6+IL5OyWftImZreXB9VDAxlRk4GhtGSuE3eShxQ5CmYP7YV9SFJpsposFOODrqH/M XMddEgfFPqbmw+rwydtEpbADNt+2pztRm/8V4eNqKyDwtpRXa1tsw0GhJtxeCoHvevVw 4YUexJXuE2KX2Dta84W+JPUzjl0DL9dlC4VnMLXsFy/fq4RrYFWAzwMLTM+5t4+IXl/5 9EYA== 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; bh=RC6wKO1Isy8ssplnFFBZCldnnaBxZKmxUbojPji9Nn8=; b=CSKL8XS6jDHXd4EmHUCbRSaKztj9GgwGYsbcTpDUDE7Fmzr+gWCX0oDtItNyrEaJ7p viZX0ZH0/5MwOHxmE8oZfTet0VSdHrV+DqKEzCSvlgvPqe2O1wYBFV1fwwd2d1lRKkWI Tui2n8uWrh5O8j11irt9YnlNxwYBXPUDZWu6Nr/ZxOd3hOruZcZPdO73DB5zYB89rSN0 2DElOtIIBb8xz4ccwDAqB4k58qicqR54OkX7kKN7yzuhgv75JeDu/7HJMqP8xnmhvZmn 9qL4Mfxm+qIdN0pFteXhzlbxhY4r8Y/f09KhsoGwXDUWbeuEfYoX03NqpVgd45d3IItg Ob7Q== X-Gm-Message-State: APjAAAW47cSuq3ZVqeG72r1XtsqXbo9upphDgey+1VXvARSat0gNSEnJ 7znu4ma4t/zaUSW/TaR8KsjBtwpjFSVhGpDBsjw= X-Received: by 2002:a2e:5d1:: with SMTP id 200mr68535653ljf.10.1564665573273; Thu, 01 Aug 2019 06:19:33 -0700 (PDT) MIME-Version: 1.0 References: <20190801124446.15703-1-frieder.schrempf@kontron.de> In-Reply-To: <20190801124446.15703-1-frieder.schrempf@kontron.de> From: Fabio Estevam Date: Thu, 1 Aug 2019 10:19:45 -0300 Message-ID: Subject: Re: [PATCH] serial: mctrl_gpio: Avoid probe failures in case of missing gpiolib To: Schrempf Frieder Cc: "u.kleine-koenig@pengutronix.de" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "linux-imx@nxp.com" , Greg Kroah-Hartman , "linux-arm-kernel@lists.infradead.org" , Jiri Slaby , "linux-serial@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Geert Uytterhoeven Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Schrempf, On Thu, Aug 1, 2019 at 9:47 AM Schrempf Frieder wrote: > > 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 Looks good to me: Reviewed-by: Fabio Estevam Also adding Geert on Cc as the patch touches sh-sci. Thanks > --- > 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