| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Support for the S1 button on Routerboard 532 |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2009 Phil Sutter <n0-1@freewrt.org> |
|---|
| 5 | 6 | */ |
|---|
| 6 | 7 | |
|---|
| 7 | | -#include <linux/input-polldev.h> |
|---|
| 8 | +#include <linux/input.h> |
|---|
| 8 | 9 | #include <linux/module.h> |
|---|
| 9 | 10 | #include <linux/platform_device.h> |
|---|
| 10 | 11 | #include <linux/gpio.h> |
|---|
| .. | .. |
|---|
| 45 | 46 | return !val; |
|---|
| 46 | 47 | } |
|---|
| 47 | 48 | |
|---|
| 48 | | -static void rb532_button_poll(struct input_polled_dev *poll_dev) |
|---|
| 49 | +static void rb532_button_poll(struct input_dev *input) |
|---|
| 49 | 50 | { |
|---|
| 50 | | - input_report_key(poll_dev->input, RB532_BTN_KSYM, |
|---|
| 51 | | - rb532_button_pressed()); |
|---|
| 52 | | - input_sync(poll_dev->input); |
|---|
| 51 | + input_report_key(input, RB532_BTN_KSYM, rb532_button_pressed()); |
|---|
| 52 | + input_sync(input); |
|---|
| 53 | 53 | } |
|---|
| 54 | 54 | |
|---|
| 55 | 55 | static int rb532_button_probe(struct platform_device *pdev) |
|---|
| 56 | 56 | { |
|---|
| 57 | | - struct input_polled_dev *poll_dev; |
|---|
| 57 | + struct input_dev *input; |
|---|
| 58 | 58 | int error; |
|---|
| 59 | 59 | |
|---|
| 60 | | - poll_dev = input_allocate_polled_device(); |
|---|
| 61 | | - if (!poll_dev) |
|---|
| 60 | + input = devm_input_allocate_device(&pdev->dev); |
|---|
| 61 | + if (!input) |
|---|
| 62 | 62 | return -ENOMEM; |
|---|
| 63 | 63 | |
|---|
| 64 | | - poll_dev->poll = rb532_button_poll; |
|---|
| 65 | | - poll_dev->poll_interval = RB532_BTN_RATE; |
|---|
| 64 | + input->name = "rb532 button"; |
|---|
| 65 | + input->phys = "rb532/button0"; |
|---|
| 66 | + input->id.bustype = BUS_HOST; |
|---|
| 66 | 67 | |
|---|
| 67 | | - poll_dev->input->name = "rb532 button"; |
|---|
| 68 | | - poll_dev->input->phys = "rb532/button0"; |
|---|
| 69 | | - poll_dev->input->id.bustype = BUS_HOST; |
|---|
| 70 | | - poll_dev->input->dev.parent = &pdev->dev; |
|---|
| 68 | + input_set_capability(input, EV_KEY, RB532_BTN_KSYM); |
|---|
| 71 | 69 | |
|---|
| 72 | | - dev_set_drvdata(&pdev->dev, poll_dev); |
|---|
| 73 | | - |
|---|
| 74 | | - input_set_capability(poll_dev->input, EV_KEY, RB532_BTN_KSYM); |
|---|
| 75 | | - |
|---|
| 76 | | - error = input_register_polled_device(poll_dev); |
|---|
| 77 | | - if (error) { |
|---|
| 78 | | - input_free_polled_device(poll_dev); |
|---|
| 70 | + error = input_setup_polling(input, rb532_button_poll); |
|---|
| 71 | + if (error) |
|---|
| 79 | 72 | return error; |
|---|
| 80 | | - } |
|---|
| 81 | 73 | |
|---|
| 82 | | - return 0; |
|---|
| 83 | | -} |
|---|
| 74 | + input_set_poll_interval(input, RB532_BTN_RATE); |
|---|
| 84 | 75 | |
|---|
| 85 | | -static int rb532_button_remove(struct platform_device *pdev) |
|---|
| 86 | | -{ |
|---|
| 87 | | - struct input_polled_dev *poll_dev = dev_get_drvdata(&pdev->dev); |
|---|
| 88 | | - |
|---|
| 89 | | - input_unregister_polled_device(poll_dev); |
|---|
| 90 | | - input_free_polled_device(poll_dev); |
|---|
| 76 | + error = input_register_device(input); |
|---|
| 77 | + if (error) |
|---|
| 78 | + return error; |
|---|
| 91 | 79 | |
|---|
| 92 | 80 | return 0; |
|---|
| 93 | 81 | } |
|---|
| 94 | 82 | |
|---|
| 95 | 83 | static struct platform_driver rb532_button_driver = { |
|---|
| 96 | 84 | .probe = rb532_button_probe, |
|---|
| 97 | | - .remove = rb532_button_remove, |
|---|
| 98 | 85 | .driver = { |
|---|
| 99 | 86 | .name = DRV_NAME, |
|---|
| 100 | 87 | }, |
|---|