LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-06-2008, 05:39 AM   #1
mathimca05
Member
 
Registered: Oct 2007
Posts: 66

Rep: Reputation: 15
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
 
Old 10-08-2008, 06:03 AM   #2
vivekmrathod
LQ Newbie
 
Registered: Oct 2008
Posts: 1

Rep: Reputation: 0
Lightbulb

hi friend.

i think u are referring the example from linuxjournal.com

i faced a similar problem.

The solution i came up with is i removed the whole parport folder

from /lib/modules/kernel/drivers .

rebooted

and the original modules no more registered 0x378!!! hurray


then i used the custom made parallelport module for led lighting.

Last edited by vivekmrathod; 10-08-2008 at 06:04 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
illegal seek when writing to parallel port pzydak Programming 1 12-08-2006 07:06 AM
Writing to parallel port 0x37a works, 0x378 don't Pier Linux - Hardware 3 06-27-2006 04:51 PM
How can I remove my existing parallel port driver? asprakash Linux - Kernel 1 06-26-2006 04:22 AM
Parallel Port Device Driver rajtendulkar Linux - Hardware 4 03-16-2006 11:34 PM
linux device driver & parallel port albatros Linux - General 1 01-08-2003 04:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 10:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration