diag: Rate limit usb write error messages for hsic data

When writing hsic data on the usb (usb_diag_write) the device
can get into the state where an error is returned each time.
If this happens, then the device is flooded with these messages.
Prevent the flooding with messages by rate limiting the error
message.

Signed-off-by: Dixon Peterson <dixonp@codeaurora.org>

Change-Id: I08d68e62e79c5855709feb27d8eec426851d829f
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
This commit is contained in:
Dixon Peterson 2012-09-13 18:51:47 -07:00 committed by Stephen Boyd
parent 21bc5513e9
commit 91f5cebc3c
2 changed files with 13 additions and 3 deletions

View file

@ -16,6 +16,7 @@
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/sched.h>
#include <linux/ratelimit.h>
#include <linux/workqueue.h>
#include <linux/pm_runtime.h>
#include <linux/diagchar.h>
@ -442,7 +443,8 @@ int diag_device_write(void *buf, int proc_num, struct diag_request *write_ptr)
diagmem_free(driver,
write_ptr_mdm,
POOL_TYPE_HSIC_WRITE);
pr_err("diag: HSIC write failure\n");
pr_err_ratelimited("diag: HSIC write failure, err: %d\n",
err);
}
} else {
pr_err("diag: allocate write fail\n");

View file

@ -71,6 +71,13 @@ static void diag_read_hsic_work_fn(struct work_struct *work)
write_ptrs_available--;
/*
* No sense queuing a read if the hsic bridge was
* closed in another thread
*/
if (!driver->hsic_ch)
break;
buf_in_hsic = diagmem_alloc(driver, READ_HSIC_BUF_SIZE,
POOL_TYPE_HSIC);
if (buf_in_hsic) {
@ -107,7 +114,8 @@ static void diag_read_hsic_work_fn(struct work_struct *work)
* (-ENODEV is an unrecoverable error), then set up the next read
*/
if ((driver->count_hsic_pool < driver->poolsize_hsic) &&
(num_reads_submitted == 0) && (err != -ENODEV))
(num_reads_submitted == 0) && (err != -ENODEV) &&
(driver->hsic_ch != 0))
queue_work(driver->diag_bridge_wq,
&driver->diag_read_hsic_work);
}
@ -146,7 +154,7 @@ static void diag_hsic_read_complete_callback(void *ctxt, char *buf,
/* If an error, return buffer to the pool */
if (err) {
diagmem_free(driver, buf, POOL_TYPE_HSIC);
pr_err("diag: In %s, error calling diag_device_write, err: %d\n",
pr_err_ratelimited("diag: In %s, error calling diag_device_write, err: %d\n",
__func__, err);
}
}