0
我剛開始學習linux內核,當讀平臺設備的內核代碼時,我很困惑,爲什麼不把設備當成platform_device結構的第一個成員,而是使用to_platform_device(),轉移到struct start?linux內核:爲什麼不把設備作爲platform_device的第一個成員struct
struct platform_device {
const char * name;
int id;
struct device dev;
u32 num_resources;
struct resource * resource;
const struct platform_device_id *id_entry;
/* MFD cell pointer */
struct mfd_cell *mfd_cell;
/* arch specific additions */
struct pdev_archdata archdata;
};
#define to_platform_device(x) container_of((x), struct platform_device, dev)