diff options
author | Amit Kucheria <amit.kucheria@linaro.org> | 2018-02-08 17:03:21 +0530 |
---|---|---|
committer | Amit Kucheria <amit.kucheria@linaro.org> | 2019-07-08 18:58:49 +0530 |
commit | a8cd626ccdff8a3c14388c4bc211f7f602a8d345 (patch) | |
tree | 0644ef58d5bf34093c3f129cafbac4e5806c709f | |
parent | 52cce7fe47b9375c79fd0e99697e56c377438034 (diff) |
drivers: thermal: Initialize thermal core earlier
Modern devices have two contradictory boot requirements - boot as
quickly as possible (which often means runs as fast as possible) while
staying under the thermal envelope.
Now that we've moved cpufreq initialisation and supported platform
drivers to core_initcall, let us move the thermal framework
initialization earlier too.
However, netlink initialization happens only as part of fs_initcall so
it has a userspace available. Initialize netlink events separately,
later in the boot process.
Originally-by: Lina Iyer <ilina@codeaurora.org>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
-rw-r--r-- | drivers/thermal/thermal_core.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 46cfb7de4eb2..12242fdf0a0e 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1462,6 +1462,8 @@ static struct genl_family thermal_event_genl_family __ro_after_init = { .n_mcgrps = ARRAY_SIZE(thermal_event_mcgrps), }; +static bool allow_netlink_events; + int thermal_generate_netlink_event(struct thermal_zone_device *tz, enum events event) { @@ -1476,6 +1478,9 @@ int thermal_generate_netlink_event(struct thermal_zone_device *tz, if (!tz) return -EINVAL; + if (!allow_netlink_events) + return -ENODEV; + /* allocate memory */ size = nla_total_size(sizeof(struct thermal_genl_event)) + nla_total_size(0); @@ -1527,16 +1532,18 @@ EXPORT_SYMBOL_GPL(thermal_generate_netlink_event); static int __init genetlink_init(void) { - return genl_register_family(&thermal_event_genl_family); -} + int err; -static void genetlink_exit(void) -{ - genl_unregister_family(&thermal_event_genl_family); + err = genl_register_family(&thermal_event_genl_family); + if (!err) + allow_netlink_events = true; + return err; } + #else /* !CONFIG_NET */ static inline int genetlink_init(void) { return 0; } -static inline void genetlink_exit(void) {} +static inline int thermal_generate_netlink_event(struct thermal_zone_device *tz, + enum events event) { return -ENODEV; } #endif /* !CONFIG_NET */ static int thermal_pm_notify(struct notifier_block *nb, @@ -1585,19 +1592,15 @@ static int __init thermal_init(void) mutex_init(&poweroff_lock); result = thermal_register_governors(); if (result) - goto error; + goto init_exit; result = class_register(&thermal_class); if (result) goto unregister_governors; - result = genetlink_init(); - if (result) - goto unregister_class; - result = of_parse_thermal_zones(); if (result) - goto exit_netlink; + goto exit_zone_parse; result = register_pm_notifier(&thermal_pm_nb); if (result) @@ -1606,13 +1609,11 @@ static int __init thermal_init(void) return 0; -exit_netlink: - genetlink_exit(); -unregister_class: +exit_zone_parse: class_unregister(&thermal_class); unregister_governors: thermal_unregister_governors(); -error: +init_exit: ida_destroy(&thermal_tz_ida); ida_destroy(&thermal_cdev_ida); mutex_destroy(&thermal_list_lock); @@ -1620,4 +1621,10 @@ error: mutex_destroy(&poweroff_lock); return result; } -fs_initcall(thermal_init); + +static int __init thermal_netlink_init(void) +{ + return genetlink_init(); +} +core_initcall(thermal_init); +fs_initcall(thermal_netlink_init); |