From: Frank Li <Frank.li@nxp.com>
To: Shengjiu Wang <shengjiu.wang@nxp.com>
Cc: abelvesa@kernel.org, peng.fan@nxp.com, mturquette@baylibre.com,
sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de,
kernel@pengutronix.de, festevam@gmail.com, marex@denx.de,
linux-clk@vger.kernel.org, imx@lists.linux.dev,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, p.zabel@pengutronix.de,
shengjiu.wang@gmail.com
Subject: Re: [PATCH v4 2/5] clk: imx: clk-audiomix: Add reset controller
Date: Mon, 20 May 2024 11:44:28 -0400 [thread overview]
Message-ID: <Zktv3OcDbV1cggP1@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <1716188963-16175-3-git-send-email-shengjiu.wang@nxp.com>
On Mon, May 20, 2024 at 03:09:20PM +0800, Shengjiu Wang wrote:
> Audiomix block control can be a reset controller for
> Enhanced Audio Return Channel (EARC), which is one of
> modules in this audiomix subsystem.
>
> The reset controller is supported by the auxiliary device
> framework.
>
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---
> drivers/clk/imx/Kconfig | 1 +
> drivers/clk/imx/clk-imx8mp-audiomix.c | 61 +++++++++++++++++++++++++++
> 2 files changed, 62 insertions(+)
>
> diff --git a/drivers/clk/imx/Kconfig b/drivers/clk/imx/Kconfig
> index 6da0fba68225..9edfb030bea9 100644
> --- a/drivers/clk/imx/Kconfig
> +++ b/drivers/clk/imx/Kconfig
> @@ -81,6 +81,7 @@ config CLK_IMX8MP
> tristate "IMX8MP CCM Clock Driver"
> depends on ARCH_MXC || COMPILE_TEST
> select MXC_CLK
> + select AUXILIARY_BUS
> help
> Build the driver for i.MX8MP CCM Clock Driver
>
> diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
> index b381d6f784c8..d2eaabe431cd 100644
> --- a/drivers/clk/imx/clk-imx8mp-audiomix.c
> +++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
> @@ -5,6 +5,7 @@
> * Copyright (C) 2022 Marek Vasut <marex@denx.de>
> */
>
> +#include <linux/auxiliary_bus.h>
> #include <linux/clk-provider.h>
> #include <linux/device.h>
> #include <linux/io.h>
> @@ -217,6 +218,62 @@ struct clk_imx8mp_audiomix_priv {
> struct clk_hw_onecell_data clk_data;
> };
>
> +#if IS_ENABLED(CONFIG_RESET_CONTROLLER)
> +
> +static void clk_imx8mp_audiomix_reset_unregister_adev(void *_adev)
> +{
> + struct auxiliary_device *adev = _adev;
> +
> + auxiliary_device_delete(adev);
> + auxiliary_device_uninit(adev);
> +}
> +
> +static void clk_imx8mp_audiomix_reset_adev_release(struct device *dev)
> +{
> + struct auxiliary_device *adev = to_auxiliary_dev(dev);
> +
> + kfree(adev);
> +}
> +
> +static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
> + struct clk_imx8mp_audiomix_priv *priv)
> +{
> + struct auxiliary_device *adev;
> + int ret;
> +
> + adev = kzalloc(sizeof(*adev), GFP_KERNEL);
You may use scoped free
struct auxiliary_device *adev __free(kfree) = kzalloc(sizeof(*adev), GFP_KERNEL);
> + if (!adev)
> + return -ENOMEM;
> +
> + adev->name = "reset";
> + adev->dev.parent = dev;
> + adev->dev.release = clk_imx8mp_audiomix_reset_adev_release;
> +
> + ret = auxiliary_device_init(adev);
> + if (ret) {
> + kfree(adev);
> + return ret;
> + }
if use scoped free,
if (ret)
return ret;
> +
> + ret = auxiliary_device_add(adev);
> + if (ret) {
> + auxiliary_device_uninit(adev);
> + kfree(adev);
> + return ret;
the same here.
> + }
> +
> + return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev, adev);
if use scope free
return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev, no_free_ptr(adev));
> +}
> +
> +#else /* !CONFIG_RESET_CONTROLLER */
> +
> +static int clk_imx8mp_audiomix_reset_controller_register(struct clk_imx8mp_audiomix_priv *priv)
> +{
> + return 0;
> +}
> +
> +#endif /* !CONFIG_RESET_CONTROLLER */
> +
> static void clk_imx8mp_audiomix_save_restore(struct device *dev, bool save)
> {
> struct clk_imx8mp_audiomix_priv *priv = dev_get_drvdata(dev);
> @@ -337,6 +394,10 @@ static int clk_imx8mp_audiomix_probe(struct platform_device *pdev)
> if (ret)
> goto err_clk_register;
>
> + ret = clk_imx8mp_audiomix_reset_controller_register(dev, priv);
> + if (ret)
> + goto err_clk_register;
> +
> pm_runtime_put_sync(dev);
> return 0;
>
> --
> 2.34.1
>
next prev parent reply other threads:[~2024-05-20 15:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 7:09 [PATCH v4 0/5] clk: imx: clk-audiomix: Improvement for audiomix Shengjiu Wang
2024-05-20 7:09 ` [PATCH v4 1/5] dt-bindings: clock: imx8mp: Add #reset-cells property Shengjiu Wang
2024-05-20 7:09 ` [PATCH v4 2/5] clk: imx: clk-audiomix: Add reset controller Shengjiu Wang
2024-05-20 10:29 ` kernel test robot
2024-05-20 13:51 ` kernel test robot
2024-05-20 15:44 ` Frank Li [this message]
2024-05-22 2:05 ` Shengjiu Wang
2024-05-20 17:04 ` kernel test robot
2024-05-20 7:09 ` [PATCH v4 3/5] reset: imx-aux: Add i.MX auxiliary reset driver Shengjiu Wang
2024-05-20 7:09 ` [PATCH v4 4/5] clk: imx: clk-audiomix: Add CLK_SET_RATE_PARENT flags for clocks Shengjiu Wang
2024-05-20 7:09 ` [PATCH v4 5/5] clk: imx: clk-audiomix: Corrent parent clock for earc_phy and audpll Shengjiu Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zktv3OcDbV1cggP1@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=abelvesa@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marex@denx.de \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=peng.fan@nxp.com \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=sboyd@kernel.org \
--cc=shawnguo@kernel.org \
--cc=shengjiu.wang@gmail.com \
--cc=shengjiu.wang@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®