Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 16 May 2019 23:16:18 +0000 (16:16 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 16 May 2019 23:16:18 +0000 (16:16 -0700)
Pull thermal management updates from Zhang Rui:

 - Remove the 'module' Kconfig option for thermal subsystem framework
   because the thermal framework are required to be ready as early as
   possible to avoid overheat at boot time (Daniel Lezcano)

 - Fix a bug that thermal framework pokes disabled thermal zones upon
   resume (Wei Wang)

  - A couple of cleanups and trivial fixes on int340x thermal drivers
    (Srinivas Pandruvada, Zhang Rui, Sumeet Pawnikar)

* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
  drivers: thermal: processor_thermal: Downgrade error message
  mlxsw: Remove obsolete dependency on THERMAL=m
  hwmon/drivers/core: Simplify complex dependency
  thermal/drivers/core: Fix typo in the option name
  thermal/drivers/core: Remove depends on THERMAL in Kconfig
  thermal/drivers/core: Remove module unload code
  thermal/drivers/core: Remove the module Kconfig's option
  thermal: core: skip update disabled thermal zones after suspend
  thermal: make device_register's type argument const
  thermal: intel: int340x: processor_thermal_device: simplify to get driver data
  thermal/int3403_thermal: favor _TMP instead of PTYP

1  2 
arch/arm/configs/mini2440_defconfig
arch/arm/configs/pxa_defconfig
drivers/hwmon/hwmon.c
drivers/net/ethernet/mellanox/mlxsw/Kconfig
drivers/thermal/Kconfig
drivers/thermal/thermal_core.c
include/linux/thermal.h

@@@ -92,7 -92,7 +92,7 @@@ CONFIG_MTD_CFI_AMDSTD=
  CONFIG_MTD_CFI_STAA=y
  CONFIG_MTD_RAM=y
  CONFIG_MTD_ROM=y
 -CONFIG_MTD_NAND=y
 +CONFIG_MTD_RAW_NAND=y
  CONFIG_MTD_NAND_S3C2410=y
  CONFIG_MTD_NAND_PLATFORM=y
  CONFIG_MTD_LPDDR=y
@@@ -152,7 -152,7 +152,7 @@@ CONFIG_SPI_S3C24XX=
  CONFIG_SPI_SPIDEV=y
  CONFIG_GPIO_SYSFS=y
  CONFIG_SENSORS_LM75=y
- CONFIG_THERMAL=m
+ CONFIG_THERMAL=y
  CONFIG_WATCHDOG=y
  CONFIG_S3C2410_WATCHDOG=y
  CONFIG_FB=y
@@@ -185,8 -185,8 +185,8 @@@ CONFIG_MTD_PXA2XX=
  CONFIG_MTD_M25P80=m
  CONFIG_MTD_BLOCK2MTD=y
  CONFIG_MTD_DOCG3=m
 -CONFIG_MTD_NAND=m
 -CONFIG_MTD_NAND_ECC_BCH=y
 +CONFIG_MTD_RAW_NAND=m
 +CONFIG_MTD_NAND_ECC_SW_BCH=y
  CONFIG_MTD_NAND_GPIO=m
  CONFIG_MTD_NAND_DISKONCHIP=m
  CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED=y
@@@ -387,7 -387,7 +387,7 @@@ CONFIG_SENSORS_LM75=
  CONFIG_SENSORS_LM90=m
  CONFIG_SENSORS_LM95245=m
  CONFIG_SENSORS_NTC_THERMISTOR=m
- CONFIG_THERMAL=m
+ CONFIG_THERMAL=y
  CONFIG_WATCHDOG=y
  CONFIG_XILINX_WATCHDOG=m
  CONFIG_SA1100_WATCHDOG=m
diff --combined drivers/hwmon/hwmon.c
@@@ -118,9 -118,7 +118,7 @@@ static DEFINE_IDA(hwmon_ida)
   * The complex conditional is necessary to avoid a cyclic dependency
   * between hwmon and thermal_sys modules.
   */
- #if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \
-       (!defined(CONFIG_THERMAL_HWMON) || \
-        !(defined(MODULE) && IS_MODULE(CONFIG_THERMAL)))
+ #ifdef CONFIG_THERMAL_OF
  static int hwmon_thermal_get_temp(void *data, int *temp)
  {
        struct hwmon_thermal_data *tdata = data;
@@@ -324,11 -322,6 +322,11 @@@ static const char * const hwmon_chip_at
        [hwmon_chip_power_reset_history] = "power_reset_history",
        [hwmon_chip_update_interval] = "update_interval",
        [hwmon_chip_alarms] = "alarms",
 +      [hwmon_chip_samples] = "samples",
 +      [hwmon_chip_curr_samples] = "curr_samples",
 +      [hwmon_chip_in_samples] = "in_samples",
 +      [hwmon_chip_power_samples] = "power_samples",
 +      [hwmon_chip_temp_samples] = "temp_samples",
  };
  
  static const char * const hwmon_temp_attr_templates[] = {
@@@ -4,7 -4,6 +4,7 @@@
  
  config MLXSW_CORE
        tristate "Mellanox Technologies Switch ASICs support"
 +      select NET_DEVLINK
        ---help---
          This driver supports Mellanox Technologies Switch ASICs family.
  
@@@ -22,7 -21,6 +22,6 @@@ config MLXSW_CORE_HWMO
  config MLXSW_CORE_THERMAL
        bool "Thermal zone support for Mellanox Technologies Switch ASICs"
        depends on MLXSW_CORE && THERMAL
-       depends on !(MLXSW_CORE=y && THERMAL=m)
        default y
        ---help---
         Say Y here if you want to automatically control fans speed according
diff --combined drivers/thermal/Kconfig
@@@ -3,7 -3,7 +3,7 @@@
  #
  
  menuconfig THERMAL
-       tristate "Generic Thermal sysfs driver"
+       bool "Generic Thermal sysfs driver"
        help
          Generic Thermal Sysfs driver offers a generic mechanism for
          thermal management. Usually it's made up of one or more thermal
@@@ -11,7 -11,7 +11,7 @@@
          Each thermal zone contains its own temperature, trip points,
          cooling devices.
          All platforms with ACPI thermal support can use this driver.
-         If you want this support, you should say Y or M here.
+         If you want this support, you should say Y here.
  
  if THERMAL
  
@@@ -24,7 -24,6 +24,6 @@@ config THERMAL_STATISTIC
  
  config THERMAL_EMERGENCY_POWEROFF_DELAY_MS
        int "Emergency poweroff delay in milli-seconds"
-       depends on THERMAL
        default 0
        help
          Thermal subsystem will issue a graceful shutdown when
@@@ -149,10 -148,9 +148,9 @@@ config THERMAL_GOV_POWER_ALLOCATO
          allocating and limiting power to devices.
  
  config CPU_THERMAL
-       bool "generic cpu cooling support"
+       bool "Generic cpu cooling support"
        depends on CPU_FREQ
        depends on THERMAL_OF
-       depends on THERMAL=y
        help
          This implements the generic cpu cooling mechanism through frequency
          reduction. An ACPI version of this already exists
@@@ -200,17 -198,6 +198,17 @@@ config THERMAL_EMULATIO
          because userland can easily disable the thermal policy by simply
          flooding this sysfs node with low temperature values.
  
 +config THERMAL_MMIO
 +      tristate "Generic Thermal MMIO driver"
 +      depends on OF || COMPILE_TEST
 +      depends on HAS_IOMEM
 +      help
 +        This option enables the generic thermal MMIO driver that will use
 +        memory-mapped reads to get the temperature.  Any HW/System that
 +        allows temperature reading by a single memory-mapped reading, be it
 +        register or shared memory, is a potential candidate to work with this
 +        driver.
 +
  config HISI_THERMAL
        tristate "Hisilicon thermal driver"
        depends on ARCH_HISI || COMPILE_TEST
@@@ -266,7 -266,7 +266,7 @@@ static int __init thermal_register_gove
        return thermal_gov_power_allocator_register();
  }
  
- static void thermal_unregister_governors(void)
+ static void __init thermal_unregister_governors(void)
  {
        thermal_gov_step_wise_unregister();
        thermal_gov_fair_share_unregister();
@@@ -941,7 -941,7 +941,7 @@@ static void bind_cdev(struct thermal_co
   */
  static struct thermal_cooling_device *
  __thermal_cooling_device_register(struct device_node *np,
-                                 char *type, void *devdata,
+                                 const char *type, void *devdata,
                                  const struct thermal_cooling_device_ops *ops)
  {
        struct thermal_cooling_device *cdev;
   * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
   */
  struct thermal_cooling_device *
- thermal_cooling_device_register(char *type, void *devdata,
+ thermal_cooling_device_register(const char *type, void *devdata,
                                const struct thermal_cooling_device_ops *ops)
  {
        return __thermal_cooling_device_register(NULL, type, devdata, ops);
@@@ -1039,62 -1039,13 +1039,62 @@@ EXPORT_SYMBOL_GPL(thermal_cooling_devic
   */
  struct thermal_cooling_device *
  thermal_of_cooling_device_register(struct device_node *np,
-                                  char *type, void *devdata,
+                                  const char *type, void *devdata,
                                   const struct thermal_cooling_device_ops *ops)
  {
        return __thermal_cooling_device_register(np, type, devdata, ops);
  }
  EXPORT_SYMBOL_GPL(thermal_of_cooling_device_register);
  
 +static void thermal_cooling_device_release(struct device *dev, void *res)
 +{
 +      thermal_cooling_device_unregister(
 +                              *(struct thermal_cooling_device **)res);
 +}
 +
 +/**
 + * devm_thermal_of_cooling_device_register() - register an OF thermal cooling
 + *                                           device
 + * @dev:      a valid struct device pointer of a sensor device.
 + * @np:               a pointer to a device tree node.
 + * @type:     the thermal cooling device type.
 + * @devdata:  device private data.
 + * @ops:      standard thermal cooling devices callbacks.
 + *
 + * This function will register a cooling device with device tree node reference.
 + * This interface function adds a new thermal cooling device (fan/processor/...)
 + * to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself
 + * to all the thermal zone devices registered at the same time.
 + *
 + * Return: a pointer to the created struct thermal_cooling_device or an
 + * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
 + */
 +struct thermal_cooling_device *
 +devm_thermal_of_cooling_device_register(struct device *dev,
 +                              struct device_node *np,
 +                              char *type, void *devdata,
 +                              const struct thermal_cooling_device_ops *ops)
 +{
 +      struct thermal_cooling_device **ptr, *tcd;
 +
 +      ptr = devres_alloc(thermal_cooling_device_release, sizeof(*ptr),
 +                         GFP_KERNEL);
 +      if (!ptr)
 +              return ERR_PTR(-ENOMEM);
 +
 +      tcd = __thermal_cooling_device_register(np, type, devdata, ops);
 +      if (IS_ERR(tcd)) {
 +              devres_free(ptr);
 +              return tcd;
 +      }
 +
 +      *ptr = tcd;
 +      devres_add(dev, ptr);
 +
 +      return tcd;
 +}
 +EXPORT_SYMBOL_GPL(devm_thermal_of_cooling_device_register);
 +
  static void __unbind(struct thermal_zone_device *tz, int mask,
                     struct thermal_cooling_device *cdev)
  {
@@@ -1543,6 -1494,7 +1543,7 @@@ static int thermal_pm_notify(struct not
                             unsigned long mode, void *_unused)
  {
        struct thermal_zone_device *tz;
+       enum thermal_device_mode tz_mode;
  
        switch (mode) {
        case PM_HIBERNATION_PREPARE:
        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);
+                       if (tz_mode == THERMAL_DEVICE_DISABLED)
+                               continue;
                        thermal_zone_device_init(tz);
                        thermal_zone_device_update(tz,
                                                   THERMAL_EVENT_UNSPECIFIED);
@@@ -1612,19 -1571,4 +1620,4 @@@ error
        mutex_destroy(&poweroff_lock);
        return result;
  }
- static void __exit thermal_exit(void)
- {
-       unregister_pm_notifier(&thermal_pm_nb);
-       of_thermal_destroy_zones();
-       genetlink_exit();
-       class_unregister(&thermal_class);
-       thermal_unregister_governors();
-       ida_destroy(&thermal_tz_ida);
-       ida_destroy(&thermal_cdev_ida);
-       mutex_destroy(&thermal_list_lock);
-       mutex_destroy(&thermal_governor_lock);
- }
  fs_initcall(thermal_init);
- module_exit(thermal_exit);
diff --combined include/linux/thermal.h
@@@ -442,16 -442,11 +442,16 @@@ void thermal_zone_device_update(struct 
                                enum thermal_notify_event);
  void thermal_zone_set_trips(struct thermal_zone_device *);
  
- struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
-               const struct thermal_cooling_device_ops *);
+ struct thermal_cooling_device *thermal_cooling_device_register(const char *,
+               void *, const struct thermal_cooling_device_ops *);
  struct thermal_cooling_device *
- thermal_of_cooling_device_register(struct device_node *np, char *, void *,
+ thermal_of_cooling_device_register(struct device_node *np, const char *, void *,
                                   const struct thermal_cooling_device_ops *);
 +struct thermal_cooling_device *
 +devm_thermal_of_cooling_device_register(struct device *dev,
 +                              struct device_node *np,
 +                              char *type, void *devdata,
 +                              const struct thermal_cooling_device_ops *ops);
  void thermal_cooling_device_unregister(struct thermal_cooling_device *);
  struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
  int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
@@@ -508,14 -503,6 +508,14 @@@ static inline struct thermal_cooling_de
  thermal_of_cooling_device_register(struct device_node *np,
        char *type, void *devdata, const struct thermal_cooling_device_ops *ops)
  { return ERR_PTR(-ENODEV); }
 +static inline struct thermal_cooling_device *
 +devm_thermal_of_cooling_device_register(struct device *dev,
 +                              struct device_node *np,
 +                              char *type, void *devdata,
 +                              const struct thermal_cooling_device_ops *ops)
 +{
 +      return ERR_PTR(-ENODEV);
 +}
  static inline void thermal_cooling_device_unregister(
        struct thermal_cooling_device *cdev)
  { }