Re: parallel port

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

 



From: Martin Knappe <martin.knappe@xxxxxxxxx>
Date: 2009/12/2
Subject: parallel port
To: kernelnewbies@xxxxxxxxxxxx

hi
i am working my way through "essential linux device drivers"
it has an example of a driver for an led attached to the parallel port
in the init function, a call to parport_register_driver is made, but it's
not well explained whats going on here
this function takes a pointer to a struct parport_driver with socalled
attach and detach functions
the attach function simply calls parport_register_device with a pointer to
yet another function called led_preempt
the book says "when the kernel finds the led board during led attach, it
registers the device by invoking parport_register_device()"
how does the kernel know if the led board is connected? if it finds
something is connected to the parport, how does it know its the led board,
and not, say, a printer?

you do first register a class_device with the device name "led" (class_device_create). After that the kernel knows that there is a device called "led". When you register the led_driver, his name is also "led", so the kernel matches the two and call your attach function of your led_driver struct. So if you plug in a printer but register the led board in the kernel, the kernel will think that the led board is connected and communicate to the printer as if it were a led board.
when is led_detach called?

led_detach is called when you unregister the led_driver (attach and detach).
and what about led_preempt?

I'm not into the parport code, have a look on lxr.linux.no what it does exactly.
can someone shed some light on this?

I hope i did.
the code im talking about can be found here http://elinuxdd.com/~elinuxdd/elinuxdd.docs/listings/listing05.6.html<http://elinuxdd.com/%7Eelinuxdd/elinuxdd.docs/listings/listing05.6.html>
i would like to try this out but dont know how to build the hardware to do
that
is there a simpler way i can try this out without much electronics work
involved? thanks martin
--
motzblog.wordpress.com

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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