mediatek: add support for the new MT7623 Arm SoC
[openwrt.git] / target / linux / mediatek / patches / 0013-thermal-Use-IS_ENABLED-instead-of-ifdef.patch
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
5
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().
9
10 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
11 ---
12  drivers/thermal/thermal_core.c |   45 +++++++++++++++++-----------------------
13  1 file changed, 19 insertions(+), 26 deletions(-)
14
15 diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
16 index 1b68d20..3e0fe55 100644
17 --- a/drivers/thermal/thermal_core.c
18 +++ b/drivers/thermal/thermal_core.c
19 @@ -414,11 +414,9 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
20  int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
21  {
22         int ret = -EINVAL;
23 -#ifdef CONFIG_THERMAL_EMULATION
24         int count;
25         int crit_temp = INT_MAX;
26         enum thermal_trip_type type;
27 -#endif
28  
29         if (!tz || IS_ERR(tz) || !tz->ops->get_temp)
30                 goto exit;
31 @@ -426,25 +424,21 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
32         mutex_lock(&tz->lock);
33  
34         ret = tz->ops->get_temp(tz, temp);
35 -#ifdef CONFIG_THERMAL_EMULATION
36 -       if (!tz->emul_temperature)
37 -               goto skip_emul;
38 -
39 -       for (count = 0; count < tz->trips; count++) {
40 -               ret = tz->ops->get_trip_type(tz, count, &type);
41 -               if (!ret && type == THERMAL_TRIP_CRITICAL) {
42 -                       ret = tz->ops->get_trip_temp(tz, count, &crit_temp);
43 -                       break;
44 -               }
45 -       }
46  
47 -       if (ret)
48 -               goto skip_emul;
49 +       if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
50 +               for (count = 0; count < tz->trips; count++) {
51 +                       ret = tz->ops->get_trip_type(tz, count, &type);
52 +                       if (!ret && type == THERMAL_TRIP_CRITICAL) {
53 +                               ret = tz->ops->get_trip_temp(tz, count,
54 +                                               &crit_temp);
55 +                               break;
56 +                       }
57 +               }
58  
59 -       if (*temp < crit_temp)
60 -               *temp = tz->emul_temperature;
61 -skip_emul:
62 -#endif
63 +               if (!ret && *temp < crit_temp)
64 +                       *temp = tz->emul_temperature;
65 +       }
66
67         mutex_unlock(&tz->lock);
68  exit:
69         return ret;
70 @@ -780,7 +774,6 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf)
71         return sprintf(buf, "%s\n", tz->governor->name);
72  }
73  
74 -#ifdef CONFIG_THERMAL_EMULATION
75  static ssize_t
76  emul_temp_store(struct device *dev, struct device_attribute *attr,
77                      const char *buf, size_t count)
78 @@ -806,7 +799,6 @@ emul_temp_store(struct device *dev, struct device_attribute *attr,
79         return ret ? ret : count;
80  }
81  static DEVICE_ATTR(emul_temp, S_IWUSR, NULL, emul_temp_store);
82 -#endif/*CONFIG_THERMAL_EMULATION*/
83  
84  static DEVICE_ATTR(type, 0444, type_show, NULL);
85  static DEVICE_ATTR(temp, 0444, temp_show, NULL);
86 @@ -1536,11 +1528,12 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
87                         goto unregister;
88         }
89  
90 -#ifdef CONFIG_THERMAL_EMULATION
91 -       result = device_create_file(&tz->device, &dev_attr_emul_temp);
92 -       if (result)
93 -               goto unregister;
94 -#endif
95 +       if (IS_ENABLED(CONFIG_THERMAL_EMULATION)) {
96 +               result = device_create_file(&tz->device, &dev_attr_emul_temp);
97 +               if (result)
98 +                       goto unregister;
99 +       }
100 +
101         /* Create policy attribute */
102         result = device_create_file(&tz->device, &dev_attr_policy);
103         if (result)
104 -- 
105 1.7.10.4
106