Skip to content

Commit cf7139a

Browse files
MrVanShawn Guo
authored andcommitted
soc: imx8m: Unregister cpufreq and soc dev in cleanup path
Unregister the cpufreq device and soc device when resource unwinding, 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: 9cc832d ("soc: imx8m: Probe the SoC driver as platform driver") Cc: Marco Felsch <[email protected]> Signed-off-by: Peng Fan <[email protected]> Reviewed-by: Marco Felsch <[email protected]> Signed-off-by: Shawn Guo <[email protected]>
1 parent 83964a2 commit cf7139a

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

drivers/soc/imx/soc-imx8m.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,20 @@ static __maybe_unused const struct of_device_id imx8_soc_match[] = {
192192
devm_kasprintf((dev), GFP_KERNEL, "%d.%d", ((soc_rev) >> 4) & 0xf, (soc_rev) & 0xf) : \
193193
"unknown"
194194

195+
static void imx8m_unregister_soc(void *data)
196+
{
197+
soc_device_unregister(data);
198+
}
199+
200+
static void imx8m_unregister_cpufreq(void *data)
201+
{
202+
platform_device_unregister(data);
203+
}
204+
195205
static int imx8m_soc_probe(struct platform_device *pdev)
196206
{
197207
struct soc_device_attribute *soc_dev_attr;
208+
struct platform_device *cpufreq_dev;
198209
const struct imx8_soc_data *data;
199210
struct device *dev = &pdev->dev;
200211
const struct of_device_id *id;
@@ -239,11 +250,22 @@ static int imx8m_soc_probe(struct platform_device *pdev)
239250
if (IS_ERR(soc_dev))
240251
return PTR_ERR(soc_dev);
241252

253+
ret = devm_add_action(dev, imx8m_unregister_soc, soc_dev);
254+
if (ret)
255+
return ret;
256+
242257
pr_info("SoC: %s revision %s\n", soc_dev_attr->soc_id,
243258
soc_dev_attr->revision);
244259

245-
if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT))
246-
platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
260+
if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT)) {
261+
cpufreq_dev = platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
262+
if (IS_ERR(cpufreq_dev))
263+
return dev_err_probe(dev, PTR_ERR(cpufreq_dev),
264+
"Failed to register imx-cpufreq-dev device\n");
265+
ret = devm_add_action(dev, imx8m_unregister_cpufreq, cpufreq_dev);
266+
if (ret)
267+
return ret;
268+
}
247269

248270
return 0;
249271
}

0 commit comments

Comments
 (0)