mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:07:34 +00:00
Kernel: Modify the IOCTL API to return KResult
The kernel has been gradually moving towards KResult from just bare int's, this change migrates the IOCTL paths.
This commit is contained in:
parent
46c9b1d81c
commit
de9ff0af50
16 changed files with 151 additions and 151 deletions
|
@ -311,38 +311,38 @@ KResultOr<size_t> KeyboardDevice::write(FileDescription&, u64, const UserOrKerne
|
|||
return 0;
|
||||
}
|
||||
|
||||
int KeyboardDevice::ioctl(FileDescription&, unsigned request, Userspace<void*> arg)
|
||||
KResult KeyboardDevice::ioctl(FileDescription&, unsigned request, Userspace<void*> arg)
|
||||
{
|
||||
switch (request) {
|
||||
case KEYBOARD_IOCTL_GET_NUM_LOCK: {
|
||||
auto output = static_ptr_cast<bool*>(arg);
|
||||
if (!copy_to_user(output, &m_num_lock_on))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
return EFAULT;
|
||||
return KSuccess;
|
||||
}
|
||||
case KEYBOARD_IOCTL_SET_NUM_LOCK: {
|
||||
// In this case we expect the value to be a boolean and not a pointer.
|
||||
auto num_lock_value = static_cast<u8>(arg.ptr());
|
||||
if (num_lock_value != 0 && num_lock_value != 1)
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
m_num_lock_on = !!num_lock_value;
|
||||
return 0;
|
||||
return KSuccess;
|
||||
}
|
||||
case KEYBOARD_IOCTL_GET_CAPS_LOCK: {
|
||||
auto output = static_ptr_cast<bool*>(arg);
|
||||
if (!copy_to_user(output, &m_caps_lock_on))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
return EFAULT;
|
||||
return KSuccess;
|
||||
}
|
||||
case KEYBOARD_IOCTL_SET_CAPS_LOCK: {
|
||||
auto caps_lock_value = static_cast<u8>(arg.ptr());
|
||||
if (caps_lock_value != 0 && caps_lock_value != 1)
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
m_caps_lock_on = !!caps_lock_value;
|
||||
return 0;
|
||||
return KSuccess;
|
||||
}
|
||||
default:
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue