Skip to content

Commit 7c2d8ee

Browse files
committed
media: si2157: rework the firmware load logic
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 <[email protected]>
1 parent 48dde94 commit 7c2d8ee

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

drivers/media/tuners/si2157.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ static int si2157_init(struct dvb_frontend *fe)
129129
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
130130
struct i2c_client *client = fe->tuner_priv;
131131
struct si2157_dev *dev = i2c_get_clientdata(client);
132+
bool warn_firmware_not_loaded = false;
132133
unsigned int chip_id, xtal_trim;
133-
unsigned int fw_required;
134+
bool fw_required = true;
134135
struct si2157_cmd cmd;
135136
const char *fw_name;
136137
int ret;
@@ -199,10 +200,6 @@ static int si2157_init(struct dvb_frontend *fe)
199200
#define SI2146_A10 ('A' << 24 | 46 << 16 | '1' << 8 | '0' << 0)
200201
#define SI2141_A10 ('A' << 24 | 41 << 16 | '1' << 8 | '0' << 0)
201202

202-
/* assume firmware is required, unless verified not to be */
203-
/* only the SI2157_A30 has been verified not to yet */
204-
fw_required = true;
205-
206203
switch (chip_id) {
207204
case SI2158_A20:
208205
case SI2148_A20:
@@ -212,9 +209,8 @@ static int si2157_init(struct dvb_frontend *fe)
212209
fw_name = SI2141_A10_FIRMWARE;
213210
break;
214211
case SI2157_A30:
215-
fw_name = SI2157_A30_FIRMWARE;
216212
fw_required = false;
217-
break;
213+
fallthrough;
218214
case SI2177_A30:
219215
fw_name = SI2157_A30_FIRMWARE;
220216
break;
@@ -237,12 +233,11 @@ static int si2157_init(struct dvb_frontend *fe)
237233
goto skip_fw_download;
238234

239235
ret = si2157_load_firmware(fe, fw_name);
240-
if (ret) {
241-
if (!fw_required)
242-
goto skip_fw_download;
243-
244-
dev_err(&client->dev, "firmware file '%s' not found\n",
245-
fw_name);
236+
if (fw_required && ret == -ENOENT)
237+
warn_firmware_not_loaded = true;
238+
else if (ret < 0) {
239+
dev_err(&client->dev, "error %d when loading firmware file '%s'\n",
240+
ret, fw_name);
246241
goto err;
247242
}
248243

@@ -263,6 +258,11 @@ static int si2157_init(struct dvb_frontend *fe)
263258
if (ret)
264259
goto err;
265260

261+
if (warn_firmware_not_loaded) {
262+
dev_warn(&client->dev, "firmware file '%s' not found. Using firmware from eeprom.\n",
263+
fw_name);
264+
warn_firmware_not_loaded = false;
265+
}
266266
dev_info(&client->dev, "firmware version: %c.%c.%d\n",
267267
cmd.args[6], cmd.args[7], cmd.args[8]);
268268

@@ -298,6 +298,11 @@ static int si2157_init(struct dvb_frontend *fe)
298298
return 0;
299299

300300
err:
301+
if (warn_firmware_not_loaded)
302+
dev_err(&client->dev,
303+
"firmware file '%s' not found. Can't continue without a firmware.\n",
304+
fw_name);
305+
301306
dev_dbg(&client->dev, "failed=%d\n", ret);
302307
return ret;
303308
}

0 commit comments

Comments
 (0)