]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/res_counter.h
res_counter: limit change support ebusy
[linux-2.6-omap-h63xx.git] / include / linux / res_counter.h
index 290205dfe094325a98c77581dea27b3e4a6c69c6..fdeadd9740dc5f99deaa4a8662494914f438e8c4 100644 (file)
@@ -158,4 +158,20 @@ static inline void res_counter_reset_failcnt(struct res_counter *cnt)
        cnt->failcnt = 0;
        spin_unlock_irqrestore(&cnt->lock, flags);
 }
+
+static inline int res_counter_set_limit(struct res_counter *cnt,
+               unsigned long long limit)
+{
+       unsigned long flags;
+       int ret = -EBUSY;
+
+       spin_lock_irqsave(&cnt->lock, flags);
+       if (cnt->usage < limit) {
+               cnt->limit = limit;
+               ret = 0;
+       }
+       spin_unlock_irqrestore(&cnt->lock, flags);
+       return ret;
+}
+
 #endif