[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZvPscRdWlFPmtCyR@smile.fi.intel.com>
Date: Wed, 25 Sep 2024 13:56:49 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Chen-Yu Tsai <wenst@...omium.org>
Cc: Ulf Hansson <ulf.hansson@...aro.org>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
Mark Brown <broonie@...nel.org>, devicetree@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-pm@...r.kernel.org, Douglas Anderson <dianders@...omium.org>,
Johan Hovold <johan@...nel.org>, Pablo Sun <pablo.sun@...iatek.com>,
Macpaul Lin <macpaul.lin@...iatek.com>,
Sebastian Reichel <sebastian.reichel@...labora.com>
Subject: Re: [PATCH v8 2/3] regulator: Add devres version of
of_regulator_get_optional()
On Wed, Sep 25, 2024 at 05:38:05PM +0800, Chen-Yu Tsai wrote:
> There are existing uses for a devres version of of_regulator_get_optional()
> in power domain drivers. On MediaTek platforms, power domains may have
> regulator supplies tied to them. The driver currently tries to use
> devm_regulator_get() to not have to manage the lifecycle, but ends up
> doing it in a very hacky way by replacing the device node of the power
> domain controller device to the device node of the power domain that is
> currently being registered, getting the supply, and reverting the device
> node.
>
> Provide a better API so that the hack can be replaced.
...
> +#if IS_ENABLED(CONFIG_OF)
Do we really need this?
> +static struct regulator *_devm_of_regulator_get(struct device *dev, struct device_node *node,
> + const char *id, int get_type)
> +{
> + struct regulator **ptr, *regulator;
> +
> + ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL);
> + if (!ptr)
> + return ERR_PTR(-ENOMEM);
> +
> + regulator = _of_regulator_get(dev, node, id, get_type);
> + if (!IS_ERR(regulator)) {
> + *ptr = regulator;
> + devres_add(dev, ptr);
> + } else {
> + devres_free(ptr);
> + }
> +
> + return regulator;
Why not using devm_add_action() / devm_add_action_or_reset()
(whichever suits better here)?
> +}
> +#endif
...
> +static inline struct regulator *__must_check devm_of_regulator_get_optional(struct device *dev,
> + struct device_node *node,
> + const char *id)
I don't know the conventions here, but I find better to have it as
static inline __must_check struct regulator *
devm_of_regulator_get_optional(struct device *dev, struct device_node *node, const char *id)
Similar to other stubs and declarations.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists