Skip to contentSkip to conversation

weird array index in zl10036.c

PATCH In review Dan Carpenter 2 participants 4 messages Dec 27, 2009 – Dec 29, 2009 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

drivers/media/dvb/frontends/zl10036.c
397 /* could also be one block from reg 2 to 13 and additional 10/11 */
398 u8 zl10036_init_tab[][2] = {

   399                  { 0x04, 0x00 },         /*   2/3: div=0x400 - arbitrary value */
   400                  { 0x8b, _RDIV_REG },    /*   4/5: rfg=0 ba=1 bg=1 len=? */
   401                                          /*        p0=0 c=0 r=_RDIV_REG */
   402                  { 0xc0, 0x20 },         /*   6/7: rsd=0 bf=0x10 */
   403                  { 0xd3, 0x40 },         /*   8/9: from datasheet */
   404                  { 0xe3, 0x5b },         /* 10/11: lock window level */
   405                  { 0xf0, 0x28 },         /* 12/13: br=0xa clr=0 tl=0*/
   406                  { 0xe3, 0xf9 },         /* 10/11: unlock window level */
   407          };
   408
   409          /* invalid values to trigger writing */
   410          state->br = 0xff;
   411          state->bf = 0xff;

412
413 if (!state->config->rf_loop_enable)
414 zl10036_init_tab[1][2] |= 0x01;

This seems like an off by one error. I think it maybe should say zl10036_init_tab[1][1] |= 0x01;?

regards,
dan carpenter

#1 lore raw
Quoted 20 lines · Dan Carpenter

drivers/media/dvb/frontends/zl10036.c
397 /* could also be one block from reg 2 to 13 and additional

 10/11 */ 398          u8 zl10036_init_tab[][2] = {
   399                  { 0x04, 0x00 },         /*   2/3: div=0x400 -
 arbitrary value */ 400                  { 0x8b, _RDIV_REG },    /*   4/5:
 rfg=0 ba=1 bg=1 len=? */ 401                                          /*  
      p0=0 c=0 r=_RDIV_REG */ 402                  { 0xc0, 0x20 },        
 /*   6/7: rsd=0 bf=0x10 */ 403                  { 0xd3, 0x40 },         /*
   8/9: from datasheet */ 404                  { 0xe3, 0x5b },         /*
 10/11: lock window level */ 405                  { 0xf0, 0x28 },        
 /* 12/13: br=0xa clr=0 tl=0*/ 406                  { 0xe3, 0xf9 },        
 /* 10/11: unlock window level */ 407          };
   408
   409          /* invalid values to trigger writing */
   410          state->br = 0xff;
   411          state->bf = 0xff;
   412
   413          if (!state->config->rf_loop_enable)
   414                  zl10036_init_tab[1][2] |= 0x01;
Quoted 3 lines

This seems like an off by one error. I think it maybe should say zl10036_init_tab[1][1] |= 0x01;?

Good catch!
But according to the datasheet it should be
zl10036_init_tab[1][0] |= 0x01;

Please submit a patch for it.

Regards
Matthias

#2 lore raw

PATCH 1/1 fix weird array index in zl10036.c

I was initially concerned about the weird array index (the 2 bumps into the next row of the array). Matthias Schwarzott look at the datasheet and it turns out it should be zl10036_init_tab[1][0] |= 0x01;

drivers/media/dvb/frontends/zl10036.c +1 -1
@@ -411,7 +411,7 @@ static int zl10036_init_regs(struct zl10
 	state->bf = 0xff;
 
 	if (!state->config->rf_loop_enable)
-		zl10036_init_tab[1][2] |= 0x01;
+		zl10036_init_tab[1][0] |= 0x01;
 
 	deb_info("%s\n", __func__);
 
#3 lore raw

Re: [patch] fix weird array index in zl10036.c

Quoted 5 lines · Dan Carpenter

I was initially concerned about the weird array index (the 2 bumps into the next row of the array). Matthias Schwarzott look at the datasheet and it turns out it should be zl10036_init_tab[1][0] |= 0x01;

It may be better to add "linux/" path component to make it apply easier.

Matthias

Quoted 18 lines

--- orig/drivers/media/dvb/frontends/zl10036.c 2009-12-28
19:04:51.000000000 +0200 +++
devel/drivers/media/dvb/frontends/zl10036.c 2009-12-28 19:07:18.000000000
+0200 @@ -411,7 +411,7 @@ static int zl10036_init_regs(struct zl10

drivers/media/dvb/frontends/zl10036.c +1 -2
 	state->bf = 0xff;
 
 	if (!state->config->rf_loop_enable)
-		zl10036_init_tab[1][2] |= 0x01;
+		zl10036_init_tab[1][0] |= 0x01;
 
 	deb_info("%s\n", __func__);
 
--

To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html