* [PATCH] soc: imx8m: Add remove function
@ 2024-12-06 11:28 Peng Fan (OSS)
2024-12-06 11:41 ` Marco Felsch
0 siblings, 1 reply; 5+ messages in thread
From: Peng Fan (OSS) @ 2024-12-06 11:28 UTC (permalink / raw)
To: shawnguo, s.hauer
Cc: kernel, festevam, marex, imx, linux-arm-kernel, linux-kernel,
Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Unregister the cpufreq device and soc device in remove path, otherwise
there will be warning when do removing test:
sysfs: cannot create duplicate filename '/devices/platform/imx-cpufreq-dt'
CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.13.0-rc1-next-20241204
Hardware name: NXP i.MX8MPlus EVK board (DT)
Fixes: 9cc832d37799 ("soc: imx8m: Probe the SoC driver as platform driver")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/soc/imx/soc-imx8m.c | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
index 8ac7658e3d52..8c368947d1e5 100644
--- a/drivers/soc/imx/soc-imx8m.c
+++ b/drivers/soc/imx/soc-imx8m.c
@@ -33,6 +33,11 @@ struct imx8_soc_data {
int (*soc_revision)(u32 *socrev, u64 *socuid);
};
+struct imx8m_soc_priv {
+ struct soc_device *soc_dev;
+ struct platform_device *cpufreq_dev;
+};
+
#ifdef CONFIG_HAVE_ARM_SMCCC
static u32 imx8mq_soc_revision_from_atf(void)
{
@@ -198,7 +203,7 @@ static int imx8m_soc_probe(struct platform_device *pdev)
const struct imx8_soc_data *data;
struct device *dev = &pdev->dev;
const struct of_device_id *id;
- struct soc_device *soc_dev;
+ struct imx8m_soc_priv *priv;
u32 soc_rev = 0;
u64 soc_uid = 0;
int ret;
@@ -207,6 +212,10 @@ static int imx8m_soc_probe(struct platform_device *pdev)
if (!soc_dev_attr)
return -ENOMEM;
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
soc_dev_attr->family = "Freescale i.MX";
ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
@@ -235,21 +244,34 @@ static int imx8m_soc_probe(struct platform_device *pdev)
if (!soc_dev_attr->serial_number)
return -ENOMEM;
- soc_dev = soc_device_register(soc_dev_attr);
- if (IS_ERR(soc_dev))
- return PTR_ERR(soc_dev);
+ priv->soc_dev = soc_device_register(soc_dev_attr);
+ if (IS_ERR(priv->soc_dev))
+ return PTR_ERR(priv->soc_dev);
pr_info("SoC: %s revision %s\n", soc_dev_attr->soc_id,
soc_dev_attr->revision);
if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT))
- platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
+ priv->cpufreq_dev = platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
+
+ platform_set_drvdata(pdev, priv);
return 0;
}
+static void imx8m_soc_remove(struct platform_device *pdev)
+{
+ struct imx8m_soc_priv *priv = platform_get_drvdata(pdev);
+
+ if (!IS_ERR(priv->cpufreq_dev))
+ platform_device_unregister(priv->cpufreq_dev);
+
+ soc_device_unregister(priv->soc_dev);
+}
+
static struct platform_driver imx8m_soc_driver = {
.probe = imx8m_soc_probe,
+ .remove = imx8m_soc_remove,
.driver = {
.name = "imx8m-soc",
},
--
2.37.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] soc: imx8m: Add remove function
2024-12-06 11:28 [PATCH] soc: imx8m: Add remove function Peng Fan (OSS)
@ 2024-12-06 11:41 ` Marco Felsch
2024-12-09 8:26 ` Peng Fan
0 siblings, 1 reply; 5+ messages in thread
From: Marco Felsch @ 2024-12-06 11:41 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: shawnguo, s.hauer, marex, imx, Peng Fan, linux-kernel, kernel,
festevam, linux-arm-kernel
On 24-12-06, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Unregister the cpufreq device and soc device in remove path, otherwise
> there will be warning when do removing test:
> sysfs: cannot create duplicate filename '/devices/platform/imx-cpufreq-dt'
> CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.13.0-rc1-next-20241204
> Hardware name: NXP i.MX8MPlus EVK board (DT)
>
> Fixes: 9cc832d37799 ("soc: imx8m: Probe the SoC driver as platform driver")
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/soc/imx/soc-imx8m.c | 32 +++++++++++++++++++++++++++-----
> 1 file changed, 27 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
> index 8ac7658e3d52..8c368947d1e5 100644
> --- a/drivers/soc/imx/soc-imx8m.c
> +++ b/drivers/soc/imx/soc-imx8m.c
> @@ -33,6 +33,11 @@ struct imx8_soc_data {
> int (*soc_revision)(u32 *socrev, u64 *socuid);
> };
>
> +struct imx8m_soc_priv {
> + struct soc_device *soc_dev;
> + struct platform_device *cpufreq_dev;
> +};
> +
> #ifdef CONFIG_HAVE_ARM_SMCCC
> static u32 imx8mq_soc_revision_from_atf(void)
> {
> @@ -198,7 +203,7 @@ static int imx8m_soc_probe(struct platform_device *pdev)
> const struct imx8_soc_data *data;
> struct device *dev = &pdev->dev;
> const struct of_device_id *id;
> - struct soc_device *soc_dev;
> + struct imx8m_soc_priv *priv;
> u32 soc_rev = 0;
> u64 soc_uid = 0;
> int ret;
> @@ -207,6 +212,10 @@ static int imx8m_soc_probe(struct platform_device *pdev)
> if (!soc_dev_attr)
> return -ENOMEM;
>
> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> soc_dev_attr->family = "Freescale i.MX";
>
> ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
> @@ -235,21 +244,34 @@ static int imx8m_soc_probe(struct platform_device *pdev)
> if (!soc_dev_attr->serial_number)
> return -ENOMEM;
>
> - soc_dev = soc_device_register(soc_dev_attr);
> - if (IS_ERR(soc_dev))
> - return PTR_ERR(soc_dev);
> + priv->soc_dev = soc_device_register(soc_dev_attr);
> + if (IS_ERR(priv->soc_dev))
> + return PTR_ERR(priv->soc_dev);
>
> pr_info("SoC: %s revision %s\n", soc_dev_attr->soc_id,
> soc_dev_attr->revision);
>
> if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT))
> - platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
> + priv->cpufreq_dev = platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
If CONFIG_ARM_IMX_CPUFREQ_DT is enabled, I asusme that
platform_device_register_simple() shouldn't fail else it will be an
error, right? Therefore I would like to add the 'if(!IS_ERR())' check
here instead of the remove function.
> +
> + platform_set_drvdata(pdev, priv);
>
> return 0;
> }
>
> +static void imx8m_soc_remove(struct platform_device *pdev)
> +{
> + struct imx8m_soc_priv *priv = platform_get_drvdata(pdev);
> +
> + if (!IS_ERR(priv->cpufreq_dev))
With the above shifted, we only need to:
if (priv->cpufreq_dev)
Regards,
Marco
> + platform_device_unregister(priv->cpufreq_dev);
> +
> + soc_device_unregister(priv->soc_dev);
> +}
> +
> static struct platform_driver imx8m_soc_driver = {
> .probe = imx8m_soc_probe,
> + .remove = imx8m_soc_remove,
> .driver = {
> .name = "imx8m-soc",
> },
> --
> 2.37.1
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: [PATCH] soc: imx8m: Add remove function
2024-12-06 11:41 ` Marco Felsch
@ 2024-12-09 8:26 ` Peng Fan
2024-12-30 5:00 ` Shawn Guo
0 siblings, 1 reply; 5+ messages in thread
From: Peng Fan @ 2024-12-09 8:26 UTC (permalink / raw)
To: Marco Felsch, Peng Fan (OSS)
Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, marex@denx.de,
imx@lists.linux.dev, linux-kernel@vger.kernel.org,
kernel@pengutronix.de, festevam@gmail.com,
linux-arm-kernel@lists.infradead.org
> Subject: Re: [PATCH] soc: imx8m: Add remove function
>
> On 24-12-06, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > Unregister the cpufreq device and soc device in remove path,
> otherwise
> > there will be warning when do removing test:
> > sysfs: cannot create duplicate filename '/devices/platform/imx-
> cpufreq-dt'
> > CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted
> > 6.13.0-rc1-next-20241204 Hardware name: NXP i.MX8MPlus EVK
> board (DT)
> >
> > Fixes: 9cc832d37799 ("soc: imx8m: Probe the SoC driver as platform
> > driver")
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> > drivers/soc/imx/soc-imx8m.c | 32 +++++++++++++++++++++++++++----
> -
> > 1 file changed, 27 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-
> imx8m.c
> > index 8ac7658e3d52..8c368947d1e5 100644
> > --- a/drivers/soc/imx/soc-imx8m.c
> > +++ b/drivers/soc/imx/soc-imx8m.c
> > @@ -33,6 +33,11 @@ struct imx8_soc_data {
> > int (*soc_revision)(u32 *socrev, u64 *socuid); };
> >
> > +struct imx8m_soc_priv {
> > + struct soc_device *soc_dev;
> > + struct platform_device *cpufreq_dev; };
> > +
> > #ifdef CONFIG_HAVE_ARM_SMCCC
> > static u32 imx8mq_soc_revision_from_atf(void)
> > {
> > @@ -198,7 +203,7 @@ static int imx8m_soc_probe(struct
> platform_device *pdev)
> > const struct imx8_soc_data *data;
> > struct device *dev = &pdev->dev;
> > const struct of_device_id *id;
> > - struct soc_device *soc_dev;
> > + struct imx8m_soc_priv *priv;
> > u32 soc_rev = 0;
> > u64 soc_uid = 0;
> > int ret;
> > @@ -207,6 +212,10 @@ static int imx8m_soc_probe(struct
> platform_device *pdev)
> > if (!soc_dev_attr)
> > return -ENOMEM;
> >
> > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> > + if (!priv)
> > + return -ENOMEM;
> > +
> > soc_dev_attr->family = "Freescale i.MX";
> >
> > ret = of_property_read_string(of_root, "model",
> > &soc_dev_attr->machine); @@ -235,21 +244,34 @@ static int
> imx8m_soc_probe(struct platform_device *pdev)
> > if (!soc_dev_attr->serial_number)
> > return -ENOMEM;
> >
> > - soc_dev = soc_device_register(soc_dev_attr);
> > - if (IS_ERR(soc_dev))
> > - return PTR_ERR(soc_dev);
> > + priv->soc_dev = soc_device_register(soc_dev_attr);
> > + if (IS_ERR(priv->soc_dev))
> > + return PTR_ERR(priv->soc_dev);
> >
> > pr_info("SoC: %s revision %s\n", soc_dev_attr->soc_id,
> > soc_dev_attr->revision);
> >
> > if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT))
> > - platform_device_register_simple("imx-cpufreq-dt", -1,
> NULL, 0);
> > + priv->cpufreq_dev =
> > +platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
>
> If CONFIG_ARM_IMX_CPUFREQ_DT is enabled, I asusme that
> platform_device_register_simple() shouldn't fail else it will be an error,
> right? Therefore I would like to add the 'if(!IS_ERR())' check here
> instead of the remove function.
You mean below?
dev = platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
if (!IS_ERR(dev))
plat->cpufreq_dev = dev;
else
pr_err("Failed to register imx-cpufreq-dt: %d\n", ERR_PTR(dev))?
But using !IS_ERR(plat->cpufreq_dev) in remove path looks
simpler.
Thanks,
Peng
>
> > +
> > + platform_set_drvdata(pdev, priv);
> >
> > return 0;
> > }
> >
> > +static void imx8m_soc_remove(struct platform_device *pdev) {
> > + struct imx8m_soc_priv *priv = platform_get_drvdata(pdev);
> > +
> > + if (!IS_ERR(priv->cpufreq_dev))
>
> With the above shifted, we only need to:
> if (priv->cpufreq_dev)
>
> Regards,
> Marco
>
>
> > + platform_device_unregister(priv->cpufreq_dev);
> > +
> > + soc_device_unregister(priv->soc_dev);
> > +}
> > +
> > static struct platform_driver imx8m_soc_driver = {
> > .probe = imx8m_soc_probe,
> > + .remove = imx8m_soc_remove,
> > .driver = {
> > .name = "imx8m-soc",
> > },
> > --
> > 2.37.1
> >
> >
> >
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] soc: imx8m: Add remove function
2024-12-09 8:26 ` Peng Fan
@ 2024-12-30 5:00 ` Shawn Guo
2024-12-30 6:29 ` Peng Fan
0 siblings, 1 reply; 5+ messages in thread
From: Shawn Guo @ 2024-12-30 5:00 UTC (permalink / raw)
To: Peng Fan
Cc: Marco Felsch, Peng Fan (OSS), shawnguo@kernel.org,
s.hauer@pengutronix.de, marex@denx.de, imx@lists.linux.dev,
linux-kernel@vger.kernel.org, kernel@pengutronix.de,
festevam@gmail.com, linux-arm-kernel@lists.infradead.org
On Mon, Dec 09, 2024 at 08:26:48AM +0000, Peng Fan wrote:
> > Subject: Re: [PATCH] soc: imx8m: Add remove function
> >
> > On 24-12-06, Peng Fan (OSS) wrote:
> > > From: Peng Fan <peng.fan@nxp.com>
> > >
> > > Unregister the cpufreq device and soc device in remove path,
> > otherwise
> > > there will be warning when do removing test:
> > > sysfs: cannot create duplicate filename '/devices/platform/imx-
> > cpufreq-dt'
> > > CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted
> > > 6.13.0-rc1-next-20241204 Hardware name: NXP i.MX8MPlus EVK
> > board (DT)
> > >
> > > Fixes: 9cc832d37799 ("soc: imx8m: Probe the SoC driver as platform
> > > driver")
> > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > > ---
> > > drivers/soc/imx/soc-imx8m.c | 32 +++++++++++++++++++++++++++----
> > -
> > > 1 file changed, 27 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-
> > imx8m.c
> > > index 8ac7658e3d52..8c368947d1e5 100644
> > > --- a/drivers/soc/imx/soc-imx8m.c
> > > +++ b/drivers/soc/imx/soc-imx8m.c
> > > @@ -33,6 +33,11 @@ struct imx8_soc_data {
> > > int (*soc_revision)(u32 *socrev, u64 *socuid); };
> > >
> > > +struct imx8m_soc_priv {
> > > + struct soc_device *soc_dev;
> > > + struct platform_device *cpufreq_dev; };
> > > +
> > > #ifdef CONFIG_HAVE_ARM_SMCCC
> > > static u32 imx8mq_soc_revision_from_atf(void)
> > > {
> > > @@ -198,7 +203,7 @@ static int imx8m_soc_probe(struct
> > platform_device *pdev)
> > > const struct imx8_soc_data *data;
> > > struct device *dev = &pdev->dev;
> > > const struct of_device_id *id;
> > > - struct soc_device *soc_dev;
> > > + struct imx8m_soc_priv *priv;
> > > u32 soc_rev = 0;
> > > u64 soc_uid = 0;
> > > int ret;
> > > @@ -207,6 +212,10 @@ static int imx8m_soc_probe(struct
> > platform_device *pdev)
> > > if (!soc_dev_attr)
> > > return -ENOMEM;
> > >
> > > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> > > + if (!priv)
> > > + return -ENOMEM;
> > > +
> > > soc_dev_attr->family = "Freescale i.MX";
> > >
> > > ret = of_property_read_string(of_root, "model",
> > > &soc_dev_attr->machine); @@ -235,21 +244,34 @@ static int
> > imx8m_soc_probe(struct platform_device *pdev)
> > > if (!soc_dev_attr->serial_number)
> > > return -ENOMEM;
> > >
> > > - soc_dev = soc_device_register(soc_dev_attr);
> > > - if (IS_ERR(soc_dev))
> > > - return PTR_ERR(soc_dev);
> > > + priv->soc_dev = soc_device_register(soc_dev_attr);
> > > + if (IS_ERR(priv->soc_dev))
> > > + return PTR_ERR(priv->soc_dev);
> > >
> > > pr_info("SoC: %s revision %s\n", soc_dev_attr->soc_id,
> > > soc_dev_attr->revision);
> > >
> > > if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT))
> > > - platform_device_register_simple("imx-cpufreq-dt", -1,
> > NULL, 0);
> > > + priv->cpufreq_dev =
> > > +platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
> >
> > If CONFIG_ARM_IMX_CPUFREQ_DT is enabled, I asusme that
> > platform_device_register_simple() shouldn't fail else it will be an error,
> > right? Therefore I would like to add the 'if(!IS_ERR())' check here
> > instead of the remove function.
>
> You mean below?
> dev = platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
> if (!IS_ERR(dev))
> plat->cpufreq_dev = dev;
> else
> pr_err("Failed to register imx-cpufreq-dt: %d\n", ERR_PTR(dev))?
Hmm, I'm not sure why we do not have error check on
platform_device_register_simple(). Shouldn't we do the following?
priv->cpufreq_dev = platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
if (IS_ERR(priv->cpufreq_dev))
return PTR_ERR(priv->cpufreq_dev);
Then I'm with Marco that we only need to check 'if (priv->cpufreq_dev)' in
remove function.
Shawn
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: [PATCH] soc: imx8m: Add remove function
2024-12-30 5:00 ` Shawn Guo
@ 2024-12-30 6:29 ` Peng Fan
0 siblings, 0 replies; 5+ messages in thread
From: Peng Fan @ 2024-12-30 6:29 UTC (permalink / raw)
To: Shawn Guo
Cc: Marco Felsch, Peng Fan (OSS), shawnguo@kernel.org,
s.hauer@pengutronix.de, marex@denx.de, imx@lists.linux.dev,
linux-kernel@vger.kernel.org, kernel@pengutronix.de,
festevam@gmail.com, linux-arm-kernel@lists.infradead.org
Hi Shawn,
> Subject: Re: [PATCH] soc: imx8m: Add remove function
>
> On Mon, Dec 09, 2024 at 08:26:48AM +0000, Peng Fan wrote:
> > > Subject: Re: [PATCH] soc: imx8m: Add remove function
> > >
> > > On 24-12-06, Peng Fan (OSS) wrote:
> > > > From: Peng Fan <peng.fan@nxp.com>
> > > >
> > > > Unregister the cpufreq device and soc device in remove path,
> > > otherwise
> > > > there will be warning when do removing test:
> > > > sysfs: cannot create duplicate filename '/devices/platform/imx-
> > > cpufreq-dt'
> > > > CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted
> > > > 6.13.0-rc1-next-20241204 Hardware name: NXP i.MX8MPlus EVK
> > > board (DT)
> > > >
> > > > Fixes: 9cc832d37799 ("soc: imx8m: Probe the SoC driver as
> platform
> > > > driver")
> > > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > > > ---
> > > > drivers/soc/imx/soc-imx8m.c | 32
> +++++++++++++++++++++++++++----
> > > -
> > > > 1 file changed, 27 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-
> > > imx8m.c
> > > > index 8ac7658e3d52..8c368947d1e5 100644
> > > > --- a/drivers/soc/imx/soc-imx8m.c
> > > > +++ b/drivers/soc/imx/soc-imx8m.c
> > > > @@ -33,6 +33,11 @@ struct imx8_soc_data {
> > > > int (*soc_revision)(u32 *socrev, u64 *socuid); };
> > > >
> > > > +struct imx8m_soc_priv {
> > > > + struct soc_device *soc_dev;
> > > > + struct platform_device *cpufreq_dev; };
> > > > +
> > > > #ifdef CONFIG_HAVE_ARM_SMCCC
> > > > static u32 imx8mq_soc_revision_from_atf(void)
> > > > {
> > > > @@ -198,7 +203,7 @@ static int imx8m_soc_probe(struct
> > > platform_device *pdev)
> > > > const struct imx8_soc_data *data;
> > > > struct device *dev = &pdev->dev;
> > > > const struct of_device_id *id;
> > > > - struct soc_device *soc_dev;
> > > > + struct imx8m_soc_priv *priv;
> > > > u32 soc_rev = 0;
> > > > u64 soc_uid = 0;
> > > > int ret;
> > > > @@ -207,6 +212,10 @@ static int imx8m_soc_probe(struct
> > > platform_device *pdev)
> > > > if (!soc_dev_attr)
> > > > return -ENOMEM;
> > > >
> > > > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> > > > + if (!priv)
> > > > + return -ENOMEM;
> > > > +
> > > > soc_dev_attr->family = "Freescale i.MX";
> > > >
> > > > ret = of_property_read_string(of_root, "model",
> > > > &soc_dev_attr->machine); @@ -235,21 +244,34 @@ static int
> > > imx8m_soc_probe(struct platform_device *pdev)
> > > > if (!soc_dev_attr->serial_number)
> > > > return -ENOMEM;
> > > >
> > > > - soc_dev = soc_device_register(soc_dev_attr);
> > > > - if (IS_ERR(soc_dev))
> > > > - return PTR_ERR(soc_dev);
> > > > + priv->soc_dev = soc_device_register(soc_dev_attr);
> > > > + if (IS_ERR(priv->soc_dev))
> > > > + return PTR_ERR(priv->soc_dev);
> > > >
> > > > pr_info("SoC: %s revision %s\n", soc_dev_attr->soc_id,
> > > > soc_dev_attr->revision);
> > > >
> > > > if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT))
> > > > - platform_device_register_simple("imx-cpufreq-dt", -1,
> > > NULL, 0);
> > > > + priv->cpufreq_dev =
> > > > +platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
> > >
> > > If CONFIG_ARM_IMX_CPUFREQ_DT is enabled, I asusme that
> > > platform_device_register_simple() shouldn't fail else it will be an
> > > error, right? Therefore I would like to add the 'if(!IS_ERR())'
> > > check here instead of the remove function.
> >
> > You mean below?
> > dev = platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
> > if (!IS_ERR(dev))
> > plat->cpufreq_dev = dev;
> > else
> > pr_err("Failed to register imx-cpufreq-dt: %d\n", ERR_PTR(dev))?
>
> Hmm, I'm not sure why we do not have error check on
> platform_device_register_simple(). Shouldn't we do the following?
>
> priv->cpufreq_dev = platform_device_register_simple("imx-
> cpufreq-dt", -1, NULL, 0);
> if (IS_ERR(priv->cpufreq_dev))
> return PTR_ERR(priv->cpufreq_dev);
>
> Then I'm with Marco that we only need to check 'if (priv-
> >cpufreq_dev)' in remove function.
Please give a look on v3:
https://lore.kernel.org/all/20241219145029.1776006-1-peng.fan@oss.nxp.com/
Thanks,
Peng.
>
> Shawn
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-30 6:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-06 11:28 [PATCH] soc: imx8m: Add remove function Peng Fan (OSS)
2024-12-06 11:41 ` Marco Felsch
2024-12-09 8:26 ` Peng Fan
2024-12-30 5:00 ` Shawn Guo
2024-12-30 6:29 ` Peng Fan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox