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
83 lines
1.8 KiB
C
83 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* INT3401 processor thermal device
|
|
* Copyright (c) 2020, Intel Corporation.
|
|
*/
|
|
#include <linux/acpi.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/thermal.h>
|
|
|
|
#include "int340x_thermal_zone.h"
|
|
#include "processor_thermal_device.h"
|
|
|
|
static const struct acpi_device_id int3401_device_ids[] = {
|
|
{"INT3401", 0},
|
|
{"", 0},
|
|
};
|
|
MODULE_DEVICE_TABLE(acpi, int3401_device_ids);
|
|
|
|
static int int3401_add(struct platform_device *pdev)
|
|
{
|
|
struct proc_thermal_device *proc_priv;
|
|
int ret;
|
|
|
|
proc_priv = devm_kzalloc(&pdev->dev, sizeof(*proc_priv), GFP_KERNEL);
|
|
if (!proc_priv)
|
|
return -ENOMEM;
|
|
|
|
ret = proc_thermal_add(&pdev->dev, proc_priv);
|
|
if (ret)
|
|
return ret;
|
|
|
|
platform_set_drvdata(pdev, proc_priv);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int int3401_remove(struct platform_device *pdev)
|
|
{
|
|
proc_thermal_remove(platform_get_drvdata(pdev));
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_PM_SLEEP
|
|
static int int3401_thermal_resume(struct device *dev)
|
|
{
|
|
return proc_thermal_resume(dev);
|
|
}
|
|
#else
|
|
#define int3401_thermal_resume NULL
|
|
#endif
|
|
|
|
static SIMPLE_DEV_PM_OPS(int3401_proc_thermal_pm, NULL, int3401_thermal_resume);
|
|
|
|
static struct platform_driver int3401_driver = {
|
|
.probe = int3401_add,
|
|
.remove = int3401_remove,
|
|
.driver = {
|
|
.name = "int3401 thermal",
|
|
.acpi_match_table = int3401_device_ids,
|
|
.pm = &int3401_proc_thermal_pm,
|
|
},
|
|
};
|
|
|
|
static int __init proc_thermal_init(void)
|
|
{
|
|
return platform_driver_register(&int3401_driver);
|
|
}
|
|
|
|
static void __exit proc_thermal_exit(void)
|
|
{
|
|
platform_driver_unregister(&int3401_driver);
|
|
}
|
|
|
|
module_init(proc_thermal_init);
|
|
module_exit(proc_thermal_exit);
|
|
|
|
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
|
|
MODULE_DESCRIPTION("Processor Thermal Reporting Device Driver");
|
|
MODULE_LICENSE("GPL v2");
|