diff options
author | Antti Palosaari <crope@iki.fi> | 2014-12-05 17:08:22 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-01-29 18:44:00 -0200 |
commit | 68c16a76c64e2cd9c0dd4bda6400a3f28e82488e (patch) | |
tree | bae0d38e3074406fa8665a751e3cd76d08938c67 | |
parent | 1ee5e7dd5eced2ec13d3810c55b4ecd73cb5c92f (diff) |
[media] si2168: enhance firmware download routine
All known old firmware firmware formats are downloaded using 8 byte
chunks. Reject firmware if it could not be divided to 8 byte chunks
and because of that we could simplify some calculations. Now both
supported firmware download routines are rather similar.
Cc: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r-- | drivers/media/dvb-frontends/si2168.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c index 06e54d10cc4..66b9c9ca28f 100644 --- a/drivers/media/dvb-frontends/si2168.c +++ b/drivers/media/dvb-frontends/si2168.c @@ -348,7 +348,6 @@ static int si2168_init(struct dvb_frontend *fe) int ret, len, remaining; const struct firmware *fw = NULL; u8 *fw_file; - const unsigned int i2c_wr_max = 8; struct si2168_cmd cmd; unsigned int chip_id; @@ -459,31 +458,28 @@ static int si2168_init(struct dvb_frontend *fe) cmd.wlen = len; cmd.rlen = 1; ret = si2168_cmd_execute(client, &cmd); - if (ret) { - dev_err(&client->dev, - "firmware download failed=%d\n", - ret); - goto err_release_firmware; - } + if (ret) + break; } - } else { + } else if (fw->size % 8 == 0) { /* firmware is in the old format */ - for (remaining = fw->size; remaining > 0; remaining -= i2c_wr_max) { - len = remaining; - if (len > i2c_wr_max) - len = i2c_wr_max; - + for (remaining = fw->size; remaining > 0; remaining -= 8) { + len = 8; memcpy(cmd.args, &fw->data[fw->size - remaining], len); cmd.wlen = len; cmd.rlen = 1; ret = si2168_cmd_execute(client, &cmd); - if (ret) { - dev_err(&client->dev, - "firmware download failed=%d\n", - ret); - goto err_release_firmware; - } + if (ret) + break; } + } else { + /* bad or unknown firmware format */ + ret = -EINVAL; + } + + if (ret) { + dev_err(&client->dev, "firmware download failed %d\n", ret); + goto err_release_firmware; } release_firmware(fw); |