Re: parport and char driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks, i remember that in the 3rd chapter of the Rubini'sbook
there explain something like you wrote to me.
Now I have understead to steps to do.

Thanks

Claudio Fiorini


Scrive Shine Mohamed Jabbar <shinemohamed_j@naturesoft.net>:

> On Tue, 2004-04-27 at 10:07, Claudio Fiorini wrote:
> > Hi,
> > I'm new to kernel hacking, I'm trying to devel a kernel module to use
> > parallel port with simple led because i do in user-space, but now
> > i want to do that in kernel-space.
> > I start to read the linux device driver 2nd edition and I'm
> > ok where i register a char device, but the book show
> > me the file_operations struct that has many pointers functions
> > this is what i do:
> >  
> > struct file_operations *f_pport;
> 
> In my opinion, u need to define file operations and
> then pass it over to the register_chrdev.
> 
> Eg:
> struct file_operations f_pport {
> 
> 	.owner = THIS_MODULE,
> 	.open = Your_open_function, /* U may refer any of the 
>                                      * character device code
> 	                             */
> 	.write = Your_write_function, /* Function pointer to do your
> 	                               * function, LED write
> 	                               */
> 	.read = Your_read_function,   /* Function pointer to do your
> 	                               * function, LED read
> 	                               */
> 	...
> }
> 
> 
> > pport = register_chrdev(PPORT_MAJOR_NUMBER, PPORT_CONST_NAME,
> > f_pport);
> 
> 
> Here u are registering a char device using
> the major number PPORT_MAJOR_NUMBER. Using this major number
> u can make a character device with a minor number from
> the userland. This can be done using command mknod.
> 
> >  
> > now if i want to open i have to do something like this?
> >             f_pport->open(struct inode *, struct file *);
> 
> I think u don't need to call the open function from the
> kernel module. When u try to open the character device 
> file from userland after registration, it will be called 
> ( kernel will do it ).
> 
> Similarly, when u write to the device file your write function 
> will be called. ( echo something > /dev/your_device )
> 
> >  
> > and in the book i don't understand which information i have
> > to give to struct inode and struct file.
> >  
> > Thanks 
> >  
> > Claudio
> 
> Regards,
> Shine Mohamed Jabbar
> 
> 




--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux