mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:07:35 +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
|
@ -140,7 +140,7 @@ void FrameBufferDevice::set_buffer(int buffer_index)
|
|||
buffer.dirty_rect = {};
|
||||
}
|
||||
|
||||
int FrameBufferDevice::ioctl(FileDescription&, unsigned request, Userspace<void*> arg)
|
||||
KResult FrameBufferDevice::ioctl(FileDescription&, unsigned request, Userspace<void*> arg)
|
||||
{
|
||||
REQUIRE_PROMISE(video);
|
||||
switch (request) {
|
||||
|
@ -148,20 +148,20 @@ int FrameBufferDevice::ioctl(FileDescription&, unsigned request, Userspace<void*
|
|||
auto out = static_ptr_cast<size_t*>(arg);
|
||||
size_t value = m_buffer_size * 2;
|
||||
if (!copy_to_user(out, &value))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
return EFAULT;
|
||||
return KSuccess;
|
||||
}
|
||||
case FB_IOCTL_SET_RESOLUTION: {
|
||||
auto user_resolution = static_ptr_cast<FBResolution*>(arg);
|
||||
FBResolution resolution;
|
||||
if (!copy_from_user(&resolution, user_resolution))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
if (!try_to_set_resolution(resolution.width, resolution.height))
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
resolution.pitch = pitch();
|
||||
if (!copy_to_user(user_resolution, &resolution))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
return EFAULT;
|
||||
return KSuccess;
|
||||
}
|
||||
case FB_IOCTL_GET_RESOLUTION: {
|
||||
auto user_resolution = static_ptr_cast<FBResolution*>(arg);
|
||||
|
@ -170,33 +170,33 @@ int FrameBufferDevice::ioctl(FileDescription&, unsigned request, Userspace<void*
|
|||
resolution.width = width();
|
||||
resolution.height = height();
|
||||
if (!copy_to_user(user_resolution, &resolution))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
return EFAULT;
|
||||
return KSuccess;
|
||||
}
|
||||
case FB_IOCTL_SET_BUFFER: {
|
||||
auto buffer_index = static_cast<int>(arg.ptr());
|
||||
if (!is_valid_buffer_index(buffer_index))
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
if (m_last_set_buffer_index.exchange(buffer_index) != buffer_index && m_are_writes_active)
|
||||
set_buffer(buffer_index);
|
||||
return 0;
|
||||
return KSuccess;
|
||||
}
|
||||
case FB_IOCTL_FLUSH_BUFFERS: {
|
||||
auto user_flush_rects = static_ptr_cast<FBFlushRects*>(arg);
|
||||
FBFlushRects flush_rects;
|
||||
if (!copy_from_user(&flush_rects, user_flush_rects))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
if (!is_valid_buffer_index(flush_rects.buffer_index))
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
if (Checked<unsigned>::multiplication_would_overflow(flush_rects.count, sizeof(FBRect)))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
if (m_are_writes_active && flush_rects.count > 0) {
|
||||
auto& buffer = buffer_from_index(flush_rects.buffer_index);
|
||||
MutexLocker locker(m_gpu.operation_lock());
|
||||
for (unsigned i = 0; i < flush_rects.count; i++) {
|
||||
FBRect user_dirty_rect;
|
||||
if (!copy_from_user(&user_dirty_rect, &flush_rects.rects[i]))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
Protocol::Rect dirty_rect {
|
||||
.x = user_dirty_rect.x,
|
||||
.y = user_dirty_rect.y,
|
||||
|
@ -222,22 +222,22 @@ int FrameBufferDevice::ioctl(FileDescription&, unsigned request, Userspace<void*
|
|||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return KSuccess;
|
||||
}
|
||||
case FB_IOCTL_GET_BUFFER_OFFSET: {
|
||||
auto user_buffer_offset = static_ptr_cast<FBBufferOffset*>(arg);
|
||||
FBBufferOffset buffer_offset;
|
||||
if (!copy_from_user(&buffer_offset, user_buffer_offset))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
if (!is_valid_buffer_index(buffer_offset.buffer_index))
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
buffer_offset.offset = (size_t)buffer_offset.buffer_index * m_buffer_size;
|
||||
if (!copy_to_user(user_buffer_offset, &buffer_offset))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
return EFAULT;
|
||||
return KSuccess;
|
||||
}
|
||||
default:
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue