public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: media: av7110: cleanup sleep   timers and dead code
@ 2026-01-28 11:06 Timothée Kremer
  2026-01-28 12:31 ` gregkh
  0 siblings, 1 reply; 5+ messages in thread
From: Timothée Kremer @ 2026-01-28 11:06 UTC (permalink / raw)
  To: mchehab@kernel.org, gregkh@linuxfoundation.org
  Cc: linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org

Refactor sleep timers to use usleep_range() for short delays (<20ms)
while retaining msleep() for longer delays to maintain hardware stability.

Also remove dead code blocks wrapped in #if 0 to clean up the driver.

Signed-off-by: Timothée KREMER <timothee.kremer@epitech.eu>
---
 drivers/staging/media/av7110/av7110_hw.c | 64 ++++--------------------
 1 file changed, 10 insertions(+), 54 deletions(-)

diff --git a/drivers/staging/media/av7110/av7110_hw.c b/drivers/staging/media/av7110/av7110_hw.c
index bf8e6dca40e5..202d2383556f 100644
--- a/drivers/staging/media/av7110/av7110_hw.c
+++ b/drivers/staging/media/av7110/av7110_hw.c
@@ -95,28 +95,7 @@ u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, unsigned int co
        return result;
 }
 
-/* av7110 ARM core boot stuff */
-#if 0
-void av7110_reset_arm(struct av7110 *av7110)
-{ 
-       saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTLO);
-
-       /* Disable DEBI and GPIO irq */
-       SAA7146_IER_DISABLE(av7110->dev, MASK_19 | MASK_03);
-       SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03);
-
-       saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTHI);
-       msleep(30);     /* the firmware needs some time to initialize */
-
-       ARM_ResetMailBox(av7110);
-
-       SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03);
-       SAA7146_IER_ENABLE(av7110->dev, MASK_03);
-
-       av7110->arm_ready = 1;
-       dprintk(1, "reset ARM\n");
-}
-#endif  /*  0  */
-
 static int waitdebi(struct av7110 *av7110, int adr, int state)
 {
@@ -312,7 +291,7 @@ int av7110_wait_msgstate(struct av7110 *av7110, u16 flags)
                        pr_err("%s(): timeout waiting for MSGSTATE %04x\n", __func__, stat & flags);
                        return -ETIMEDOUT;
                }
-               msleep(1)
+               usleep_range(1000, 2000);
        }
        return 0;
 }
@@ -343,7 +322,7 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16 *buf, int length)
                        av7110->arm_errors++;
                        return -ETIMEDOUT;
                }
-               msleep(1)
+               usleep_range(1000, 2000);
        }
 
        if (FW_VERSION(av7110->arm_app) <= 0x261f)
@@ -359,7 +338,7 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16 *buf, int length)
                        pr_err("%s(): timeout waiting for HANDSHAKE_REG\n", __func__);
                        return -ETIMEDOUT;
                }
-               msleep(1)
+               usleep_range(1000, 2000);
        }
 #endif
 
@@ -405,7 +384,7 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16 *buf, int length)
                                av7110->arm_errors++;
                                return -ETIMEDOUT;
                        }
-                       msleep(1)
+                       usleep_range(1000, 2000);
                }
        }
 
@@ -433,7 +412,7 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16 *buf, int length)
                               __func__, (buf[0] >> 8) & 0xff);
                        return -ETIMEDOUT;
                }
-               msleep(1)
+               usleep_range(1000, 2000);
        }
 
        stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
@@ -498,29 +477,6 @@ int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...)
        return ret;
 }
 
-#if 0
-int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len)
-{ 
-       int i, ret;
-       u16 cmd[18] = { ((COMTYPE_COMMON_IF << 8) + subcom), 
-               16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
-       dprintk(4, "%p\n", av7110);
-
-       for (i = 0; i < len && i < 32; i++) {
-               if (i % 2 == 0)
-                       cmd[(i / 2) + 2] = (u16)(buf[i]) << 8;
-               else
-                       cmd[(i / 2) + 2] |= buf[i];
-       }
-
-       ret = av7110_send_fw_cmd(av7110, cmd, 18);
-       if (ret && ret != -ERESTARTSYS)
-               pr_err("%s(): error %d\n", __func__, ret);
-       return ret;
-}
-#endif  /*  0  */
-
 int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
                      int request_buf_len, u16 *reply_buf, int reply_buf_len)
 {
@@ -559,7 +515,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
                        return -ETIMEDOUT;
                }
 #ifdef _NOHANDSHAKE
-               msleep(1)
+               usleep_range(1000, 2000);
 #endif
        }
 
@@ -574,7 +530,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
                        mutex_unlock(&av7110->dcomlock);
                        return -ETIMEDOUT;
                }
-               msleep(1)
+               usleep_range(1000, 2000);
        }
 #endif
 
@@ -719,7 +675,7 @@ static int FlushText(struct av7110 *av7110)
                        mutex_unlock(&av7110->dcomlock);
                        return -ETIMEDOUT;
                }
-               msleep(1)
+               usleep_range(1000, 2000);
        }
        mutex_unlock(&av7110->dcomlock);
        return 0;
@@ -745,7 +701,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, char *buf)
                        mutex_unlock(&av7110->dcomlock);
                        return -ETIMEDOUT;
                }
-               msleep(1)
+               usleep_range(1000, 2000);
        }
 #ifndef _NOHANDSHAKE
        start = jiffies;
@@ -758,7 +714,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, char *buf)
                        mutex_unlock(&av7110->dcomlock);
                        return -ETIMEDOUT;
                }
-               msleep(1)
+               usleep_range(1000, 2000);
        }
 #endif
        for (i = 0; i < length / 2; i++)
-- 
2.52.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-01-28 16:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-28 11:06 [PATCH] staging: media: av7110: cleanup sleep timers and dead code Timothée Kremer
2026-01-28 12:31 ` gregkh
2026-01-28 13:06   ` [PATCH] staging: media: av7110: refactor sleep timers Timothée Kremer
2026-01-28 15:08     ` Timothée Kremer
2026-01-28 16:10       ` gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox