From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: unlisted-recipients:; (no To-header on input)
Cc: linuxarm@huawei.com, mauro.chehab@huawei.com,
Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
"Robert Schlabbach" <robert_s@gmx.net>,
Antti Palosaari <crope@iki.fi>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: [PATCH 3/3] media: si2157: rework the firmware load logic
Date: Wed, 8 Dec 2021 11:13:26 +0100 [thread overview]
Message-ID: <842e61352a54e9f1a7f44c4e3250a055c2d45e13.1638958050.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1638958050.git.mchehab+huawei@kernel.org>
Loading a firmware file should not be mandatory, as devices
could work with an eeprom firmware, if available.
Yet, using the eeprom firmware could lead into unpredictable
results, so the best is to warn about that.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 0/3] at: https://lore.kernel.org/all/cover.1638958050.git.mchehab+huawei@kernel.org/
drivers/media/tuners/si2157.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index ed28672c060d..5f4ae8593864 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -129,8 +129,9 @@ static int si2157_init(struct dvb_frontend *fe)
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct i2c_client *client = fe->tuner_priv;
struct si2157_dev *dev = i2c_get_clientdata(client);
+ bool warn_firmware_not_loaded = false;
unsigned int chip_id, xtal_trim;
- unsigned int fw_required;
+ bool fw_required = true;
struct si2157_cmd cmd;
const char *fw_name;
int ret;
@@ -199,10 +200,6 @@ static int si2157_init(struct dvb_frontend *fe)
#define SI2146_A10 ('A' << 24 | 46 << 16 | '1' << 8 | '0' << 0)
#define SI2141_A10 ('A' << 24 | 41 << 16 | '1' << 8 | '0' << 0)
- /* assume firmware is required, unless verified not to be */
- /* only the SI2157_A30 has been verified not to yet */
- fw_required = true;
-
switch (chip_id) {
case SI2158_A20:
case SI2148_A20:
@@ -212,9 +209,8 @@ static int si2157_init(struct dvb_frontend *fe)
fw_name = SI2141_A10_FIRMWARE;
break;
case SI2157_A30:
- fw_name = SI2157_A30_FIRMWARE;
fw_required = false;
- break;
+ fallthrough;
case SI2177_A30:
fw_name = SI2157_A30_FIRMWARE;
break;
@@ -237,12 +233,11 @@ static int si2157_init(struct dvb_frontend *fe)
goto skip_fw_download;
ret = si2157_load_firmware(fe, fw_name);
- if (ret) {
- if (!fw_required)
- goto skip_fw_download;
-
- dev_err(&client->dev, "firmware file '%s' not found\n",
- fw_name);
+ if (fw_required && ret == -ENOENT)
+ warn_firmware_not_loaded = true;
+ else if (ret < 0) {
+ dev_err(&client->dev, "error %d when loading firmware file '%s'\n",
+ ret, fw_name);
goto err;
}
@@ -263,6 +258,11 @@ static int si2157_init(struct dvb_frontend *fe)
if (ret)
goto err;
+ if (warn_firmware_not_loaded) {
+ dev_warn(&client->dev, "firmware file '%s' not found. Using firmware from eeprom.\n",
+ fw_name);
+ warn_firmware_not_loaded = false;
+ }
dev_info(&client->dev, "firmware version: %c.%c.%d\n",
cmd.args[6], cmd.args[7], cmd.args[8]);
@@ -298,6 +298,11 @@ static int si2157_init(struct dvb_frontend *fe)
return 0;
err:
+ if (warn_firmware_not_loaded)
+ dev_err(&client->dev,
+ "firmware file '%s' not found. Can't continue without a firmware.\n",
+ fw_name);
+
dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
--
2.33.1
prev parent reply other threads:[~2021-12-08 10:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20211206150055.43043b53@coco.lan>
2021-12-08 10:13 ` [PATCH 0/3] media: si2157: rework " Mauro Carvalho Chehab
2021-12-08 10:13 ` [PATCH 1/3] media: si2157: move firmware load to a separate function Mauro Carvalho Chehab
2021-12-08 10:13 ` [PATCH 2/3] media: si2157: Add optional firmware download Mauro Carvalho Chehab
2021-12-08 10:13 ` Mauro Carvalho Chehab [this message]
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=842e61352a54e9f1a7f44c4e3250a055c2d45e13.1638958050.git.mchehab+huawei@kernel.org \
--to=mchehab+huawei@kernel.org \
--cc=crope@iki.fi \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=mauro.chehab@huawei.com \
--cc=mchehab@kernel.org \
--cc=robert_s@gmx.net \
/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
all inboxes | Powered by JetHome®