- class_export_put(exp);
- thread_set_flags(thread, SVC_STOPPED);
- wake_up(&thread->t_ctl_waitq);
+ if (xchg(&lwp->lpd_notify_task, NULL) == NULL)
+ /* lwp_device_fini() is waiting for me
+ * Note that the wakeup comes direct from
+ * kthread_stop, not from wake_up_var().
+ * lwp_device_fini() will call class_export_put().
+ */
+ wait_var_event(lwp, kthread_should_stop());
+ else
+ class_export_put(exp);
+