staging: media: av7110: replace msleep with usleep_range
Subsystems (2)
PATCH 1/2 staging: media: av7110: replace msleep with usleep_range
The msleep() function is not precise for short delays under 20ms. Replace it with usleep_range() to provide more accurate timing and avoid unnecessary scheduler overhead.
--- drivers/staging/media/av7110/av7110.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/av7110/av7110.c +1 -1
@@ -1818,7 +1818,7 @@ static int nexusca_stv0297_tuner_set_params(struct dvb_frontend *fe)if (i2c_transfer (&av7110->i2c_adap, &readmsg,1 ) ==1 )if (data[0 ] &0x40 )break ; -msleep (10 ); +usleep_range (10000 ,11000 ); }return 0 ;
Signature · 1 line
2.43.0
PATCH 2/2 staging: media: av7110: refactor av7110_start_feed to reduce indentation
The av7110_start_feed function contains heavily nested if-statements, causing excessive indentation and violating code style guidelines. Refactor the logic inside the DMX_MEMORY_FE case by inverting the conditional check to break early, reducing the indentation level.
--- drivers/staging/media/av7110/av7110.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/staging/media/av7110/av7110.c +10 -10
@@ -942,16 +942,16 @@ static int av7110_start_feed(struct dvb_demux_feed *feed) (feed->pes_type <= DMX_PES_PCR)) {switch (demux->dmx.frontend->source) {case DMX_MEMORY_FE : -if (feed->ts_type &TS_DECODER ) -if (feed->pes_type <2 && - !(demux->pids[0 ] &0x8000 ) && - !(demux->pids[1 ] &0x8000 )) { -dvb_ringbuffer_flush_spinlock_wakeup (&av7110->avout); -dvb_ringbuffer_flush_spinlock_wakeup (&av7110->aout); - ret =av7110_av_start_play (av7110,RP_AV ); -if (!ret) - demux->playing =1 ; - } +if (feed->pes_type >=2 || + (demux->pids[0 ] &0x8000 ) || + (demux->pids[1 ] &0x8000 )) +break ; + +dvb_ringbuffer_flush_spinlock_wakeup (&av7110->avout); +dvb_ringbuffer_flush_spinlock_wakeup (&av7110->aout); + ret =av7110_av_start_play (av7110,RP_AV ); +if (!ret) + demux->playing =1 ;break ;default : ret =dvb_feed_start_pid (feed);
Signature · 1 line
2.43.0
Re: [PATCH 2/2] staging: media: av7110: refactor av7110_start_feed to reduce indentation
Quoted 6 lines · André Moreira
The
av7110_start_feedfunction contains heavily nested if-statements, causing excessive indentation and violating code style guidelines. Refactor the logic inside theDMX_MEMORY_FEcase by inverting the conditional check to break early, reducing the indentation level.Signed-off-by André Moreira <[email protected]>
Imagine I read this commit message
drivers/staging/media/av7110/av7110.c static int av7110_start_feed(struct dvb_demux_feed *feed) · line 945
Quoted 13 lines
--- drivers/staging/media/av7110/av7110.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)drivers/staging/media/av7110/av7110.c +0
-1@@ -942,16 +942,16 @@ static int av7110_start_feed(struct dvb_demux_feed *feed) (feed->pes_type <= DMX_PES_PCR)) {switch (demux->dmx.frontend->source) {case DMX_MEMORY_FE : -if (feed->ts_type &TS_DECODER )
And the first thing that I saw is that you removed this check. There is no information in the email why this is okay. I have to look at the code itself to see that.
The patch is fine, but I don't want to have to read the code to find my answers. Re-write the commit message and resend.
regards,
dan carpenter
Quoted 22 lines
drivers/staging/media/av7110/av7110.c +10
-9-if (feed->pes_type <2 && - !(demux->pids[0 ] &0x8000 ) && - !(demux->pids[1 ] &0x8000 )) { -dvb_ringbuffer_flush_spinlock_wakeup (&av7110->avout); -dvb_ringbuffer_flush_spinlock_wakeup (&av7110->aout); - ret =av7110_av_start_play (av7110,RP_AV ); -if (!ret) - demux->playing =1 ; - } +if (feed->pes_type >=2 || + (demux->pids[0 ] &0x8000 ) || + (demux->pids[1 ] &0x8000 )) +break ; + +dvb_ringbuffer_flush_spinlock_wakeup (&av7110->avout); +dvb_ringbuffer_flush_spinlock_wakeup (&av7110->aout); + ret =av7110_av_start_play (av7110,RP_AV ); +if (!ret) + demux->playing =1 ;break ;default : ret =dvb_feed_start_pid (feed);
PATCH v2 1/1 staging: media: av7110: refactor av7110_start_feed to reduce indentation
The av7110_start_feed function contains heavily nested if-statements, causing excessive indentation and violating code style guidelines.
Refactor the logic inside the DMX_MEMORY_FE case by inverting the conditional check to break early. Additionally, remove the inner 'if (feed->ts_type & TS_DECODER)' check, as it is redundant since the outer block already validates this condition.
This reduces the indentation level and cleans up redundant checks without altering the underlying driver behavior.
--- drivers/staging/media/av7110/av7110.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/staging/media/av7110/av7110.c +10 -10
@@ -942,16 +942,16 @@ static int av7110_start_feed(struct dvb_demux_feed *feed) (feed->pes_type <= DMX_PES_PCR)) {switch (demux->dmx.frontend->source) {case DMX_MEMORY_FE : -if (feed->ts_type &TS_DECODER ) -if (feed->pes_type <2 && - !(demux->pids[0 ] &0x8000 ) && - !(demux->pids[1 ] &0x8000 )) { -dvb_ringbuffer_flush_spinlock_wakeup (&av7110->avout); -dvb_ringbuffer_flush_spinlock_wakeup (&av7110->aout); - ret =av7110_av_start_play (av7110,RP_AV ); -if (!ret) - demux->playing =1 ; - } +if (feed->pes_type >=2 || + (demux->pids[0 ] &0x8000 ) || + (demux->pids[1 ] &0x8000 )) +break ; + +dvb_ringbuffer_flush_spinlock_wakeup (&av7110->avout); +dvb_ringbuffer_flush_spinlock_wakeup (&av7110->aout); + ret =av7110_av_start_play (av7110,RP_AV ); +if (!ret) + demux->playing =1 ;break ;default : ret =dvb_feed_start_pid (feed);
Signature · 1 line
2.43.0
PATCH v2 1/1 staging: media: av7110: refactor av7110_start_feed to reduce indentation
In reply to Dan CarpenterThe av7110_start_feed function contains heavily nested if-statements, causing excessive indentation and violating code style guidelines.
Refactor the logic inside the DMX_MEMORY_FE case by inverting the conditional check to break early. Additionally, remove the inner 'if (feed->ts_type & TS_DECODER)' check, as it is redundant since the outer block already validates this condition.
This reduces the indentation level and cleans up redundant checks without altering the underlying driver behavior.
--- drivers/staging/media/av7110/av7110.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/staging/media/av7110/av7110.c +10 -10
@@ -942,16 +942,16 @@ static int av7110_start_feed(struct dvb_demux_feed *feed) (feed->pes_type <= DMX_PES_PCR)) {switch (demux->dmx.frontend->source) {case DMX_MEMORY_FE : -if (feed->ts_type &TS_DECODER ) -if (feed->pes_type <2 && - !(demux->pids[0 ] &0x8000 ) && - !(demux->pids[1 ] &0x8000 )) { -dvb_ringbuffer_flush_spinlock_wakeup (&av7110->avout); -dvb_ringbuffer_flush_spinlock_wakeup (&av7110->aout); - ret =av7110_av_start_play (av7110,RP_AV ); -if (!ret) - demux->playing =1 ; - } +if (feed->pes_type >=2 || + (demux->pids[0 ] &0x8000 ) || + (demux->pids[1 ] &0x8000 )) +break ; + +dvb_ringbuffer_flush_spinlock_wakeup (&av7110->avout); +dvb_ringbuffer_flush_spinlock_wakeup (&av7110->aout); + ret =av7110_av_start_play (av7110,RP_AV ); +if (!ret) + demux->playing =1 ;break ;default : ret =dvb_feed_start_pid (feed);
Signature · 1 line
2.43.0
Quoted 6 lines · André Moreira
The
msleep()function is not precise for short delays under 20ms. Replace it withusleep_range()to provide more accurate timing and avoid unnecessary scheduler overhead.Signed-off-by André Moreira <[email protected]>---
We don't accept this kind of patch without testing. But also this is not the current way to do it. Do a search for "usleep_range staging" on lore.kernel.org to find the current way.
regards,
dan carpenter