linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [media] imon: rate-limit send_packet spew
@ 2011-07-13 21:58 Jarod Wilson
  2011-07-14 16:12 ` Mauro Carvalho Chehab
  2011-07-14 17:20 ` [PATCH v2] " Jarod Wilson
  0 siblings, 2 replies; 4+ messages in thread
From: Jarod Wilson @ 2011-07-13 21:58 UTC (permalink / raw)
  To: linux-media; +Cc: Jarod Wilson

There are folks with flaky imon hardware out there that doesn't always
respond to requests to write to their displays for some reason, which
can flood logs quickly when something like lcdproc is trying to
constantly update the display, so lets rate-limit all that error spew.

Signed-off-by: Jarod Wilson <jarod@redhat.com>
---
 drivers/media/rc/imon.c |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 6bc35ee..ba48c1e 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -516,19 +516,19 @@ static int send_packet(struct imon_context *ictx)
 	if (retval) {
 		ictx->tx.busy = false;
 		smp_rmb(); /* ensure later readers know we're not busy */
-		pr_err("error submitting urb(%d)\n", retval);
+		pr_err_ratelimited("error submitting urb(%d)\n", retval);
 	} else {
 		/* Wait for transmission to complete (or abort) */
 		mutex_unlock(&ictx->lock);
 		retval = wait_for_completion_interruptible(
 				&ictx->tx.finished);
 		if (retval)
-			pr_err("task interrupted\n");
+			pr_err_ratelimited("task interrupted\n");
 		mutex_lock(&ictx->lock);
 
 		retval = ictx->tx.status;
 		if (retval)
-			pr_err("packet tx failed (%d)\n", retval);
+			pr_err_ratelimited("packet tx failed (%d)\n", retval);
 	}
 
 	kfree(control_req);
