![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only */ 0002 /* Copyright (c) 2021 Intel Corporation */ 0003 0004 #include <linux/mutex.h> 0005 #include <linux/types.h> 0006 0007 #ifndef __PECI_HWMON_COMMON_H 0008 #define __PECI_HWMON_COMMON_H 0009 0010 #define PECI_HWMON_UPDATE_INTERVAL HZ 0011 0012 /** 0013 * struct peci_sensor_state - PECI state information 0014 * @valid: flag to indicate the sensor value is valid 0015 * @last_updated: time of the last update in jiffies 0016 * @lock: mutex to protect sensor access 0017 */ 0018 struct peci_sensor_state { 0019 bool valid; 0020 unsigned long last_updated; 0021 struct mutex lock; /* protect sensor access */ 0022 }; 0023 0024 /** 0025 * struct peci_sensor_data - PECI sensor information 0026 * @value: sensor value in milli units 0027 * @state: sensor update state 0028 */ 0029 0030 struct peci_sensor_data { 0031 s32 value; 0032 struct peci_sensor_state state; 0033 }; 0034 0035 /** 0036 * peci_sensor_need_update() - check whether sensor update is needed or not 0037 * @sensor: pointer to sensor data struct 0038 * 0039 * Return: true if update is needed, false if not. 0040 */ 0041 0042 static inline bool peci_sensor_need_update(struct peci_sensor_state *state) 0043 { 0044 return !state->valid || 0045 time_after(jiffies, state->last_updated + PECI_HWMON_UPDATE_INTERVAL); 0046 } 0047 0048 /** 0049 * peci_sensor_mark_updated() - mark the sensor is updated 0050 * @sensor: pointer to sensor data struct 0051 */ 0052 static inline void peci_sensor_mark_updated(struct peci_sensor_state *state) 0053 { 0054 state->valid = true; 0055 state->last_updated = jiffies; 0056 } 0057 0058 #endif /* __PECI_HWMON_COMMON_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |