summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/peci-hwmon.h
blob: 6ca1855a86bbde643087df77cf4e4968a5d1172b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2018 Intel Corporation */

#ifndef __PECI_HWMON_H
#define __PECI_HWMON_H

#include <linux/peci.h>

#define TEMP_TYPE_PECI   6 /* Sensor type 6: Intel PECI */
#define UPDATE_INTERVAL  HZ

/**
 * struct temp_data - PECI temperature information
 * @valid: flag to indicate the temperature value is valid
 * @value: temperature value in millidegree Celsius
 * @last_updated: time of the last update in jiffies
 */
struct temp_data {
	uint  valid;
	s32   value;
	ulong last_updated;
};

/**
 * peci_temp_need_update - check whether temperature update is needed or not
 * @temp: pointer to temperature data struct
 *
 * Return: true if update is needed, false if not.
 */
static inline bool peci_temp_need_update(struct temp_data *temp)
{
	if (temp->valid &&
	    time_before(jiffies, temp->last_updated + UPDATE_INTERVAL))
		return false;

	return true;
}

/**
 * peci_temp_mark_updated - mark the temperature is updated
 * @temp: pointer to temperature data struct
 */
static inline void peci_temp_mark_updated(struct temp_data *temp)
{
	temp->valid = 1;
	temp->last_updated = jiffies;
}

#endif /* __PECI_HWMON_H */
OpenPOWER on IntegriCloud