From patchwork Fri Dec 18 09:35:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Wang X-Patchwork-Id: 11981605 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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 A2A47C4361B for ; Fri, 18 Dec 2020 09:37:21 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 625E523A7D for ; Fri, 18 Dec 2020 09:37:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 625E523A7D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=YivP2dy1IpuGR2f78SpOCxx2Rq7FXrDoHno+d9LoGvU=; b=sp2dAfU6u1fi1Mu6hJdQe7uV3U pmd7L9cON9MUKYt8K5pH1vJTBS9ln232KLhbJvKcbdG3jqOEb1B7BUtQx7KF+REad0MpgDB5AEMYB ObGS8WMcWunXqCCYzVF2dAFj239hpXM0Sb1w8YcLW/8yqfoBcwpK3aRxABBpk9619W91goG96Gvan gMabkLiHKtvTfRmCvQyzzK+Tv+U6YPFPWmIprrPsqyNewRs6dIuBaz2WGPQi1HuI5mkTUulxgvZra pPHVUZI0W4obpI/jnk+5JeLQUp1NUtAOxstY2ECFlrZswF1zrOHRZ2AtKBKKYM0GRRT417I+LIzMz 0yXee3fw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kqCAg-0001aC-Id; Fri, 18 Dec 2020 09:35:34 +0000 Received: from smtp25.cstnet.cn ([159.226.251.25] helo=cstnet.cn) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kqCAc-0001Ya-CB for linux-arm-kernel@lists.infradead.org; Fri, 18 Dec 2020 09:35:32 +0000 Received: from localhost.localdomain (unknown [124.16.141.242]) by APP-05 (Coremail) with SMTP id zQCowACXn7PSd9xfS84SAA--.35060S2; Fri, 18 Dec 2020 17:35:15 +0800 (CST) From: Xu Wang To: jic23@kernel.org, lars@metafoo.de, pmeerw@pmeerw.net, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, fabrice.gasnier@st.com, krzk@kernel.org, andy.shevchenko@gmail.com, olivier.moysan@st.com, etienne.carriere@st.com, alexandru.ardelean@analog.com, peter.ujfalusi@ti.com, linux-iio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH] iio: adc: stm32-adc: Remove redundant null check before clk_prepare_enable/clk_disable_unprepare Date: Fri, 18 Dec 2020 09:35:12 +0000 Message-Id: <20201218093512.871-1-vulab@iscas.ac.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: zQCowACXn7PSd9xfS84SAA--.35060S2 X-Coremail-Antispam: 1UD129KBjvJXoWxZr1UWFW5ZFyxKF4DWr1xXwb_yoW5ZFyUpw nFyF4Fyrs7Za40vFn8JrWjqFyFqa15Ka4IvF4UG3WrWr4ayr98ZFyrtF1IvFWFyrykK3Zx KFyjkFWkuF48uF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvmb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwV C2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC 0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr 1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4IIrI8v6xkF7I0E8cxan2IY 04v7MxkIecxEwVAFwVW8uwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8Jw C20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAF wI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjx v20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2 z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnU UI43ZEXa7IU5l1vDUUUUU== X-Originating-IP: [124.16.141.242] X-CM-SenderInfo: pyxotu46lvutnvoduhdfq/1tbiBgYOA10Te2kdngAAsS X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201218_043530_941396_BA3EA067 X-CRM114-Status: GOOD ( 13.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Because clk_prepare_enable() and clk_disable_unprepare() already checked NULL clock parameter, so the additional checks are unnecessary, just remove them. Signed-off-by: Xu Wang Acked-by: Fabrice Gasnier --- drivers/iio/adc/stm32-adc-core.c | 29 +++++++++++------------------ drivers/iio/adc/stm32-adc.c | 14 +++++--------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c index 9d1ad6e38e85..c088cb990193 100644 --- a/drivers/iio/adc/stm32-adc-core.c +++ b/drivers/iio/adc/stm32-adc-core.c @@ -535,20 +535,16 @@ static int stm32_adc_core_hw_start(struct device *dev) goto err_switches_dis; } - if (priv->bclk) { - ret = clk_prepare_enable(priv->bclk); - if (ret < 0) { - dev_err(dev, "bus clk enable failed\n"); - goto err_regulator_disable; - } + ret = clk_prepare_enable(priv->bclk); + if (ret < 0) { + dev_err(dev, "bus clk enable failed\n"); + goto err_regulator_disable; } - if (priv->aclk) { - ret = clk_prepare_enable(priv->aclk); - if (ret < 0) { - dev_err(dev, "adc clk enable failed\n"); - goto err_bclk_disable; - } + ret = clk_prepare_enable(priv->aclk); + if (ret < 0) { + dev_err(dev, "adc clk enable failed\n"); + goto err_bclk_disable; } writel_relaxed(priv->ccr_bak, priv->common.base + priv->cfg->regs->ccr); @@ -556,8 +552,7 @@ static int stm32_adc_core_hw_start(struct device *dev) return 0; err_bclk_disable: - if (priv->bclk) - clk_disable_unprepare(priv->bclk); + clk_disable_unprepare(priv->bclk); err_regulator_disable: regulator_disable(priv->vref); err_switches_dis: @@ -575,10 +570,8 @@ static void stm32_adc_core_hw_stop(struct device *dev) /* Backup CCR that may be lost (depends on power state to achieve) */ priv->ccr_bak = readl_relaxed(priv->common.base + priv->cfg->regs->ccr); - if (priv->aclk) - clk_disable_unprepare(priv->aclk); - if (priv->bclk) - clk_disable_unprepare(priv->bclk); + clk_disable_unprepare(priv->aclk); + clk_disable_unprepare(priv->bclk); regulator_disable(priv->vref); stm32_adc_core_switches_supply_dis(priv); regulator_disable(priv->vdda); diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index c067c994dae2..f7c53cea509a 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -546,8 +546,7 @@ static int stm32_adc_hw_stop(struct device *dev) if (adc->cfg->unprepare) adc->cfg->unprepare(indio_dev); - if (adc->clk) - clk_disable_unprepare(adc->clk); + clk_disable_unprepare(adc->clk); return 0; } @@ -558,11 +557,9 @@ static int stm32_adc_hw_start(struct device *dev) struct stm32_adc *adc = iio_priv(indio_dev); int ret; - if (adc->clk) { - ret = clk_prepare_enable(adc->clk); - if (ret) - return ret; - } + ret = clk_prepare_enable(adc->clk); + if (ret) + return ret; stm32_adc_set_res(adc); @@ -575,8 +572,7 @@ static int stm32_adc_hw_start(struct device *dev) return 0; err_clk_dis: - if (adc->clk) - clk_disable_unprepare(adc->clk); + clk_disable_unprepare(adc->clk); return ret; }