在itop4412驱动中,驱动的名字,可以和设备的名字不一样,理解过程:
在驱动中,有以下定义。
#define DRIVER_NAME “hello_ctl” // 驱动的名字。
#define DEVICE_NAME “hello_gpio” // 设备的名字;
在开发板上的显示:
[root@iTOP-4412]# **ls /sys/bus/platform/devices/**
...
**hello_ctl** s3c64xx-spi.2 samsung-pd.0
...
[root@iTOP-4412]# **ls /sys/bus/platform/drivers**
...
**hello_ctl** s3c24xx-pwm si_gps
...
[root@iTOP-4412]# **ls /dev/**
...
**hello_gpio** mmcblk1 ram8 ttySAC3
...
但是:
#define DRIVER_NAME “hello_ctl” // 驱动的名字。
需要与内核中,定义的设备结构体名字相同,方能正确匹配。
// 定义对应设备的结构体。
#ifdef CONFIG_HELLO_CTL
struct platform_device s3c_device_hello_ctl = {
.name = "hello_ctl", // 设备的名字,只要编译进内核中,不管驱动加载与否,在 /sys/bus/platform/devices 中,都会出现。
.id = -1,
};
#endif
// 在平台设备列表中,将会加载这个设备。
static struct platform_device *smdk4x12_devices[] __initdata = {
...
#ifdef CONFIG_HELLO_CTL
&s3c_device_hello_ctl,
#endif
...
}