Commit 333478a7 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux

Pull thermal management fixes from Zhang Rui:

 - Fix a race condition that sysfs could be accessed before necessary
   initialization in int340x thermal driver. (Aaron Hill)

 - Fix a NULL vs IS_ERR() check in int340x thermal driver. (Dan
   Carpenter)

* 'for-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
  drivers: thermal: int340x_thermal: Fix sysfs race condition
  thermal: int340x_thermal: Fix a NULL vs IS_ERR() check
parents 0b0d4be6 129699bb
...@@ -84,7 +84,12 @@ static ssize_t power_limit_##index##_##suffix##_show(struct device *dev, \ ...@@ -84,7 +84,12 @@ static ssize_t power_limit_##index##_##suffix##_show(struct device *dev, \
struct pci_dev *pci_dev; \ struct pci_dev *pci_dev; \
struct platform_device *pdev; \ struct platform_device *pdev; \
struct proc_thermal_device *proc_dev; \ struct proc_thermal_device *proc_dev; \
\ \
if (proc_thermal_emum_mode == PROC_THERMAL_NONE) { \
dev_warn(dev, "Attempted to get power limit before device was initialized!\n"); \
return 0; \
} \
\
if (proc_thermal_emum_mode == PROC_THERMAL_PLATFORM_DEV) { \ if (proc_thermal_emum_mode == PROC_THERMAL_PLATFORM_DEV) { \
pdev = to_platform_device(dev); \ pdev = to_platform_device(dev); \
proc_dev = platform_get_drvdata(pdev); \ proc_dev = platform_get_drvdata(pdev); \
...@@ -298,11 +303,6 @@ static int proc_thermal_add(struct device *dev, ...@@ -298,11 +303,6 @@ static int proc_thermal_add(struct device *dev,
*priv = proc_priv; *priv = proc_priv;
ret = proc_thermal_read_ppcc(proc_priv); ret = proc_thermal_read_ppcc(proc_priv);
if (!ret) {
ret = sysfs_create_group(&dev->kobj,
&power_limit_attribute_group);
}
if (ret) if (ret)
return ret; return ret;
...@@ -316,8 +316,7 @@ static int proc_thermal_add(struct device *dev, ...@@ -316,8 +316,7 @@ static int proc_thermal_add(struct device *dev,
proc_priv->int340x_zone = int340x_thermal_zone_add(adev, ops); proc_priv->int340x_zone = int340x_thermal_zone_add(adev, ops);
if (IS_ERR(proc_priv->int340x_zone)) { if (IS_ERR(proc_priv->int340x_zone)) {
ret = PTR_ERR(proc_priv->int340x_zone); return PTR_ERR(proc_priv->int340x_zone);
goto remove_group;
} else } else
ret = 0; ret = 0;
...@@ -331,9 +330,6 @@ static int proc_thermal_add(struct device *dev, ...@@ -331,9 +330,6 @@ static int proc_thermal_add(struct device *dev,
remove_zone: remove_zone:
int340x_thermal_zone_remove(proc_priv->int340x_zone); int340x_thermal_zone_remove(proc_priv->int340x_zone);
remove_group:
sysfs_remove_group(&proc_priv->dev->kobj,
&power_limit_attribute_group);
return ret; return ret;
} }
...@@ -364,7 +360,10 @@ static int int3401_add(struct platform_device *pdev) ...@@ -364,7 +360,10 @@ static int int3401_add(struct platform_device *pdev)
platform_set_drvdata(pdev, proc_priv); platform_set_drvdata(pdev, proc_priv);
proc_thermal_emum_mode = PROC_THERMAL_PLATFORM_DEV; proc_thermal_emum_mode = PROC_THERMAL_PLATFORM_DEV;
return 0; dev_info(&pdev->dev, "Creating sysfs group for PROC_THERMAL_PLATFORM_DEV\n");
return sysfs_create_group(&pdev->dev.kobj,
&power_limit_attribute_group);
} }
static int int3401_remove(struct platform_device *pdev) static int int3401_remove(struct platform_device *pdev)
...@@ -423,7 +422,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, ...@@ -423,7 +422,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev,
proc_priv->soc_dts = intel_soc_dts_iosf_init( proc_priv->soc_dts = intel_soc_dts_iosf_init(
INTEL_SOC_DTS_INTERRUPT_MSI, 2, 0); INTEL_SOC_DTS_INTERRUPT_MSI, 2, 0);
if (proc_priv->soc_dts && pdev->irq) { if (!IS_ERR(proc_priv->soc_dts) && pdev->irq) {
ret = pci_enable_msi(pdev); ret = pci_enable_msi(pdev);
if (!ret) { if (!ret) {
ret = request_threaded_irq(pdev->irq, NULL, ret = request_threaded_irq(pdev->irq, NULL,
...@@ -441,7 +440,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, ...@@ -441,7 +440,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev,
dev_err(&pdev->dev, "No auxiliary DTSs enabled\n"); dev_err(&pdev->dev, "No auxiliary DTSs enabled\n");
} }
return 0; dev_info(&pdev->dev, "Creating sysfs group for PROC_THERMAL_PCI\n");
return sysfs_create_group(&pdev->dev.kobj,
&power_limit_attribute_group);
} }
static void proc_thermal_pci_remove(struct pci_dev *pdev) static void proc_thermal_pci_remove(struct pci_dev *pdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment