Commit 47a09b08 authored by Jarod Wilson's avatar Jarod Wilson Committed by Mauro Carvalho Chehab

[media] imon: rate-limit send_packet spew

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: default avatarJarod Wilson <jarod@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent d59a7b1d
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/ratelimit.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/usb.h> #include <linux/usb.h>
...@@ -516,19 +517,19 @@ static int send_packet(struct imon_context *ictx) ...@@ -516,19 +517,19 @@ static int send_packet(struct imon_context *ictx)
if (retval) { if (retval) {
ictx->tx.busy = false; ictx->tx.busy = false;
smp_rmb(); /* ensure later readers know we're not busy */ 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 { } else {
/* Wait for transmission to complete (or abort) */ /* Wait for transmission to complete (or abort) */
mutex_unlock(&ictx->lock); mutex_unlock(&ictx->lock);
retval = wait_for_completion_interruptible( retval = wait_for_completion_interruptible(
&ictx->tx.finished); &ictx->tx.finished);
if (retval) if (retval)
pr_err("task interrupted\n"); pr_err_ratelimited("task interrupted\n");
mutex_lock(&ictx->lock); mutex_lock(&ictx->lock);
retval = ictx->tx.status; retval = ictx->tx.status;
if (retval) if (retval)
pr_err("packet tx failed (%d)\n", retval); pr_err_ratelimited("packet tx failed (%d)\n", retval);
} }
kfree(control_req); kfree(control_req);
...@@ -830,20 +831,20 @@ static ssize_t vfd_write(struct file *file, const char *buf, ...@@ -830,20 +831,20 @@ static ssize_t vfd_write(struct file *file, const char *buf,
ictx = file->private_data; ictx = file->private_data;
if (!ictx) { if (!ictx) {
pr_err("no context for device\n"); pr_err_ratelimited("no context for device\n");
return -ENODEV; return -ENODEV;
} }
mutex_lock(&ictx->lock); mutex_lock(&ictx->lock);
if (!ictx->dev_present_intf0) { if (!ictx->dev_present_intf0) {
pr_err("no iMON device present\n"); pr_err_ratelimited("no iMON device present\n");
retval = -ENODEV; retval = -ENODEV;
goto exit; goto exit;
} }
if (n_bytes <= 0 || n_bytes > 32) { if (n_bytes <= 0 || n_bytes > 32) {
pr_err("invalid payload size\n"); pr_err_ratelimited("invalid payload size\n");
retval = -EINVAL; retval = -EINVAL;
goto exit; goto exit;
} }
...@@ -869,7 +870,7 @@ static ssize_t vfd_write(struct file *file, const char *buf, ...@@ -869,7 +870,7 @@ static ssize_t vfd_write(struct file *file, const char *buf,
retval = send_packet(ictx); retval = send_packet(ictx);
if (retval) { 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; goto exit;
} else { } else {
seq += 2; seq += 2;
...@@ -883,7 +884,7 @@ static ssize_t vfd_write(struct file *file, const char *buf, ...@@ -883,7 +884,7 @@ static ssize_t vfd_write(struct file *file, const char *buf,
ictx->usb_tx_buf[7] = (unsigned char) seq; ictx->usb_tx_buf[7] = (unsigned char) seq;
retval = send_packet(ictx); retval = send_packet(ictx);
if (retval) if (retval)
pr_err("send packet failed for packet #%d\n", seq / 2); pr_err_ratelimited("send packet #%d failed\n", seq / 2);
exit: exit:
mutex_unlock(&ictx->lock); mutex_unlock(&ictx->lock);
...@@ -912,20 +913,21 @@ static ssize_t lcd_write(struct file *file, const char *buf, ...@@ -912,20 +913,21 @@ static ssize_t lcd_write(struct file *file, const char *buf,
ictx = file->private_data; ictx = file->private_data;
if (!ictx) { if (!ictx) {
pr_err("no context for device\n"); pr_err_ratelimited("no context for device\n");
return -ENODEV; return -ENODEV;
} }
mutex_lock(&ictx->lock); mutex_lock(&ictx->lock);
if (!ictx->display_supported) { if (!ictx->display_supported) {
pr_err("no iMON display present\n"); pr_err_ratelimited("no iMON display present\n");
retval = -ENODEV; retval = -ENODEV;
goto exit; goto exit;
} }
if (n_bytes != 8) { 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; retval = -EINVAL;
goto exit; goto exit;
} }
...@@ -937,7 +939,7 @@ static ssize_t lcd_write(struct file *file, const char *buf, ...@@ -937,7 +939,7 @@ static ssize_t lcd_write(struct file *file, const char *buf,
retval = send_packet(ictx); retval = send_packet(ictx);
if (retval) { if (retval) {
pr_err("send packet failed!\n"); pr_err_ratelimited("send packet failed!\n");
goto exit; goto exit;
} else { } else {
dev_dbg(ictx->dev, "%s: write %d bytes to LCD\n", dev_dbg(ictx->dev, "%s: write %d bytes to LCD\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment