#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/major.h>
#include <asm/uaccess.h>

MODULE_LICENSE("GPL");

int result;
struct file_operations sk_fops;
/**/
int sk_open(struct inode *inode, struct file *filp);
int sk_release(struct inode *inode, struct file *filp);
int sk_write(struct file *filp, const char *buf,size_t count,loff_t *f_pos);
int sk_read(struct file *filp, char *buf, size_t count, loff_t *f_pos);
/**/
int sk_write(struct file *filp,const char *buf, size_t count,loff_t *f_pos){
	char data[11];
	copy_from_user(data, buf, count);
	printk("data >>>>=%s \n",data);
	return count;
}
int sk_open(struct inode *inode, struct file *filp){
	printk("DEVICE has been opened.. \n");
	return 0;
}
int sk_release(struct inode *inode, struct file *filp){
	printk("Device has been closed.. \n");
	return 0;
}
int sk_read(struct file *filp,char *buf,size_t count, loff_t *fpos){
	/*It is a space for sending string characters*/
	char data[20] = "this is read func...";
	/*contents (from Address received app to count )Move to buffer*/
	copy_to_user(buf, data, count);

	return 0;
}
struct file_operations sk_fops={
	.open	= sk_open,
	.release = sk_release,
	.write = sk_write,
	.read = sk_read,
};

static int __init sk_init(void){

	printk("SK Module is up... \n");
	result = register_chrdev(0,"SK",&sk_fops);
	printk("major number = %d \n", result);
	return 0;
}

static void __exit sk_exit(void){
	printk("The moudule is down..\n");
	unregister_chrdev(result, "SK");
}

module_init(sk_init);
module_exit(sk_exit);
