Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (core) Avoid ifdef CONFIG_THERMAL in C source file

Using an #ifdef in a C source files to have different definitions
of the same symbol makes the code harder to read and understand.
Furthermore it makes it harder to test compilation of the different
branches.

Replace the ifdeffery with IS_ENABLED() which is just a normal
conditional.
The resulting binary is still the same as before as the compiler
optimizes away all the unused code and definitions.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Thomas Weißschuh and committed by
Guenter Roeck
4d2ffc42 868dc3cd

+6 -15
+6 -15
drivers/hwmon/hwmon.c
··· 158 158 159 159 /* Thermal zone handling */ 160 160 161 - /* 162 - * The complex conditional is necessary to avoid a cyclic dependency 163 - * between hwmon and thermal_sys modules. 164 - */ 165 - #ifdef CONFIG_THERMAL_OF 166 161 static int hwmon_thermal_get_temp(struct thermal_zone_device *tz, int *temp) 167 162 { 168 163 struct hwmon_thermal_data *tdata = thermal_zone_device_priv(tz); ··· 263 268 void *drvdata = dev_get_drvdata(dev); 264 269 int i; 265 270 271 + if (!IS_ENABLED(CONFIG_THERMAL_OF)) 272 + return 0; 273 + 266 274 for (i = 1; info[i]; i++) { 267 275 int j; 268 276 ··· 294 296 struct hwmon_device *hwdev = to_hwmon_device(dev); 295 297 struct hwmon_thermal_data *tzdata; 296 298 299 + if (!IS_ENABLED(CONFIG_THERMAL_OF)) 300 + return; 301 + 297 302 list_for_each_entry(tzdata, &hwdev->tzdata, node) { 298 303 if (tzdata->index == index) { 299 304 thermal_zone_device_update(tzdata->tzd, ··· 304 303 } 305 304 } 306 305 } 307 - 308 - #else 309 - static int hwmon_thermal_register_sensors(struct device *dev) 310 - { 311 - return 0; 312 - } 313 - 314 - static void hwmon_thermal_notify(struct device *dev, int index) { } 315 - 316 - #endif /* IS_REACHABLE(CONFIG_THERMAL) && ... */ 317 306 318 307 static int hwmon_attr_base(enum hwmon_sensor_types type) 319 308 {