@@ -192,9 +192,20 @@ static __maybe_unused const struct of_device_id imx8_soc_match[] = {
192
192
devm_kasprintf((dev), GFP_KERNEL, "%d.%d", ((soc_rev) >> 4) & 0xf, (soc_rev) & 0xf) : \
193
193
"unknown"
194
194
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
+
195
205
static int imx8m_soc_probe (struct platform_device * pdev )
196
206
{
197
207
struct soc_device_attribute * soc_dev_attr ;
208
+ struct platform_device * cpufreq_dev ;
198
209
const struct imx8_soc_data * data ;
199
210
struct device * dev = & pdev -> dev ;
200
211
const struct of_device_id * id ;
@@ -239,11 +250,22 @@ static int imx8m_soc_probe(struct platform_device *pdev)
239
250
if (IS_ERR (soc_dev ))
240
251
return PTR_ERR (soc_dev );
241
252
253
+ ret = devm_add_action (dev , imx8m_unregister_soc , soc_dev );
254
+ if (ret )
255
+ return ret ;
256
+
242
257
pr_info ("SoC: %s revision %s\n" , soc_dev_attr -> soc_id ,
243
258
soc_dev_attr -> revision );
244
259
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
+ }
247
269
248
270
return 0 ;
249
271
}
0 commit comments