diff options
author | Gary King <gking@nvidia.com> | 2010-09-07 09:07:47 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2011-11-30 21:52:12 -0800 |
commit | dfe37d54ac9bd327267c618ee53694084fa8548b (patch) | |
tree | 01b87e5fb2e8e03dbb4589906602b55cf8f6cc0a /drivers | |
parent | ed30818749f16530a381a109710cec51af9fcb4e (diff) |
HACK: 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.
Original-Change-Id: I231bdc0bb497758174ec12a69c8d17d5dc95d4db
Rebase-Id: R56e66e16e212dee5fd95ebb392955e06018e16bd
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/f_adb.c | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/drivers/usb/gadget/f_adb.c b/drivers/usb/gadget/f_adb.c index fe4455e50d10..8ed7b0123194 100644 --- a/drivers/usb/gadget/f_adb.c +++ b/drivers/usb/gadget/f_adb.c @@ -147,12 +147,16 @@ static void adb_request_free(struct usb_request *req, struct usb_ep *ep) static inline int adb_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 adb_unlock(atomic_t *excl) @@ -406,12 +410,28 @@ 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"); + static unsigned long last_print; + static unsigned long count = 0; + if (!_adb_dev) return -ENODEV; + if (++count == 1) + last_print = jiffies; + else { + if (!time_before(jiffies, last_print + HZ/2)) + count = 0; + last_print = jiffies; + } + if (adb_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; @@ -423,7 +443,19 @@ static int adb_open(struct inode *ip, struct file *fp) 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"); adb_unlock(&_adb_dev->open_excl); return 0; } |