Skip to content

Commit 8fe145f

Browse files
spandruvadadlezcano
authored andcommitted
thermal/drivers/int340x/processor_thermal: Split enumeration and processing part
Remove enumeration part from the processor_thermal_device to two different modules. One for ACPI and one for PCI: ACPI enumeration: int3401_thermal PCI part: processor_thermal_device_pci_legacy The current processor_thermal_device now just implements interface functions to be used by the ACPI and PCI enumeration module. This is done by: 1. Make functions proc_thermal_add() and proc_thermal_remove() non static and export them for usage in other processor_thermal_device_pci_legacy.c and in int3401_thermal.c. 2. Move the sysfs file creation for TCC offset and power limit attribute group to the proc_thermal_add() from the individual enumeration callbacks for PCI and ACPI. 3. Create new interface functions proc_thermal_mmio_add() and proc_thermal_mmio_remove() which will be called from the processor_thermal_device_pci_legacy module. 4. Export proc_thermal_resume(), so that it can be used by power management callbacks. 5. Remove special check for double enumeration as it never happens. While here, fix some cleanup on error conditions in proc_thermal_add(). No functional changes are expected with this change. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20210525204811.3793651-2-srinivas.pandruvada@linux.intel.com
1 parent 8b2ea89 commit 8fe145f

5 files changed

Lines changed: 286 additions & 259 deletions

File tree

drivers/thermal/intel/int340x_thermal/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ obj-$(CONFIG_INT340X_THERMAL) += int340x_thermal_zone.o
44
obj-$(CONFIG_INT340X_THERMAL) += int3402_thermal.o
55
obj-$(CONFIG_INT340X_THERMAL) += int3403_thermal.o
66
obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_device.o
7+
obj-$(CONFIG_INT340X_THERMAL) += int3401_thermal.o
8+
obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_device_pci_legacy.o
79
obj-$(CONFIG_PROC_THERMAL_MMIO_RAPL) += processor_thermal_rapl.o
810
obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_rfim.o
911
obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_mbox.o
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* INT3401 processor thermal device
4+
* Copyright (c) 2020, Intel Corporation.
5+
*/
6+
#include <linux/acpi.h>
7+
#include <linux/kernel.h>
8+
#include <linux/module.h>
9+
#include <linux/platform_device.h>
10+
#include <linux/thermal.h>
11+
12+
#include "int340x_thermal_zone.h"
13+
#include "processor_thermal_device.h"
14+
15+
static const struct acpi_device_id int3401_device_ids[] = {
16+
{"INT3401", 0},
17+
{"", 0},
18+
};
19+
MODULE_DEVICE_TABLE(acpi, int3401_device_ids);
20+
21+
static int int3401_add(struct platform_device *pdev)
22+
{
23+
struct proc_thermal_device *proc_priv;
24+
int ret;
25+
26+
proc_priv = devm_kzalloc(&pdev->dev, sizeof(*proc_priv), GFP_KERNEL);
27+
if (!proc_priv)
28+
return -ENOMEM;
29+
30+
ret = proc_thermal_add(&pdev->dev, proc_priv);
31+
if (ret)
32+
return ret;
33+
34+
platform_set_drvdata(pdev, proc_priv);
35+
36+
return ret;
37+
}
38+
39+
static int int3401_remove(struct platform_device *pdev)
40+
{
41+
proc_thermal_remove(platform_get_drvdata(pdev));
42+
43+
return 0;
44+
}
45+
46+
#ifdef CONFIG_PM_SLEEP
47+
static int int3401_thermal_resume(struct device *dev)
48+
{
49+
return proc_thermal_resume(dev);
50+
}
51+
#else
52+
#define int3401_thermal_resume NULL
53+
#endif
54+
55+
static SIMPLE_DEV_PM_OPS(int3401_proc_thermal_pm, NULL, int3401_thermal_resume);
56+
57+
static struct platform_driver int3401_driver = {
58+
.probe = int3401_add,
59+
.remove = int3401_remove,
60+
.driver = {
61+
.name = "int3401 thermal",
62+
.acpi_match_table = int3401_device_ids,
63+
.pm = &int3401_proc_thermal_pm,
64+
},
65+
};
66+
67+
static int __init proc_thermal_init(void)
68+
{
69+
return platform_driver_register(&int3401_driver);
70+
}
71+
72+
static void __exit proc_thermal_exit(void)
73+
{
74+
platform_driver_unregister(&int3401_driver);
75+
}
76+
77+
module_init(proc_thermal_init);
78+
module_exit(proc_thermal_exit);
79+
80+
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
81+
MODULE_DESCRIPTION("Processor Thermal Reporting Device Driver");
82+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)