summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNarendra Damahe <ndamahe@nvidia.com>2010-09-17 13:40:52 -0700
committerGary King <gking@nvidia.com>2010-09-21 11:12:41 -0700
commit3dab0e0518e951e62ebcdceb9f170f304cb9d9b5 (patch)
tree807563dbefff1b46873366ca6358e1bb6c852913
parentd8b15af16bce67bcb47eda7938ca12695affc681 (diff)
[USB ADB]: rate control adb prints
limit the number of times adb_open and adb_release may be printed in a short period of time, to prevent adb death spirals when exiting suspend (cherry picked from commit 3a1e33f6715f7133ba9fe26d68342c1ff6106b20) Change-Id: I575f38269c9a4c46a3a59ff7a06c8bda36a0c0d4 Reviewed-on: http://git-master/r/6723 Reviewed-by: Narendra Damahe <ndamahe@nvidia.com> Tested-by: Narendra Damahe <ndamahe@nvidia.com> Reviewed-by: Gary King <gking@nvidia.com>
-rw-r--r--drivers/usb/gadget/f_adb.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/drivers/usb/gadget/f_adb.c b/drivers/usb/gadget/f_adb.c
index 301300e04cab..8e2347781be5 100644
--- a/drivers/usb/gadget/f_adb.c
+++ b/drivers/usb/gadget/f_adb.c
@@ -154,12 +154,14 @@ static void adb_request_free(struct usb_request *req, struct usb_ep *ep)
static inline int _lock(atomic_t *excl)
{
+ int ret = -1;
+ preempt_disable();
if (atomic_inc_return(excl) == 1) {
- return 0;
- } else {
+ ret= 0;
+ } else
atomic_dec(excl);
- return -1;
- }
+ preempt_enable();
+ return ret;
}
static inline void _unlock(atomic_t *excl)
@@ -409,21 +411,43 @@ static ssize_t adb_write(struct file *fp, const char __user *buf,
static int adb_open(struct inode *ip, struct file *fp)
{
- printk(KERN_INFO "adb_open\n");
- if (_lock(&_adb_dev->open_excl))
+ static unsigned long last_print;
+ static unsigned long count = 0;
+ if (++count == 1)
+ last_print = jiffies;
+ else {
+ if (!time_before(jiffies, last_print + HZ/2))
+ count = 0;
+ last_print = jiffies;
+ }
+ if (_lock(&_adb_dev->open_excl)) {
+ cpu_relax();
return -EBUSY;
+ }
+ if (count < 5)
+ printk(KERN_INFO "adb_open(%s)\n", current->comm);
fp->private_data = _adb_dev;
/* clear the error latch */
_adb_dev->error = 0;
-
return 0;
}
static int adb_release(struct inode *ip, struct file *fp)
{
- printk(KERN_INFO "adb_release\n");
+ static unsigned long last_print;
+ static unsigned long count = 0;
+ if (++count == 1)
+ last_print = jiffies;
+ else {
+ if (!time_before(jiffies, last_print + HZ/2))
+ count = 0;
+ last_print = jiffies;
+ }
+
+ if (count < 5)
+ printk(KERN_INFO "adb_release\n");
_unlock(&_adb_dev->open_excl);
return 0;
}