obj: add read() and write() object callbacks

This commit is contained in:
2023-05-14 21:11:32 +01:00
parent 0238008986
commit d02d05d922
10 changed files with 91 additions and 28 deletions

View File

@@ -35,9 +35,9 @@ struct input_device *input_device_create(void)
kern_status_t input_device_report_event(struct input_device *dev, const struct input_event *ev, bool noblock)
{
struct ringbuffer *event_queue = &dev->i_events;
enum ringbuffer_flags flags = RB_NORMAL;
socks_flags_t flags = S_NORMAL;
if (noblock) {
flags = RB_NOBLOCK;
flags = S_NOBLOCK;
}
size_t r = ringbuffer_write(event_queue, sizeof *ev, ev, flags);
@@ -45,7 +45,7 @@ kern_status_t input_device_report_event(struct input_device *dev, const struct i
return r == sizeof *ev ? KERN_OK : KERN_WOULD_BLOCK;
}
kern_status_t input_device_read(struct device *dev, void *buf, size_t size, size_t *bytes_read)
kern_status_t input_device_read(struct device *dev, void *buf, size_t size, size_t *bytes_read, socks_flags_t flags)
{
if (dev->dev_type != DEV_TYPE_INPUT || (size % sizeof (struct input_event)) != 0) {
return KERN_INVALID_ARGUMENT;
@@ -54,7 +54,7 @@ kern_status_t input_device_read(struct device *dev, void *buf, size_t size, size
struct input_device *input_dev = INPUT_DEVICE(dev);
struct ringbuffer *event_queue = &input_dev->i_events;
size_t r = ringbuffer_read(event_queue, size, buf, RB_NORMAL);
size_t r = ringbuffer_read(event_queue, size, buf, flags);
if (bytes_read) {
*bytes_read = r;