@@ -123,7 +123,7 @@ static const struct genpd_lock_ops genpd_spin_ops = {
123123#define genpd_lock_interruptible (p ) p->lock_ops->lock_interruptible(p)
124124#define genpd_unlock (p ) p->lock_ops->unlock(p)
125125
126- #define genpd_status_on (genpd ) (genpd->status == GPD_STATE_ACTIVE )
126+ #define genpd_status_on (genpd ) (genpd->status == GENPD_STATE_ON )
127127#define genpd_is_irq_safe (genpd ) (genpd->flags & GENPD_FLAG_IRQ_SAFE)
128128#define genpd_is_always_on (genpd ) (genpd->flags & GENPD_FLAG_ALWAYS_ON)
129129#define genpd_is_active_wakeup (genpd ) (genpd->flags & GENPD_FLAG_ACTIVE_WAKEUP)
@@ -222,7 +222,7 @@ static void genpd_update_accounting(struct generic_pm_domain *genpd)
222222 * out of off and so update the idle time and vice
223223 * versa.
224224 */
225- if (genpd -> status == GPD_STATE_ACTIVE ) {
225+ if (genpd -> status == GENPD_STATE_ON ) {
226226 int state_idx = genpd -> state_idx ;
227227
228228 genpd -> states [state_idx ].idle_time =
@@ -497,6 +497,7 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
497497 struct pm_domain_data * pdd ;
498498 struct gpd_link * link ;
499499 unsigned int not_suspended = 0 ;
500+ int ret ;
500501
501502 /*
502503 * Do not try to power off the domain in the following situations:
@@ -544,26 +545,15 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
544545 if (!genpd -> gov )
545546 genpd -> state_idx = 0 ;
546547
547- if (genpd -> power_off ) {
548- int ret ;
549-
550- if (atomic_read (& genpd -> sd_count ) > 0 )
551- return - EBUSY ;
548+ /* Don't power off, if a child domain is waiting to power on. */
549+ if (atomic_read (& genpd -> sd_count ) > 0 )
550+ return - EBUSY ;
552551
553- /*
554- * If sd_count > 0 at this point, one of the subdomains hasn't
555- * managed to call genpd_power_on() for the parent yet after
556- * incrementing it. In that case genpd_power_on() will wait
557- * for us to drop the lock, so we can call .power_off() and let
558- * the genpd_power_on() restore power for us (this shouldn't
559- * happen very often).
560- */
561- ret = _genpd_power_off (genpd , true);
562- if (ret )
563- return ret ;
564- }
552+ ret = _genpd_power_off (genpd , true);
553+ if (ret )
554+ return ret ;
565555
566- genpd -> status = GPD_STATE_POWER_OFF ;
556+ genpd -> status = GENPD_STATE_OFF ;
567557 genpd_update_accounting (genpd );
568558
569559 list_for_each_entry (link , & genpd -> child_links , child_node ) {
@@ -616,7 +606,7 @@ static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth)
616606 if (ret )
617607 goto err ;
618608
619- genpd -> status = GPD_STATE_ACTIVE ;
609+ genpd -> status = GENPD_STATE_ON ;
620610 genpd_update_accounting (genpd );
621611
622612 return 0 ;
@@ -961,7 +951,7 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
961951 if (_genpd_power_off (genpd , false))
962952 return ;
963953
964- genpd -> status = GPD_STATE_POWER_OFF ;
954+ genpd -> status = GENPD_STATE_OFF ;
965955
966956 list_for_each_entry (link , & genpd -> child_links , child_node ) {
967957 genpd_sd_counter_dec (link -> parent );
@@ -1007,8 +997,7 @@ static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock,
1007997 }
1008998
1009999 _genpd_power_on (genpd , false);
1010-
1011- genpd -> status = GPD_STATE_ACTIVE ;
1000+ genpd -> status = GENPD_STATE_ON ;
10121001}
10131002
10141003/**
@@ -1287,7 +1276,7 @@ static int genpd_restore_noirq(struct device *dev)
12871276 * so make it appear as powered off to genpd_sync_power_on(),
12881277 * so that it tries to power it on in case it was really off.
12891278 */
1290- genpd -> status = GPD_STATE_POWER_OFF ;
1279+ genpd -> status = GENPD_STATE_OFF ;
12911280
12921281 genpd_sync_power_on (genpd , true, 0 );
12931282 genpd_unlock (genpd );
@@ -1777,7 +1766,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
17771766 genpd -> gov = gov ;
17781767 INIT_WORK (& genpd -> power_off_work , genpd_power_off_work_fn );
17791768 atomic_set (& genpd -> sd_count , 0 );
1780- genpd -> status = is_off ? GPD_STATE_POWER_OFF : GPD_STATE_ACTIVE ;
1769+ genpd -> status = is_off ? GENPD_STATE_OFF : GENPD_STATE_ON ;
17811770 genpd -> device_count = 0 ;
17821771 genpd -> max_off_time_ns = -1 ;
17831772 genpd -> max_off_time_changed = true;
@@ -2804,8 +2793,8 @@ static int genpd_summary_one(struct seq_file *s,
28042793 struct generic_pm_domain * genpd )
28052794{
28062795 static const char * const status_lookup [] = {
2807- [GPD_STATE_ACTIVE ] = "on" ,
2808- [GPD_STATE_POWER_OFF ] = "off"
2796+ [GENPD_STATE_ON ] = "on" ,
2797+ [GENPD_STATE_OFF ] = "off"
28092798 };
28102799 struct pm_domain_data * pm_data ;
28112800 const char * kobj_path ;
@@ -2883,8 +2872,8 @@ static int summary_show(struct seq_file *s, void *data)
28832872static int status_show (struct seq_file * s , void * data )
28842873{
28852874 static const char * const status_lookup [] = {
2886- [GPD_STATE_ACTIVE ] = "on" ,
2887- [GPD_STATE_POWER_OFF ] = "off"
2875+ [GENPD_STATE_ON ] = "on" ,
2876+ [GENPD_STATE_OFF ] = "off"
28882877 };
28892878
28902879 struct generic_pm_domain * genpd = s -> private ;
@@ -2897,7 +2886,7 @@ static int status_show(struct seq_file *s, void *data)
28972886 if (WARN_ON_ONCE (genpd -> status >= ARRAY_SIZE (status_lookup )))
28982887 goto exit ;
28992888
2900- if (genpd -> status == GPD_STATE_POWER_OFF )
2889+ if (genpd -> status == GENPD_STATE_OFF )
29012890 seq_printf (s , "%s-%u\n" , status_lookup [genpd -> status ],
29022891 genpd -> state_idx );
29032892 else
@@ -2940,7 +2929,7 @@ static int idle_states_show(struct seq_file *s, void *data)
29402929 ktime_t delta = 0 ;
29412930 s64 msecs ;
29422931
2943- if ((genpd -> status == GPD_STATE_POWER_OFF ) &&
2932+ if ((genpd -> status == GENPD_STATE_OFF ) &&
29442933 (genpd -> state_idx == i ))
29452934 delta = ktime_sub (ktime_get (), genpd -> accounting_time );
29462935
@@ -2963,7 +2952,7 @@ static int active_time_show(struct seq_file *s, void *data)
29632952 if (ret )
29642953 return - ERESTARTSYS ;
29652954
2966- if (genpd -> status == GPD_STATE_ACTIVE )
2955+ if (genpd -> status == GENPD_STATE_ON )
29672956 delta = ktime_sub (ktime_get (), genpd -> accounting_time );
29682957
29692958 seq_printf (s , "%lld ms\n" , ktime_to_ms (
@@ -2986,7 +2975,7 @@ static int total_idle_time_show(struct seq_file *s, void *data)
29862975
29872976 for (i = 0 ; i < genpd -> state_count ; i ++ ) {
29882977
2989- if ((genpd -> status == GPD_STATE_POWER_OFF ) &&
2978+ if ((genpd -> status == GENPD_STATE_OFF ) &&
29902979 (genpd -> state_idx == i ))
29912980 delta = ktime_sub (ktime_get (), genpd -> accounting_time );
29922981
0 commit comments