From 9595b72bc118ddeaa3805b74d2772aa2c9f75048 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Mon, 16 Jun 2025 21:30:39 +0100 Subject: [PATCH] more io stuff --- driver/io.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/driver/io.c b/driver/io.c index 0b3ea90..9cb89c7 100644 --- a/driver/io.c +++ b/driver/io.c @@ -1,9 +1,50 @@ #include #include +#include +#include #include "io.h" +#include "counter_io_calls.h" + + +static dev_t io_device_no; +static struct class *io_device_class; +static struct cdev io_device; + +#define DRIVER_NAME "cntiodev" +#define DRIVER_CLASS "CounterClass" + + + +static int io_open(struct inode *device_file, struct file *instance) { + printk("counter - Info! io open was called\n"); + return 0; +} + +static int io_close(struct inode *device_file, struct file *instance) { + printk("counter - Info! io close was called\n"); + return 0; +} + + + +static struct file_operations fops = { + .owner = THIS_MODULE, + .open = io_open, + .release = io_close, +}; int io_init(void) { + printk("counter - Info! io init\n"); + + if (alloc_chrdev_region(&io_device_no, 0, 1, DRIVER_NAME) < 0) { + printk("counter - ERROR! Device No. could not be allocated\n"); + return -1; + } + printk("counter - Info! Device No. Major: %d, Minor: %d was registered!\n", my_device_nr >> 20, my_device_nr & 0xfffff); + + + return 0; }