Lines Matching +full:fan +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * hwmon interface for the ACPI Fan driver.
16 #include "fan.h"
18 /* Returned when the ACPI fan does not support speed reporting */
22 static struct acpi_fan_fps *acpi_fan_get_current_fps(struct acpi_fan *fan, u64 control) in acpi_fan_get_current_fps() argument
26 for (i = 0; i < fan->fps_count; i++) { in acpi_fan_get_current_fps()
27 if (fan->fps[i].control == control) in acpi_fan_get_current_fps()
28 return &fan->fps[i]; in acpi_fan_get_current_fps()
37 const struct acpi_fan *fan = drvdata; in acpi_fan_hwmon_is_visible() local
47 * When in fine grain control mode, not every fan control value in acpi_fan_hwmon_is_visible()
48 * has an associated fan performance state. in acpi_fan_hwmon_is_visible()
50 if (fan->fif.fine_grain_ctrl) in acpi_fan_hwmon_is_visible()
51 return 0; in acpi_fan_hwmon_is_visible()
55 return 0; in acpi_fan_hwmon_is_visible()
61 * When in fine grain control mode, not every fan control value in acpi_fan_hwmon_is_visible()
62 * has an associated fan performance state. in acpi_fan_hwmon_is_visible()
64 if (fan->fif.fine_grain_ctrl) in acpi_fan_hwmon_is_visible()
65 return 0; in acpi_fan_hwmon_is_visible()
68 * When all fan performance states contain no valid power data, in acpi_fan_hwmon_is_visible()
71 for (i = 0; i < fan->fps_count; i++) { in acpi_fan_hwmon_is_visible()
72 if (fan->fps[i].power != FAN_POWER_UNAVAILABLE) in acpi_fan_hwmon_is_visible()
76 return 0; in acpi_fan_hwmon_is_visible()
78 return 0; in acpi_fan_hwmon_is_visible()
81 return 0; in acpi_fan_hwmon_is_visible()
88 struct acpi_device *adev = to_acpi_device(dev->parent); in acpi_fan_hwmon_read()
89 struct acpi_fan *fan = dev_get_drvdata(dev); in acpi_fan_hwmon_read() local
95 if (ret < 0) in acpi_fan_hwmon_read()
103 return -ENODEV; in acpi_fan_hwmon_read()
106 return -EOVERFLOW; in acpi_fan_hwmon_read()
109 return 0; in acpi_fan_hwmon_read()
111 fps = acpi_fan_get_current_fps(fan, fst.control); in acpi_fan_hwmon_read()
113 return -EIO; in acpi_fan_hwmon_read()
115 if (fps->speed > LONG_MAX) in acpi_fan_hwmon_read()
116 return -EOVERFLOW; in acpi_fan_hwmon_read()
118 *val = fps->speed; in acpi_fan_hwmon_read()
119 return 0; in acpi_fan_hwmon_read()
121 return -EOPNOTSUPP; in acpi_fan_hwmon_read()
126 fps = acpi_fan_get_current_fps(fan, fst.control); in acpi_fan_hwmon_read()
128 return -EIO; in acpi_fan_hwmon_read()
130 if (fps->power == FAN_POWER_UNAVAILABLE) in acpi_fan_hwmon_read()
131 return -ENODEV; in acpi_fan_hwmon_read()
133 if (fps->power > LONG_MAX / MICROWATT_PER_MILLIWATT) in acpi_fan_hwmon_read()
134 return -EOVERFLOW; in acpi_fan_hwmon_read()
136 *val = fps->power * MICROWATT_PER_MILLIWATT; in acpi_fan_hwmon_read()
137 return 0; in acpi_fan_hwmon_read()
139 return -EOPNOTSUPP; in acpi_fan_hwmon_read()
142 return -EOPNOTSUPP; in acpi_fan_hwmon_read()
152 HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_TARGET),
164 struct acpi_fan *fan = acpi_driver_data(device); in devm_acpi_fan_create_hwmon() local
167 hdev = devm_hwmon_device_register_with_info(&device->dev, "acpi_fan", fan, in devm_acpi_fan_create_hwmon()