All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Herdler <herdler@nurfuerspam.de>
To: hverkuil-cisco@xs4all.nl
Cc: linux-media@vger.kernel.org, smoch@web.de, tmn505@gmail.com,
	vinschen@redhat.com
Subject: [PATCH 11/11] media: ttpci: checkpatch fixes: msleep
Date: Thu, 28 Mar 2024 03:05:22 +0100	[thread overview]
Message-ID: <20240328020522.50995-12-herdler@nurfuerspam.de> (raw)
In-Reply-To: <20240328020522.50995-1-herdler@nurfuerspam.de>

This patch fixes the following checkpatch warnings:

WARNING:MSLEEP: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.rst


The driver is working with this behaviour since years. Just replacing
all msleep < 20ms with msleep 20ms to silence the warning.
Add a comment to indicate the time choice was not hardware related.

There are only a few of these msleep in a row, the extra sleep time
won't add up to much.


Signed-off-by: Stefan Herdler <herdler@nurfuerspam.de>
---

Warning:
I'm not able to test this changes properly. None of my cards are affected
directly and I don't have a operational CAM.

I think, we have 3 options to deal with this warnings:
* Ignore them.
  This is save, but will keep the warnings.
* Use usleep_range.
  Probably dangerous, it may break the driver.
* Rise all shorter msleep to 20ms.
  This should be pretty save.
  Many of this msleep are in a row with much longer msleeps anyway and
  there are only less of 2 of these in a function.
  Most of the affected functions are init functions only.
  The most time critical msleeps I have spotted are tuning related. So
  tuning a new transponder may take up to 20ms longer on some frontends,
  in the worst case.
Nevertheless, please consider this patch as a proposal and optional.

 drivers/media/pci/ttpci/budget-av.c |  8 ++++----
 drivers/media/pci/ttpci/budget-ci.c | 10 +++++-----
 drivers/media/pci/ttpci/budget.c    |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/media/pci/ttpci/budget-av.c b/drivers/media/pci/ttpci/budget-av.c
index fd5a88e64..680e46cf1 100644
--- a/drivers/media/pci/ttpci/budget-av.c
+++ b/drivers/media/pci/ttpci/budget-av.c
@@ -211,7 +211,7 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
 	saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */

 	saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
-	msleep(2);
+	msleep(20); // Was 2, but msleep would have slept up to 20ms nevertheless.
 	saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO); /* Vcc on */
 	msleep(20); /* 20 ms Vcc settling time */

@@ -637,7 +637,7 @@ static int philips_cu1216_tuner_set_params(struct dvb_frontend *fe)
 			fe->ops.i2c_gate_ctrl(fe, 1);
 		if (i2c_transfer(&budget->i2c_adap, &msg, 1) == 1 && (buf[0] & 0x40))
 			break;
-		msleep(10);
+		msleep(20); // Was 10, but msleep would have slept up to 20ms nevertheless.
 	}

 	/* switch the charge pump to the lower current */
@@ -679,7 +679,7 @@ static int philips_tu1216_tuner_init(struct dvb_frontend *fe)
 		fe->ops.i2c_gate_ctrl(fe, 1);
 	if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
 		return -EIO;
-	msleep(1);
+	msleep(20); // Was 1, but msleep would have slept up to 20ms nevertheless.

 	return 0;
 }
@@ -764,7 +764,7 @@ static int philips_tu1216_tuner_set_params(struct dvb_frontend *fe)
 	if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
 		return -EIO;

-	msleep(1);
+	msleep(20); // Was 1, but msleep would have slept up to 20ms nevertheless.
 	return 0;
 }

diff --git a/drivers/media/pci/ttpci/budget-ci.c b/drivers/media/pci/ttpci/budget-ci.c
index d821710bb..066eba67f 100644
--- a/drivers/media/pci/ttpci/budget-ci.c
+++ b/drivers/media/pci/ttpci/budget-ci.c
@@ -308,7 +308,7 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
 	}
 	budget_ci->slot_status = SLOTSTATUS_RESET;
 	ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0);
-	msleep(1);
+	msleep(20); // Was 1, but msleep would have slept up to 20ms nevertheless.
 	ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
 			       CICONTROL_RESET, 1, 0);

