Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

exit: Rename complete_and_exit to kthread_complete_and_exit

Update complete_and_exit to call kthread_exit instead of do_exit.

Change the name to reflect this change in functionality. All of the
users of complete_and_exit are causing the current kthread to exit so
this change makes it clear what is happening.

Move the implementation of kthread_complete_and_exit from
kernel/exit.c to to kernel/kthread.c. As this function is kthread
specific it makes most sense to live with the kthread functions.

There are no functional change.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

+43 -31
+1 -1
drivers/net/wireless/rsi/rsi_91x_coex.c
··· 63 63 rsi_coex_sched_tx_pkts(coex_cb); 64 64 } while (atomic_read(&coex_cb->coex_tx_thread.thread_done) == 0); 65 65 66 - complete_and_exit(&coex_cb->coex_tx_thread.completion, 0); 66 + kthread_complete_and_exit(&coex_cb->coex_tx_thread.completion, 0); 67 67 } 68 68 69 69 int rsi_coex_recv_pkt(struct rsi_common *common, u8 *msg)
+1 -1
drivers/net/wireless/rsi/rsi_91x_main.c
··· 260 260 if (common->init_done) 261 261 rsi_core_qos_processor(common); 262 262 } while (atomic_read(&common->tx_thread.thread_done) == 0); 263 - complete_and_exit(&common->tx_thread.completion, 0); 263 + kthread_complete_and_exit(&common->tx_thread.completion, 0); 264 264 } 265 265 266 266 #ifdef CONFIG_RSI_COEX
+1 -1
drivers/net/wireless/rsi/rsi_91x_sdio_ops.c
··· 75 75 76 76 rsi_dbg(INFO_ZONE, "%s: Terminated SDIO RX thread\n", __func__); 77 77 atomic_inc(&sdev->rx_thread.thread_done); 78 - complete_and_exit(&sdev->rx_thread.completion, 0); 78 + kthread_complete_and_exit(&sdev->rx_thread.completion, 0); 79 79 } 80 80 81 81 /**
+1 -1
drivers/net/wireless/rsi/rsi_91x_usb_ops.c
··· 56 56 out: 57 57 rsi_dbg(INFO_ZONE, "%s: Terminated thread\n", __func__); 58 58 skb_queue_purge(&dev->rx_q); 59 - complete_and_exit(&dev->rx_thread.completion, 0); 59 + kthread_complete_and_exit(&dev->rx_thread.completion, 0); 60 60 } 61 61
+3 -3
drivers/pnp/pnpbios/core.c
··· 160 160 * No dock to manage 161 161 */ 162 162 case PNP_FUNCTION_NOT_SUPPORTED: 163 - complete_and_exit(&unload_sem, 0); 163 + kthread_complete_and_exit(&unload_sem, 0); 164 164 case PNP_SYSTEM_NOT_DOCKED: 165 165 d = 0; 166 166 break; ··· 170 170 default: 171 171 pnpbios_print_status("pnp_dock_thread", status); 172 172 printk(KERN_WARNING "PnPBIOS: disabling dock monitoring.\n"); 173 - complete_and_exit(&unload_sem, 0); 173 + kthread_complete_and_exit(&unload_sem, 0); 174 174 } 175 175 if (d != docked) { 176 176 if (pnp_dock_event(d, &now) == 0) { ··· 183 183 } 184 184 } 185 185 } 186 - complete_and_exit(&unload_sem, 0); 186 + kthread_complete_and_exit(&unload_sem, 0); 187 187 } 188 188 189 189 static int pnpbios_get_resources(struct pnp_dev *dev)
+8 -8
drivers/staging/rts5208/rtsx.c
··· 450 450 * after the down() -- that's necessary for the thread-shutdown 451 451 * case. 452 452 * 453 - * complete_and_exit() goes even further than this -- it is safe in 454 - * the case that the thread of the caller is going away (not just 455 - * the structure) -- this is necessary for the module-remove case. 456 - * This is important in preemption kernels, which transfer the flow 457 - * of execution immediately upon a complete(). 453 + * kthread_complete_and_exit() goes even further than this -- 454 + * it is safe in the case that the thread of the caller is going away 455 + * (not just the structure) -- this is necessary for the module-remove 456 + * case. This is important in preemption kernels, which transfer the 457 + * flow of execution immediately upon a complete(). 458 458 */ 459 - complete_and_exit(&dev->control_exit, 0); 459 + kthread_complete_and_exit(&dev->control_exit, 0); 460 460 } 461 461 462 462 static int rtsx_polling_thread(void *__dev) ··· 501 501 mutex_unlock(&dev->dev_mutex); 502 502 } 503 503 504 - complete_and_exit(&dev->polling_exit, 0); 504 + kthread_complete_and_exit(&dev->polling_exit, 0); 505 505 } 506 506 507 507 /* ··· 682 682 /* Should we unbind if no devices were detected? */ 683 683 } 684 684 685 - complete_and_exit(&dev->scanning_done, 0); 685 + kthread_complete_and_exit(&dev->scanning_done, 0); 686 686 } 687 687 688 688 static void rtsx_init_options(struct rtsx_chip *chip)
+1 -1
drivers/usb/atm/usbatm.c
··· 969 969 instance->thread = NULL; 970 970 mutex_unlock(&instance->serialize); 971 971 972 - complete_and_exit(&instance->thread_exited, ret); 972 + kthread_complete_and_exit(&instance->thread_exited, ret); 973 973 } 974 974 975 975 static int usbatm_heavy_init(struct usbatm_data *instance)
+1 -1
drivers/usb/gadget/function/f_mass_storage.c
··· 2547 2547 up_write(&common->filesem); 2548 2548 2549 2549 /* Let fsg_unbind() know the thread has exited */ 2550 - complete_and_exit(&common->thread_notifier, 0); 2550 + kthread_complete_and_exit(&common->thread_notifier, 0); 2551 2551 } 2552 2552 2553 2553
+1 -1
fs/jffs2/background.c
··· 161 161 spin_lock(&c->erase_completion_lock); 162 162 c->gc_task = NULL; 163 163 spin_unlock(&c->erase_completion_lock); 164 - complete_and_exit(&c->gc_thread_exit, 0); 164 + kthread_complete_and_exit(&c->gc_thread_exit, 0); 165 165 }
-1
include/linux/kernel.h
··· 187 187 #endif 188 188 189 189 void do_exit(long error_code) __noreturn; 190 - void complete_and_exit(struct completion *, long) __noreturn; 191 190 192 191 extern int num_to_str(char *buf, int size, 193 192 unsigned long long num, unsigned int width);
+1
include/linux/kthread.h
··· 71 71 void kthread_unpark(struct task_struct *k); 72 72 void kthread_parkme(void); 73 73 void kthread_exit(long result) __noreturn; 74 + void kthread_complete_and_exit(struct completion *, long) __noreturn; 74 75 75 76 int kthreadd(void *unused); 76 77 extern struct task_struct *kthreadd_task;
-9
kernel/exit.c
··· 891 891 do_exit(signr); 892 892 } 893 893 894 - void complete_and_exit(struct completion *comp, long code) 895 - { 896 - if (comp) 897 - complete(comp); 898 - 899 - do_exit(code); 900 - } 901 - EXPORT_SYMBOL(complete_and_exit); 902 - 903 894 SYSCALL_DEFINE1(exit, int, error_code) 904 895 { 905 896 do_exit((error_code&0xff)<<8);
+21
kernel/kthread.c
··· 283 283 do_exit(result); 284 284 } 285 285 286 + /** 287 + * kthread_complete_and exit - Exit the current kthread. 288 + * @comp: Completion to complete 289 + * @code: The integer value to return to kthread_stop(). 290 + * 291 + * If present complete @comp and the reuturn code to kthread_stop(). 292 + * 293 + * A kernel thread whose module may be removed after the completion of 294 + * @comp can use this function exit safely. 295 + * 296 + * Does not return. 297 + */ 298 + void __noreturn kthread_complete_and_exit(struct completion *comp, long code) 299 + { 300 + if (comp) 301 + complete(comp); 302 + 303 + kthread_exit(code); 304 + } 305 + EXPORT_SYMBOL(kthread_complete_and_exit); 306 + 286 307 static int kthread(void *_create) 287 308 { 288 309 static const struct sched_param param = { .sched_priority = 0 };
+2 -2
lib/kunit/try-catch.c
··· 17 17 void __noreturn kunit_try_catch_throw(struct kunit_try_catch *try_catch) 18 18 { 19 19 try_catch->try_result = -EFAULT; 20 - complete_and_exit(try_catch->try_completion, -EFAULT); 20 + kthread_complete_and_exit(try_catch->try_completion, -EFAULT); 21 21 } 22 22 EXPORT_SYMBOL_GPL(kunit_try_catch_throw); 23 23 ··· 27 27 28 28 try_catch->try(try_catch->context); 29 29 30 - complete_and_exit(try_catch->try_completion, 0); 30 + kthread_complete_and_exit(try_catch->try_completion, 0); 31 31 } 32 32 33 33 static unsigned long kunit_test_timeout(void)
+1 -1
tools/objtool/check.c
··· 171 171 "kthread_exit", 172 172 "make_task_dead", 173 173 "__module_put_and_kthread_exit", 174 - "complete_and_exit", 174 + "kthread_complete_and_exit", 175 175 "__reiserfs_panic", 176 176 "lbug_with_loc", 177 177 "fortify_panic",