Untitled

 avatar
unknown
plain_text
a year ago
1.2 kB
5
Indexable
#include<linux/module.h>
#include<linux/fs.h>

#define DEV_MEM_SIZE 512

char device_buffer[DEV_MEM_SIZE];

dev_t device_number;

struct cdev pcd_cdev;

loff_t pcd_lseek(struct file *filp, loff_t off, int whence){
	return 0;
}

ssize_t pcd_read(struct file *filp, char __user *buff, size_t count, loff_t *f_pos){
	return 0;
}

ssize_t pcd_write(struct file *filp, const char __user *buff, size_t count, loff_t *f_pos){
	return 0;
}

int pcd_open(struct inode *inode, struct file *filp){
	return 0;
}

int pcd_release(struct inode *inode, struct file *filp){
	return 0;
}

struct file_operations pcd_fops = 
{
	.open = pcd_open,
	.write = pcd_write,
	.release = pcd_release,
	.read = pcd_read
	.llseek = pcd_lseek,
};

static int __init pcd_driver_init(void){
	int ret;
	ret = alloc_chrdev_region(&device_number,0,1,"pcd");
	cdev_init(&pcd_cdev, &pcd_fops);
	pcd_cdev.owner = THIS_MODULE;
	cdev_add(&pcd_cdev, device_number, 1);
	return 0;
}

static void __exit pcd_driver_cleanup(void){
	
}

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Tra");
MODULE_DESCRIPTION("First driver");
MODULE_VERSION("2:1.0");
Editor is loading...
Leave a Comment