summaryrefslogtreecommitdiff
path: root/Kernel/Graphics/VirtIOGPU
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-10-22 01:21:34 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-22 01:21:34 +0200
commit4ffee78146c2d685b189eb256efc585e92fbac2c (patch)
tree71629898093a82a9fdd5edade0770a8859dc37e3 /Kernel/Graphics/VirtIOGPU
parent21bfa02dd283e3c8199519901d128a7f2340a172 (diff)
downloadserenity-4ffee78146c2d685b189eb256efc585e92fbac2c.zip
Kernel: Make FrameBufferDevice::try_to_set_resolution() return KResult
Diffstat (limited to 'Kernel/Graphics/VirtIOGPU')
-rw-r--r--Kernel/Graphics/VirtIOGPU/Console.cpp2
-rw-r--r--Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp12
-rw-r--r--Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h2
3 files changed, 6 insertions, 10 deletions
diff --git a/Kernel/Graphics/VirtIOGPU/Console.cpp b/Kernel/Graphics/VirtIOGPU/Console.cpp
index 32e9a82023..880aa93e43 100644
--- a/Kernel/Graphics/VirtIOGPU/Console.cpp
+++ b/Kernel/Graphics/VirtIOGPU/Console.cpp
@@ -45,7 +45,7 @@ Console::Console(RefPtr<FrameBufferDevice> const& framebuffer_device)
void Console::set_resolution(size_t width, size_t height, size_t)
{
auto did_set_resolution = m_framebuffer_device->try_to_set_resolution(width, height);
- VERIFY(did_set_resolution);
+ VERIFY(!did_set_resolution.is_error());
}
void Console::flush(size_t x, size_t y, size_t width, size_t height)
diff --git a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp
index ed7e022057..9903b49d7a 100644
--- a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp
+++ b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp
@@ -114,10 +114,10 @@ void FrameBufferDevice::flush_displayed_image(Protocol::Rect const& dirty_rect,
m_gpu.flush_displayed_image(dirty_rect, buffer.resource_id);
}
-bool FrameBufferDevice::try_to_set_resolution(size_t width, size_t height)
+KResult FrameBufferDevice::try_to_set_resolution(size_t width, size_t height)
{
if (width > MAX_VIRTIOGPU_RESOLUTION_WIDTH || height > MAX_VIRTIOGPU_RESOLUTION_HEIGHT)
- return false;
+ return EINVAL;
auto& info = display_info();
@@ -130,10 +130,7 @@ bool FrameBufferDevice::try_to_set_resolution(size_t width, size_t height)
.height = (u32)height,
};
- // FIXME: Would be nice to be able to return KResultOr here.
- if (auto result = create_framebuffer(); result.is_error())
- return false;
- return true;
+ return create_framebuffer();
}
void FrameBufferDevice::set_buffer(int buffer_index)
@@ -161,8 +158,7 @@ KResult FrameBufferDevice::ioctl(OpenFileDescription&, unsigned request, Userspa
auto user_resolution = static_ptr_cast<FBResolution*>(arg);
FBResolution resolution;
TRY(copy_from_user(&resolution, user_resolution));
- if (!try_to_set_resolution(resolution.width, resolution.height))
- return EINVAL;
+ TRY(try_to_set_resolution(resolution.width, resolution.height));
resolution.pitch = pitch();
return copy_to_user(user_resolution, &resolution);
}
diff --git a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h
index d686658ae7..cb20c8d90c 100644
--- a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h
+++ b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h
@@ -29,7 +29,7 @@ public:
virtual void deactivate_writes();
virtual void activate_writes();
- bool try_to_set_resolution(size_t width, size_t height);
+ KResult try_to_set_resolution(size_t width, size_t height);
void clear_to_black(Buffer&);
size_t width() const { return display_info().rect.width; }