[media] rtl2832: move stats polling to read status
authorAntti Palosaari <crope@iki.fi>
Sat, 6 Feb 2016 22:12:05 +0000 (20:12 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 3 Mar 2016 12:27:35 +0000 (09:27 -0300)
Do statistics polling on read status in order to avoid
unnecessary delayed work.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/dvb-frontends/rtl2832.c
drivers/media/dvb-frontends/rtl2832_priv.h

index 8c6971121ed5c3c7bcde2b1ca9b54fd822d12572..7c96f76796691af6c58f6f4a3ea678cbcccb3dc6 100644 (file)
@@ -408,8 +408,6 @@ static int rtl2832_init(struct dvb_frontend *fe)
        c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
        c->post_bit_count.len = 1;
        c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
-       /* start statistics polling */
-       schedule_delayed_work(&dev->stat_work, msecs_to_jiffies(2000));
        dev->sleeping = false;
 
        return 0;
@@ -427,8 +425,6 @@ static int rtl2832_sleep(struct dvb_frontend *fe)
        dev_dbg(&client->dev, "\n");
 
        dev->sleeping = true;
-       /* stop statistics polling */
-       cancel_delayed_work_sync(&dev->stat_work);
        dev->fe_status = 0;
 
        ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x1);
@@ -691,8 +687,11 @@ static int rtl2832_read_status(struct dvb_frontend *fe, enum fe_status *status)
 {
        struct rtl2832_dev *dev = fe->demodulator_priv;
        struct i2c_client *client = dev->client;
+       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        int ret;
        u32 uninitialized_var(tmp);
+       u8 u8tmp, buf[2];
+       u16 u16tmp;
 
        dev_dbg(&client->dev, "\n");
 
@@ -713,45 +712,6 @@ static int rtl2832_read_status(struct dvb_frontend *fe, enum fe_status *status)
        }
 
        dev->fe_status = *status;
-       return 0;
-err:
-       dev_dbg(&client->dev, "failed=%d\n", ret);
-       return ret;
-}
-
-static int rtl2832_read_snr(struct dvb_frontend *fe, u16 *snr)
-{
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
-
-       /* report SNR in resolution of 0.1 dB */
-       if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL)
-               *snr = div_s64(c->cnr.stat[0].svalue, 100);
-       else
-               *snr = 0;
-
-       return 0;
-}
-
-static int rtl2832_read_ber(struct dvb_frontend *fe, u32 *ber)
-{
-       struct rtl2832_dev *dev = fe->demodulator_priv;
-
-       *ber = (dev->post_bit_error - dev->post_bit_error_prev);
-       dev->post_bit_error_prev = dev->post_bit_error;
-
-       return 0;
-}
-
-static void rtl2832_stat_work(struct work_struct *work)
-{
-       struct rtl2832_dev *dev = container_of(work, struct rtl2832_dev, stat_work.work);
-       struct i2c_client *client = dev->client;
-       struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache;
-       int ret, tmp;
-       u8 u8tmp, buf[2];
-       u16 u16tmp;
-
-       dev_dbg(&client->dev, "\n");
 
        /* signal strength */
        if (dev->fe_status & FE_HAS_SIGNAL) {
@@ -788,11 +748,11 @@ static void rtl2832_stat_work(struct work_struct *work)
 
                constellation = (u8tmp >> 2) & 0x03; /* [3:2] */
                if (constellation > CONSTELLATION_NUM - 1)
-                       goto err_schedule_delayed_work;
+                       goto err;
 
                hierarchy = (u8tmp >> 4) & 0x07; /* [6:4] */
                if (hierarchy > HIERARCHY_NUM - 1)
-                       goto err_schedule_delayed_work;
+                       goto err;
 
                ret = rtl2832_bulk_read(client, 0x40c, buf, 2);
                if (ret)
@@ -834,11 +794,33 @@ static void rtl2832_stat_work(struct work_struct *work)
                c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
        }
 
-err_schedule_delayed_work:
-       schedule_delayed_work(&dev->stat_work, msecs_to_jiffies(2000));
-       return;
+       return 0;
 err:
        dev_dbg(&client->dev, "failed=%d\n", ret);
+       return ret;
+}
+
+static int rtl2832_read_snr(struct dvb_frontend *fe, u16 *snr)
+{
+       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+
+       /* report SNR in resolution of 0.1 dB */
+       if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL)
+               *snr = div_s64(c->cnr.stat[0].svalue, 100);
+       else
+               *snr = 0;
+
+       return 0;
+}
+
+static int rtl2832_read_ber(struct dvb_frontend *fe, u32 *ber)
+{
+       struct rtl2832_dev *dev = fe->demodulator_priv;
+
+       *ber = (dev->post_bit_error - dev->post_bit_error_prev);
+       dev->post_bit_error_prev = dev->post_bit_error;
+
+       return 0;
 }
 
 /*
@@ -1235,7 +1217,6 @@ static int rtl2832_probe(struct i2c_client *client,
        dev->pdata = client->dev.platform_data;
        dev->sleeping = true;
        INIT_DELAYED_WORK(&dev->i2c_gate_work, rtl2832_i2c_gate_work);
-       INIT_DELAYED_WORK(&dev->stat_work, rtl2832_stat_work);
        /* create regmap */
        mutex_init(&dev->regmap_mutex);
        dev->regmap_config.reg_bits =  8,
index 5dcd3a41d23fec2d6be565d6a855c2be64c17e28..6b875f462f8b35a984292828fb303cad0cdf37dc 100644 (file)
@@ -38,7 +38,6 @@ struct rtl2832_dev {
        struct regmap *regmap;
        struct i2c_adapter *i2c_adapter_tuner;
        struct dvb_frontend fe;
-       struct delayed_work stat_work;
        enum fe_status fe_status;
        u64 post_bit_error_prev; /* for old DVBv3 read_ber() calculation */
        u64 post_bit_error;