lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHLCerNQSrNdmPbgLLiTN9_kE-x4xTnBWVnC0-ewQfferG+6Bg@mail.gmail.com>
Date:   Wed, 11 Mar 2020 14:29:32 +0530
From:   Amit Kucheria <amit.kucheria@...durent.com>
To:     Anson Huang <Anson.Huang@....com>
Cc:     Zhang Rui <rui.zhang@...el.com>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        Linux PM list <linux-pm@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>, Linux-imx@....com
Subject: Re: [PATCH 1/2] thermal: qoriq: Use devm_add_action_or_reset() to
 handle all cleanups

On Wed, Mar 11, 2020 at 10:44 AM Anson Huang <Anson.Huang@....com> wrote:
>
> Use devm_add_action_or_reset() to handle all cleanups of failure in
> .probe and .remove, then .remove callback can be dropped.


Reviewed-by: Amit Kucheria <amit.kucheria@...aro.org>

> Signed-off-by: Anson Huang <Anson.Huang@....com>
> ---
>  drivers/thermal/qoriq_thermal.c | 35 ++++++++++++++---------------------
>  1 file changed, 14 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c
> index 874bc46..67a8d84 100644
> --- a/drivers/thermal/qoriq_thermal.c
> +++ b/drivers/thermal/qoriq_thermal.c
> @@ -228,6 +228,14 @@ static const struct regmap_access_table qoriq_rd_table = {
>         .n_yes_ranges   = ARRAY_SIZE(qoriq_yes_ranges),
>  };
>
> +static void qoriq_tmu_action(void *p)
> +{
> +       struct qoriq_tmu_data *data = p;
> +
> +       regmap_write(data->regmap, REGS_TMR, TMR_DISABLE);
> +       clk_disable_unprepare(data->clk);
> +}
> +
>  static int qoriq_tmu_probe(struct platform_device *pdev)
>  {
>         int ret;
> @@ -278,6 +286,10 @@ static int qoriq_tmu_probe(struct platform_device *pdev)
>                 return ret;
>         }
>
> +       ret = devm_add_action_or_reset(dev, qoriq_tmu_action, data);
> +       if (ret)
> +               return ret;
> +
>         /* version register offset at: 0xbf8 on both v1 and v2 */
>         ret = regmap_read(data->regmap, REGS_IPBRR(0), &ver);
>         if (ret) {
> @@ -290,35 +302,17 @@ static int qoriq_tmu_probe(struct platform_device *pdev)
>
>         ret = qoriq_tmu_calibration(dev, data); /* TMU calibration */
>         if (ret < 0)
> -               goto err;
> +               return ret;
>
>         ret = qoriq_tmu_register_tmu_zone(dev, data);
>         if (ret < 0) {
>                 dev_err(dev, "Failed to register sensors\n");
> -               ret = -ENODEV;
> -               goto err;
> +               return ret;
>         }
>
>         platform_set_drvdata(pdev, data);
>
>         return 0;
> -
> -err:
> -       clk_disable_unprepare(data->clk);
> -
> -       return ret;
> -}
> -
> -static int qoriq_tmu_remove(struct platform_device *pdev)
> -{
> -       struct qoriq_tmu_data *data = platform_get_drvdata(pdev);
> -
> -       /* Disable monitoring */
> -       regmap_write(data->regmap, REGS_TMR, TMR_DISABLE);
> -
> -       clk_disable_unprepare(data->clk);
> -
> -       return 0;
>  }
>
>  static int __maybe_unused qoriq_tmu_suspend(struct device *dev)
> @@ -365,7 +359,6 @@ static struct platform_driver qoriq_tmu = {
>                 .of_match_table = qoriq_tmu_match,
>         },
>         .probe  = qoriq_tmu_probe,
> -       .remove = qoriq_tmu_remove,
>  };
>  module_platform_driver(qoriq_tmu);
>
> --
> 2.7.4
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