为按键申请中断失败。
linux 2.6.29
修改的gpio_keys.c
复制代码
我在arch/arm/mach-s5pc100/mach-smdks5pc100.c里加入的
复制代码
请问各位我还有哪里没有改对?
修改的gpio_keys.c
- static int __devinit gpio_keys_probe(struct platform_device *pdev)
- {
- struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
- struct input_dev *input;
- int i, error;
- int wakeup = 0;
-
- input = input_allocate_device();
- if (!input)
- return -ENOMEM;
-
- platform_set_drvdata(pdev, input);
-
- input->evbit[0] = BIT_MASK(EV_KEY);
-
- input->name = pdev->name;
- input->phys = "gpio-keys/input0";
- input->dev.parent = &pdev->dev;
-
- input->id.bustype = BUS_HOST;
- input->id.vendor = 0x0001;
- input->id.product = 0x0001;
- input->id.version = 0x0100;
-
- for (i = 0; i < pdata->nbuttons; i++) {
- struct gpio_keys_button *button = &pdata->buttons[i];
- int irq;
- unsigned int type = button->type ?: EV_KEY;
-
- error = gpio_request(button->gpio, button->desc ?: "gpio_keys");
- if (error < 0) {
- pr_err("gpio-keys: failed to request GPIO %d,"
- " error %d\n", button->gpio, error);
- goto fail;
- }
-
- error = gpio_direction_input(button->gpio);
- if (error < 0) {
- pr_err("gpio-keys: failed to configure input"
- " direction for GPIO %d, error %d\n",
- button->gpio, error);
- gpio_free(button->gpio);
- goto fail;
- }
-
- irq = gpio_to_irq(button->gpio);
- if (irq < 0) {
- error = irq;
- ==================这里申请中断失败了===================================================
- pr_err("gpio-keys: Unable to get irq number"
- " for GPIO %d, error %d\n",
- button->gpio, error);
- gpio_free(button->gpio);
- ======================================================================
- goto fail;
- }
-
- error = request_irq(irq, gpio_keys_isr,
- IRQF_SHARED | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
- // IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING |
- // IRQF_TRIGGER_FALLING,
-
- button->desc ? button->desc : "gpio_keys",
- pdev);
- if (error) {
- pr_err("gpio-keys: Unable to claim irq %d; error %d\n",
- irq, error);
- gpio_free(button->gpio);
- goto fail;
- }
-
- if (button->wakeup)
- wakeup = 1;
-
- input_set_capability(input, type, button->code);
- }
-
- error = input_register_device(input);
- if (error) {
- pr_err("gpio-keys: Unable to register input device, "
- "error: %d\n", error);
- goto fail;
- }
-
- device_init_wakeup(&pdev->dev, wakeup);
-
- return 0;
-
- fail:
- while (--i >= 0) {
- free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev);
- gpio_free(pdata->buttons[i].gpio);
- }
-
- platform_set_drvdata(pdev, NULL);
- input_free_device(input);
-
- return error;
- }
- static struct gpio_keys_button gpio_keys_button[] = {
- [0] = {
- .desc = "ENTER",
- .code = KEY_ENTER,
- .type = EV_KEY,
- .gpio = S5PC1XX_GPH0(1),
- .wakeup = 0,
- .active_low = 0,
- },
- [1] = {
- .desc = "DOWN",
- .code = KEY_DOWN,
- .type = EV_KEY,
- .gpio = S5PC1XX_GPH0(2),
- .wakeup = 0,
- },
- [2] = {
- .desc = "RIGHT",
- .code = KEY_RIGHT,
- .type = EV_KEY,
- .gpio = S5PC1XX_GPH0(3),
- .wakeup = 0,
- },
- [3] = {
- .desc = "LEFT",
- .code = KEY_LEFT,
- .type = EV_KEY,
- .gpio = S5PC1XX_GPH0(4),
- .wakeup = 0,
- },
- [4] = {
- .desc = "ESCAPE",
- .code = KEY_ESC,
- .type = EV_KEY,
- .gpio = S5PC1XX_GPH0(6),
- .wakeup = 0,
- },
- [5] = {
- .desc = "SPACE",
- .code = KEY_SPACE,
- .type = EV_KEY,
- .gpio = S5PC1XX_GPH0(7),
- .wakeup = 0,
- },
- [6] = {
- .desc = "UP",
- .code = KEY_UP,
- .type = EV_KEY,
- .gpio = S5PC1XX_GPH1(3),
- .wakeup = 0,
- },
-
- };
-
- static struct gpio_keys_platform_data pixstar_gpio_keys = {
- .buttons = gpio_keys_button,
- .nbuttons = 7,
- };
-
- static struct platform_device pix_gpio_keys_device = {
- .name = "gpio-keys",
- .id = -1,
- .dev = {
- .platform_data = &pixstar_gpio_keys,
- },
- };
作者: jn200002 发布时间: 2011-01-11
结贴
没有对应gpio_to_irq的头文件,没有对应关系
gpio_to_irq()
没有对应gpio_to_irq的头文件,没有对应关系
gpio_to_irq()
作者: jn200002 发布时间: 2011-01-12