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: <CAHp75VcUY5_gB=VVWF2pAa4iEo_9Lt5itNH5RAy6NjnTk5PZWA@mail.gmail.com>
Date: Fri, 26 Jan 2024 23:38:53 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Thomas Richard <thomas.richard@...tlin.com>
Cc: Linus Walleij <linus.walleij@...aro.org>, Bartosz Golaszewski <brgl@...ev.pl>, 
	Andy Shevchenko <andy@...nel.org>, Tony Lindgren <tony@...mide.com>, 
	Haojian Zhuang <haojian.zhuang@...aro.org>, Vignesh R <vigneshr@...com>, 
	Aaro Koskinen <aaro.koskinen@....fi>, Janusz Krzysztofik <jmkrzyszt@...il.com>, 
	Andi Shyti <andi.shyti@...nel.org>, Peter Rosin <peda@...ntia.se>, Vinod Koul <vkoul@...nel.org>, 
	Kishon Vijay Abraham I <kishon@...nel.org>, Philipp Zabel <p.zabel@...gutronix.de>, 
	Tom Joseph <tjoseph@...ence.com>, Lorenzo Pieralisi <lpieralisi@...nel.org>, 
	Krzysztof Wilczyński <kw@...ux.com>, 
	Rob Herring <robh@...nel.org>, Bjorn Helgaas <bhelgaas@...gle.com>, linux-gpio@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org, 
	linux-omap@...r.kernel.org, linux-i2c@...r.kernel.org, 
	linux-phy@...ts.infradead.org, linux-pci@...r.kernel.org, 
	gregory.clement@...tlin.com, theo.lebrun@...tlin.com, 
	thomas.petazzoni@...tlin.com, u-kumar1@...com
Subject: Re: [PATCH v2 06/15] phy: ti: phy-j721e-wiz: make wiz_clock_init
 callable multiple times

On Fri, Jan 26, 2024 at 4:37 PM Thomas Richard
<thomas.richard@...tlin.com> wrote:
>
> For suspend and resume support, wiz_clock_init needs to be called multiple

wiz_clock_init()

> times.
>
> Add a parameter to wiz_clock_init to be able to skip clocks registration.

Ditto.

..to skip the registration of the clocks.

..

> -static int wiz_clock_init(struct wiz *wiz, struct device_node *node)
> +static int wiz_clock_init(struct wiz *wiz, struct device_node *node, bool probe)

So, why not refactor this to two functions first?

..

> +               clk = devm_clk_get(dev, "core_ref_clk");
> +               if (IS_ERR(clk)) {

> +                       dev_err(dev, "core_ref_clk clock not found\n");
> +                       ret = PTR_ERR(clk);
> +                       return ret;

This is wrong and has to be fixed in the original code.
The correct approach is to use `return dev_err_probe(...)` or open
code it, but since we have a helper, open coding is highly
discouraged.

> +               }

..

> +               if (wiz->data->pma_cmn_refclk1_int_mode) {
> +                       clk = devm_clk_get(dev, "core_ref1_clk");
> +                       if (IS_ERR(clk)) {
> +                               dev_err(dev, "core_ref1_clk clock not found\n");
> +                               ret = PTR_ERR(clk);
> +                               return ret;

Ditto.

> +                       }

..

> +               clk = devm_clk_get(dev, "ext_ref_clk");
> +               if (IS_ERR(clk)) {
> +                       dev_err(dev, "ext_ref_clk clock not found\n");
> +                       ret = PTR_ERR(clk);
> +                       return ret;

Ditto.

> +               }

..

> +       /* What follows is about registering clocks. */
> +       if (!probe)
> +               return 0;

Just refactor properly, no need to have this ugly mix of devm_*() for
probe stage, parameter and HW related things.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