aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2011-05-04 20:23:09 (GMT)
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-05-05 04:05:28 (GMT)
commit52646ae1e655ec64a042333c948360a4878990df (patch)
tree3cccc54c062ccb9dc43232ac6336f683bfdcd8a0
parent6e80de7d228c39b41577bfcc3b194610414306da (diff)
[media] cx24116: make FW DL split more readable
Change firmware download split, which I introduced few patch earlier, a little bit to make it more readable as requested [1]. Anyhow, for some reason this seems to increase compiled binary size 52 bytes, on my AMD64 box, which is rather much for so small change. [1] http://www.spinics.net/lists/linux-media/msg31968.html Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/frontends/cx24116.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/media/dvb/frontends/cx24116.c b/drivers/media/dvb/frontends/cx24116.c
index 26e65a6..95c6465 100644
--- a/drivers/media/dvb/frontends/cx24116.c
+++ b/drivers/media/dvb/frontends/cx24116.c
@@ -566,7 +566,7 @@ static int cx24116_load_firmware(struct dvb_frontend *fe,
{
struct cx24116_state *state = fe->demodulator_priv;
struct cx24116_cmd cmd;
- int i, ret, len, remaining;
+ int i, ret, len, max, remaining;
unsigned char vers[4];
dprintk("%s\n", __func__);
@@ -604,14 +604,16 @@ static int cx24116_load_firmware(struct dvb_frontend *fe,
cx24116_writereg(state, 0xF6, 0x00);
/* Split firmware to the max I2C write len and write.
- * This overflows 16 bit intentionally in order to get max write
- * len when i2c_wr_max is set to 0. */
- for (remaining = fw->size; remaining > 0;
- remaining -= (u16) (state->config->i2c_wr_max - 1)) {
+ * Writes whole firmware as one write when i2c_wr_max is set to 0. */
+ if (state->config->i2c_wr_max)
+ max = state->config->i2c_wr_max;
+ else
+ max = INT_MAX; /* enough for 32k firmware */
+ for (remaining = fw->size; remaining > 0; remaining -= max - 1) {
len = remaining;
- if (len > (u16) (state->config->i2c_wr_max - 1))
- len = (u16) (state->config->i2c_wr_max - 1);
+ if (len > max - 1)
+ len = max - 1;
cx24116_writeregN(state, 0xF7, &fw->data[fw->size - remaining],
len);

Privacy Policy