thermal zone
生活随笔
收集整理的這篇文章主要介紹了
thermal zone
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
- 注冊thermal zone設(shè)備
- 函數(shù)申明
- 函數(shù)定義thermal_corec
- 函數(shù)使用
- 功能描述
- 參數(shù)說明
- 使用注意事項(xiàng)
- 使用示例
- 注冊cooling device
- 函數(shù)申明
- 函數(shù)定義thermal_corec
- 函數(shù)使用
- 功能描述
- 參數(shù)說明
- 使用示例
- thermal zone 和cool device 綁定
注冊thermal zone設(shè)備
thermal_zone_device_register函數(shù)申明:
#include <linux/thermal.h>函數(shù)定義:thermal_core.c
struct thermal_zone_device* thermal_zone_device_register(const char *type,int trips,int mask, void *devdata,struct thermal_zone_device_ops *ops,struct thermal_zone_params *tzp,int polling_delay)函數(shù)使用
功能描述
- 注冊一個thermal zone device
- 在/sys/class/thermal 目錄下面創(chuàng)建 thermal_zone[0-*]. 設(shè)備節(jié)點(diǎn)
- 創(chuàng)建對應(yīng)的thermal_zone* 下面對應(yīng)的文件節(jié)點(diǎn),定義讀寫函數(shù)回調(diào)相關(guān)tz的ops方法
- 嘗試綁定所有的cool device 到該tz
- 創(chuàng)建一個工作隊(duì)列,定時獲取溫度并采取策略
參數(shù)說明
* @type: tz設(shè)備類型,用來標(biāo)識不同tz的字符串* @trips: tz設(shè)備支持的觸發(fā)點(diǎn)個數(shù)* @mask: 要求mask 小于trips個數(shù),一般為0* @devdata: 設(shè)備私有數(shù)據(jù)* @ops: tz設(shè)備回調(diào)函數(shù),trip num大于0 的情況下,ops 中g(shù)et_trip_type 和 get_trip_temp 必須不為null* @tzp: tz的特殊參數(shù),可以用于標(biāo)識控制策略等* @passive_delay: passive cooling模式間隔ms數(shù),一般設(shè)置為0* @polling_delay: 出發(fā)點(diǎn)檢測間隔ms數(shù)使用注意事項(xiàng)
* 不需要這個tz設(shè)備的時候需要調(diào)用thermal_zone_device_unregister()來注銷* passive cooling 取決于 the .get_trend()函數(shù)的返回值* 返回一個指向thermal_zone設(shè)備的指針,需要使用IS_ERR來判斷返回值使用示例
if (IS_ERR(thermal)) {dev_err(&pdev->dev,"Failed to register thermal zone device\n");return PTR_ERR(thermal); }注冊cooling device
thermal_cooling_device_register函數(shù)申明:
#include <linux/thermal.h>函數(shù)定義:thermal_core.c
struct thermal_cooling_device * thermal_cooling_device_register(char *type, void *devdata,const struct thermal_cooling_device_ops *ops) {return __thermal_cooling_device_register(NULL, type, devdata, ops); } EXPORT_SYMBOL_GPL(thermal_cooling_device_register);實(shí)際調(diào)用的函數(shù)是:__thermal_cooling_device_register
static struct thermal_cooling_device * __thermal_cooling_device_register(struct device_node *np,char *type,void *devdata,const struct thermal_cooling_device_ops *ops)函數(shù)使用
功能描述
- 注冊一個cooling 設(shè)備
- 創(chuàng)建設(shè)備節(jié)點(diǎn)/sys/class/thermal/cooling_device[0-*]
- 嘗試將自己綁定到所有tz
- 返回一個指向cooling device 的指針
參數(shù)說明
@np: 指向設(shè)備數(shù)節(jié)點(diǎn)的指針@type: cooling device的設(shè)備類型@devdata: 設(shè)備私有數(shù)據(jù)@ops: 設(shè)備操作的回調(diào)函數(shù),ops必須定義并且必須至少包含 get_max_state,get_cur_state,set_cur_state方法使用示例:
cdev = thermal_cooling_device_register("xxxx", NULL, &xxx_cooling_ops); if (IS_ERR(cdev)) {retval = PTR_ERR(cdev); goto err1; }thermal zone 和cool device 綁定
在thermal zone 和 cool device 設(shè)備注冊的時候會分別調(diào)用bind_tz(tz)和bind_cdev(cdev) 進(jìn)行綁定
這樣就可以保證無論兩個設(shè)備的注冊順序如何都不會出現(xiàn)綁定不成功的意外
綁定規(guī)則如下:
- 遍歷thermal_tz_list,如果當(dāng)前tz 定義了bind 回調(diào)函數(shù),就使用該回調(diào)函數(shù)決定是否綁定成功
- 如果當(dāng)前tz沒有定義bind 回調(diào)函數(shù),則通過tz 注冊時候的tzp->tbp 相關(guān)規(guī)則綁定
- 如果tzp->tbp 和bind 都沒有定義,直接調(diào)到下個tz進(jìn)行綁定
總結(jié)
以上是生活随笔為你收集整理的thermal zone的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 5G(NR)网络中的SRB定义和类型
- 下一篇: character在mysql什么类型_