Skip to content

Commit 1ee1482

Browse files
andrzejtpdlezcano
authored andcommitted
thermal: remove get_mode() operation of drivers
get_mode() is now redundant, as the state is stored in struct thermal_zone_device. Consequently the "mode" attribute in sysfs can always be visible, because it is always possible to get the mode from struct tzd. Signed-off-by: Andrzej Pietrasiewicz <[email protected]> [for acerhdf] Acked-by: Peter Kaestle <[email protected]> Reviewed-by: Bartlomiej Zolnierkiewicz <[email protected]> Reviewed-by: Amit Kucheria <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5a35066 commit 1ee1482

File tree

11 files changed

+3
-119
lines changed

11 files changed

+3
-119
lines changed

drivers/acpi/thermal.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -525,14 +525,6 @@ static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp)
525525
return 0;
526526
}
527527

528-
static int thermal_get_mode(struct thermal_zone_device *thermal,
529-
enum thermal_device_mode *mode)
530-
{
531-
*mode = thermal->mode;
532-
533-
return 0;
534-
}
535-
536528
static int thermal_set_mode(struct thermal_zone_device *thermal,
537529
enum thermal_device_mode mode)
538530
{
@@ -847,7 +839,6 @@ static struct thermal_zone_device_ops acpi_thermal_zone_ops = {
847839
.bind = acpi_thermal_bind_cooling_device,
848840
.unbind = acpi_thermal_unbind_cooling_device,
849841
.get_temp = thermal_get_temp,
850-
.get_mode = thermal_get_mode,
851842
.set_mode = thermal_set_mode,
852843
.get_trip_type = thermal_get_trip_type,
853844
.get_trip_temp = thermal_get_trip_temp,

drivers/net/ethernet/mellanox/mlxsw/core_thermal.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,6 @@ static int mlxsw_thermal_unbind(struct thermal_zone_device *tzdev,
275275
return 0;
276276
}
277277

278-
static int mlxsw_thermal_get_mode(struct thermal_zone_device *tzdev,
279-
enum thermal_device_mode *mode)
280-
{
281-
*mode = tzdev->mode;
282-
283-
return 0;
284-
}
285-
286278
static int mlxsw_thermal_set_mode(struct thermal_zone_device *tzdev,
287279
enum thermal_device_mode mode)
288280
{
@@ -402,7 +394,6 @@ static int mlxsw_thermal_trend_get(struct thermal_zone_device *tzdev,
402394
static struct thermal_zone_device_ops mlxsw_thermal_ops = {
403395
.bind = mlxsw_thermal_bind,
404396
.unbind = mlxsw_thermal_unbind,
405-
.get_mode = mlxsw_thermal_get_mode,
406397
.set_mode = mlxsw_thermal_set_mode,
407398
.get_temp = mlxsw_thermal_get_temp,
408399
.get_trip_type = mlxsw_thermal_get_trip_type,
@@ -461,14 +452,6 @@ static int mlxsw_thermal_module_unbind(struct thermal_zone_device *tzdev,
461452
return err;
462453
}
463454

464-
static int mlxsw_thermal_module_mode_get(struct thermal_zone_device *tzdev,
465-
enum thermal_device_mode *mode)
466-
{
467-
*mode = tzdev->mode;
468-
469-
return 0;
470-
}
471-
472455
static int mlxsw_thermal_module_mode_set(struct thermal_zone_device *tzdev,
473456
enum thermal_device_mode mode)
474457
{
@@ -606,7 +589,6 @@ static int mlxsw_thermal_module_trend_get(struct thermal_zone_device *tzdev,
606589
static struct thermal_zone_device_ops mlxsw_thermal_module_ops = {
607590
.bind = mlxsw_thermal_module_bind,
608591
.unbind = mlxsw_thermal_module_unbind,
609-
.get_mode = mlxsw_thermal_module_mode_get,
610592
.set_mode = mlxsw_thermal_module_mode_set,
611593
.get_temp = mlxsw_thermal_module_temp_get,
612594
.get_trip_type = mlxsw_thermal_module_trip_type_get,
@@ -645,7 +627,6 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
645627
static struct thermal_zone_device_ops mlxsw_thermal_gearbox_ops = {
646628
.bind = mlxsw_thermal_module_bind,
647629
.unbind = mlxsw_thermal_module_unbind,
648-
.get_mode = mlxsw_thermal_module_mode_get,
649630
.set_mode = mlxsw_thermal_module_mode_set,
650631
.get_temp = mlxsw_thermal_gearbox_temp_get,
651632
.get_trip_type = mlxsw_thermal_module_trip_type_get,

drivers/platform/x86/acerhdf.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -413,17 +413,6 @@ static inline void acerhdf_enable_kernelmode(void)
413413
pr_notice("kernel mode fan control ON\n");
414414
}
415415

416-
static int acerhdf_get_mode(struct thermal_zone_device *thermal,
417-
enum thermal_device_mode *mode)
418-
{
419-
if (verbose)
420-
pr_notice("kernel mode fan control %d\n", kernelmode);
421-
422-
*mode = thermal->mode;
423-
424-
return 0;
425-
}
426-
427416
/*
428417
* set operation mode;
429418
* enabled: the thermal layer of the kernel takes care about
@@ -490,7 +479,6 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = {
490479
.bind = acerhdf_bind,
491480
.unbind = acerhdf_unbind,
492481
.get_temp = acerhdf_get_ec_temp,
493-
.get_mode = acerhdf_get_mode,
494482
.set_mode = acerhdf_set_mode,
495483
.get_trip_type = acerhdf_get_trip_type,
496484
.get_trip_hyst = acerhdf_get_trip_hyst,

drivers/thermal/da9062-thermal.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,6 @@ static irqreturn_t da9062_thermal_irq_handler(int irq, void *data)
120120
return IRQ_HANDLED;
121121
}
122122

123-
static int da9062_thermal_get_mode(struct thermal_zone_device *z,
124-
enum thermal_device_mode *mode)
125-
{
126-
*mode = z->mode;
127-
return 0;
128-
}
129-
130123
static int da9062_thermal_get_trip_type(struct thermal_zone_device *z,
131124
int trip,
132125
enum thermal_trip_type *type)
@@ -179,7 +172,6 @@ static int da9062_thermal_get_temp(struct thermal_zone_device *z,
179172

180173
static struct thermal_zone_device_ops da9062_thermal_ops = {
181174
.get_temp = da9062_thermal_get_temp,
182-
.get_mode = da9062_thermal_get_mode,
183175
.get_trip_type = da9062_thermal_get_trip_type,
184176
.get_trip_temp = da9062_thermal_get_trip_temp,
185177
};

drivers/thermal/imx_thermal.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,6 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
330330
return 0;
331331
}
332332

333-
static int imx_get_mode(struct thermal_zone_device *tz,
334-
enum thermal_device_mode *mode)
335-
{
336-
*mode = tz->mode;
337-
338-
return 0;
339-
}
340-
341333
static int imx_set_mode(struct thermal_zone_device *tz,
342334
enum thermal_device_mode mode)
343335
{
@@ -464,7 +456,6 @@ static struct thermal_zone_device_ops imx_tz_ops = {
464456
.bind = imx_bind,
465457
.unbind = imx_unbind,
466458
.get_temp = imx_get_temp,
467-
.get_mode = imx_get_mode,
468459
.set_mode = imx_set_mode,
469460
.get_trip_type = imx_get_trip_type,
470461
.get_trip_temp = imx_get_trip_temp,

drivers/thermal/intel/int340x_thermal/int3400_thermal.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,14 +377,6 @@ static int int3400_thermal_get_temp(struct thermal_zone_device *thermal,
377377
return 0;
378378
}
379379

380-
static int int3400_thermal_get_mode(struct thermal_zone_device *thermal,
381-
enum thermal_device_mode *mode)
382-
{
383-
*mode = thermal->mode;
384-
385-
return 0;
386-
}
387-
388380
static int int3400_thermal_set_mode(struct thermal_zone_device *thermal,
389381
enum thermal_device_mode mode)
390382
{
@@ -412,7 +404,6 @@ static int int3400_thermal_set_mode(struct thermal_zone_device *thermal,
412404

413405
static struct thermal_zone_device_ops int3400_thermal_ops = {
414406
.get_temp = int3400_thermal_get_temp,
415-
.get_mode = int3400_thermal_get_mode,
416407
.set_mode = int3400_thermal_set_mode,
417408
};
418409

drivers/thermal/intel/intel_quark_dts_thermal.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,6 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd,
308308
return 0;
309309
}
310310

311-
static int sys_get_mode(struct thermal_zone_device *tzd,
312-
enum thermal_device_mode *mode)
313-
{
314-
*mode = tzd->mode;
315-
return 0;
316-
}
317-
318311
static int sys_set_mode(struct thermal_zone_device *tzd,
319312
enum thermal_device_mode mode)
320313
{
@@ -336,7 +329,6 @@ static struct thermal_zone_device_ops tzone_ops = {
336329
.get_trip_type = sys_get_trip_type,
337330
.set_trip_temp = sys_set_trip_temp,
338331
.get_crit_temp = sys_get_crit_temp,
339-
.get_mode = sys_get_mode,
340332
.set_mode = sys_set_mode,
341333
};
342334

drivers/thermal/thermal_core.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,6 @@ static int thermal_pm_notify(struct notifier_block *nb,
14561456
unsigned long mode, void *_unused)
14571457
{
14581458
struct thermal_zone_device *tz;
1459-
enum thermal_device_mode tz_mode;
14601459

14611460
switch (mode) {
14621461
case PM_HIBERNATION_PREPARE:
@@ -1469,11 +1468,7 @@ static int thermal_pm_notify(struct notifier_block *nb,
14691468
case PM_POST_SUSPEND:
14701469
atomic_set(&in_suspend, 0);
14711470
list_for_each_entry(tz, &thermal_tz_list, node) {
1472-
tz_mode = THERMAL_DEVICE_ENABLED;
1473-
if (tz->ops->get_mode)
1474-
tz->ops->get_mode(tz, &tz_mode);
1475-
1476-
if (tz_mode == THERMAL_DEVICE_DISABLED)
1471+
if (tz->mode == THERMAL_DEVICE_DISABLED)
14771472
continue;
14781473

14791474
thermal_zone_device_init(tz);

drivers/thermal/thermal_of.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,6 @@ static int of_thermal_unbind(struct thermal_zone_device *thermal,
267267
return 0;
268268
}
269269

270-
static int of_thermal_get_mode(struct thermal_zone_device *tz,
271-
enum thermal_device_mode *mode)
272-
{
273-
*mode = tz->mode;
274-
275-
return 0;
276-
}
277-
278270
static int of_thermal_set_mode(struct thermal_zone_device *tz,
279271
enum thermal_device_mode mode)
280272
{
@@ -389,7 +381,6 @@ static int of_thermal_get_crit_temp(struct thermal_zone_device *tz,
389381
}
390382

391383
static struct thermal_zone_device_ops of_thermal_ops = {
392-
.get_mode = of_thermal_get_mode,
393384
.set_mode = of_thermal_set_mode,
394385

395386
.get_trip_type = of_thermal_get_trip_type,

drivers/thermal/thermal_sysfs.c

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,9 @@ static ssize_t
4949
mode_show(struct device *dev, struct device_attribute *attr, char *buf)
5050
{
5151
struct thermal_zone_device *tz = to_thermal_zone(dev);
52-
enum thermal_device_mode mode;
53-
int result;
54-
55-
if (!tz->ops->get_mode)
56-
return -EPERM;
5752

58-
result = tz->ops->get_mode(tz, &mode);
59-
if (result)
60-
return result;
61-
62-
return sprintf(buf, "%s\n", mode == THERMAL_DEVICE_ENABLED ? "enabled"
63-
: "disabled");
53+
return sprintf(buf, "%s\n", tz->mode == THERMAL_DEVICE_ENABLED ?
54+
"enabled" : "disabled");
6455
}
6556

6657
static ssize_t
@@ -428,30 +419,13 @@ static struct attribute_group thermal_zone_attribute_group = {
428419
.attrs = thermal_zone_dev_attrs,
429420
};
430421

431-
/* We expose mode only if .get_mode is present */
432422
static struct attribute *thermal_zone_mode_attrs[] = {
433423
&dev_attr_mode.attr,
434424
NULL,
435425
};
436426

437-
static umode_t thermal_zone_mode_is_visible(struct kobject *kobj,
438-
struct attribute *attr,
439-
int attrno)
440-
{
441-
struct device *dev = container_of(kobj, struct device, kobj);
442-
struct thermal_zone_device *tz;
443-
444-
tz = container_of(dev, struct thermal_zone_device, device);
445-
446-
if (tz->ops->get_mode)
447-
return attr->mode;
448-
449-
return 0;
450-
}
451-
452427
static struct attribute_group thermal_zone_mode_attribute_group = {
453428
.attrs = thermal_zone_mode_attrs,
454-
.is_visible = thermal_zone_mode_is_visible,
455429
};
456430

457431
/* We expose passive only if passive trips are present */

0 commit comments

Comments
 (0)