As you have already learned, the mutex_lock_interruptible() API is used when the driver (or module) is willing to acknowledge any (user space) signal interrupting it (and returns -ERESTARTSYS to tell the kernel VFS layer to perform signal handling; the user space system call will fail with errno set to EINTR). An example can be found in the module handling code in the kernel, within the delete_module(2) system call (which rmmod(8) invokes):
// kernel/module.c
[ ... ]
SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
unsigned int, flags)
{
struct module *mod;
[ ... ]
if (!capable(CAP_SYS_MODULE) || modules_disabled)
return -EPERM;
[ ... ]
if (mutex_lock_interruptible(&module_mutex) != 0)
return -EINTR;
mod = find_module(name);
[ ... ]
out:
mutex_unlock(&module_mutex);
return ret;
}
Notice how the API returns -EINTR on failure. (The SYSCALL_DEFINEn...