From: Benjamin Larsson <benjamin@southpole.se>
To: linux-media@vger.kernel.org
Subject: [PATCH 2/3] mn88472: add work around for failing firmware loading
Date: Sun, 29 Nov 2015 03:10:15 +0100 [thread overview]
Message-ID: <1448763016-10527-2-git-send-email-benjamin@southpole.se> (raw)
In-Reply-To: <1448763016-10527-1-git-send-email-benjamin@southpole.se>
Sometimes the firmware fails to load because of an i2c error.
Work around that by adding retry logic. This kind of logic
also exist in the binary driver and failures have been observed
there also. Thus this seems to be a property of the hardware
and a fix like this is needed.
Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
drivers/staging/media/mn88472/mn88472.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
index cf2e96b..80c5807 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -282,7 +282,7 @@ static int mn88472_init(struct dvb_frontend *fe)
int ret, len, remaining;
const struct firmware *fw = NULL;
u8 *fw_file = MN88472_FIRMWARE;
- unsigned int tmp;
+ unsigned int tmp, retry_cnt;
dev_dbg(&client->dev, "\n");
@@ -330,9 +330,22 @@ static int mn88472_init(struct dvb_frontend *fe)
if (len > (dev->i2c_wr_max - 1))
len = dev->i2c_wr_max - 1;
+ /* I2C transfers during firmware load might fail sometimes,
+ * just retry in that case. 4 consecutive failures have
+ * been observed thus a retry limit of 20 is used.
+ */
+ retry_cnt = 20;
+retry:
ret = regmap_bulk_write(dev->regmap[0], 0xf6,
&fw->data[fw->size - remaining], len);
if (ret) {
+ if (retry_cnt) {
+ dev_dbg(&client->dev,
+ "i2c error, retry %d triggered\n", retry_cnt);
+ retry_cnt--;
+ usleep_range(200, 10000);
+ goto retry;
+ }
dev_err(&client->dev,
"firmware download failed=%d\n", ret);
goto firmware_release;
--
2.1.4
next prev parent reply other threads:[~2015-11-29 2:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-29 2:10 [PATCH 1/3] rtl2832: add support for slave ts pid filter Benjamin Larsson
2015-11-29 2:10 ` Benjamin Larsson [this message]
2015-12-21 2:52 ` [PATCH 2/3] mn88472: add work around for failing firmware loading Antti Palosaari
2015-12-21 10:07 ` Benjamin Larsson
2015-11-29 2:10 ` [PATCH 3/3] rtl28xxu: change Astrometa DVB-T2 to always use hardware pid filters Benjamin Larsson
2015-12-20 3:36 ` Antti Palosaari
2015-12-20 9:47 ` Benjamin Larsson
2015-12-21 2:42 ` [PATCH 1/3] rtl2832: add support for slave ts pid filter Antti Palosaari
2015-12-21 9:51 ` Benjamin Larsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448763016-10527-2-git-send-email-benjamin@southpole.se \
--to=benjamin@southpole.se \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).