diff options
author | Tejun Heo <tj@kernel.org> | 2012-08-03 13:30:44 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2012-08-03 13:30:44 -0400 |
commit | d4283e9378619c14dc3826a6b0527eb5d967ffde (patch) | |
tree | 1b1e401e51021c90407fae58e000c183a0e6c0e2 /kernel/workqueue.c | |
parent | 0a13c00e9d4502b8e3fd9260ce781758ff2c3970 (diff) |
workqueue: make queueing functions return bool
All queueing functions return 1 on success, 0 if the work item was
already pending. Update them to return bool instead. This signifies
better that they don't return 0 / -errno.
This is cleanup and doesn't cause any functional difference.
While at it, fix comment opening for schedule_work_on().
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r-- | kernel/workqueue.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 07d309e7e359..70f95ab28f3d 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -1058,19 +1058,19 @@ static void __queue_work(unsigned int cpu, struct workqueue_struct *wq, | |||
1058 | * @wq: workqueue to use | 1058 | * @wq: workqueue to use |
1059 | * @work: work to queue | 1059 | * @work: work to queue |
1060 | * | 1060 | * |
1061 | * Returns 0 if @work was already on a queue, non-zero otherwise. | 1061 | * Returns %false if @work was already on a queue, %true otherwise. |
1062 | * | 1062 | * |
1063 | * We queue the work to a specific CPU, the caller must ensure it | 1063 | * We queue the work to a specific CPU, the caller must ensure it |
1064 | * can't go away. | 1064 | * can't go away. |
1065 | */ | 1065 | */ |
1066 | int | 1066 | bool queue_work_on(int cpu, struct workqueue_struct *wq, |
1067 | queue_work_on(int cpu, struct workqueue_struct *wq, struct work_struct *work) | 1067 | struct work_struct *work) |
1068 | { | 1068 | { |
1069 | int ret = 0; | 1069 | bool ret = false; |
1070 | 1070 | ||
1071 | if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))) { | 1071 | if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))) { |
1072 | __queue_work(cpu, wq, work); | 1072 | __queue_work(cpu, wq, work); |
1073 | ret = 1; | 1073 | ret = true; |
1074 | } | 1074 | } |
1075 | return ret; | 1075 | return ret; |
1076 | } | 1076 | } |
@@ -1081,14 +1081,14 @@ EXPORT_SYMBOL_GPL(queue_work_on); | |||
1081 | * @wq: workqueue to use | 1081 | * @wq: workqueue to use |
1082 | * @work: work to queue | 1082 | * @work: work to queue |
1083 | * | 1083 | * |
1084 | * Returns 0 if @work was already on a queue, non-zero otherwise. | 1084 | * Returns %false if @work was already on a queue, %true otherwise. |
1085 | * | 1085 | * |
1086 | * We queue the work to the CPU on which it was submitted, but if the CPU dies | 1086 | * We queue the work to the CPU on which it was submitted, but if the CPU dies |
1087 | * it can be processed by another CPU. | 1087 | * it can be processed by another CPU. |
1088 | */ | 1088 | */ |
1089 | int queue_work(struct workqueue_struct *wq, struct work_struct *work) | 1089 | bool queue_work(struct workqueue_struct *wq, struct work_struct *work) |
1090 | { | 1090 | { |
1091 | int ret; | 1091 | bool ret; |
1092 | 1092 | ||
1093 | ret = queue_work_on(get_cpu(), wq, work); | 1093 | ret = queue_work_on(get_cpu(), wq, work); |
1094 | put_cpu(); | 1094 | put_cpu(); |
@@ -1112,14 +1112,14 @@ static void delayed_work_timer_fn(unsigned long __data) | |||
1112 | * @dwork: work to queue | 1112 | * @dwork: work to queue |
1113 | * @delay: number of jiffies to wait before queueing | 1113 | * @delay: number of jiffies to wait before queueing |
1114 | * | 1114 | * |
1115 | * Returns 0 if @work was already on a queue, non-zero otherwise. | 1115 | * Returns %false if @work was already on a queue, %true otherwise. |
1116 | */ | 1116 | */ |
1117 | int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, | 1117 | bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq, |
1118 | struct delayed_work *dwork, unsigned long delay) | 1118 | struct delayed_work *dwork, unsigned long delay) |
1119 | { | 1119 | { |
1120 | int ret = 0; | ||
1121 | struct timer_list *timer = &dwork->timer; | 1120 | struct timer_list *timer = &dwork->timer; |
1122 | struct work_struct *work = &dwork->work; | 1121 | struct work_struct *work = &dwork->work; |
1122 | bool ret = false; | ||
1123 | 1123 | ||
1124 | if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))) { | 1124 | if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))) { |
1125 | unsigned int lcpu; | 1125 | unsigned int lcpu; |
@@ -1154,7 +1154,7 @@ int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, | |||
1154 | add_timer_on(timer, cpu); | 1154 | add_timer_on(timer, cpu); |
1155 | else | 1155 | else |
1156 | add_timer(timer); | 1156 | add_timer(timer); |
1157 | ret = 1; | 1157 | ret = true; |
1158 | } | 1158 | } |
1159 | return ret; | 1159 | return ret; |
1160 | } | 1160 | } |
@@ -1166,9 +1166,9 @@ EXPORT_SYMBOL_GPL(queue_delayed_work_on); | |||
1166 | * @dwork: delayable work to queue | 1166 | * @dwork: delayable work to queue |
1167 | * @delay: number of jiffies to wait before queueing | 1167 | * @delay: number of jiffies to wait before queueing |
1168 | * | 1168 | * |
1169 | * Returns 0 if @work was already on a queue, non-zero otherwise. | 1169 | * Returns %false if @work was already on a queue, %true otherwise. |
1170 | */ | 1170 | */ |
1171 | int queue_delayed_work(struct workqueue_struct *wq, | 1171 | bool queue_delayed_work(struct workqueue_struct *wq, |
1172 | struct delayed_work *dwork, unsigned long delay) | 1172 | struct delayed_work *dwork, unsigned long delay) |
1173 | { | 1173 | { |
1174 | if (delay == 0) | 1174 | if (delay == 0) |
@@ -2877,14 +2877,14 @@ bool cancel_delayed_work_sync(struct delayed_work *dwork) | |||
2877 | } | 2877 | } |
2878 | EXPORT_SYMBOL(cancel_delayed_work_sync); | 2878 | EXPORT_SYMBOL(cancel_delayed_work_sync); |
2879 | 2879 | ||
2880 | /* | 2880 | /** |
2881 | * schedule_work_on - put work task on a specific cpu | 2881 | * schedule_work_on - put work task on a specific cpu |
2882 | * @cpu: cpu to put the work task on | 2882 | * @cpu: cpu to put the work task on |
2883 | * @work: job to be done | 2883 | * @work: job to be done |
2884 | * | 2884 | * |
2885 | * This puts a job on a specific cpu | 2885 | * This puts a job on a specific cpu |
2886 | */ | 2886 | */ |
2887 | int schedule_work_on(int cpu, struct work_struct *work) | 2887 | bool schedule_work_on(int cpu, struct work_struct *work) |
2888 | { | 2888 | { |
2889 | return queue_work_on(cpu, system_wq, work); | 2889 | return queue_work_on(cpu, system_wq, work); |
2890 | } | 2890 | } |
@@ -2894,14 +2894,14 @@ EXPORT_SYMBOL(schedule_work_on); | |||
2894 | * schedule_work - put work task in global workqueue | 2894 | * schedule_work - put work task in global workqueue |
2895 | * @work: job to be done | 2895 | * @work: job to be done |
2896 | * | 2896 | * |
2897 | * Returns zero if @work was already on the kernel-global workqueue and | 2897 | * Returns %false if @work was already on the kernel-global workqueue and |
2898 | * non-zero otherwise. | 2898 | * %true otherwise. |
2899 | * | 2899 | * |
2900 | * This puts a job in the kernel-global workqueue if it was not already | 2900 | * This puts a job in the kernel-global workqueue if it was not already |
2901 | * queued and leaves it in the same position on the kernel-global | 2901 | * queued and leaves it in the same position on the kernel-global |
2902 | * workqueue otherwise. | 2902 | * workqueue otherwise. |
2903 | */ | 2903 | */ |
2904 | int schedule_work(struct work_struct *work) | 2904 | bool schedule_work(struct work_struct *work) |
2905 | { | 2905 | { |
2906 | return queue_work(system_wq, work); | 2906 | return queue_work(system_wq, work); |
2907 | } | 2907 | } |
@@ -2916,8 +2916,8 @@ EXPORT_SYMBOL(schedule_work); | |||
2916 | * After waiting for a given time this puts a job in the kernel-global | 2916 | * After waiting for a given time this puts a job in the kernel-global |
2917 | * workqueue on the specified CPU. | 2917 | * workqueue on the specified CPU. |
2918 | */ | 2918 | */ |
2919 | int schedule_delayed_work_on(int cpu, | 2919 | bool schedule_delayed_work_on(int cpu, struct delayed_work *dwork, |
2920 | struct delayed_work *dwork, unsigned long delay) | 2920 | unsigned long delay) |
2921 | { | 2921 | { |
2922 | return queue_delayed_work_on(cpu, system_wq, dwork, delay); | 2922 | return queue_delayed_work_on(cpu, system_wq, dwork, delay); |
2923 | } | 2923 | } |
@@ -2931,8 +2931,7 @@ EXPORT_SYMBOL(schedule_delayed_work_on); | |||
2931 | * After waiting for a given time this puts a job in the kernel-global | 2931 | * After waiting for a given time this puts a job in the kernel-global |
2932 | * workqueue. | 2932 | * workqueue. |
2933 | */ | 2933 | */ |
2934 | int schedule_delayed_work(struct delayed_work *dwork, | 2934 | bool schedule_delayed_work(struct delayed_work *dwork, unsigned long delay) |
2935 | unsigned long delay) | ||
2936 | { | 2935 | { |
2937 | return queue_delayed_work(system_wq, dwork, delay); | 2936 | return queue_delayed_work(system_wq, dwork, delay); |
2938 | } | 2937 | } |