diff mbox

[2/2] mmc: meson-mx-sdio: Cleanup IS_ERR() checks

Message ID 20171013112049.rdcdqv6ooktlv5wz@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Oct. 13, 2017, 11:20 a.m. UTC
Using PTR_ERR_OR_ZERO() instead of IS_ERR() works, but it's not how
you're supposed to write these conditions.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I really hope it doesn't become a trend on to wrap all error checks in a
WARN_ON() macro...

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Martin Blumenstingl Oct. 13, 2017, 7:02 p.m. UTC | #1
On Fri, Oct 13, 2017 at 1:20 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Using PTR_ERR_OR_ZERO() instead of IS_ERR() works, but it's not how
> you're supposed to write these conditions.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

thank you for spotting and fixing this!
I double-checked devm_clk_register: we don't need IS_ERR_OR_NULL
because devm_clk_register never returns NULL

> ---
> I really hope it doesn't become a trend on to wrap all error checks in a
> WARN_ON() macro...
>
> diff --git a/drivers/mmc/host/meson-mx-sdio.c b/drivers/mmc/host/meson-mx-sdio.c
> index dc30ed5e964b..d0d921e0e589 100644
> --- a/drivers/mmc/host/meson-mx-sdio.c
> +++ b/drivers/mmc/host/meson-mx-sdio.c
> @@ -602,7 +602,7 @@ static int meson_mx_mmc_register_clks(struct meson_mx_mmc_host *host)
>
>         host->fixed_factor_clk = devm_clk_register(host->controller_dev,
>                                                  &host->fixed_factor.hw);
> -       if (WARN_ON(PTR_ERR_OR_ZERO(host->fixed_factor_clk)))
> +       if (WARN_ON(IS_ERR(host->fixed_factor_clk)))
>                 return PTR_ERR(host->fixed_factor_clk);
>
>         clk_div_parent = __clk_get_name(host->fixed_factor_clk);
> @@ -620,7 +620,7 @@ static int meson_mx_mmc_register_clks(struct meson_mx_mmc_host *host)
>
>         host->cfg_div_clk = devm_clk_register(host->controller_dev,
>                                               &host->cfg_div.hw);
> -       if (WARN_ON(PTR_ERR_OR_ZERO(host->cfg_div_clk)))
> +       if (WARN_ON(IS_ERR(host->cfg_div_clk)))
>                 return PTR_ERR(host->cfg_div_clk);
>
>         return 0;
>
> _______________________________________________
> linux-amlogic mailing list
> linux-amlogic@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-amlogic
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ulf Hansson Oct. 20, 2017, 10:02 a.m. UTC | #2
On 13 October 2017 at 13:20, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Using PTR_ERR_OR_ZERO() instead of IS_ERR() works, but it's not how
> you're supposed to write these conditions.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, applied for next!

Kind regards
Uffe

> ---
> I really hope it doesn't become a trend on to wrap all error checks in a
> WARN_ON() macro...
>
> diff --git a/drivers/mmc/host/meson-mx-sdio.c b/drivers/mmc/host/meson-mx-sdio.c
> index dc30ed5e964b..d0d921e0e589 100644
> --- a/drivers/mmc/host/meson-mx-sdio.c
> +++ b/drivers/mmc/host/meson-mx-sdio.c
> @@ -602,7 +602,7 @@ static int meson_mx_mmc_register_clks(struct meson_mx_mmc_host *host)
>
>         host->fixed_factor_clk = devm_clk_register(host->controller_dev,
>                                                  &host->fixed_factor.hw);
> -       if (WARN_ON(PTR_ERR_OR_ZERO(host->fixed_factor_clk)))
> +       if (WARN_ON(IS_ERR(host->fixed_factor_clk)))
>                 return PTR_ERR(host->fixed_factor_clk);
>
>         clk_div_parent = __clk_get_name(host->fixed_factor_clk);
> @@ -620,7 +620,7 @@ static int meson_mx_mmc_register_clks(struct meson_mx_mmc_host *host)
>
>         host->cfg_div_clk = devm_clk_register(host->controller_dev,
>                                               &host->cfg_div.hw);
> -       if (WARN_ON(PTR_ERR_OR_ZERO(host->cfg_div_clk)))
> +       if (WARN_ON(IS_ERR(host->cfg_div_clk)))
>                 return PTR_ERR(host->cfg_div_clk);
>
>         return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/host/meson-mx-sdio.c b/drivers/mmc/host/meson-mx-sdio.c
index dc30ed5e964b..d0d921e0e589 100644
--- a/drivers/mmc/host/meson-mx-sdio.c
+++ b/drivers/mmc/host/meson-mx-sdio.c
@@ -602,7 +602,7 @@  static int meson_mx_mmc_register_clks(struct meson_mx_mmc_host *host)
 
 	host->fixed_factor_clk = devm_clk_register(host->controller_dev,
 						 &host->fixed_factor.hw);
-	if (WARN_ON(PTR_ERR_OR_ZERO(host->fixed_factor_clk)))
+	if (WARN_ON(IS_ERR(host->fixed_factor_clk)))
 		return PTR_ERR(host->fixed_factor_clk);
 
 	clk_div_parent = __clk_get_name(host->fixed_factor_clk);
@@ -620,7 +620,7 @@  static int meson_mx_mmc_register_clks(struct meson_mx_mmc_host *host)
 
 	host->cfg_div_clk = devm_clk_register(host->controller_dev,
 					      &host->cfg_div.hw);
-	if (WARN_ON(PTR_ERR_OR_ZERO(host->cfg_div_clk)))
+	if (WARN_ON(IS_ERR(host->cfg_div_clk)))
 		return PTR_ERR(host->cfg_div_clk);
 
 	return 0;