Re: [PARPORT] parport driver


Tim Waugh (tim@cyberelk.demon.co.uk)
Wed, 15 Apr 1998 23:53:59 +0100 (BST)


On Thu, 16 Apr 1998, Riccardo Facchetti wrote:

> if (!ParportPresent())
> return NOWAY;
> register_device(lp);

So this is the equivalent of parport_enumerate.

> lp_open(minor) {
> if (handle = ParportOpen(minor))
> return -ENODEV;
> lp_handles[minor] = handle;
> }

And this is parport_register_device.

> lp_ioctl(minor, cmd, arg) {
> switch (cmd) {
> ...
> case LPPARPORTSETUP:
> ParportSetup(lp_handles[minor], arg);
> /* E.g. set up ECP+IRQ+DMA if available */
> break;
> ...
> }

I'm not quite sure how this would work. I guess it's similar to
parport_change_mode, with whatever additional stuff.

> lp_write(minor, buf, len) {
> written = ParportWrite(lp_handles[minor], buf, len);
> return written;
> }

Trouble with that is it essentially makes parport into a printer driver
itself. I suppose you could have ParportSetup specify the manner in which
ParportWrite writes stuff out, but sooner or later you'd want to fiddle
with registers yourself.

> struct parport_operations {
> function write;
> function read;
> } EPP_ops, ECP_ops;
>
> struct parport_mode {
> int flags;
> struct parport_operations *ops;
> function initialize;
> } EPP_mode, ECP_mode;
>
> struct parport_handle {
> ...
> struct parport_mode *mode;
> ...
> } handle;

This is nice, but is essentially what we already have, isn't it? The
parport_mode struct is missing, but probably wouldn't be as simple as
having a struct parport_operations anyway.

The thing to do really would be to have a separate parport_operations_xxx
struct for each mode. So, struct parport_operations_ecp would have a
write_fifo, or whatever.

> Note that in the parport_operations functions, you can do whatever you
> want. Even bit bang into the port .. of course .. at the cost of some
> function calls [ParportWrite() => ops->write()].

Well, take a look at CONFIG_PARPORT_OTHER=n in recent kernels. The
equivalent would be that ParportWrite becomes a #define to the name of an
inlined function.

Tim.
*/

-- To unsubscribe, send mail to: linux-parport-request@torque.net --
-- with the single word "unsubscribe" in the body of the message. --



This archive was generated by hypermail 2.0b3 on Wed 30 Dec 1998 - 10:17:37 EST