@@ -534,7 +534,7 @@ static void ciintf_deinit(struct budget_ci *budget_ci)

 	// reset interface
 	ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0);
-	msleep(1);
+	msleep(20); // Was 1, but msleep would have slept up to 20ms nevertheless.
 	ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
 			       CICONTROL_RESET, 1, 0);

@@ -706,7 +706,7 @@ static int philips_tdm1316l_tuner_init(struct dvb_frontend *fe)
 		fe->ops.i2c_gate_ctrl(fe, 1);
 	if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
 		return -EIO;
-	msleep(1);
+	msleep(20); // Was 1, but msleep would have slept up to 20ms nevertheless.

 	// disable the mc44BC374c (do not check for errors)
 	tuner_msg.addr = 0x65;
@@ -805,7 +805,7 @@ static int philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe)
 	if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
 		return -EIO;

-	msleep(1);
+	msleep(20); // Was 1, but msleep would have slept up to 20ms nevertheless.
 	return 0;
 }

@@ -910,7 +910,7 @@ static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe)
 	if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
 		return -EIO;

-	msleep(1);
+	msleep(20); // Was 1, but msleep would have slept up to 20ms nevertheless.

 	return 0;
 }
diff --git a/drivers/media/pci/ttpci/budget.c b/drivers/media/pci/ttpci/budget.c
index 3842bad8d..10599037c 100644
--- a/drivers/media/pci/ttpci/budget.c
+++ b/drivers/media/pci/ttpci/budget.c
@@ -630,9 +630,9 @@ static void frontend_init(struct budget *budget)

 		// gpio2 is connected to CLB - reset it + leave it high
 		saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO);
-		msleep(1);
+		msleep(20); // Was 1, but msleep would have slept up to 20ms nevertheless.
 		saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI);
-		msleep(1);
+		msleep(20); // Was 1, but msleep would have slept up to 20ms nevertheless.

 		fe = dvb_attach(tda10086_attach, &tda10086_config, &budget->i2c_adap);
 		if (fe) {
--
2.34.0


  parent reply	other threads:[~2024-03-28  2:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28  2:05 [PATCH 00/11] media: ttpci: make checkpatch happy Stefan Herdler
2024-03-28  2:05 ` [PATCH 01/11] media: ttpci: checkpatch fixes: whitespace and newlines Stefan Herdler
2024-03-28  2:05 ` [PATCH 02/11] media: ttpci: checkpatch fixes: whitespace Stefan Herdler
2024-03-28  2:05 ` [PATCH 03/11] media: ttpci: checkpatch fixes: comments Stefan Herdler
2024-03-28  2:05 ` [PATCH 04/11] media: ttpci: checkpatch fixes: braces Stefan Herdler
2024-04-08 14:47   ` Hans Verkuil
2024-03-28  2:05 ` [PATCH 05/11] media: ttpci: checkpatch fixes: export_symbol Stefan Herdler
2024-03-28  2:05 ` [PATCH 06/11] media: ttpci: checkpatch fixes: assign_in_if Stefan Herdler
2024-03-28  2:05 ` [PATCH 07/11] media: ttpci: checkpatch fixes: trailing_statements Stefan Herdler
2024-03-28  2:05 ` [PATCH 08/11] media: ttpci: checkpatch fixes: constant_comparsation Stefan Herdler
2024-03-28  2:05 ` [PATCH 09/11] media: ttpci: checkpatch fixes: miscellaneous Stefan Herdler
2024-03-28  2:05 ` [PATCH 10/11] media: ttpci: checkpatch fixes: logging Stefan Herdler
2024-03-28  2:05 ` Stefan Herdler [this message]
2024-04-08 14:53   ` [PATCH 11/11] media: ttpci: checkpatch fixes: msleep Hans Verkuil
2024-04-08 14:54 ` [PATCH 00/11] media: ttpci: make checkpatch happy Hans Verkuil
2024-04-12 21:59   ` Stefan Herdler

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=20240328020522.50995-12-herdler@nurfuerspam.de \
    --to=herdler@nurfuerspam.de \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=smoch@web.de \
    --cc=tmn505@gmail.com \
    --cc=vinschen@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.