@@ -830,20 +830,20 @@ static ssize_t vfd_write(struct file *file, const char *buf,
 
 	ictx = file->private_data;
 	if (!ictx) {
-		pr_err("no context for device\n");
+		pr_err_ratelimited("no context for device\n");
 		return -ENODEV;
 	}
 
 	mutex_lock(&ictx->lock);
 
 	if (!ictx->dev_present_intf0) {
-		pr_err("no iMON device present\n");
+		pr_err_ratelimited("no iMON device present\n");
 		retval = -ENODEV;
 		goto exit;
 	}
 
 	if (n_bytes <= 0 || n_bytes > 32) {
-		pr_err("invalid payload size\n");
+		pr_err_ratelimited("invalid payload size\n");
 		retval = -EINVAL;
 		goto exit;
 	}
@@ -869,7 +869,7 @@ static ssize_t vfd_write(struct file *file, const char *buf,
 
 		retval = send_packet(ictx);
 		if (retval) {
-			pr_err("send packet failed for packet #%d\n", seq / 2);
+			pr_err_ratelimited("send packet #%d failed\n", seq / 2);
 			goto exit;
 		} else {
 			seq += 2;
@@ -883,7 +883,7 @@ static ssize_t vfd_write(struct file *file, const char *buf,
 	ictx->usb_tx_buf[7] = (unsigned char) seq;
 	retval = send_packet(ictx);
 	if (retval)
-		pr_err("send packet failed for packet #%d\n", seq / 2);
+		pr_err_ratelimited("send packet #%d failed\n", seq / 2);
 
 exit:
 	mutex_unlock(&ictx->lock);
@@ -912,20 +912,21 @@ static ssize_t lcd_write(struct file *file, const char *buf,
 
 	ictx = file->private_data;
 	if (!ictx) {
-		pr_err("no context for device\n");
+		pr_err_ratelimited("no context for device\n");
 		return -ENODEV;
 	}
 
 	mutex_lock(&ictx->lock);
 
 	if (!ictx->display_supported) {
-		pr_err("no iMON display present\n");
+		pr_err_ratelimited("no iMON display present\n");
 		retval = -ENODEV;
 		goto exit;
 	}
 
 	if (n_bytes != 8) {
-		pr_err("invalid payload size: %d (expected 8)\n", (int)n_bytes);
+		pr_err_ratelimited("invalid payload size: %d (expected 8)\n",
+				   (int)n_bytes);
 		retval = -EINVAL;
 		goto exit;
 	}
@@ -937,7 +938,7 @@ static ssize_t lcd_write(struct file *file, const char *buf,
 
 	retval = send_packet(ictx);
 	if (retval) {
-		pr_err("send packet failed!\n");
+		pr_err_ratelimited("send packet failed!\n");
 		goto exit;
 	} else {
 		dev_dbg(ictx->dev, "%s: write %d bytes to LCD\n",
-- 
1.7.1


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

* Re: [PATCH] [media] imon: rate-limit send_packet spew
  2011-07-13 21:58 [PATCH] [media] imon: rate-limit send_packet spew Jarod Wilson
@ 2011-07-14 16:12 ` Mauro Carvalho Chehab
  2011-07-14 16:17   ` Jarod Wilson
  2011-07-14 17:20 ` [PATCH v2] " Jarod Wilson
  1 sibling, 1 reply; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2011-07-14 16:12 UTC (permalink / raw)
  To: Jarod Wilson; +Cc: linux-media

Em 13-07-2011 18:58, Jarod Wilson escreveu:
> There are folks with flaky imon hardware out there that doesn't always
> respond to requests to write to their displays for some reason, which
> can flood logs quickly when something like lcdproc is trying to
> constantly update the display, so lets rate-limit all that error spew.

This patch caused a compilation error here:

drivers/media/rc/imon.c: In function ‘send_packet’:
drivers/media/rc/imon.c:519: warning: type defaults to ‘int’ in declaration of ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:519: warning: parameter names (without types) in function declaration
drivers/media/rc/imon.c:519: error: invalid storage class for function ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:519: error: implicit declaration of function ‘__ratelimit’
drivers/media/rc/imon.c:519: error: ‘_rs’ undeclared (first use in this function)
drivers/media/rc/imon.c:519: error: (Each undeclared identifier is reported only once
drivers/media/rc/imon.c:519: error: for each function it appears in.)
drivers/media/rc/imon.c:526: warning: type defaults to ‘int’ in declaration of ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:526: warning: parameter names (without types) in function declaration
drivers/media/rc/imon.c:526: error: invalid storage class for function ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:531: warning: type defaults to ‘int’ in declaration of ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:531: warning: parameter names (without types) in function declaration
drivers/media/rc/imon.c:531: error: invalid storage class for function ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c: In function ‘vfd_write’:
drivers/media/rc/imon.c:833: warning: type defaults to ‘int’ in declaration of ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:833: warning: parameter names (without types) in function declaration
drivers/media/rc/imon.c:833: error: invalid storage class for function ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:833: error: ‘_rs’ undeclared (first use in this function)
drivers/media/rc/imon.c:840: warning: type defaults to ‘int’ in declaration of ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:840: warning: parameter names (without types) in function declaration
drivers/media/rc/imon.c:840: error: invalid storage class for function ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:846: warning: type defaults to ‘int’ in declaration of ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:846: warning: parameter names (without types) in function declaration
drivers/media/rc/imon.c:846: error: invalid storage class for function ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:872: warning: type defaults to ‘int’ in declaration of ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:872: warning: parameter names (without types) in function declaration
drivers/media/rc/imon.c:872: error: invalid storage class for function ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:886: warning: type defaults to ‘int’ in declaration of ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:886: warning: parameter names (without types) in function declaration
drivers/media/rc/imon.c:886: error: invalid storage class for function ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c: In function ‘lcd_write’:
drivers/media/rc/imon.c:915: warning: type defaults to ‘int’ in declaration of ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:915: warning: parameter names (without types) in function declaration
drivers/media/rc/imon.c:915: error: invalid storage class for function ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:915: error: ‘_rs’ undeclared (first use in this function)
drivers/media/rc/imon.c:922: warning: type defaults to ‘int’ in declaration of ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:922: warning: parameter names (without types) in function declaration
drivers/media/rc/imon.c:922: error: invalid storage class for function ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:928: warning: type defaults to ‘int’ in declaration of ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:928: warning: parameter names (without types) in function declaration
drivers/media/rc/imon.c:928: error: invalid storage class for function ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:941: warning: type defaults to ‘int’ in declaration of ‘DEFINE_RATELIMIT_STATE’
drivers/media/rc/imon.c:941: warning: parameter names (without types) in function declaration
drivers/media/rc/imon.c:941: error: invalid storage class for function ‘DEFINE_RATELIMIT_STATE’


> 
> Signed-off-by: Jarod Wilson <jarod@redhat.com>
> ---
>  drivers/media/rc/imon.c |   25 +++++++++++++------------
>  1 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
> index 6bc35ee..ba48c1e 100644
> --- a/drivers/media/rc/imon.c
> +++ b/drivers/media/rc/imon.c
> @@ -516,19 +516,19 @@ static int send_packet(struct imon_context *ictx)
>  	if (retval) {
>  		ictx->tx.busy = false;
>  		smp_rmb(); /* ensure later readers know we're not busy */
> -		pr_err("error submitting urb(%d)\n", retval);
> +		pr_err_ratelimited("error submitting urb(%d)\n", retval);
>  	} else {
>  		/* Wait for transmission to complete (or abort) */
>  		mutex_unlock(&ictx->lock);
>  		retval = wait_for_completion_interruptible(
>  				&ictx->tx.finished);
>  		if (retval)
> -			pr_err("task interrupted\n");
> +			pr_err_ratelimited("task interrupted\n");
>  		mutex_lock(&ictx->lock);
>  
>  		retval = ictx->tx.status;
>  		if (retval)
> -			pr_err("packet tx failed (%d)\n", retval);
> +			pr_err_ratelimited("packet tx failed (%d)\n", retval);
>  	}
>  
>  	kfree(control_req);
> @@ -830,20 +830,20 @@ static ssize_t vfd_write(struct file *file, const char *buf,
>  
>  	ictx = file->private_data;
>  	if (!ictx) {
> -		pr_err("no context for device\n");
> +		pr_err_ratelimited("no context for device\n");
>  		return -ENODEV;
>  	}
>  
>  	mutex_lock(&ictx->lock);
>  
>  	if (!ictx->dev_present_intf0) {
> -		pr_err("no iMON device present\n");
> +		pr_err_ratelimited("no iMON device present\n");
>  		retval = -ENODEV;
>  		goto exit;
>  	}
>  
>  	if (n_bytes <= 0 || n_bytes > 32) {
> -		pr_err("invalid payload size\n");
> +		pr_err_ratelimited("invalid payload size\n");
>  		retval = -EINVAL;
>  		goto exit;
>  	}
> @@ -869,7 +869,7 @@ static ssize_t vfd_write(struct file *file, const char *buf,
>  
>  		retval = send_packet(ictx);
>  		if (retval) {
> -			pr_err("send packet failed for packet #%d\n", seq / 2);
> +			pr_err_ratelimited("send packet #%d failed\n", seq / 2);
>  			goto exit;
>  		} else {
>  			seq += 2;
> @@ -883,7 +883,7 @@ static ssize_t vfd_write(struct file *file, const char *buf,
>  	ictx->usb_tx_buf[7] = (unsigned char) seq;
>  	retval = send_packet(ictx);
>  	if (retval)
> -		pr_err("send packet failed for packet #%d\n", seq / 2);
> +		pr_err_ratelimited("send packet #%d failed\n", seq / 2);
>  
>  exit:
>  	mutex_unlock(&ictx->lock);
> @@ -912,20 +912,21 @@ static ssize_t lcd_write(struct file *file, const char *buf,
>  
>  	ictx = file->private_data;
>  	if (!ictx) {
> -		pr_err("no context for device\n");
> +		pr_err_ratelimited("no context for device\n");
>  		return -ENODEV;
>  	}
>  
>  	mutex_lock(&ictx->lock);
>  
>  	if (!ictx->display_supported) {
> -		pr_err("no iMON display present\n");
> +		pr_err_ratelimited("no iMON display present\n");
>  		retval = -ENODEV;
>  		goto exit;
>  	}
>  
>  	if (n_bytes != 8) {
> -		pr_err("invalid payload size: %d (expected 8)\n", (int)n_bytes);
> +		pr_err_ratelimited("invalid payload size: %d (expected 8)\n",
> +				   (int)n_bytes);
>  		retval = -EINVAL;
>  		goto exit;
>  	}
> @@ -937,7 +938,7 @@ static ssize_t lcd_write(struct file *file, const char *buf,
>  
>  	retval = send_packet(ictx);
>  	if (retval) {
> -		pr_err("send packet failed!\n");
> +		pr_err_ratelimited("send packet failed!\n");
>  		goto exit;
>  	} else {
>  		dev_dbg(ictx->dev, "%s: write %d bytes to LCD\n",


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

* Re: [PATCH] [media] imon: rate-limit send_packet spew
  2011-07-14 16:12 ` Mauro Carvalho Chehab
@ 2011-07-14 16:17   ` Jarod Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Jarod Wilson @ 2011-07-14 16:17 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media

Mauro Carvalho Chehab wrote:
> Em 13-07-2011 18:58, Jarod Wilson escreveu:
>> There are folks with flaky imon hardware out there that doesn't always
>> respond to requests to write to their displays for some reason, which
>> can flood logs quickly when something like lcdproc is trying to
>> constantly update the display, so lets rate-limit all that error spew.
>
> This patch caused a compilation error here:
>
> drivers/media/rc/imon.c: In function ‘send_packet’:
> drivers/media/rc/imon.c:519: warning: type defaults to ‘int’ in declaration of ‘DEFINE_RATELIMIT_STATE’
> drivers/media/rc/imon.c:519: warning: parameter names (without types) in function declaration

D'oh, sorry. Missing the <linux/ratelimit.h> #include... Will send a 
proper v2 after lunch (and a compile sanity-check).

-- 
Jarod Wilson
jarod@redhat.com



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

* [PATCH v2] [media] imon: rate-limit send_packet spew
  2011-07-13 21:58 [PATCH] [media] imon: rate-limit send_packet spew Jarod Wilson
  2011-07-14 16:12 ` Mauro Carvalho Chehab
@ 2011-07-14 17:20 ` Jarod Wilson
  1 sibling, 0 replies; 4+ messages in thread
From: Jarod Wilson @ 2011-07-14 17:20 UTC (permalink / raw)
  To: linux-media; +Cc: Jarod Wilson

There are folks with flaky imon hardware out there that doesn't always
respond to requests to write to their displays for some reason, which
can flood logs quickly when something like lcdproc is trying to
constantly update the display, so lets rate-limit all that error spew.

v2: add missing ratelimit.h include

Signed-off-by: Jarod Wilson <jarod@redhat.com>
---
 drivers/media/rc/imon.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 6bc35ee..caa3e3a 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -34,6 +34,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
+#include <linux/ratelimit.h>
 
 #include <linux/input.h>
 #include <linux/usb.h>
@@ -516,19 +517,19 @@ static int send_packet(struct imon_context *ictx)
 	if (retval) {
 		ictx->tx.busy = false;
 		smp_rmb(); /* ensure later readers know we're not busy */
-		pr_err("error submitting urb(%d)\n", retval);
+		pr_err_ratelimited("error submitting urb(%d)\n", retval);
 	} else {
 		/* Wait for transmission to complete (or abort) */
 		mutex_unlock(&ictx->lock);
 		retval = wait_for_completion_interruptible(
 				&ictx->tx.finished);
 		if (retval)
-			pr_err("task interrupted\n");
+			pr_err_ratelimited("task interrupted\n");
 		mutex_lock(&ictx->lock);
 
 		retval = ictx->tx.status;
 		if (retval)
-			pr_err("packet tx failed (%d)\n", retval);
+			pr_err_ratelimited("packet tx failed (%d)\n", retval);
 	}
 
 	kfree(control_req);
@@ -830,20 +831,20 @@ static ssize_t vfd_write(struct file *file, const char *buf,
 
 	ictx = file->private_data;
 	if (!ictx) {
-		pr_err("no context for device\n");
+		pr_err_ratelimited("no context for device\n");
 		return -ENODEV;
 	}
 
 	mutex_lock(&ictx->lock);
 
 	if (!ictx->dev_present_intf0) {
-		pr_err("no iMON device present\n");
+		pr_err_ratelimited("no iMON device present\n");
 		retval = -ENODEV;
 		goto exit;
 	}
 
 	if (n_bytes <= 0 || n_bytes > 32) {
-		pr_err("invalid payload size\n");
+		pr_err_ratelimited("invalid payload size\n");
 		retval = -EINVAL;
 		goto exit;
 	}
@@ -869,7 +870,7 @@ static ssize_t vfd_write(struct file *file, const char *buf,
 
 		retval = send_packet(ictx);
 		if (retval) {
-			pr_err("send packet failed for packet #%d\n", seq / 2);
+			pr_err_ratelimited("send packet #%d failed\n", seq / 2);
 			goto exit;
 		} else {
 			seq += 2;
@@ -883,7 +884,7 @@ static ssize_t vfd_write(struct file *file, const char *buf,
 	ictx->usb_tx_buf[7] = (unsigned char) seq;
 	retval = send_packet(ictx);
 	if (retval)
-		pr_err("send packet failed for packet #%d\n", seq / 2);
+		pr_err_ratelimited("send packet #%d failed\n", seq / 2);
 
 exit:
 	mutex_unlock(&ictx->lock);
@@ -912,20 +913,21 @@ static ssize_t lcd_write(struct file *file, const char *buf,
 
 	ictx = file->private_data;
 	if (!ictx) {
-		pr_err("no context for device\n");
+		pr_err_ratelimited("no context for device\n");
 		return -ENODEV;
 	}
 
 	mutex_lock(&ictx->lock);
 
 	if (!ictx->display_supported) {
-		pr_err("no iMON display present\n");
+		pr_err_ratelimited("no iMON display present\n");
 		retval = -ENODEV;
 		goto exit;
 	}
 
 	if (n_bytes != 8) {
-		pr_err("invalid payload size: %d (expected 8)\n", (int)n_bytes);
+		pr_err_ratelimited("invalid payload size: %d (expected 8)\n",
+				   (int)n_bytes);
 		retval = -EINVAL;
 		goto exit;
 	}
@@ -937,7 +939,7 @@ static ssize_t lcd_write(struct file *file, const char *buf,
 
 	retval = send_packet(ictx);
 	if (retval) {
-		pr_err("send packet failed!\n");
+		pr_err_ratelimited("send packet failed!\n");
 		goto exit;
 	} else {
 		dev_dbg(ictx->dev, "%s: write %d bytes to LCD\n",
-- 
1.7.5.4


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

end of thread, other threads:[~2011-07-14 17:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-13 21:58 [PATCH] [media] imon: rate-limit send_packet spew Jarod Wilson
2011-07-14 16:12 ` Mauro Carvalho Chehab
2011-07-14 16:17   ` Jarod Wilson
2011-07-14 17:20 ` [PATCH v2] " Jarod Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).