kernel: update kernel 4.1 to version 4.1.20
[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 --- a/drivers/thermal/thermal_core.c
16 +++ b/drivers/thermal/thermal_core.c
17 @@ -417,11 +417,9 @@ static void handle_thermal_trip(struct t
18  int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
19  {
20         int ret = -EINVAL;
21 -#ifdef CONFIG_THERMAL_EMULATION
22         int count;
23         int crit_temp = INT_MAX;
24         enum thermal_trip_type type;
25 -#endif
26  
27         if (!tz || IS_ERR(tz) || !tz->ops->get_temp)
28                 goto exit;
29 @@ -429,25 +427,21 @@ int thermal_zone_get_temp(struct thermal
30         mutex_lock(&tz->lock);
31  
32         ret = tz->ops->get_temp(tz, temp);
33 -#ifdef CONFIG_THERMAL_EMULATION
34 -       if (!tz->emul_temperature)
35 -               goto skip_emul;
36 -
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);
41 -                       break;
42 -               }
43 -       }
44  
45 -       if (ret)
46 -               goto skip_emul;
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,
52 +                                               &crit_temp);
53 +                               break;
54 +                       }
55 +               }
56  
57 -       if (*temp < crit_temp)
58 -               *temp = tz->emul_temperature;
59 -skip_emul:
60 -#endif
61 +               if (!ret && *temp < crit_temp)
62 +                       *temp = tz->emul_temperature;
63 +       }
64
65         mutex_unlock(&tz->lock);
66  exit:
67         return ret;
68 @@ -800,7 +794,6 @@ policy_show(struct device *dev, struct d
69         return sprintf(buf, "%s\n", tz->governor->name);
70  }
71  
72 -#ifdef CONFIG_THERMAL_EMULATION
73  static ssize_t
74  emul_temp_store(struct device *dev, struct device_attribute *attr,
75                      const char *buf, size_t count)
76 @@ -826,7 +819,6 @@ emul_temp_store(struct device *dev, stru
77         return ret ? ret : count;
78  }
79  static DEVICE_ATTR(emul_temp, S_IWUSR, NULL, emul_temp_store);
80 -#endif/*CONFIG_THERMAL_EMULATION*/
81  
82  static DEVICE_ATTR(type, 0444, type_show, NULL);
83  static DEVICE_ATTR(temp, 0444, temp_show, NULL);
84 @@ -1566,11 +1558,12 @@ struct thermal_zone_device *thermal_zone
85                         goto unregister;
86         }
87  
88 -#ifdef CONFIG_THERMAL_EMULATION
89 -       result = device_create_file(&tz->device, &dev_attr_emul_temp);
90 -       if (result)
91 -               goto unregister;
92 -#endif
93 +       if (IS_ENABLED(CONFIG_THERMAL_EMULATION)) {
94 +               result = device_create_file(&tz->device, &dev_attr_emul_temp);
95 +               if (result)
96 +                       goto unregister;
97 +       }
98 +
99         /* Create policy attribute */
100         result = device_create_file(&tz->device, &dev_attr_policy);
101         if (result)