Skip to contentSkip to conversation

DVB: add support for the LG2160 ATSC-MH demodulator

media Dan Carpenter 2 participants 2 messages May 21, 2012 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

Hi Michael,

I have a question about e26f2ae4527b: "[media] DVB: add support for the LG2160 ATSC-MH demodulator" from Jan 29, 2012.

122 static int lg216x_write_regs(struct lg216x_state *state,
123 struct lg216x_reg *regs, int len)
124 {
125 int i, ret;
126
127 lg_reg("writing %d registers...\n", len);
128

   129          for (i = 0; i < len - 1; i++) {
                            ^^^^^^^^^^^

Shouldn't this just be i < len? Why do we skip the last element in the array?

   130                  ret = lg216x_write_reg(state, regs[i].reg, regs[i].val);
   131                  if (lg_fail(ret))
   132                          return ret;
   133          }
   134          return 0;
   135  }

This function is called like:

	ret = lg216x_write_regs(state, lg2160_init, ARRAY_SIZE(lg2160_init));

The last element of the lg2160_init[] array looks useful.

regards,
dan carpenter

#1 lore raw
Quoted 24 lines · Dan Carpenter

Hi Michael,

I have a question about e26f2ae4527b: "[media] DVB: add support for the LG2160 ATSC-MH demodulator" from Jan 29, 2012.

  122  static int lg216x_write_regs(struct lg216x_state *state, 123                               struct lg216x_reg *regs, int len) 124  {
  125          int i, ret;
  126
  127          lg_reg("writing %d registers...\n", len);
  128
  129          for (i = 0; i < len - 1; i++) {
                           ^^^^^^^^^^^
Shouldn't this just be i < len?  Why do we skip the last element in the array?

  130                  ret = lg216x_write_reg(state, regs[i].reg, regs[i].val); 131                  if (lg_fail(ret))
  132                          return ret;
  133          }
  134          return 0;
  135  }

Quoted 4 lines

This function is called like:
       ret = lg216x_write_regs(state, lg2160_init, ARRAY_SIZE(lg2160_init));

The last element of the lg2160_init[] array looks useful.

You're right, Dan - that's a bug -- thanks!

I'll queue up a fix for this.

Best Regards,

Mike Krufky