Platform: Rockchip
OS: Android 6.0
Kernel: 3.10.92
有看到網友在讨論device tree中的status到底該如何設定,預設狀态是什麼,知識點如下:
- 預設情況下不設定status屬性的話表示此節點的功能是enable的
- 如果要設定status,那麼值必須是”okay”或者”ok”
- dts裡的status屬性值會覆寫dtsi中的值(編譯dtb的時候會覆寫)
對應代碼在kernel/drivers/of/base.c:
/**
* of_device_is_available - check if a device is available for use
*
* @device: Node to check for availability
*
* Returns if the status property is absent or set to "okay" or "ok",
* otherwise
*/
int of_device_is_available(const struct device_node *device)
{
unsigned long flags;
int res;
raw_spin_lock_irqsave(&devtree_lock, flags);
res = __of_device_is_available(device);
raw_spin_unlock_irqrestore(&devtree_lock, flags);
return res;
}
__of_device_is_available():
/**
* __of_device_is_available - check if a device is available for use
*
* @device: Node to check for availability, with locks already held
*
* Returns 1 if the status property is absent or set to "okay" or "ok",
* 0 otherwise
*/
static int __of_device_is_available(const struct device_node *device)
{
const char *status;
int statlen;
status = __of_get_property(device, "status", &statlen);
if (status == NULL)
return ;
if (statlen > ) {
if (!strcmp(status, "okay") || !strcmp(status, "ok"))
return ;
}
return ;
}
參考:
Linux Device Tree: What those status = “okay” are about