summaryrefslogtreecommitdiff
path: root/drivers/media/video/em28xx
diff options
context:
space:
mode:
authorChris Rankin <rankincj@yahoo.com>2011-08-20 16:01:26 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-09-03 20:50:22 -0300
commit0b8bd83cf393832f1d00096b866d888b75b374c3 (patch)
tree86b8f92a7fa4c6ee0b71b496859e3a7a319a1794 /drivers/media/video/em28xx
parent76424a0a50982e4026c7d1d5a0cddc92eecc5969 (diff)
[media] em28xx: don't sleep on disconnect
The DVB framework will try to power-down an adapter that no-one is using any more, but this assumes that the adapter is still connected to the machine. That's not always true for a USB adapter, so disable the sleep operations when the adapter has been physically unplugged. This prevents I2C write failures with error -19 from appearing occasionally in the dmesg log. Signed-off-by: Chris Rankin <rankincj@yahoo.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/em28xx')
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index b606fc7f842d..62b558ddc02e 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -842,6 +842,13 @@ out_free:
goto ret;
}
+static inline void prevent_sleep(struct dvb_frontend_ops *ops)
+{
+ ops->set_voltage = NULL;
+ ops->sleep = NULL;
+ ops->tuner_ops.sleep = NULL;
+}
+
static int em28xx_dvb_fini(struct em28xx *dev)
{
if (!dev->board.has_dvb) {
@@ -850,8 +857,19 @@ static int em28xx_dvb_fini(struct em28xx *dev)
}
if (dev->dvb) {
- em28xx_unregister_dvb(dev->dvb);
- kfree(dev->dvb);
+ struct em28xx_dvb *dvb = dev->dvb;
+
+ if (dev->state & DEV_DISCONNECTED) {
+ /* We cannot tell the device to sleep
+ * once it has been unplugged. */
+ if (dvb->fe[0])
+ prevent_sleep(&dvb->fe[0]->ops);
+ if (dvb->fe[1])
+ prevent_sleep(&dvb->fe[1]->ops);
+ }
+
+ em28xx_unregister_dvb(dvb);
+ kfree(dvb);
dev->dvb = NULL;
}