Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

thermal: core: Allocate thermal_class statically

Define thermal_class as a static structure to simplify thermal_init()
and to simplify thermal class availability checks that will need to
be carried out during the suspend and resume of thermal zones after
subsequent changes.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/10831981.nUPlyArG6x@rafael.j.wysocki

+12 -18
+12 -18
drivers/thermal/thermal_core.c
··· 972 972 } 973 973 } 974 974 975 - static struct class *thermal_class; 975 + static const struct class thermal_class = { 976 + .name = "thermal", 977 + .dev_release = thermal_release, 978 + }; 979 + static bool thermal_class_unavailable __ro_after_init = true; 976 980 977 981 static inline 978 982 void print_bind_err_msg(struct thermal_zone_device *tz, ··· 1069 1065 !ops->set_cur_state) 1070 1066 return ERR_PTR(-EINVAL); 1071 1067 1072 - if (!thermal_class) 1068 + if (thermal_class_unavailable) 1073 1069 return ERR_PTR(-ENODEV); 1074 1070 1075 1071 cdev = kzalloc_obj(*cdev); ··· 1092 1088 cdev->np = np; 1093 1089 cdev->ops = ops; 1094 1090 cdev->updated = false; 1095 - cdev->device.class = thermal_class; 1091 + cdev->device.class = &thermal_class; 1096 1092 cdev->devdata = devdata; 1097 1093 1098 1094 ret = cdev->ops->get_max_state(cdev, &cdev->max_state); ··· 1540 1536 if (polling_delay && passive_delay > polling_delay) 1541 1537 return ERR_PTR(-EINVAL); 1542 1538 1543 - if (!thermal_class) 1539 + if (thermal_class_unavailable) 1544 1540 return ERR_PTR(-ENODEV); 1545 1541 1546 1542 tz = kzalloc_flex(*tz, trips, num_trips); ··· 1576 1572 if (!tz->ops.critical) 1577 1573 tz->ops.critical = thermal_zone_device_critical; 1578 1574 1579 - tz->device.class = thermal_class; 1575 + tz->device.class = &thermal_class; 1580 1576 tz->devdata = devdata; 1581 1577 tz->num_trips = num_trips; 1582 1578 for_each_trip_desc(tz, td) { ··· 1918 1914 if (result) 1919 1915 goto destroy_workqueue; 1920 1916 1921 - thermal_class = kzalloc_obj(*thermal_class); 1922 - if (!thermal_class) { 1923 - result = -ENOMEM; 1917 + result = class_register(&thermal_class); 1918 + if (result) 1924 1919 goto unregister_governors; 1925 - } 1926 1920 1927 - thermal_class->name = "thermal"; 1928 - thermal_class->dev_release = thermal_release; 1929 - 1930 - result = class_register(thermal_class); 1931 - if (result) { 1932 - kfree(thermal_class); 1933 - thermal_class = NULL; 1934 - goto unregister_governors; 1935 - } 1921 + thermal_class_unavailable = false; 1936 1922 1937 1923 result = register_pm_notifier(&thermal_pm_nb); 1938 1924 if (result)