diff options
author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-11-01 17:05:53 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-12-11 13:13:39 -0500 |
commit | f161544d9d7d8e617c13fe30504317c417ed49e9 (patch) | |
tree | 2c5b68f7a98af9c2cb0643b04d454092b4fbbdef /drivers/media/dvb-frontends/drxd_hard.c | |
parent | 07ade2d0f680864ba0c93553d008900dd3e1a421 (diff) | |
download | talos-op-linux-f161544d9d7d8e617c13fe30504317c417ed49e9.tar.gz talos-op-linux-f161544d9d7d8e617c13fe30504317c417ed49e9.zip |
media: drxd_hard: better handle I2C errors
As warned by smatch:
drivers/media/dvb-frontends/drxd_hard.c:989 HI_Command() error: uninitialized symbol 'waitCmd'.
drivers/media/dvb-frontends/drxd_hard.c:1306 SC_WaitForReady() error: uninitialized symbol 'curCmd'.
drivers/media/dvb-frontends/drxd_hard.c:1322 SC_SendCommand() error: uninitialized symbol 'errCode'.
drivers/media/dvb-frontends/drxd_hard.c:1339 SC_ProcStartCommand() error: uninitialized symbol 'scExec'.
The error handling on several places are somewhat flawed, as
they don't check if Read16() returns an error.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/dvb-frontends/drxd_hard.c')
-rw-r--r-- | drivers/media/dvb-frontends/drxd_hard.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/media/dvb-frontends/drxd_hard.c b/drivers/media/dvb-frontends/drxd_hard.c index 0696bc62dcc9..3215d003b2a1 100644 --- a/drivers/media/dvb-frontends/drxd_hard.c +++ b/drivers/media/dvb-frontends/drxd_hard.c @@ -972,7 +972,6 @@ static int DownloadMicrocode(struct drxd_state *state, static int HI_Command(struct drxd_state *state, u16 cmd, u16 * pResult) { u32 nrRetries = 0; - u16 waitCmd; int status; status = Write16(state, HI_RA_RAM_SRV_CMD__A, cmd, 0); @@ -985,8 +984,8 @@ static int HI_Command(struct drxd_state *state, u16 cmd, u16 * pResult) status = -1; break; } - status = Read16(state, HI_RA_RAM_SRV_CMD__A, &waitCmd, 0); - } while (waitCmd != 0); + status = Read16(state, HI_RA_RAM_SRV_CMD__A, NULL, 0); + } while (status != 0); if (status >= 0) status = Read16(state, HI_RA_RAM_SRV_RES__A, pResult, 0); @@ -1298,12 +1297,11 @@ static int InitFT(struct drxd_state *state) static int SC_WaitForReady(struct drxd_state *state) { - u16 curCmd; int i; for (i = 0; i < DRXD_MAX_RETRIES; i += 1) { - int status = Read16(state, SC_RA_RAM_CMD__A, &curCmd, 0); - if (status == 0 || curCmd == 0) + int status = Read16(state, SC_RA_RAM_CMD__A, NULL, 0); + if (status == 0) return status; } return -1; @@ -1311,15 +1309,15 @@ static int SC_WaitForReady(struct drxd_state *state) static int SC_SendCommand(struct drxd_state *state, u16 cmd) { - int status = 0; + int status = 0, ret; u16 errCode; Write16(state, SC_RA_RAM_CMD__A, cmd, 0); SC_WaitForReady(state); - Read16(state, SC_RA_RAM_CMD_ADDR__A, &errCode, 0); + ret = Read16(state, SC_RA_RAM_CMD_ADDR__A, &errCode, 0); - if (errCode == 0xFFFF) { + if (ret < 0 || errCode == 0xFFFF) { printk(KERN_ERR "Command Error\n"); status = -1; } @@ -1330,13 +1328,13 @@ static int SC_SendCommand(struct drxd_state *state, u16 cmd) static int SC_ProcStartCommand(struct drxd_state *state, u16 subCmd, u16 param0, u16 param1) { - int status = 0; + int ret, status = 0; u16 scExec; mutex_lock(&state->mutex); do { - Read16(state, SC_COMM_EXEC__A, &scExec, 0); - if (scExec != 1) { + ret = Read16(state, SC_COMM_EXEC__A, &scExec, 0); + if (ret < 0 || scExec != 1) { status = -1; break; } |