From patchwork Mon Dec 28 20:06:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 352839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F58BC4321A for ; Mon, 28 Dec 2020 23:13:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 142F5222F9 for ; Mon, 28 Dec 2020 23:13:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730636AbgL1Wzw (ORCPT ); Mon, 28 Dec 2020 17:55:52 -0500 Received: from mga17.intel.com ([192.55.52.151]:20884 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729382AbgL1UIT (ORCPT ); Mon, 28 Dec 2020 15:08:19 -0500 IronPort-SDR: 8Z/hSQ77/38OJ3SUz2mfJFD9ejDnW6xAZ75OstJ/hBl53jtVPMdZS+mQhGE5GVvzQZ1TkxrID8 /1IQegic0eUw== X-IronPort-AV: E=McAfee;i="6000,8403,9848"; a="156207358" X-IronPort-AV: E=Sophos;i="5.78,456,1599548400"; d="scan'208";a="156207358" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2020 12:06:23 -0800 IronPort-SDR: W6LKwrETLC3WRbOG5xzlvTpxv26PmDKoRXEDvBUukESFNZjZ0lebjqfAWlPW47AQ006ZvYFJWN 32pT3crmtVKA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,456,1599548400"; d="scan'208";a="392869412" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 28 Dec 2020 12:06:20 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 98C96DE; Mon, 28 Dec 2020 22:06:19 +0200 (EET) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, Jean Delvare , Wolfram Sang , linux-i2c@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 1/3] gpiolib: Follow usual pattern for gpiod_remove_lookup_table() call Date: Mon, 28 Dec 2020 22:06:16 +0200 Message-Id: <20201228200618.58716-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The usual pattern for the remove calls, like gpiod_remove_lookup_table(), is to be NULL-aware, i.o.w. become a no-op whenever parameter is NULL. Update gpiod_remove_lookup_table() call to follow this pattern. Signed-off-by: Andy Shevchenko Acked-by: Bartosz Golaszewski Reviewed-by: Jean Delvare --- drivers/gpio/gpiolib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index b02cc2abd3b6..611d6ea82d75 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3460,6 +3460,10 @@ EXPORT_SYMBOL_GPL(gpiod_add_lookup_table); */ void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) { + /* Nothing to remove */ + if (!table) + return; + mutex_lock(&gpio_lookup_lock); list_del(&table->list); From patchwork Mon Dec 28 20:06:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 354077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E3FAC4361A for ; Mon, 28 Dec 2020 23:13:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58D98222F9 for ; Mon, 28 Dec 2020 23:13:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729465AbgL1Wzw (ORCPT ); Mon, 28 Dec 2020 17:55:52 -0500 Received: from mga09.intel.com ([134.134.136.24]:61112 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729380AbgL1UIR (ORCPT ); Mon, 28 Dec 2020 15:08:17 -0500 IronPort-SDR: RREgzjBaso99mSTeVlNaUy/fo6AtEYfr5dvuAwWn4/WESK/hUOpSStApNE9gzeb07uazx5RTfe t/9l6eZMOEaA== X-IronPort-AV: E=McAfee;i="6000,8403,9848"; a="176575254" X-IronPort-AV: E=Sophos;i="5.78,456,1599548400"; d="scan'208";a="176575254" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2020 12:06:22 -0800 IronPort-SDR: zJFJp+S+NPWOURQbhlYG5sNbx6K0NY67QRYgLpqSe3+GVrv6pIJj4j/3YkUdHUf3jvZOZG2DP6 XQjzhODS1dEg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,456,1599548400"; d="scan'208";a="418919057" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 28 Dec 2020 12:06:20 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A9F3973; Mon, 28 Dec 2020 22:06:19 +0200 (EET) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, Jean Delvare , Wolfram Sang , linux-i2c@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 2/3] i2c: i801: Drop duplicate NULL check in i801_del_mux() Date: Mon, 28 Dec 2020 22:06:17 +0200 Message-Id: <20201228200618.58716-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228200618.58716-1-andriy.shevchenko@linux.intel.com> References: <20201228200618.58716-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Since gpiod_remove_lookup_table() is NULL-aware, no need to have this check in the caller. Drop duplicate NULL check. Signed-off-by: Andy Shevchenko Reviewed-by: Jean Delvare --- drivers/i2c/busses/i2c-i801.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index ae90713443fa..7c2569a18f8c 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -1487,8 +1487,7 @@ static void i801_del_mux(struct i801_priv *priv) { if (priv->mux_pdev) platform_device_unregister(priv->mux_pdev); - if (priv->lookup) - gpiod_remove_lookup_table(priv->lookup); + gpiod_remove_lookup_table(priv->lookup); } static unsigned int i801_get_adapter_class(struct i801_priv *priv) From patchwork Mon Dec 28 20:06:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 352840 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 110C7C43219 for ; Mon, 28 Dec 2020 23:13:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD42C222F9 for ; Mon, 28 Dec 2020 23:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729384AbgL1Wzw (ORCPT ); Mon, 28 Dec 2020 17:55:52 -0500 Received: from mga12.intel.com ([192.55.52.136]:28661 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729381AbgL1UIT (ORCPT ); Mon, 28 Dec 2020 15:08:19 -0500 IronPort-SDR: qxJEmYEOcl//nJ1CwVeAPYXnzU4tXSCraNWuIPEGpzxLB+AYTZDEx/oe2pvc6L4LsWkt+S3moL OnIvLP+xxI0w== X-IronPort-AV: E=McAfee;i="6000,8403,9848"; a="155625473" X-IronPort-AV: E=Sophos;i="5.78,456,1599548400"; d="scan'208";a="155625473" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2020 12:06:22 -0800 IronPort-SDR: ns2x00IEq3P4ivZEYLQzzPqlKG2xceSqcgNl6KdngvnTIeYREdndXZdmgVojWnsiASHVPRuOdH hqklLaP2pA2g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,456,1599548400"; d="scan'208";a="459871195" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 28 Dec 2020 12:06:20 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id AFBDF109; Mon, 28 Dec 2020 22:06:19 +0200 (EET) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, Jean Delvare , Wolfram Sang , linux-i2c@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 3/3] i2c: i801: Refactor mux code since platform_device_unregister() is NULL aware Date: Mon, 28 Dec 2020 22:06:18 +0200 Message-Id: <20201228200618.58716-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228200618.58716-1-andriy.shevchenko@linux.intel.com> References: <20201228200618.58716-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org platform_device_unregister() is NULL-aware and thus doesn't required a duplication check in i801_del_mux(). Besides that it's also error pointer aware, and we may drop unneeded assignment in i801_add_mux() followed by conversion to PTR_ERR_OR_ZERO() for the returned value. Signed-off-by: Andy Shevchenko Reviewed-by: Jean Delvare --- drivers/i2c/busses/i2c-i801.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 7c2569a18f8c..1400a8716388 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -1433,7 +1433,7 @@ static int i801_add_mux(struct i801_priv *priv) const struct i801_mux_config *mux_config; struct i2c_mux_gpio_platform_data gpio_data; struct gpiod_lookup_table *lookup; - int err, i; + int i; if (!priv->mux_drvdata) return 0; @@ -1473,20 +1473,16 @@ static int i801_add_mux(struct i801_priv *priv) PLATFORM_DEVID_NONE, &gpio_data, sizeof(struct i2c_mux_gpio_platform_data)); if (IS_ERR(priv->mux_pdev)) { - err = PTR_ERR(priv->mux_pdev); gpiod_remove_lookup_table(lookup); - priv->mux_pdev = NULL; dev_err(dev, "Failed to register i2c-mux-gpio device\n"); - return err; } - return 0; + return PTR_ERR_OR_ZERO(priv->mux_pdev); } static void i801_del_mux(struct i801_priv *priv) { - if (priv->mux_pdev) - platform_device_unregister(priv->mux_pdev); + platform_device_unregister(priv->mux_pdev); gpiod_remove_lookup_table(priv->lookup); }