@@ -64,6 +64,13 @@ static atomic_t in_suspend;
6464
6565static struct thermal_governor * def_governor ;
6666
67+ /*
68+ * Governor section: set of functions to handle thermal governors
69+ *
70+ * Functions to help in the life cycle of thermal governors within
71+ * the thermal core and by the thermal governor code.
72+ */
73+
6774static struct thermal_governor * __find_governor (const char * name )
6875{
6976 struct thermal_governor * pos ;
@@ -206,6 +213,79 @@ void thermal_unregister_governor(struct thermal_governor *governor)
206213 return ;
207214}
208215
216+ int thermal_zone_device_set_policy (struct thermal_zone_device * tz ,
217+ char * policy )
218+ {
219+ struct thermal_governor * gov ;
220+ int ret = - EINVAL ;
221+
222+ mutex_lock (& thermal_governor_lock );
223+ mutex_lock (& tz -> lock );
224+
225+ gov = __find_governor (strim (policy ));
226+ if (!gov )
227+ goto exit ;
228+
229+ ret = thermal_set_governor (tz , gov );
230+
231+ exit :
232+ mutex_unlock (& tz -> lock );
233+ mutex_unlock (& thermal_governor_lock );
234+
235+ return ret ;
236+ }
237+
238+ int thermal_build_list_of_policies (char * buf )
239+ {
240+ struct thermal_governor * pos ;
241+ ssize_t count = 0 ;
242+ ssize_t size = PAGE_SIZE ;
243+
244+ mutex_lock (& thermal_governor_lock );
245+
246+ list_for_each_entry (pos , & thermal_governor_list , governor_list ) {
247+ size = PAGE_SIZE - count ;
248+ count += scnprintf (buf + count , size , "%s " , pos -> name );
249+ }
250+ count += scnprintf (buf + count , size , "\n" );
251+
252+ mutex_unlock (& thermal_governor_lock );
253+
254+ return count ;
255+ }
256+
257+ static int __init thermal_register_governors (void )
258+ {
259+ int result ;
260+
261+ result = thermal_gov_step_wise_register ();
262+ if (result )
263+ return result ;
264+
265+ result = thermal_gov_fair_share_register ();
266+ if (result )
267+ return result ;
268+
269+ result = thermal_gov_bang_bang_register ();
270+ if (result )
271+ return result ;
272+
273+ result = thermal_gov_user_space_register ();
274+ if (result )
275+ return result ;
276+
277+ return thermal_gov_power_allocator_register ();
278+ }
279+
280+ static void thermal_unregister_governors (void )
281+ {
282+ thermal_gov_step_wise_unregister ();
283+ thermal_gov_fair_share_unregister ();
284+ thermal_gov_bang_bang_unregister ();
285+ thermal_gov_user_space_unregister ();
286+ thermal_gov_power_allocator_unregister ();
287+ }
288+
209289static int get_idr (struct idr * idr , struct mutex * lock , int * id )
210290{
211291 int ret ;
@@ -617,47 +697,6 @@ void thermal_zone_device_unbind_exception(struct thermal_zone_device *tz,
617697 mutex_unlock (& thermal_list_lock );
618698}
619699
620- int thermal_zone_device_set_policy (struct thermal_zone_device * tz ,
621- char * policy )
622- {
623- struct thermal_governor * gov ;
624- int ret = - EINVAL ;
625-
626- mutex_lock (& thermal_governor_lock );
627- mutex_lock (& tz -> lock );
628-
629- gov = __find_governor (strim (policy ));
630- if (!gov )
631- goto exit ;
632-
633- ret = thermal_set_governor (tz , gov );
634-
635- exit :
636- mutex_unlock (& tz -> lock );
637- mutex_unlock (& thermal_governor_lock );
638-
639- return ret ;
640- }
641-
642- int thermal_build_list_of_policies (char * buf )
643- {
644- struct thermal_governor * pos ;
645- ssize_t count = 0 ;
646- ssize_t size = PAGE_SIZE ;
647-
648- mutex_lock (& thermal_governor_lock );
649-
650- list_for_each_entry (pos , & thermal_governor_list , governor_list ) {
651- size = PAGE_SIZE - count ;
652- count += scnprintf (buf + count , size , "%s " , pos -> name );
653- }
654- count += scnprintf (buf + count , size , "\n" );
655-
656- mutex_unlock (& thermal_governor_lock );
657-
658- return count ;
659- }
660-
661700/* Device management */
662701
663702/**
@@ -1424,38 +1463,6 @@ static inline int genetlink_init(void) { return 0; }
14241463static inline void genetlink_exit (void ) {}
14251464#endif /* !CONFIG_NET */
14261465
1427- static int __init thermal_register_governors (void )
1428- {
1429- int result ;
1430-
1431- result = thermal_gov_step_wise_register ();
1432- if (result )
1433- return result ;
1434-
1435- result = thermal_gov_fair_share_register ();
1436- if (result )
1437- return result ;
1438-
1439- result = thermal_gov_bang_bang_register ();
1440- if (result )
1441- return result ;
1442-
1443- result = thermal_gov_user_space_register ();
1444- if (result )
1445- return result ;
1446-
1447- return thermal_gov_power_allocator_register ();
1448- }
1449-
1450- static void thermal_unregister_governors (void )
1451- {
1452- thermal_gov_step_wise_unregister ();
1453- thermal_gov_fair_share_unregister ();
1454- thermal_gov_bang_bang_unregister ();
1455- thermal_gov_user_space_unregister ();
1456- thermal_gov_power_allocator_unregister ();
1457- }
1458-
14591466static int thermal_pm_notify (struct notifier_block * nb ,
14601467 unsigned long mode , void * _unused )
14611468{
0 commit comments