added open/release syscalls

This commit is contained in:
Lauchmelder 2022-06-07 16:00:49 +02:00
parent 2d6fde40de
commit 7e4220219f
3 changed files with 13 additions and 6 deletions

View file

@ -8,7 +8,6 @@ device=lcd
rm -rf /dev/$device
major=$(awk "\$2 == \"$module\" { print \$1 }" /proc/devices)
echo $major
mknod /dev/$device c $major 0
chmod 664 /dev/$device

View file

@ -1,6 +1,7 @@
#ifndef LCD_IO_H_
#define LCD_IO_H_
#include <linux/fs.h>
#include "lcd.h"
loff_t lcd_llseek(struct file* filp, loff_t where, int whence)
@ -10,12 +11,12 @@ loff_t lcd_llseek(struct file* filp, loff_t where, int whence)
ssize_t lcd_read(struct file* filp, char __user* buf, size_t count, loff_t* off)
{
return 0;
return count;
}
ssize_t lcd_write(struct file* filp, const char __user* buf, size_t size, loff_t* off)
ssize_t lcd_write(struct file* filp, const char __user* buf, size_t count, loff_t* off)
{
return 0;
return count;
}
long lcd_ioctl(struct file* filp, unsigned int cmd, unsigned long arg)
@ -23,13 +24,19 @@ long lcd_ioctl(struct file* filp, unsigned int cmd, unsigned long arg)
return 0;
}
int lcd_open(struct inode* inode, struct file* file)
int lcd_open(struct inode* inode, struct file* filp)
{
struct lcd_dev* dev;
dev = container_of(inode->i_cdev, struct lcd_dev, dev);
filp->private_data = (void*)dev;
printk(KERN_INFO "%s: Opened device\n", THIS_MODULE->name);
return 0;
}
int lcd_release(struct inode* inode, struct file* file)
int lcd_release(struct inode* inode, struct file* filp)
{
printk(KERN_INFO "%s: Released device\n", THIS_MODULE->name);
return 0;
}

View file

@ -1,6 +1,7 @@
#ifndef _LCD_H
#define _LCD_H
#include <linux/module.h>
#include <linux/cdev.h>
#define LCD_MAJOR 0