summaryrefslogtreecommitdiff
path: root/Kernel/Devices
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-08-31 23:44:55 -0700
committerAndreas Kling <kling@serenityos.org>2021-09-01 18:06:14 +0200
commit668c4299000e013852bd07e5df81750db672d607 (patch)
treef65ddce4c981fa983a3c54d2de90a3d2c15b8cc4 /Kernel/Devices
parentf3baa5d8c915285ea109cf12553e497adb7051ca (diff)
downloadserenity-668c4299000e013852bd07e5df81750db672d607.zip
Kernel: Convert UserOrKernelBuffer callbacks to use AK::Bytes
Diffstat (limited to 'Kernel/Devices')
-rw-r--r--Kernel/Devices/HID/KeyboardDevice.cpp6
-rw-r--r--Kernel/Devices/RandomDevice.cpp6
-rw-r--r--Kernel/Devices/SerialDevice.cpp16
3 files changed, 14 insertions, 14 deletions
diff --git a/Kernel/Devices/HID/KeyboardDevice.cpp b/Kernel/Devices/HID/KeyboardDevice.cpp
index 85c5611d18..485d5ccbb3 100644
--- a/Kernel/Devices/HID/KeyboardDevice.cpp
+++ b/Kernel/Devices/HID/KeyboardDevice.cpp
@@ -292,9 +292,9 @@ KResultOr<size_t> KeyboardDevice::read(FileDescription&, u64, UserOrKernelBuffer
lock.unlock();
- auto result = buffer.write_buffered<sizeof(Event)>(sizeof(Event), [&](u8* data, size_t data_bytes) {
- memcpy(data, &event, sizeof(Event));
- return data_bytes;
+ auto result = buffer.write_buffered<sizeof(Event)>(sizeof(Event), [&](Bytes bytes) {
+ memcpy(bytes.data(), &event, sizeof(Event));
+ return bytes.size();
});
if (result.is_error())
return result.error();
diff --git a/Kernel/Devices/RandomDevice.cpp b/Kernel/Devices/RandomDevice.cpp
index caf06614b7..9c4503d7bc 100644
--- a/Kernel/Devices/RandomDevice.cpp
+++ b/Kernel/Devices/RandomDevice.cpp
@@ -31,9 +31,9 @@ bool RandomDevice::can_read(const FileDescription&, size_t) const
KResultOr<size_t> RandomDevice::read(FileDescription&, u64, UserOrKernelBuffer& buffer, size_t size)
{
- return buffer.write_buffered<256>(size, [&](u8* data, size_t data_size) {
- get_good_random_bytes({ data, data_size });
- return data_size;
+ return buffer.write_buffered<256>(size, [&](Bytes bytes) {
+ get_good_random_bytes(bytes);
+ return bytes.size();
});
}
diff --git a/Kernel/Devices/SerialDevice.cpp b/Kernel/Devices/SerialDevice.cpp
index 5b6b2dac3d..a84491f538 100644
--- a/Kernel/Devices/SerialDevice.cpp
+++ b/Kernel/Devices/SerialDevice.cpp
@@ -63,10 +63,10 @@ KResultOr<size_t> SerialDevice::read(FileDescription&, u64, UserOrKernelBuffer&
if (!(get_line_status() & DataReady))
return 0;
- return buffer.write_buffered<128>(size, [&](u8* data, size_t data_size) {
- for (size_t i = 0; i < data_size; i++)
- data[i] = m_base_addr.in<u8>();
- return data_size;
+ return buffer.write_buffered<128>(size, [&](Bytes bytes) {
+ for (auto& byte : bytes)
+ byte = m_base_addr.in<u8>();
+ return bytes.size();
});
}
@@ -84,10 +84,10 @@ KResultOr<size_t> SerialDevice::write(FileDescription& description, u64, const U
if (!can_write(description, size))
return EAGAIN;
- return buffer.read_buffered<128>(size, [&](u8 const* data, size_t data_size) {
- for (size_t i = 0; i < data_size; i++)
- put_char(data[i]);
- return data_size;
+ return buffer.read_buffered<128>(size, [&](ReadonlyBytes bytes) {
+ for (const auto& byte : bytes)
+ put_char(byte);
+ return bytes.size();
});
}