| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | | - * intel_menlow.c - Intel menlow Driver for thermal management extension |
|---|
| 3 | + * Intel menlow Driver for thermal management extension |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2008 Intel Corp |
|---|
| 5 | 6 | * Copyright (C) 2008 Sujith Thomas <sujith.thomas@intel.com> |
|---|
| 6 | 7 | * Copyright (C) 2008 Zhang Rui <rui.zhang@intel.com> |
|---|
| 7 | | - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 11 | | - * the Free Software Foundation; version 2 of the License. |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 14 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 16 | | - * General Public License for more details. |
|---|
| 17 | | - * |
|---|
| 18 | | - * You should have received a copy of the GNU General Public License along |
|---|
| 19 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
|---|
| 20 | | - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|---|
| 21 | | - * |
|---|
| 22 | | - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 23 | 8 | * |
|---|
| 24 | 9 | * This driver creates the sys I/F for programming the sensors. |
|---|
| 25 | 10 | * It also implements the driver for intel menlow memory controller (hardware |
|---|
| .. | .. |
|---|
| 29 | 14 | |
|---|
| 30 | 15 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| 31 | 16 | |
|---|
| 17 | +#include <linux/acpi.h> |
|---|
| 32 | 18 | #include <linux/kernel.h> |
|---|
| 33 | 19 | #include <linux/module.h> |
|---|
| 34 | | -#include <linux/init.h> |
|---|
| 35 | | -#include <linux/slab.h> |
|---|
| 36 | | -#include <linux/types.h> |
|---|
| 37 | 20 | #include <linux/pci.h> |
|---|
| 38 | 21 | #include <linux/pm.h> |
|---|
| 22 | +#include <linux/slab.h> |
|---|
| 39 | 23 | #include <linux/thermal.h> |
|---|
| 40 | | -#include <linux/acpi.h> |
|---|
| 24 | +#include <linux/types.h> |
|---|
| 25 | +#include <linux/units.h> |
|---|
| 41 | 26 | |
|---|
| 42 | 27 | MODULE_AUTHOR("Thomas Sujith"); |
|---|
| 43 | 28 | MODULE_AUTHOR("Zhang Rui"); |
|---|
| 44 | 29 | MODULE_DESCRIPTION("Intel Menlow platform specific driver"); |
|---|
| 45 | | -MODULE_LICENSE("GPL"); |
|---|
| 30 | +MODULE_LICENSE("GPL v2"); |
|---|
| 46 | 31 | |
|---|
| 47 | 32 | /* |
|---|
| 48 | 33 | * Memory controller device control |
|---|
| .. | .. |
|---|
| 196 | 181 | |
|---|
| 197 | 182 | static int intel_menlow_memory_remove(struct acpi_device *device) |
|---|
| 198 | 183 | { |
|---|
| 199 | | - struct thermal_cooling_device *cdev = acpi_driver_data(device); |
|---|
| 184 | + struct thermal_cooling_device *cdev; |
|---|
| 200 | 185 | |
|---|
| 201 | | - if (!device || !cdev) |
|---|
| 186 | + if (!device) |
|---|
| 187 | + return -EINVAL; |
|---|
| 188 | + |
|---|
| 189 | + cdev = acpi_driver_data(device); |
|---|
| 190 | + if (!cdev) |
|---|
| 202 | 191 | return -EINVAL; |
|---|
| 203 | 192 | |
|---|
| 204 | 193 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); |
|---|
| .. | .. |
|---|
| 314 | 303 | int result; |
|---|
| 315 | 304 | |
|---|
| 316 | 305 | result = sensor_get_auxtrip(attr->handle, idx, &value); |
|---|
| 306 | + if (result) |
|---|
| 307 | + return result; |
|---|
| 317 | 308 | |
|---|
| 318 | | - return result ? result : sprintf(buf, "%lu", DECI_KELVIN_TO_CELSIUS(value)); |
|---|
| 309 | + return sprintf(buf, "%lu", deci_kelvin_to_celsius(value)); |
|---|
| 319 | 310 | } |
|---|
| 320 | 311 | |
|---|
| 321 | 312 | static ssize_t aux0_show(struct device *dev, |
|---|
| .. | .. |
|---|
| 344 | 335 | if (value < 0) |
|---|
| 345 | 336 | return -EINVAL; |
|---|
| 346 | 337 | |
|---|
| 347 | | - result = sensor_set_auxtrip(attr->handle, idx, |
|---|
| 348 | | - CELSIUS_TO_DECI_KELVIN(value)); |
|---|
| 338 | + result = sensor_set_auxtrip(attr->handle, idx, |
|---|
| 339 | + celsius_to_deci_kelvin(value)); |
|---|
| 349 | 340 | return result ? result : count; |
|---|
| 350 | 341 | } |
|---|
| 351 | 342 | |
|---|