1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:57:45 +00:00

Kernel: Stop lock & unlock repeatedly while reading from a mouse device

This was a thing we needed to do in the days where we didn't have
safe_memcpy and some wrappers around it to handle possible page faults
safely.
This commit is contained in:
Liav A 2023-04-08 14:08:54 +03:00 committed by Jelle Raaijmakers
parent d8cbda6950
commit 3a261f5ee8

View file

@ -30,7 +30,6 @@ ErrorOr<size_t> MouseDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer&
SpinlockLocker lock(m_queue_lock);
while (!m_queue.is_empty() && remaining_space_in_buffer) {
auto packet = m_queue.dequeue();
lock.unlock();
dbgln_if(MOUSE_DEBUG, "Mouse Read: Buttons {:x}", packet.buttons);
dbgln_if(MOUSE_DEBUG, "PS2 Mouse: X {}, Y {}, Z {}, W {}, Relative {}", packet.x, packet.y, packet.z, packet.w, packet.buttons);
@ -40,8 +39,6 @@ ErrorOr<size_t> MouseDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer&
TRY(buffer.write(&packet, nread, bytes_read_from_packet));
nread += bytes_read_from_packet;
remaining_space_in_buffer -= bytes_read_from_packet;
lock.lock();
}
return nread;
}