@@ -361,6 +361,24 @@ static irqreturn_t rcar_thermal_irq(int irq, void *data)
361361/*
362362 * platform functions
363363 */
364+ static int rcar_thermal_remove (struct platform_device * pdev )
365+ {
366+ struct rcar_thermal_common * common = platform_get_drvdata (pdev );
367+ struct device * dev = & pdev -> dev ;
368+ struct rcar_thermal_priv * priv ;
369+
370+ rcar_thermal_for_each_priv (priv , common ) {
371+ if (rcar_has_irq_support (priv ))
372+ rcar_thermal_irq_disable (priv );
373+ thermal_zone_device_unregister (priv -> zone );
374+ }
375+
376+ pm_runtime_put (dev );
377+ pm_runtime_disable (dev );
378+
379+ return 0 ;
380+ }
381+
364382static int rcar_thermal_probe (struct platform_device * pdev )
365383{
366384 struct rcar_thermal_common * common ;
@@ -377,6 +395,8 @@ static int rcar_thermal_probe(struct platform_device *pdev)
377395 if (!common )
378396 return - ENOMEM ;
379397
398+ platform_set_drvdata (pdev , common );
399+
380400 INIT_LIST_HEAD (& common -> head );
381401 spin_lock_init (& common -> lock );
382402 common -> dev = dev ;
@@ -454,43 +474,16 @@ static int rcar_thermal_probe(struct platform_device *pdev)
454474 rcar_thermal_common_write (common , ENR , enr_bits );
455475 }
456476
457- platform_set_drvdata (pdev , common );
458-
459477 dev_info (dev , "%d sensor probed\n" , i );
460478
461479 return 0 ;
462480
463481error_unregister :
464- rcar_thermal_for_each_priv (priv , common ) {
465- if (rcar_has_irq_support (priv ))
466- rcar_thermal_irq_disable (priv );
467- thermal_zone_device_unregister (priv -> zone );
468- }
469-
470- pm_runtime_put (dev );
471- pm_runtime_disable (dev );
482+ rcar_thermal_remove (pdev );
472483
473484 return ret ;
474485}
475486
476- static int rcar_thermal_remove (struct platform_device * pdev )
477- {
478- struct rcar_thermal_common * common = platform_get_drvdata (pdev );
479- struct device * dev = & pdev -> dev ;
480- struct rcar_thermal_priv * priv ;
481-
482- rcar_thermal_for_each_priv (priv , common ) {
483- if (rcar_has_irq_support (priv ))
484- rcar_thermal_irq_disable (priv );
485- thermal_zone_device_unregister (priv -> zone );
486- }
487-
488- pm_runtime_put (dev );
489- pm_runtime_disable (dev );
490-
491- return 0 ;
492- }
493-
494487static const struct of_device_id rcar_thermal_dt_ids [] = {
495488 { .compatible = "renesas,rcar-thermal" , },
496489 {},
0 commit comments