From: Josef Schlehofer <pepe.schlehofer@gmail.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Hyunwoo Kim <v4bel@theori.io>,
Josef Schlehofer <pepe.schlehofer@gmail.com>
Subject: [PATCH 3/6] media: drxk: stop retrying after disconnect
Date: Wed, 23 Sep 2026 02:14:07 +0200 [thread overview]
Message-ID: <20260923001410.30297-4-pepe.schlehofer@gmail.com> (raw)
In-Reply-To: <20260923001410.30297-1-pepe.schlehofer@gmail.com>
drxk's wait loops retry I2C transfers on every error. In
dvbt_sc_command(), read16() can leave cur_cmd unchanged when the read
fails, so the loop can either exit early or retry until the maximum when
the device has disappeared.
Stop retrying on -ENODEV and return the error instead of continuing with
the command. In power_up_device(), check the final transfer status after
the shortened loop.
-ENODEV is only returned here after a USB device has been disconnected,
so this does not change behaviour while the device is present.
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---
drivers/media/dvb-frontends/drxk_hard.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index 47786d0610f0..0815083e54eb 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -467,9 +467,9 @@ static int power_up_device(struct drxk_state *state)
continue;
status = i2c_read1(state, state->demod_address,
&data);
- } while (status < 0 &&
+ } while (status < 0 && status != -ENODEV &&
(retry_count < DRXK_MAX_RETRIES_POWERUP));
- if (status < 0 && retry_count >= DRXK_MAX_RETRIES_POWERUP)
+ if (status < 0)
goto error;
}
@@ -992,7 +992,8 @@ static int hi_command(struct drxk_state *state, u16 cmd, u16 *p_result)
retry_count += 1;
status = read16(state, SIO_HI_RA_RAM_CMD__A,
&wait_cmd);
- } while ((status < 0 || wait_cmd) && (retry_count < DRXK_MAX_RETRIES));
+ } while ((status < 0 || wait_cmd) && status != -ENODEV &&
+ (retry_count < DRXK_MAX_RETRIES));
if (status < 0)
goto error;
status = read16(state, SIO_HI_RA_RAM_RES__A, p_result);
@@ -3199,8 +3200,10 @@ static int dvbt_sc_command(struct drxk_state *state,
usleep_range(1000, 2000);
status = read16(state, OFDM_SC_RA_RAM_CMD__A, &cur_cmd);
retry_cnt++;
- } while ((cur_cmd != 0) && (retry_cnt < DRXK_MAX_RETRIES));
- if (retry_cnt >= DRXK_MAX_RETRIES && (status < 0))
+ } while ((cur_cmd != 0) && status != -ENODEV &&
+ (retry_cnt < DRXK_MAX_RETRIES));
+ if (status == -ENODEV ||
+ (retry_cnt >= DRXK_MAX_RETRIES && status < 0))
goto error;
/* Write sub-command */
@@ -3252,8 +3255,10 @@ static int dvbt_sc_command(struct drxk_state *state,
usleep_range(1000, 2000);
status = read16(state, OFDM_SC_RA_RAM_CMD__A, &cur_cmd);
retry_cnt++;
- } while ((cur_cmd != 0) && (retry_cnt < DRXK_MAX_RETRIES));
- if (retry_cnt >= DRXK_MAX_RETRIES && (status < 0))
+ } while ((cur_cmd != 0) && status != -ENODEV &&
+ (retry_cnt < DRXK_MAX_RETRIES));
+ if (status == -ENODEV ||
+ (retry_cnt >= DRXK_MAX_RETRIES && status < 0))
goto error;
/* Check for illegal cmd */
--
2.54.0 (Apple Git-157)
next prev parent reply other threads:[~2026-09-23 0:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 0:14 [PATCH 0/6] media: az6007/drxk/dvb-core: cope with a tuner unplugged while in use Josef Schlehofer
2026-09-23 0:14 ` [PATCH 1/6] media: az6007: fix CAM status polling after disconnect Josef Schlehofer
2026-09-23 0:14 ` [PATCH 2/6] media: az6007: propagate USB errors from I2C transfers Josef Schlehofer
2026-09-23 0:14 ` Josef Schlehofer [this message]
2026-09-23 0:14 ` [PATCH 4/6] media: drxk: stop accessing a disconnected device Josef Schlehofer
2026-09-23 0:14 ` [PATCH 5/6] media: dvb-core: dmxdev: wake up readers on release Josef Schlehofer
2026-09-23 0:14 ` [PATCH 6/6] media: dvb-core: wake up CA users " Josef Schlehofer
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=20260923001410.30297-4-pepe.schlehofer@gmail.com \
--to=pepe.schlehofer@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=v4bel@theori.io \
/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®