There are sometime places where an API hides a completion inside it's implementation, and needs to expose the kind of wait it does to it's upper users. Instead of such cases that now need an ugly switch case to call the different wait_for_completion_xxx function define a generic one which can do all.

A new user will be added to this API in linux/kmod.h.

The return value from this member is a more Linux Kernel natural. It will return: 0 - If the wait was actually completed by a complete() signal. -ERESTARTSYS - If interrupted -ETIMEDOUT - If timeout expired

It can be seen that done here is more complicated/ugly then ifdone at kernel/sched/core.c

Note that at this stage there is a warning:kernel/kmod.c:473:1: warning: 'wait_for_completion_timeout_state' defined but not used [-Wunused-function]

Until the next patch. I keep it separate for the different optionsto be taken