@@ -517,18 +517,22 @@ static const struct of_device_id ramc_ids[] __initconst = {
517517 { /*sentinel*/ }
518518};
519519
520- static __init void at91_dt_ramc (void )
520+ static __init int at91_dt_ramc (void )
521521{
522522 struct device_node * np ;
523523 const struct of_device_id * of_id ;
524524 int idx = 0 ;
525525 void * standby = NULL ;
526526 const struct ramc_info * ramc ;
527+ int ret ;
527528
528529 for_each_matching_node_and_match (np , ramc_ids , & of_id ) {
529530 soc_pm .data .ramc [idx ] = of_iomap (np , 0 );
530- if (!soc_pm .data .ramc [idx ])
531- panic (pr_fmt ("unable to map ramc[%d] cpu registers\n" ), idx );
531+ if (!soc_pm .data .ramc [idx ]) {
532+ pr_err ("unable to map ramc[%d] cpu registers\n" , idx );
533+ ret = - ENOMEM ;
534+ goto unmap_ramc ;
535+ }
532536
533537 ramc = of_id -> data ;
534538 if (!standby )
@@ -538,15 +542,26 @@ static __init void at91_dt_ramc(void)
538542 idx ++ ;
539543 }
540544
541- if (!idx )
542- panic (pr_fmt ("unable to find compatible ram controller node in dtb\n" ));
545+ if (!idx ) {
546+ pr_err ("unable to find compatible ram controller node in dtb\n" );
547+ ret = - ENODEV ;
548+ goto unmap_ramc ;
549+ }
543550
544551 if (!standby ) {
545552 pr_warn ("ramc no standby function available\n" );
546- return ;
553+ return 0 ;
547554 }
548555
549556 at91_cpuidle_device .dev .platform_data = standby ;
557+
558+ return 0 ;
559+
560+ unmap_ramc :
561+ while (idx )
562+ iounmap (soc_pm .data .ramc [-- idx ]);
563+
564+ return ret ;
550565}
551566
552567static void at91rm9200_idle (void )
@@ -869,6 +884,8 @@ static void __init at91_pm_init(void (*pm_idle)(void))
869884
870885void __init at91rm9200_pm_init (void )
871886{
887+ int ret ;
888+
872889 if (!IS_ENABLED (CONFIG_SOC_AT91RM9200 ))
873890 return ;
874891
@@ -880,7 +897,9 @@ void __init at91rm9200_pm_init(void)
880897 soc_pm .data .standby_mode = AT91_PM_STANDBY ;
881898 soc_pm .data .suspend_mode = AT91_PM_ULP0 ;
882899
883- at91_dt_ramc ();
900+ ret = at91_dt_ramc ();
901+ if (ret )
902+ return ;
884903
885904 /*
886905 * AT91RM9200 SDRAM low-power mode cannot be used with self-refresh.
@@ -895,13 +914,17 @@ void __init sam9x60_pm_init(void)
895914 static const int modes [] __initconst = {
896915 AT91_PM_STANDBY , AT91_PM_ULP0 , AT91_PM_ULP0_FAST , AT91_PM_ULP1 ,
897916 };
917+ int ret ;
898918
899919 if (!IS_ENABLED (CONFIG_SOC_SAM9X60 ))
900920 return ;
901921
902922 at91_pm_modes_validate (modes , ARRAY_SIZE (modes ));
903923 at91_pm_modes_init ();
904- at91_dt_ramc ();
924+ ret = at91_dt_ramc ();
925+ if (ret )
926+ return ;
927+
905928 at91_pm_init (NULL );
906929
907930 soc_pm .ws_ids = sam9x60_ws_ids ;
@@ -910,6 +933,8 @@ void __init sam9x60_pm_init(void)
910933
911934void __init at91sam9_pm_init (void )
912935{
936+ int ret ;
937+
913938 if (!IS_ENABLED (CONFIG_SOC_AT91SAM9 ))
914939 return ;
915940
@@ -921,7 +946,10 @@ void __init at91sam9_pm_init(void)
921946 soc_pm .data .standby_mode = AT91_PM_STANDBY ;
922947 soc_pm .data .suspend_mode = AT91_PM_ULP0 ;
923948
924- at91_dt_ramc ();
949+ ret = at91_dt_ramc ();
950+ if (ret )
951+ return ;
952+
925953 at91_pm_init (at91sam9_idle );
926954}
927955
@@ -930,12 +958,16 @@ void __init sama5_pm_init(void)
930958 static const int modes [] __initconst = {
931959 AT91_PM_STANDBY , AT91_PM_ULP0 , AT91_PM_ULP0_FAST ,
932960 };
961+ int ret ;
933962
934963 if (!IS_ENABLED (CONFIG_SOC_SAMA5 ))
935964 return ;
936965
937966 at91_pm_modes_validate (modes , ARRAY_SIZE (modes ));
938- at91_dt_ramc ();
967+ ret = at91_dt_ramc ();
968+ if (ret )
969+ return ;
970+
939971 at91_pm_init (NULL );
940972}
941973
@@ -945,13 +977,17 @@ void __init sama5d2_pm_init(void)
945977 AT91_PM_STANDBY , AT91_PM_ULP0 , AT91_PM_ULP0_FAST , AT91_PM_ULP1 ,
946978 AT91_PM_BACKUP ,
947979 };
980+ int ret ;
948981
949982 if (!IS_ENABLED (CONFIG_SOC_SAMA5D2 ))
950983 return ;
951984
952985 at91_pm_modes_validate (modes , ARRAY_SIZE (modes ));
953986 at91_pm_modes_init ();
954- at91_dt_ramc ();
987+ ret = at91_dt_ramc ();
988+ if (ret )
989+ return ;
990+
955991 at91_pm_init (NULL );
956992
957993 soc_pm .ws_ids = sama5d2_ws_ids ;
0 commit comments