Skip to content

Commit e90eb1d

Browse files
dlezcanorafaeljw
authored andcommitted
thermal: intel: processor_thermal_device_pci: Use generic trip point
Make proc_thermal_pci_probe() register the TCPU_PCI thermal zone along with the trip point used by it and drop the zone callbacks related to this trip point that are not needed any more. Signed-off-by: Daniel Lezcano <[email protected]> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 5c36cf2 commit e90eb1d

File tree

1 file changed

+22
-31
lines changed

1 file changed

+22
-31
lines changed

drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -144,34 +144,6 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
144144
return 0;
145145
}
146146

147-
static int sys_get_trip_temp(struct thermal_zone_device *tzd,
148-
int trip, int *temp)
149-
{
150-
struct proc_thermal_pci *pci_info = tzd->devdata;
151-
u32 _temp;
152-
153-
proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_THRES_0, &_temp);
154-
if (!_temp) {
155-
*temp = THERMAL_TEMP_INVALID;
156-
} else {
157-
int tjmax;
158-
159-
proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_TJMAX, &tjmax);
160-
_temp = tjmax - _temp;
161-
*temp = (unsigned long)_temp * 1000;
162-
}
163-
164-
return 0;
165-
}
166-
167-
static int sys_get_trip_type(struct thermal_zone_device *tzd, int trip,
168-
enum thermal_trip_type *type)
169-
{
170-
*type = THERMAL_TRIP_PASSIVE;
171-
172-
return 0;
173-
}
174-
175147
static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)
176148
{
177149
struct proc_thermal_pci *pci_info = tzd->devdata;
@@ -200,10 +172,26 @@ static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp
200172
return 0;
201173
}
202174

175+
static int get_trip_temp(struct proc_thermal_pci *pci_info)
176+
{
177+
int temp, tjmax;
178+
179+
proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_THRES_0, &temp);
180+
if (!temp)
181+
return THERMAL_TEMP_INVALID;
182+
183+
proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_TJMAX, &tjmax);
184+
temp = (tjmax - temp) * 1000;
185+
186+
return temp;
187+
}
188+
189+
static struct thermal_trip psv_trip = {
190+
.type = THERMAL_TRIP_PASSIVE,
191+
};
192+
203193
static struct thermal_zone_device_ops tzone_ops = {
204194
.get_temp = sys_get_curr_temp,
205-
.get_trip_temp = sys_get_trip_temp,
206-
.get_trip_type = sys_get_trip_type,
207195
.set_trip_temp = sys_set_trip_temp,
208196
};
209197

@@ -251,7 +239,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
251239
if (ret)
252240
goto err_ret_thermal;
253241

254-
pci_info->tzone = thermal_zone_device_register("TCPU_PCI", 1, 1, pci_info,
242+
psv_trip.temperature = get_trip_temp(pci_info);
243+
244+
pci_info->tzone = thermal_zone_device_register_with_trips("TCPU_PCI", &psv_trip,
245+
1, 1, pci_info,
255246
&tzone_ops,
256247
&tzone_params, 0, 0);
257248
if (IS_ERR(pci_info->tzone)) {

0 commit comments

Comments
 (0)