From: Shaohua Li Date: Wed, 25 May 2011 00:13:35 +0000 (-0700) Subject: percpu_counter: change return value and add comments X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c84598bbfa756b7d042da31aa4e198ae866a6c7d;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git percpu_counter: change return value and add comments The percpu_counter_*_positive() API in UP case doesn't check if return value is positive. Add comments to explain why we don't. Also if count < 0, returns 0 instead of 1 for *read_positive(). [akpm@linux-foundation.org: tweak comment] Signed-off-by: Shaohua Li Acked-by: Eric Dumazet Cc: Tejun Heo Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h index 46f6ba56fa91..5edc9014263a 100644 --- a/include/linux/percpu_counter.h +++ b/include/linux/percpu_counter.h @@ -75,7 +75,7 @@ static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc) barrier(); /* Prevent reloads of fbc->count */ if (ret >= 0) return ret; - return 1; + return 0; } static inline int percpu_counter_initialized(struct percpu_counter *fbc) @@ -133,6 +133,10 @@ static inline s64 percpu_counter_read(struct percpu_counter *fbc) return fbc->count; } +/* + * percpu_counter is intended to track positive numbers. In the UP case the + * number should never be negative. + */ static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc) { return fbc->count;