[media] Fix DVB-S/S2 tune for sony ascot3a tuner
authorAbylay Ospan <aospan@netup.ru>
Thu, 24 Mar 2016 01:31:55 +0000 (22:31 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 7 Jun 2016 15:09:20 +0000 (12:09 -0300)
* fix buffer length check
* do not rely on ROLLOFF

Signed-off-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/dvb-frontends/horus3a.c

index 000606af70f7461def1f187521e6ce12d191b6a7..a98bca5270d90dddfbbd1522d05d0d05b2b01533 100644 (file)
@@ -66,7 +66,7 @@ static int horus3a_write_regs(struct horus3a_priv *priv,
                }
        };
 
-       if (len + 1 >= sizeof(buf)) {
+       if (len + 1 > sizeof(buf)) {
                dev_warn(&priv->i2c->dev,"wr reg=%04x: len=%d is too big!\n",
                         reg, len + 1);
                return -E2BIG;
@@ -272,24 +272,6 @@ static int horus3a_set_params(struct dvb_frontend *fe)
                if (fc_lpf > 36)
                        fc_lpf = 36;
        } else if (p->delivery_system == SYS_DVBS2) {
-               int rolloff;
-
-               switch (p->rolloff) {
-               case ROLLOFF_35:
-                       rolloff = 35;
-                       break;
-               case ROLLOFF_25:
-                       rolloff = 25;
-                       break;
-               case ROLLOFF_20:
-                       rolloff = 20;
-                       break;
-               case ROLLOFF_AUTO:
-               default:
-                       dev_err(&priv->i2c->dev,
-                               "horus3a: auto roll-off is not supported\n");
-                       return -EINVAL;
-               }
                /*
                 * SR <= 4.5:
                 * fc_lpf = 5
@@ -302,11 +284,9 @@ static int horus3a_set_params(struct dvb_frontend *fe)
                if (symbol_rate <= 4500)
                        fc_lpf = 5;
                else if (symbol_rate <= 10000)
-                       fc_lpf = (u8)DIV_ROUND_UP(
-                               symbol_rate * (200 + rolloff), 200000);
+                       fc_lpf = (u8)((symbol_rate * 11 + (10000-1)) / 10000);
                else
-                       fc_lpf = (u8)DIV_ROUND_UP(
-                               symbol_rate * (100 + rolloff), 200000) + 5;
+                       fc_lpf = (u8)((symbol_rate * 3 + (5000-1)) / 5000 + 5);
                /* 5 <= fc_lpf <= 36 is valid */
                if (fc_lpf > 36)
                        fc_lpf = 36;