Writing own parallel port driver
Hello All
I m new to driver development.I want to write my own parallel port driver.If a call is made to existing parallel port driver(parport) it should not be called.Instead it should call my own driver..
My question is hw to write a driver,and hw to disable the existing driver...i tried to remove the existing modules(parport,parport_pc,lp0) using rmmod command...I googled and got some codes and tested,but of no use..
This is my code
int parlelport_init(void)
{
int result;
port = check_region(0x378, 1);
if (port)
{
printk("<1>parlelport: cannot reserve 0x378\n");
result = port;
}
request_region(0x378, 1, "parlelport");
/* Registering device */
result = register_chrdev(parlelport_major, "parlelport",&parlelport_fops);
if (result < 0)
{
printk("<1>parlelport: cannot obtain major number %d\n", parlelport_major);
return result;
}
return 0;
}
this is the code for read
parlelport_buffer = inb(0x378);
copy_to_user(buf,&parlelport_buffer,1);
/* We change the reading position as best suits */
if (*f_pos == 0)
{
*f_pos+=1;
return 1;
}
else
{
return 0;
}
this is the code for write
char *tmp;
/* Buffer writing to the device */
char parlelport_buffer;
tmp=buf+count-1;
copy_from_user(&parlelport_buffer,tmp,1);
printk("\n Inside Write\n");
printk(parlelport_buffer);
/* Writing to the port */
outb(parlelport_buffer,0x378);
return 1;
can anyone suggest me any ideas to make it work?
Thanks in advance
|