[media] rtl2830: prevent .read_status() when sleeping
authorAntti Palosaari <crope@iki.fi>
Sun, 22 Jan 2012 01:40:58 +0000 (22:40 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 28 Feb 2012 21:44:25 +0000 (18:44 -0300)
Hardware is not accessible when device is sleeping.
Preventing such IOCTLs when sleep should be job of DVB CORE...

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/dvb-usb/rtl28xxu.c
drivers/media/dvb/frontends/rtl2830.c
drivers/media/dvb/frontends/rtl2830_priv.h

index b5785fa362208e2e6d3a08affb4ab4378b403daf..07597c53d07bbbc51b55bb1395625a34a94d28c0 100644 (file)
@@ -608,11 +608,6 @@ static int rtl28xxu_power_ctrl(struct dvb_usb_device *d, int onoff)
                sys0 = sys0 & 0x0f;
                sys0 |= 0xe0;
        } else {
-               /*
-                * FIXME: Use .fe_ioctl_override() to prevent demod
-                * IOCTLs in case of device is powered off. Or change
-                * RTL2830 demod not perform requestesd IOCTL & IO when sleep.
-                */
                gpio &= (~0x01); /* GPIO0 = 0 */
                gpio |= 0x10; /* GPIO4 = 1 */
                sys0 = sys0 & (~0xc0);
index f036701c12eeb59372d6f7587d343ed462287457..f971d949b2aff19a3dc5c35976c1c467b0e615ae 100644 (file)
@@ -273,12 +273,21 @@ static int rtl2830_init(struct dvb_frontend *fe)
        if (ret)
                goto err;
 
+       priv->sleeping = false;
+
        return ret;
 err:
        dbg("%s: failed=%d", __func__, ret);
        return ret;
 }
 
+static int rtl2830_sleep(struct dvb_frontend *fe)
+{
+       struct rtl2830_priv *priv = fe->demodulator_priv;
+       priv->sleeping = true;
+       return 0;
+}
+
 int rtl2830_get_tune_settings(struct dvb_frontend *fe,
        struct dvb_frontend_tune_settings *s)
 {
@@ -372,6 +381,9 @@ static int rtl2830_read_status(struct dvb_frontend *fe, fe_status_t *status)
        u8 tmp;
        *status = 0;
 
+       if (priv->sleeping)
+               return 0;
+
        ret = rtl2830_rd_reg_mask(priv, 0x351, &tmp, 0x78); /* [6:3] */
        if (ret)
                goto err;
@@ -498,6 +510,8 @@ struct dvb_frontend *rtl2830_attach(const struct rtl2830_config *cfg,
                goto err;
        }
 
+       priv->sleeping = true;
+
        return &priv->fe;
 err:
        dbg("%s: failed=%d", __func__, ret);
@@ -530,6 +544,7 @@ static struct dvb_frontend_ops rtl2830_ops = {
        .release = rtl2830_release,
 
        .init = rtl2830_init,
+       .sleep = rtl2830_sleep,
 
        .get_tune_settings = rtl2830_get_tune_settings,
 
index 49de01dd5e83129d1c16ebfe4fe920e813a59d9a..4a464761b5b888285cf6f9f866e251582190baa8 100644 (file)
@@ -43,6 +43,8 @@ struct rtl2830_priv {
        struct rtl2830_config cfg;
        struct i2c_adapter tuner_i2c_adapter;
 
+       bool sleeping;
+
        u8 page; /* active register page */
 };