* [PATCH] Input: move name/timer init to input_alloc_dev()
@ 2013-10-02 16:27 David Herrmann
2013-10-19 10:37 ` David Herrmann
0 siblings, 1 reply; 2+ messages in thread
From: David Herrmann @ 2013-10-02 16:27 UTC (permalink / raw)
To: linux-input; +Cc: Dmitry Torokhov, David Herrmann
We want to allow drivers to call input_event() at any time after the
device got allocated. This means input_event() and input_register_device()
must be allowed to run in parallel.
The only conflicting calls in input_register_device() are init_timer() and
dev_set_name(). Both can safely be moved to device allocation and we're
good to go.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
drivers/input/input.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index c044699..e75d015 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -1734,6 +1734,7 @@ EXPORT_SYMBOL_GPL(input_class);
*/
struct input_dev *input_allocate_device(void)
{
+ static atomic_t input_no = ATOMIC_INIT(0);
struct input_dev *dev;
dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
@@ -1743,9 +1744,13 @@ struct input_dev *input_allocate_device(void)
device_initialize(&dev->dev);
mutex_init(&dev->mutex);
spin_lock_init(&dev->event_lock);
+ init_timer(&dev->timer);
INIT_LIST_HEAD(&dev->h_list);
INIT_LIST_HEAD(&dev->node);
+ dev_set_name(&dev->dev, "input%ld",
+ (unsigned long) atomic_inc_return(&input_no) - 1);
+
__module_get(THIS_MODULE);
}
@@ -2019,7 +2024,6 @@ static void devm_input_device_unregister(struct device *dev, void *res)
*/
int input_register_device(struct input_dev *dev)
{
- static atomic_t input_no = ATOMIC_INIT(0);
struct input_devres *devres = NULL;
struct input_handler *handler;
unsigned int packet_size;
@@ -2059,7 +2063,6 @@ int input_register_device(struct input_dev *dev)
* If delay and period are pre-set by the driver, then autorepeating
* is handled by the driver itself and we don't do it in input.c.
*/
- init_timer(&dev->timer);
if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) {
dev->timer.data = (long) dev;
dev->timer.function = input_repeat_key;
@@ -2073,9 +2076,6 @@ int input_register_device(struct input_dev *dev)
if (!dev->setkeycode)
dev->setkeycode = input_default_setkeycode;
- dev_set_name(&dev->dev, "input%ld",
- (unsigned long) atomic_inc_return(&input_no) - 1);
-
error = device_add(&dev->dev);
if (error)
goto err_free_vals;
--
1.8.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: move name/timer init to input_alloc_dev()
2013-10-02 16:27 [PATCH] Input: move name/timer init to input_alloc_dev() David Herrmann
@ 2013-10-19 10:37 ` David Herrmann
0 siblings, 0 replies; 2+ messages in thread
From: David Herrmann @ 2013-10-19 10:37 UTC (permalink / raw)
To: open list:HID CORE LAYER; +Cc: Dmitry Torokhov, David Herrmann
ping
On Wed, Oct 2, 2013 at 6:27 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
> We want to allow drivers to call input_event() at any time after the
> device got allocated. This means input_event() and input_register_device()
> must be allowed to run in parallel.
>
> The only conflicting calls in input_register_device() are init_timer() and
> dev_set_name(). Both can safely be moved to device allocation and we're
> good to go.
>
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
> drivers/input/input.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index c044699..e75d015 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -1734,6 +1734,7 @@ EXPORT_SYMBOL_GPL(input_class);
> */
> struct input_dev *input_allocate_device(void)
> {
> + static atomic_t input_no = ATOMIC_INIT(0);
> struct input_dev *dev;
>
> dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
> @@ -1743,9 +1744,13 @@ struct input_dev *input_allocate_device(void)
> device_initialize(&dev->dev);
> mutex_init(&dev->mutex);
> spin_lock_init(&dev->event_lock);
> + init_timer(&dev->timer);
> INIT_LIST_HEAD(&dev->h_list);
> INIT_LIST_HEAD(&dev->node);
>
> + dev_set_name(&dev->dev, "input%ld",
> + (unsigned long) atomic_inc_return(&input_no) - 1);
> +
> __module_get(THIS_MODULE);
> }
>
> @@ -2019,7 +2024,6 @@ static void devm_input_device_unregister(struct device *dev, void *res)
> */
> int input_register_device(struct input_dev *dev)
> {
> - static atomic_t input_no = ATOMIC_INIT(0);
> struct input_devres *devres = NULL;
> struct input_handler *handler;
> unsigned int packet_size;
> @@ -2059,7 +2063,6 @@ int input_register_device(struct input_dev *dev)
> * If delay and period are pre-set by the driver, then autorepeating
> * is handled by the driver itself and we don't do it in input.c.
> */
> - init_timer(&dev->timer);
> if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) {
> dev->timer.data = (long) dev;
> dev->timer.function = input_repeat_key;
> @@ -2073,9 +2076,6 @@ int input_register_device(struct input_dev *dev)
> if (!dev->setkeycode)
> dev->setkeycode = input_default_setkeycode;
>
> - dev_set_name(&dev->dev, "input%ld",
> - (unsigned long) atomic_inc_return(&input_no) - 1);
> -
> error = device_add(&dev->dev);
> if (error)
> goto err_free_vals;
> --
> 1.8.4
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-10-19 10:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-02 16:27 [PATCH] Input: move name/timer init to input_alloc_dev() David Herrmann
2013-10-19 10:37 ` David Herrmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).