FILE
common.h
File preview with syntax highlighting.
linux-6.19.14/drivers/hwmon/peci/common.h
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* Copyright (c) 2021 Intel Corporation */ 3 4#include <linux/types.h> 5 6#ifndef __PECI_HWMON_COMMON_H 7#define __PECI_HWMON_COMMON_H 8 9#define PECI_HWMON_UPDATE_INTERVAL HZ 10 11/** 12 * struct peci_sensor_state - PECI state information 13 * @valid: flag to indicate the sensor value is valid 14 * @last_updated: time of the last update in jiffies 15 */ 16struct peci_sensor_state { 17 bool valid; 18 unsigned long last_updated; 19}; 20 21/** 22 * struct peci_sensor_data - PECI sensor information 23 * @value: sensor value in milli units 24 * @state: sensor update state 25 */ 26 27struct peci_sensor_data { 28 s32 value; 29 struct peci_sensor_state state; 30}; 31 32/** 33 * peci_sensor_need_update() - check whether sensor update is needed or not 34 * @sensor: pointer to sensor data struct 35 * 36 * Return: true if update is needed, false if not. 37 */ 38 39static inline bool peci_sensor_need_update(struct peci_sensor_state *state) 40{ 41 return !state->valid || 42 time_after(jiffies, state->last_updated + PECI_HWMON_UPDATE_INTERVAL); 43} 44 45/** 46 * peci_sensor_mark_updated() - mark the sensor is updated 47 * @sensor: pointer to sensor data struct 48 */ 49static inline void peci_sensor_mark_updated(struct peci_sensor_state *state) 50{ 51 state->valid = true; 52 state->last_updated = jiffies; 53} 54 55#endif /* __PECI_HWMON_COMMON_H */
~/
Read-only file preview.