diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-03-19 02:36:29 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-03-19 20:55:45 -0400 |
commit | d9080921aa32c70a95476ce387e973787b892591 (patch) | |
tree | 8fd5bc1886551a045116ba9d60f2fb3fe42c7611 /drivers/input | |
parent | 598d3b707979847d96bc4bef455ac3a0e1ec45bd (diff) |
Input: gpio_keys - constify platform data
The platform data should not be altered and therefore should be
accessed through const pointers.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/keyboard/gpio_keys.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index ed1ed469d085..19887fc10282 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/of_gpio.h> | 30 | #include <linux/of_gpio.h> |
31 | 31 | ||
32 | struct gpio_button_data { | 32 | struct gpio_button_data { |
33 | struct gpio_keys_button *button; | 33 | const struct gpio_keys_button *button; |
34 | struct input_dev *input; | 34 | struct input_dev *input; |
35 | struct timer_list timer; | 35 | struct timer_list timer; |
36 | struct work_struct work; | 36 | struct work_struct work; |
@@ -322,7 +322,7 @@ static struct attribute_group gpio_keys_attr_group = { | |||
322 | 322 | ||
323 | static void gpio_keys_report_event(struct gpio_button_data *bdata) | 323 | static void gpio_keys_report_event(struct gpio_button_data *bdata) |
324 | { | 324 | { |
325 | struct gpio_keys_button *button = bdata->button; | 325 | const struct gpio_keys_button *button = bdata->button; |
326 | struct input_dev *input = bdata->input; | 326 | struct input_dev *input = bdata->input; |
327 | unsigned int type = button->type ?: EV_KEY; | 327 | unsigned int type = button->type ?: EV_KEY; |
328 | int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low; | 328 | int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low; |
@@ -354,7 +354,7 @@ static void gpio_keys_timer(unsigned long _data) | |||
354 | static irqreturn_t gpio_keys_isr(int irq, void *dev_id) | 354 | static irqreturn_t gpio_keys_isr(int irq, void *dev_id) |
355 | { | 355 | { |
356 | struct gpio_button_data *bdata = dev_id; | 356 | struct gpio_button_data *bdata = dev_id; |
357 | struct gpio_keys_button *button = bdata->button; | 357 | const struct gpio_keys_button *button = bdata->button; |
358 | 358 | ||
359 | BUG_ON(irq != gpio_to_irq(button->gpio)); | 359 | BUG_ON(irq != gpio_to_irq(button->gpio)); |
360 | 360 | ||
@@ -368,8 +368,9 @@ static irqreturn_t gpio_keys_isr(int irq, void *dev_id) | |||
368 | } | 368 | } |
369 | 369 | ||
370 | static int __devinit gpio_keys_setup_key(struct platform_device *pdev, | 370 | static int __devinit gpio_keys_setup_key(struct platform_device *pdev, |
371 | struct input_dev *input, | ||
371 | struct gpio_button_data *bdata, | 372 | struct gpio_button_data *bdata, |
372 | struct gpio_keys_button *button) | 373 | const struct gpio_keys_button *button) |
373 | { | 374 | { |
374 | const char *desc = button->desc ? button->desc : "gpio_keys"; | 375 | const char *desc = button->desc ? button->desc : "gpio_keys"; |
375 | struct device *dev = &pdev->dev; | 376 | struct device *dev = &pdev->dev; |
@@ -378,6 +379,8 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev, | |||
378 | 379 | ||
379 | setup_timer(&bdata->timer, gpio_keys_timer, (unsigned long)bdata); | 380 | setup_timer(&bdata->timer, gpio_keys_timer, (unsigned long)bdata); |
380 | INIT_WORK(&bdata->work, gpio_keys_work_func); | 381 | INIT_WORK(&bdata->work, gpio_keys_work_func); |
382 | bdata->input = input; | ||
383 | bdata->button = button; | ||
381 | 384 | ||
382 | error = gpio_request(button->gpio, desc); | 385 | error = gpio_request(button->gpio, desc); |
383 | if (error < 0) { | 386 | if (error < 0) { |
@@ -425,6 +428,7 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev, | |||
425 | goto fail3; | 428 | goto fail3; |
426 | } | 429 | } |
427 | 430 | ||
431 | input_set_capability(input, button->type ?: EV_KEY, button->code); | ||
428 | return 0; | 432 | return 0; |
429 | 433 | ||
430 | fail3: | 434 | fail3: |
@@ -549,7 +553,7 @@ static int gpio_keys_get_devtree_pdata(struct device *dev, | |||
549 | 553 | ||
550 | static int __devinit gpio_keys_probe(struct platform_device *pdev) | 554 | static int __devinit gpio_keys_probe(struct platform_device *pdev) |
551 | { | 555 | { |
552 | struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; | 556 | const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; |
553 | struct gpio_keys_drvdata *ddata; | 557 | struct gpio_keys_drvdata *ddata; |
554 | struct device *dev = &pdev->dev; | 558 | struct device *dev = &pdev->dev; |
555 | struct gpio_keys_platform_data alt_pdata; | 559 | struct gpio_keys_platform_data alt_pdata; |
@@ -599,21 +603,15 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) | |||
599 | __set_bit(EV_REP, input->evbit); | 603 | __set_bit(EV_REP, input->evbit); |
600 | 604 | ||
601 | for (i = 0; i < pdata->nbuttons; i++) { | 605 | for (i = 0; i < pdata->nbuttons; i++) { |
602 | struct gpio_keys_button *button = &pdata->buttons[i]; | 606 | const struct gpio_keys_button *button = &pdata->buttons[i]; |
603 | struct gpio_button_data *bdata = &ddata->data[i]; | 607 | struct gpio_button_data *bdata = &ddata->data[i]; |
604 | unsigned int type = button->type ?: EV_KEY; | ||
605 | 608 | ||
606 | bdata->input = input; | 609 | error = gpio_keys_setup_key(pdev, input, bdata, button); |
607 | bdata->button = button; | ||
608 | |||
609 | error = gpio_keys_setup_key(pdev, bdata, button); | ||
610 | if (error) | 610 | if (error) |
611 | goto fail2; | 611 | goto fail2; |
612 | 612 | ||
613 | if (button->wakeup) | 613 | if (button->wakeup) |
614 | wakeup = 1; | 614 | wakeup = 1; |
615 | |||
616 | input_set_capability(input, type, button->code); | ||
617 | } | 615 | } |
618 | 616 | ||
619 | error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); | 617 | error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); |
@@ -699,11 +697,12 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev) | |||
699 | static int gpio_keys_suspend(struct device *dev) | 697 | static int gpio_keys_suspend(struct device *dev) |
700 | { | 698 | { |
701 | struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); | 699 | struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); |
700 | const struct gpio_keys_button *button; | ||
702 | int i; | 701 | int i; |
703 | 702 | ||
704 | if (device_may_wakeup(dev)) { | 703 | if (device_may_wakeup(dev)) { |
705 | for (i = 0; i < ddata->n_buttons; i++) { | 704 | for (i = 0; i < ddata->n_buttons; i++) { |
706 | struct gpio_keys_button *button = ddata->data[i].button; | 705 | button = ddata->data[i].button; |
707 | if (button->wakeup) { | 706 | if (button->wakeup) { |
708 | int irq = gpio_to_irq(button->gpio); | 707 | int irq = gpio_to_irq(button->gpio); |
709 | enable_irq_wake(irq); | 708 | enable_irq_wake(irq); |
@@ -717,11 +716,11 @@ static int gpio_keys_suspend(struct device *dev) | |||
717 | static int gpio_keys_resume(struct device *dev) | 716 | static int gpio_keys_resume(struct device *dev) |
718 | { | 717 | { |
719 | struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); | 718 | struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); |
719 | const struct gpio_keys_button *button; | ||
720 | int i; | 720 | int i; |
721 | 721 | ||
722 | for (i = 0; i < ddata->n_buttons; i++) { | 722 | for (i = 0; i < ddata->n_buttons; i++) { |
723 | 723 | button = ddata->data[i].button; | |
724 | struct gpio_keys_button *button = ddata->data[i].button; | ||
725 | if (button->wakeup && device_may_wakeup(dev)) { | 724 | if (button->wakeup && device_may_wakeup(dev)) { |
726 | int irq = gpio_to_irq(button->gpio); | 725 | int irq = gpio_to_irq(button->gpio); |
727 | disable_irq_wake(irq); | 726 | disable_irq_wake(irq); |