Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9bf792d3 authored by Lina Iyer's avatar Lina Iyer Committed by Ram Chandrasekar
Browse files

drivers: thermal: Initialize thermal core in subsys



CPUFreq drivers are available as part of subsys_initcall. In order to
facilitate thermal mitigation as early as possible in the boot cycle,
move the thermal framework initialization to subsys_initcall.

However, netlink initialization happens only as part of fs_initcall. At
this time in the boot process, the userspace would not be available
anyways, initialize the netlink separately, later in fs_initcall.

Change-Id: Ib9cda3e0bc687131de7543e5c05d8d0347438be9
Signed-off-by: default avatarLina Iyer <ilina@codeaurora.org>
parent 9d9d23fa
Loading
Loading
Loading
Loading
+33 −12
Original line number Diff line number Diff line
@@ -2172,6 +2172,8 @@ static struct genl_family thermal_event_genl_family = {
	.n_mcgrps = ARRAY_SIZE(thermal_event_mcgrps),
};

static int allow_netlink_events;

int thermal_generate_netlink_event(struct thermal_zone_device *tz,
					enum events event)
{
@@ -2186,6 +2188,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);
@@ -2237,7 +2242,13 @@ EXPORT_SYMBOL_GPL(thermal_generate_netlink_event);

static int genetlink_init(void)
{
	return genl_register_family(&thermal_event_genl_family);
	int ret;

	ret = genl_register_family(&thermal_event_genl_family);
	if (!ret)
		allow_netlink_events = true;

	return ret;
}

static void genetlink_exit(void)
@@ -2247,6 +2258,8 @@ static void genetlink_exit(void)
#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 __init thermal_register_governors(void)
@@ -2318,19 +2331,15 @@ static int __init thermal_init(void)

	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)
@@ -2339,13 +2348,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:
	idr_destroy(&thermal_tz_idr);
	idr_destroy(&thermal_cdev_idr);
	mutex_destroy(&thermal_idr_lock);
@@ -2368,5 +2375,19 @@ static void __exit thermal_exit(void)
	mutex_destroy(&thermal_governor_lock);
}

fs_initcall(thermal_init);
static int __init thermal_netlink_init(void)
{
	int ret = 0;

	ret = genetlink_init();
	if (!ret)
		goto exit_netlink;

	thermal_exit();
exit_netlink:
	return ret;
}

subsys_initcall(thermal_init);
fs_initcall(thermal_netlink_init);
module_exit(thermal_exit);