[media] rc-core: allow calling rc_open with device not initialized
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Wed, 2 Mar 2016 11:00:15 +0000 (08:00 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 3 Mar 2016 09:16:14 +0000 (06:16 -0300)
commit078600f514a12fd763ac84c86af68ef5b5267563
tree53f9cb44612819a460663e8832ff187e813d1e55
parent87294e9db50f34ac002e32669b2ff74b72d63584
[media] rc-core: allow calling rc_open with device not initialized

The device initialization completes only after calling
input_register_device(). However, rc_open() can be called while
the device is being registered by the input/evdev core. So, we
can't expect that rc_dev->initialized to be true.

Change the logic to don't require initialized == true at rc_open
and change the type of initialized to be atomic.

this way, we can check for it earlier where it is really needed,
without needing to lock the mutex just for testing it.

Tested with nuvoton_cir driver on a NUC5i7RYB with CIR integrated on it.

Reported-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/rc/rc-main.c
include/media/rc-core.h