2020-12-04 08:40:22

by Xu Wang

[permalink] [raw]
Subject: [PATCH] usb: dwc2: Remove redundant null check before clk_prepare_enable/clk_disable_unprepare

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 <[email protected]>
---
drivers/usb/dwc2/platform.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 5f18acac7406..ba2b491c7f82 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -143,11 +143,9 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg)
if (ret)
return ret;

- if (hsotg->clk) {
- ret = clk_prepare_enable(hsotg->clk);
- if (ret)
- return ret;
- }
+ ret = clk_prepare_enable(hsotg->clk);
+ if (ret)
+ return ret;

if (hsotg->uphy) {
ret = usb_phy_init(hsotg->uphy);
@@ -195,8 +193,7 @@ static int __dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg)
if (ret)
return ret;

- if (hsotg->clk)
- clk_disable_unprepare(hsotg->clk);
+ clk_disable_unprepare(hsotg->clk);

return 0;
}
--
2.17.1


2020-12-08 07:36:13

by Artur Petrosyan

[permalink] [raw]
Subject: Re: [PATCH] usb: dwc2: Remove redundant null check before clk_prepare_enable/clk_disable_unprepare

On 12/4/2020 12:36, Xu Wang wrote:
> 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 <[email protected]>

Reviewed-by: Artur Petrosyan <[email protected]>

> ---
> drivers/usb/dwc2/platform.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> index 5f18acac7406..ba2b491c7f82 100644
> --- a/drivers/usb/dwc2/platform.c
> +++ b/drivers/usb/dwc2/platform.c
> @@ -143,11 +143,9 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg)
> if (ret)
> return ret;
>
> - if (hsotg->clk) {
> - ret = clk_prepare_enable(hsotg->clk);
> - if (ret)
> - return ret;
> - }
> + ret = clk_prepare_enable(hsotg->clk);
> + if (ret)
> + return ret;
>
> if (hsotg->uphy) {
> ret = usb_phy_init(hsotg->uphy);
> @@ -195,8 +193,7 @@ static int __dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg)
> if (ret)
> return ret;
>
> - if (hsotg->clk)
> - clk_disable_unprepare(hsotg->clk);
> + clk_disable_unprepare(hsotg->clk);
>
> return 0;
> }
>

2020-12-08 07:38:27

by Minas Harutyunyan

[permalink] [raw]
Subject: Re: [PATCH] usb: dwc2: Remove redundant null check before clk_prepare_enable/clk_disable_unprepare

On 12/8/2020 11:29 AM, Artur Petrosyan wrote:
> On 12/4/2020 12:36, Xu Wang wrote:
>> 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 <[email protected]>
>
> Reviewed-by: Artur Petrosyan <[email protected]>
>

Acked-by: Minas Harutyunyan <[email protected]>