1 From bddcae2b66a23bfb6d381d089b0b862235480a9b Mon Sep 17 00:00:00 2001
2 From: Sascha Hauer <s.hauer@pengutronix.de>
3 Date: Wed, 13 May 2015 10:52:32 +0200
4 Subject: [PATCH 13/76] thermal: Use IS_ENABLED instead of #ifdef
6 Use IS_ENABLED(CONFIG_THERMAL_EMULATION) to make the code more readable
7 and to get rid of the addtional #ifdef around the variable definitions
8 in thermal_zone_get_temp().
10 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
12 drivers/thermal/thermal_core.c | 45 +++++++++++++++++-----------------------
13 1 file changed, 19 insertions(+), 26 deletions(-)
15 --- a/drivers/thermal/thermal_core.c
16 +++ b/drivers/thermal/thermal_core.c
17 @@ -414,11 +414,9 @@ static void handle_thermal_trip(struct t
18 int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
21 -#ifdef CONFIG_THERMAL_EMULATION
23 int crit_temp = INT_MAX;
24 enum thermal_trip_type type;
27 if (!tz || IS_ERR(tz) || !tz->ops->get_temp)
29 @@ -426,25 +424,21 @@ int thermal_zone_get_temp(struct thermal
30 mutex_lock(&tz->lock);
32 ret = tz->ops->get_temp(tz, temp);
33 -#ifdef CONFIG_THERMAL_EMULATION
34 - if (!tz->emul_temperature)
37 - for (count = 0; count < tz->trips; count++) {
38 - ret = tz->ops->get_trip_type(tz, count, &type);
39 - if (!ret && type == THERMAL_TRIP_CRITICAL) {
40 - ret = tz->ops->get_trip_temp(tz, count, &crit_temp);
47 + if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
48 + for (count = 0; count < tz->trips; count++) {
49 + ret = tz->ops->get_trip_type(tz, count, &type);
50 + if (!ret && type == THERMAL_TRIP_CRITICAL) {
51 + ret = tz->ops->get_trip_temp(tz, count,
57 - if (*temp < crit_temp)
58 - *temp = tz->emul_temperature;
61 + if (!ret && *temp < crit_temp)
62 + *temp = tz->emul_temperature;
65 mutex_unlock(&tz->lock);
68 @@ -780,7 +774,6 @@ policy_show(struct device *dev, struct d
69 return sprintf(buf, "%s\n", tz->governor->name);
72 -#ifdef CONFIG_THERMAL_EMULATION
74 emul_temp_store(struct device *dev, struct device_attribute *attr,
75 const char *buf, size_t count)
76 @@ -806,7 +799,6 @@ emul_temp_store(struct device *dev, stru
77 return ret ? ret : count;
79 static DEVICE_ATTR(emul_temp, S_IWUSR, NULL, emul_temp_store);
80 -#endif/*CONFIG_THERMAL_EMULATION*/
82 static DEVICE_ATTR(type, 0444, type_show, NULL);
83 static DEVICE_ATTR(temp, 0444, temp_show, NULL);
84 @@ -1536,11 +1528,12 @@ struct thermal_zone_device *thermal_zone
88 -#ifdef CONFIG_THERMAL_EMULATION
89 - result = device_create_file(&tz->device, &dev_attr_emul_temp);
93 + if (IS_ENABLED(CONFIG_THERMAL_EMULATION)) {
94 + result = device_create_file(&tz->device, &dev_attr_emul_temp);
99 /* Create policy attribute */
100 result = device_create_file(&tz->device, &dev_attr_policy);