arch/arm/machs3c6410/machmy6410.c:
static struct gpio_keys_button my6410_buttons[] = {
{
.gpio = S3C64XX_GPN(0),
.code = KEY_UP,
.desc = "Up",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(1),
.code = KEY_DOWN,
.desc = "Down",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(2),
.code = KEY_LEFT,
.desc = "Left",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(3),
.code = KEY_RIGHT,
.desc = "Right",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(4),
.code = KEY_ENTER,
.desc = "Enter",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(5),
.code = KEY_ESC,
.desc = "Esc",
.active_low = 1,
.wakeup = 0,
}
};
static struct gpio_keys_platform_data my6410_button_data ={
.buttons =my6410_buttons,
.nbuttons =ARRAY_SIZE(my6410_buttons),
};
static struct platform_device my6410_device_button = {
.name ="gpio-keys",
.id = -1,
.dev = {
.platform_data =&my6410_button_data,
},
};
Device Drivers --->
Input device support --->
[*] Keyboards --->
<*> GPIO Buttons
在移植按键驱动时候可能出现一下错误:
arch/arm/mach-s3c64xx/mach-my6410.c:298: error: array type has incomplete element type
arch/arm/mach-s3c64xx/mach-my6410.c:300: error: field name not in record or union initializer
arch/arm/mach-s3c64xx/mach-my6410.c:300: error: (near initialization for 'my6410_buttons')
arch/arm/mach-s3c64xx/mach-my6410.c:301: error: field name not in record or union initializer
arch/arm/mach-s3c64xx/mach-my6410.c:301: error: (near initialization for 'my6410_buttons')
arch/arm/mach-s3c64xx/mach-my6410.c:302: error: field name not in record or union initializer
arch/arm/mach-s3c64xx/mach-my6410.c:302: error: (near initialization for 'my6410_buttons')
arch/arm/mach-s3c64xx/mach-my6410.c:303: error: field name not in record or union initializer
arch/arm/mach-s3c64xx/mach-my6410.c:303: error: (near initialization for 'my6410_buttons')
arch/arm/mach-s3c64xx/mach-my6410.c:304: error: field name not in record or union initialize
………………..
………………………
……………………………………
可以看出这个错误提示的意思是没有找到定义的数组,然后其他的就引起一连串的错误,解决的办法很简单就是把
#include <linux/gpio_keys.h>
这个头文件添加进去就可以了。