Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp938014pxb; Tue, 9 Feb 2021 17:19:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxETzJBhZDTHMwcy5wsmFh6g6bEk3MWf6fqMbTUovBXaaCC9OjvdAyatGmgmggmVqi0zPwy X-Received: by 2002:aa7:cd45:: with SMTP id v5mr843742edw.373.1612919966977; Tue, 09 Feb 2021 17:19:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612919966; cv=none; d=google.com; s=arc-20160816; b=AviJ/U1/WhoKrw5R09n0UrDxHkSmbZQzyKhZu0xALmThAYx8lmDTAXPkqS2ZEYfp/P JZeKqCMfnBr4hapYGaVsuoeT1inO/GNPxn05bxtr78ycaoEpsbtKP/LDxpRtbhCtda0k h9tvpDjoHhF2TDNU4VM+RSFGVh+qO8r56BzQUcLeKgUrytuEe1289INpfJuLC1PECHMJ prfMtQWC82YFmfbMAo0bbAwQeUFAe0ddqXSSEF5eHk23MKjH4ZSSfICUp7rbfOXC0lBV aP4kSx9rXIn4XC0tUwj0pr2ibzC8FbF0HFWR5EvRUj/IqocO67AgmEARR3V8wzoEFEHV 57KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=am1nMOQhJYos3Zl7JvQ0JA4AqD6cuJZxZtW1POEWw/s=; b=qYuqViUeZRFLAnzmEflov+yJlPVbk85kwq1TgOZZKexQvyL4mMXjHV6fnangKa+gck FMfVUq6j5HuLVnE7AB4S+GAefnePlYA84srCG4veXWOBSHzII7hpCpZAAEK5OI/2X8mA Nuxg3bn6/9WsKwjltGnmQdN11fWcZVyULPBVpGhmwjHFDcr2jFAjVZYe1XedPiTwfbmj n6wmyYCQg+qf2MrNPVxdPiWRcnAJ9dyDEL61TDZUoaTE843eZal4eahxW+0hye34uFJt gMKwHh+AkjTRKphbes+7jrTefllBkL6OuohwrUMC69kNzrohHOFI9KlJgF17QBr0sSjl dp3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p59si352415edb.125.2021.02.09.17.18.55; Tue, 09 Feb 2021 17:19:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234389AbhBJBSQ (ORCPT + 99 others); Tue, 9 Feb 2021 20:18:16 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:12160 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234179AbhBJBQM (ORCPT ); Tue, 9 Feb 2021 20:16:12 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Db1x04nN0zlJCC; Wed, 10 Feb 2021 09:13:40 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Wed, 10 Feb 2021 09:15:23 +0800 From: Tian Tao To: , , , CC: , , Subject: [PATCH v2] hwrng: bcm2835 - remove redundant null check Date: Wed, 10 Feb 2021 09:14:58 +0800 Message-ID: <1612919698-60261-1-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org clk_prepare_enable() and clk_disable_unprepare() will check NULL clock parameter, so It is not necessary to add additional checks. Signed-off-by: Tian Tao --- v2: change devm_clk_get() to devm_clk_get_optional() which will deal with -ENOENT and return NULL in that case. --- drivers/char/hw_random/bcm2835-rng.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c index 1a7c43b..be5be39 100644 --- a/drivers/char/hw_random/bcm2835-rng.c +++ b/drivers/char/hw_random/bcm2835-rng.c @@ -88,11 +88,9 @@ static int bcm2835_rng_init(struct hwrng *rng) int ret = 0; u32 val; - if (!IS_ERR(priv->clk)) { - ret = clk_prepare_enable(priv->clk); - if (ret) - return ret; - } + ret = clk_prepare_enable(priv->clk); + if (ret) + return ret; if (priv->mask_interrupts) { /* mask the interrupt */ @@ -115,8 +113,7 @@ static void bcm2835_rng_cleanup(struct hwrng *rng) /* disable rng hardware */ rng_writel(priv, 0, RNG_CTRL); - if (!IS_ERR(priv->clk)) - clk_disable_unprepare(priv->clk); + clk_disable_unprepare(priv->clk); } struct bcm2835_rng_of_data { @@ -155,9 +152,9 @@ static int bcm2835_rng_probe(struct platform_device *pdev) return PTR_ERR(priv->base); /* Clock is optional on most platforms */ - priv->clk = devm_clk_get(dev, NULL); - if (PTR_ERR(priv->clk) == -EPROBE_DEFER) - return -EPROBE_DEFER; + priv->clk = devm_clk_get_optional(dev, NULL); + if (IS_ERR(priv->clk)) + return PTR_ERR(priv->clk); priv->rng.name = pdev->name; priv->rng.init = bcm2835_rng_init; -- 2.7.4