]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/media/dvb/frontends/af9013.c
[media] af9013: optimize code size
[mv-sheeva.git] / drivers / media / dvb / frontends / af9013.c
index 25c5124bfc597987964e0ed457e03922710360c0..6a205e68fde74867a3fedf3d0fd50eb4d2383837 100644 (file)
@@ -220,8 +220,7 @@ static u32 af913_div(u32 a, u32 b, u32 x)
 
 static int af9013_set_coeff(struct af9013_state *state, fe_bandwidth_t bw)
 {
-       int ret, i, found;
-       u8 buf[24];
+       int ret, i, j, found;
        deb_info("%s: adc_clock:%d bw:%d\n", __func__,
                state->config.adc_clock, bw);
 
@@ -240,37 +239,13 @@ static int af9013_set_coeff(struct af9013_state *state, fe_bandwidth_t bw)
                goto error;
        }
 
-       buf[0]  = (u8) ((coeff_table[i].ns_coeff1_2048nu & 0x03000000) >> 24);
-       buf[1]  = (u8) ((coeff_table[i].ns_coeff1_2048nu & 0x00ff0000) >> 16);
-       buf[2]  = (u8) ((coeff_table[i].ns_coeff1_2048nu & 0x0000ff00) >> 8);
-       buf[3]  = (u8) ((coeff_table[i].ns_coeff1_2048nu & 0x000000ff));
-       buf[4]  = (u8) ((coeff_table[i].ns_coeff2_2k     & 0x01c00000) >> 22);
-       buf[5]  = (u8) ((coeff_table[i].ns_coeff2_2k     & 0x003fc000) >> 14);
-       buf[6]  = (u8) ((coeff_table[i].ns_coeff2_2k     & 0x00003fc0) >> 6);
-       buf[7]  = (u8) ((coeff_table[i].ns_coeff2_2k     & 0x0000003f));
-       buf[8]  = (u8) ((coeff_table[i].ns_coeff1_8191nu & 0x03000000) >> 24);
-       buf[9]  = (u8) ((coeff_table[i].ns_coeff1_8191nu & 0x00ffc000) >> 16);
-       buf[10] = (u8) ((coeff_table[i].ns_coeff1_8191nu & 0x0000ff00) >> 8);
-       buf[11] = (u8) ((coeff_table[i].ns_coeff1_8191nu & 0x000000ff));
-       buf[12] = (u8) ((coeff_table[i].ns_coeff1_8192nu & 0x03000000) >> 24);
-       buf[13] = (u8) ((coeff_table[i].ns_coeff1_8192nu & 0x00ffc000) >> 16);
-       buf[14] = (u8) ((coeff_table[i].ns_coeff1_8192nu & 0x0000ff00) >> 8);
-       buf[15] = (u8) ((coeff_table[i].ns_coeff1_8192nu & 0x000000ff));
-       buf[16] = (u8) ((coeff_table[i].ns_coeff1_8193nu & 0x03000000) >> 24);
-       buf[17] = (u8) ((coeff_table[i].ns_coeff1_8193nu & 0x00ffc000) >> 16);
-       buf[18] = (u8) ((coeff_table[i].ns_coeff1_8193nu & 0x0000ff00) >> 8);
-       buf[19] = (u8) ((coeff_table[i].ns_coeff1_8193nu & 0x000000ff));
-       buf[20] = (u8) ((coeff_table[i].ns_coeff2_8k     & 0x01c00000) >> 22);
-       buf[21] = (u8) ((coeff_table[i].ns_coeff2_8k     & 0x003fc000) >> 14);
-       buf[22] = (u8) ((coeff_table[i].ns_coeff2_8k     & 0x00003fc0) >> 6);
-       buf[23] = (u8) ((coeff_table[i].ns_coeff2_8k     & 0x0000003f));
-
-       deb_info("%s: coeff:", __func__);
-       debug_dump(buf, sizeof(buf), deb_info);
+       deb_info("%s: coeff: ", __func__);
+       debug_dump(coeff_table[i].val, sizeof(coeff_table[i].val), deb_info);
 
        /* program */
-       for (i = 0; i < sizeof(buf); i++) {
-               ret = af9013_write_reg(state, 0xae00 + i, buf[i]);
+       for (j = 0; j < sizeof(coeff_table[i].val); j++) {
+               ret = af9013_write_reg(state, 0xae00 + j,
+                       coeff_table[i].val[j]);
                if (ret)
                        break;
        }