From patchwork Tue Jan 16 03:45:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darren Hart X-Patchwork-Id: 10165835 X-Patchwork-Delegate: dvhart@infradead.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F40CE60245 for ; Tue, 16 Jan 2018 03:45:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D11081FF3E for ; Tue, 16 Jan 2018 03:45:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C58D41FFFF; Tue, 16 Jan 2018 03:45:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B0481FF3E for ; Tue, 16 Jan 2018 03:45:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750990AbeAPDpP (ORCPT ); Mon, 15 Jan 2018 22:45:15 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:52414 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750842AbeAPDpN (ORCPT ); Mon, 15 Jan 2018 22:45:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=i2bjZ3f2x0OcdcUMBu8ZactC7Yddx5XfDd7L23nMhMg=; b=GuELrBBplo0ROh0i27NA4TG7b tCb4D5UOWZxB1iebJeE+//Wfujv97ep0zV9UWLFWEMjEPIAyjmHHSD3G40crRpajiKN2HgJscWh6A i315P+69QWq6+zjNgnbtTN/vSeAtapbk5vJKE9CRh2uIA0SuuYK+ie2eqPM7cZuu3g/KsBZytuwsm GBhRibk+MyCJ2yR5jH4bM/05Qtxc+SZLFvqbYxxdLmKiAdRemVYEQttTvmUh9Vw/MvBOjVclqnZOx LABKfsU/5MuBZ+TPEfInsjr48la1F6xC7c1e1Jh20xx+FcS1JRd3f/rKfwXbYRMdzE9FmjR/OT3Xh bGLxtDXAQ==; Received: from dvhart by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1ebIBT-00084l-T6; Tue, 16 Jan 2018 03:45:11 +0000 Date: Mon, 15 Jan 2018 19:45:11 -0800 From: Darren Hart To: Vadim Pasternak Cc: andy.shevchenko@gmail.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, jiri@resnulli.us Subject: Re: [patch v8 0/3] drivers/platform: replace module x86/mlxcpld-hotplug with mellanox/mlxreg-hotplug Message-ID: <20180116034511.GE4590@fury> References: <1515661123-76604-1-git-send-email-vadimp@mellanox.com> <20180116034209.GA4590@fury> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180116034209.GA4590@fury> User-Agent: Mutt/1.8.0 (2017-02-23) Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Jan 15, 2018 at 07:42:09PM -0800, Darren Hart wrote: > To follow this email, are two patches which are minor incremental > cleanups, which I'd appreciate your review of before I push them to > testing. From 2c5d26ee913e0f5f7d13c559d85e8da7e4ddcdab Mon Sep 17 00:00:00 2001 Message-Id: <2c5d26ee913e0f5f7d13c559d85e8da7e4ddcdab.1516073719.git.dvhart@infradead.org> From: "Darren Hart (VMware)" Date: Mon, 15 Jan 2018 19:16:36 -0800 Subject: [PATCH 1/2] platform/mellanox: mlxreg-hotplug: Simplify exit path Several functions use a "goto access_error" pattern result in a duplicated exit path at the end of the function. Address this by using a single exit path, and checking for (ret) prior to printing the error message. This adds a conditional, but only in the failure case, and simplifies the exit path. Signed-off-by: Darren Hart (VMware) Cc: Vadim Pasternak Acked-by: Vadim Pasternak --- drivers/platform/mellanox/mlxreg-hotplug.c | 62 ++++++++++++------------------ 1 file changed, 25 insertions(+), 37 deletions(-) diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c index 9bbaa8c..78056f7 100644 --- a/drivers/platform/mellanox/mlxreg-hotplug.c +++ b/drivers/platform/mellanox/mlxreg-hotplug.c @@ -236,12 +236,12 @@ mlxreg_hotplug_work_helper(struct mlxreg_hotplug_priv_data *priv, ret = regmap_write(priv->regmap, item->reg + MLXREG_HOTPLUG_MASK_OFF, 0); if (ret) - goto access_error; + goto out; /* Read status. */ ret = regmap_read(priv->regmap, item->reg, ®val); if (ret) - goto access_error; + goto out; /* Set asserted bits and save last status. */ regval &= item->mask; @@ -267,18 +267,15 @@ mlxreg_hotplug_work_helper(struct mlxreg_hotplug_priv_data *priv, ret = regmap_write(priv->regmap, item->reg + MLXREG_HOTPLUG_EVENT_OFF, 0); if (ret) - goto access_error; + goto out: /* Unmask event. */ ret = regmap_write(priv->regmap, item->reg + MLXREG_HOTPLUG_MASK_OFF, item->mask); - if (ret) - goto access_error; - - return; -access_error: - dev_err(priv->dev, "Failed to complete workqueue.\n"); + out: + if (ret) + dev_err(priv->dev, "Failed to complete workqueue.\n"); } static void @@ -294,12 +291,12 @@ mlxreg_hotplug_health_work_helper(struct mlxreg_hotplug_priv_data *priv, ret = regmap_write(priv->regmap, data->reg + MLXREG_HOTPLUG_MASK_OFF, 0); if (ret) - goto access_error; + goto out; /* Read status. */ ret = regmap_read(priv->regmap, data->reg, ®val); if (ret) - goto access_error; + goto out; regval &= data->mask; item->cache = regval; @@ -321,19 +318,18 @@ mlxreg_hotplug_health_work_helper(struct mlxreg_hotplug_priv_data *priv, ret = regmap_write(priv->regmap, data->reg + MLXREG_HOTPLUG_EVENT_OFF, 0); if (ret) - goto access_error; + goto out; /* Unmask event. */ ret = regmap_write(priv->regmap, data->reg + MLXREG_HOTPLUG_MASK_OFF, data->mask); if (ret) - goto access_error; + goto out; } - return; - -access_error: - dev_err(priv->dev, "Failed to complete workqueue.\n"); + out: + if (ret) + dev_err(priv->dev, "Failed to complete workqueue.\n"); } /* @@ -380,12 +376,12 @@ static void mlxreg_hotplug_work_handler(struct work_struct *work) ret = regmap_write(priv->regmap, pdata->cell + MLXREG_HOTPLUG_AGGR_MASK_OFF, 0); if (ret < 0) - goto access_error; + goto out; /* Read aggregation status. */ ret = regmap_read(priv->regmap, pdata->cell, ®val); if (ret) - goto access_error; + goto out; regval &= pdata->mask; aggr_asserted = priv->aggr_cache ^ regval; @@ -425,13 +421,10 @@ static void mlxreg_hotplug_work_handler(struct work_struct *work) /* Unmask aggregation event (no need acknowledge). */ ret = regmap_write(priv->regmap, pdata->cell + MLXREG_HOTPLUG_AGGR_MASK_OFF, pdata->mask); - if (ret) - goto access_error; - return; - -access_error: - dev_err(priv->dev, "Failed to complete workqueue.\n"); + out: + if (ret) + dev_err(priv->dev, "Failed to complete workqueue.\n"); } static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv) @@ -449,7 +442,7 @@ static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv) ret = regmap_write(priv->regmap, item->reg + MLXREG_HOTPLUG_EVENT_OFF, 0); if (ret) - goto access_error; + goto out; /* Set group initial status as mask and unmask group event. */ if (item->inversed) { @@ -458,7 +451,7 @@ static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv) MLXREG_HOTPLUG_MASK_OFF, item->mask); if (ret) - goto access_error; + goto out; } } @@ -466,7 +459,7 @@ static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv) ret = regmap_write(priv->regmap, pdata->cell + MLXREG_HOTPLUG_AGGR_MASK_OFF, pdata->mask); if (ret) - goto access_error; + goto out; /* Keep low aggregation initial status as zero and unmask events. */ if (pdata->cell_low) { @@ -474,21 +467,16 @@ static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv) MLXREG_HOTPLUG_AGGR_MASK_OFF, pdata->mask_low); if (ret) - goto access_error; + goto out; } /* Invoke work handler for initializing hot plug devices setting. */ mlxreg_hotplug_work_handler(&priv->dwork_irq.work); + out: + if (ret) + dev_err(priv->dev, "Failed to set interrupts.\n"); enable_irq(priv->irq); - - return 0; - -access_error: - dev_err(priv->dev, "Failed to set interrupts.\n"); - - enable_irq(priv->irq); - return ret; }