@@ -500,11 +500,7 @@ static void acpi_thermal_check(void *data)
struct acpi_thermal *tz = data;
enum thermal_device_mode mode;
- /*
- * this driver does not provide ->get_mode(), so calling
- * thermal_zone_device_get_mode() always succeeds
- */
- thermal_zone_device_get_mode(tz->thermal_zone, &mode);
+ mode = thermal_zone_device_get_mode(tz->thermal_zone);
if (mode != THERMAL_DEVICE_ENABLED)
return;
@@ -546,11 +542,7 @@ static int thermal_set_mode(struct thermal_zone_device *thermal,
if (mode == THERMAL_DEVICE_DISABLED)
pr_warn("thermal zone will be disabled\n");
- /*
- * this driver does not provide ->get_mode(), so calling
- * thermal_zone_device_get_mode() always succeeds
- */
- thermal_zone_device_get_mode(thermal, &old_mode);
+ old_mode = thermal_zone_device_get_mode(thermal);
if (mode != old_mode) {
thermal_zone_device_store_mode(thermal, mode);
@@ -256,11 +256,7 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
bool wait;
u32 val;
- /*
- * this driver does not provide ->get_mode(), so calling
- * thermal_zone_device_get_mode() always succeeds
- */
- thermal_zone_device_get_mode(tz, &mode);
+ mode = thermal_zone_device_get_mode(tz);
if (mode == THERMAL_DEVICE_ENABLED) {
/* Check if a measurement is currently in progress */
regmap_read(map, soc_data->temp_data, &val);
@@ -240,11 +240,7 @@ static int int3400_thermal_set_mode(struct thermal_zone_device *thermal,
mode != THERMAL_DEVICE_DISABLED)
return -EINVAL;
- /*
- * this driver does not provide ->get_mode(), so calling
- * thermal_zone_device_get_mode() always succeeds
- */
- thermal_zone_device_get_mode(thermal, &old_mode);
+ old_mode = thermal_zone_device_get_mode(thermal);
if (mode != old_mode) {
thermal_zone_device_store_mode(thermal, mode);
result = int3400_thermal_run_osc(priv->adev->handle,
@@ -469,18 +469,6 @@ static void thermal_zone_device_reset(struct thermal_zone_device *tz)
thermal_zone_device_init(tz);
}
-int thermal_zone_device_get_mode(struct thermal_zone_device *tz,
- enum thermal_device_mode *mode)
-{
- if (tz->ops->get_mode)
- return tz->ops->get_mode(tz, mode);
-
- *mode = tz->mode;
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(thermal_zone_device_get_mode);
-
int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
enum thermal_device_mode mode)
{
@@ -1507,9 +1495,7 @@ static int thermal_pm_notify(struct notifier_block *nb,
case PM_POST_SUSPEND:
atomic_set(&in_suspend, 0);
list_for_each_entry(tz, &thermal_tz_list, node) {
- tz_mode = THERMAL_DEVICE_ENABLED;
- if (tz->ops->get_mode)
- tz->ops->get_mode(tz, &tz_mode);
+ tz_mode = thermal_zone_device_get_mode(tz);
if (tz_mode == THERMAL_DEVICE_DISABLED)
continue;
@@ -50,11 +50,8 @@ mode_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct thermal_zone_device *tz = to_thermal_zone(dev);
enum thermal_device_mode mode;
- int result;
- result = thermal_zone_device_get_mode(tz, &mode);
- if (result)
- return result;
+ mode = thermal_zone_device_get_mode(tz);
return sprintf(buf, "%s\n", mode == THERMAL_DEVICE_ENABLED ? "enabled"
: "disabled");
@@ -425,30 +422,13 @@ static struct attribute_group thermal_zone_attribute_group = {
.attrs = thermal_zone_dev_attrs,
};
-/* We expose mode only if .get_mode is present */
static struct attribute *thermal_zone_mode_attrs[] = {
&dev_attr_mode.attr,
NULL,
};
-static umode_t thermal_zone_mode_is_visible(struct kobject *kobj,
- struct attribute *attr,
- int attrno)
-{
- struct device *dev = container_of(kobj, struct device, kobj);
- struct thermal_zone_device *tz;
-
- tz = container_of(dev, struct thermal_zone_device, device);
-
- if (tz->ops->get_mode)
- return attr->mode;
-
- return 0;
-}
-
static struct attribute_group thermal_zone_mode_attribute_group = {
.attrs = thermal_zone_mode_attrs,
- .is_visible = thermal_zone_mode_is_visible,
};
/* We expose passive only if passive trips are present */
@@ -86,8 +86,6 @@ struct thermal_zone_device_ops {
struct thermal_cooling_device *);
int (*get_temp) (struct thermal_zone_device *, int *);
int (*set_trips) (struct thermal_zone_device *, int, int);
- int (*get_mode) (struct thermal_zone_device *,
- enum thermal_device_mode *);
int (*set_mode) (struct thermal_zone_device *,
enum thermal_device_mode);
int (*get_trip_type) (struct thermal_zone_device *, int,
@@ -440,8 +438,12 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int,
struct thermal_cooling_device *);
-int thermal_zone_device_get_mode(struct thermal_zone_device *tz,
- enum thermal_device_mode *mode);
+static inline enum thermal_device_mode
+thermal_zone_device_get_mode(struct thermal_zone_device *tz)
+{
+ return tz->mode;
+}
+
int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
enum thermal_device_mode mode);
@@ -509,9 +511,9 @@ static inline int thermal_zone_unbind_cooling_device(
struct thermal_zone_device *tz, int trip,
struct thermal_cooling_device *cdev)
{ return -ENODEV; }
-static inline int thermal_zone_device_get_mode(struct thermal_zone_device *tz,
- enum thermal_device_mode *mode)
-{ return -ENODEV; }
+static inline enum thermal_device_mode
+thermal_zone_device_get_mode(struct thermal_zone_device *tz)
+{ return THERMAL_DEVICE_DISABLED; }
static inline int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
enum thermal_device_mode mode)
{ return -ENODEV; }
Now that mode of all thermal zone devices is stored in struct thermal_zone_device the get_mode() method is not used nor necessary any more. All its former users used it only to report the state of their then-internal variable. The sysfs "mode" attribute is always exposed from now on. It doesn't hurt the drivers which don't provide their own set_mode(), because writing to "mode" will result in -EPERM, as expected. thermal_zone_device_get_mode() will always succeed, so let it return the actual value rather than an always-zero return code. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> --- drivers/acpi/thermal.c | 12 ++-------- drivers/thermal/imx_thermal.c | 6 +---- .../intel/int340x_thermal/int3400_thermal.c | 6 +---- drivers/thermal/thermal_core.c | 16 +------------- drivers/thermal/thermal_sysfs.c | 22 +------------------ include/linux/thermal.h | 16 ++++++++------ 6 files changed, 15 insertions(+), 63 deletions(-)