My driver write routine is not working properly. As a result, when I do echo "123" > /dev/eater, the process is stopping and the control goes into an infinite loop. lsmod showed my driver was in use by 2 processes. Now if i want to forcefully remove my driver module from kernel, how to do that?
Below is the write routine: static int eater_write(struct file *file, const char *buf, size_t lbuf, loff_t *ppos) { int actual_data_allowed_to_write; int data_written; int data_to_copy=0; printk("requested bytes to write: %d\n", lbuf); actual_data_allowed_to_write = MAXSIZE - *ppos; printk("allowed bytes to write: %d\n", actual_data_allowed_to_write); if(actual_data_allowed_to_write == 0) { printk("Device has no space to write. format it\n"); return(actual_data_allowed_to_write); } //if available space can accommodate data to write if(actual_data_allowed_to_write > lbuf) data_to_copy=lbuf; //if available space can't accommodate date to write if(actual_data_allowed_to_write < lbuf) data_to_copy=actual_data_allowed_to_write; printk("data_to_copy: %d\n", data_to_copy); data_written=copy_from_user(eater_space + *ppos, /* to */ \ buf, /* from */ \ data_to_copy); //update device memory with new position *ppos += data_to_copy; printk("\nWrote %d bytes\n", data_written); return(data_written); } Appreciate any help. /Sri.