Skip to content

Commit 5b8583d

Browse files
committed
thermal: netlink: Fix compilation error when CONFIG_NET=n
When the network is not configured, the netlink is disabled on all the system. The thermal framework assumed the netlink is always opt-in. Fix this by adding a Kconfig option for the netlink notification, defaulting to yes and depending on CONFIG_NET. As the change implies multiple stubs and in order to not pollute the internal thermal header, the thermal_nelink.h has been added and included in the thermal_core.h, so this one regain some kind of clarity. Reported-by: Randy Dunlap <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Reviewed-by: Amit Kucheria <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 55cdf0a commit 5b8583d

File tree

4 files changed

+114
-19
lines changed

4 files changed

+114
-19
lines changed

drivers/thermal/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ menuconfig THERMAL
1717

1818
if THERMAL
1919

20+
config THERMAL_NETLINK
21+
bool "Thermal netlink management"
22+
depends on NET
23+
default y
24+
help
25+
The thermal framework has a netlink interface to do thermal
26+
zones discovery, temperature readings and events such as
27+
trip point crossed, cooling device update or governor
28+
change. It is recommended to enable the feature.
29+
2030
config THERMAL_STATISTICS
2131
bool "Thermal state transition statistics"
2232
help

drivers/thermal/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
obj-$(CONFIG_THERMAL) += thermal_sys.o
77
thermal_sys-y += thermal_core.o thermal_sysfs.o \
8-
thermal_helpers.o thermal_netlink.o
8+
thermal_helpers.o
9+
10+
# netlink interface to manage the thermal framework
11+
thermal_sys-$(CONFIG_THERMAL_NETLINK) += thermal_netlink.o
912

1013
# interface to/from other layers providing sensors
1114
thermal_sys-$(CONFIG_THERMAL_HWMON) += thermal_hwmon.o

drivers/thermal/thermal_core.h

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <linux/device.h>
1313
#include <linux/thermal.h>
1414

15+
#include "thermal_netlink.h"
16+
1517
/* Default Thermal Governor */
1618
#if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE)
1719
#define DEFAULT_THERMAL_GOVERNOR "step_wise"
@@ -52,24 +54,6 @@ int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *),
5254

5355
struct thermal_zone_device *thermal_zone_get_by_id(int id);
5456

55-
/* Netlink notification function */
56-
int thermal_notify_tz_create(int tz_id, const char *name);
57-
int thermal_notify_tz_delete(int tz_id);
58-
int thermal_notify_tz_enable(int tz_id);
59-
int thermal_notify_tz_disable(int tz_id);
60-
int thermal_notify_tz_trip_down(int tz_id, int id);
61-
int thermal_notify_tz_trip_up(int tz_id, int id);
62-
int thermal_notify_tz_trip_delete(int tz_id, int id);
63-
int thermal_notify_tz_trip_add(int tz_id, int id, int type,
64-
int temp, int hyst);
65-
int thermal_notify_tz_trip_change(int tz_id, int id, int type,
66-
int temp, int hyst);
67-
int thermal_notify_cdev_state_update(int cdev_id, int state);
68-
int thermal_notify_cdev_add(int cdev_id, const char *name, int max_state);
69-
int thermal_notify_cdev_delete(int cdev_id);
70-
int thermal_notify_tz_gov_change(int tz_id, const char *name);
71-
int thermal_genl_sampling_temp(int id, int temp);
72-
7357
struct thermal_attr {
7458
struct device_attribute attr;
7559
char name[THERMAL_NAME_LENGTH];

drivers/thermal/thermal_netlink.h

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (C) Linaro Ltd 2020
4+
* Author: Daniel Lezcano <[email protected]>
5+
*/
6+
7+
/* Netlink notification function */
8+
#ifdef CONFIG_THERMAL_NETLINK
9+
int thermal_notify_tz_create(int tz_id, const char *name);
10+
int thermal_notify_tz_delete(int tz_id);
11+
int thermal_notify_tz_enable(int tz_id);
12+
int thermal_notify_tz_disable(int tz_id);
13+
int thermal_notify_tz_trip_down(int tz_id, int id);
14+
int thermal_notify_tz_trip_up(int tz_id, int id);
15+
int thermal_notify_tz_trip_delete(int tz_id, int id);
16+
int thermal_notify_tz_trip_add(int tz_id, int id, int type,
17+
int temp, int hyst);
18+
int thermal_notify_tz_trip_change(int tz_id, int id, int type,
19+
int temp, int hyst);
20+
int thermal_notify_cdev_state_update(int cdev_id, int state);
21+
int thermal_notify_cdev_add(int cdev_id, const char *name, int max_state);
22+
int thermal_notify_cdev_delete(int cdev_id);
23+
int thermal_notify_tz_gov_change(int tz_id, const char *name);
24+
int thermal_genl_sampling_temp(int id, int temp);
25+
#else
26+
static inline int thermal_notify_tz_create(int tz_id, const char *name)
27+
{
28+
return 0;
29+
}
30+
31+
static inline int thermal_notify_tz_delete(int tz_id)
32+
{
33+
return 0;
34+
}
35+
36+
static inline int thermal_notify_tz_enable(int tz_id)
37+
{
38+
return 0;
39+
}
40+
41+
static inline int thermal_notify_tz_disable(int tz_id)
42+
{
43+
return 0;
44+
}
45+
46+
static inline int thermal_notify_tz_trip_down(int tz_id, int id)
47+
{
48+
return 0;
49+
}
50+
51+
static inline int thermal_notify_tz_trip_up(int tz_id, int id)
52+
{
53+
return 0;
54+
}
55+
56+
static inline int thermal_notify_tz_trip_delete(int tz_id, int id)
57+
{
58+
return 0;
59+
}
60+
61+
static inline int thermal_notify_tz_trip_add(int tz_id, int id, int type,
62+
int temp, int hyst)
63+
{
64+
return 0;
65+
}
66+
67+
static inline int thermal_notify_tz_trip_change(int tz_id, int id, int type,
68+
int temp, int hyst)
69+
{
70+
return 0;
71+
}
72+
73+
static inline int thermal_notify_cdev_state_update(int cdev_id, int state)
74+
{
75+
return 0;
76+
}
77+
78+
static inline int thermal_notify_cdev_add(int cdev_id, const char *name,
79+
int max_state)
80+
{
81+
return 0;
82+
}
83+
84+
static inline int thermal_notify_cdev_delete(int cdev_id)
85+
{
86+
return 0;
87+
}
88+
89+
static inline int thermal_notify_tz_gov_change(int tz_id, const char *name)
90+
{
91+
return 0;
92+
}
93+
94+
static inline int thermal_genl_sampling_temp(int id, int temp)
95+
{
96+
return 0;
97+
}
98+
#endif /* CONFIG_THERMAL_NETLINK */

0 commit comments

Comments
 (0)