Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

parport_register_device(9) [suse man page]

PARPORT_REGISTER_DEV(9) 				       Parallel Port Devices					   PARPORT_REGISTER_DEV(9)

NAME
parport_register_device - register a device on a parallel port SYNOPSIS
struct pardevice * parport_register_device(struct parport * port, const char * name, int (*pf) (void *), void (*kf) (void *), void (*irq_func) (void *), int flags, void * handle); ARGUMENTS
port port to which the device is attached name a name to refer to the device pf preemption callback kf kick callback (wake-up) irq_func interrupt handler flags registration flags handle data for callback functions DESCRIPTION
This function, called by parallel port device drivers, declares that a device is connected to a port, and tells the system all it needs to know. The name is allocated by the caller and must not be deallocated until the caller calls parport_unregister_device for that device. The preemption callback function, pf, is called when this device driver has claimed access to the port but another device driver wants to use it. It is given handle as its parameter, and should return zero if it is willing for the system to release the port to another driver on its behalf. If it wants to keep control of the port it should return non-zero, and no action will be taken. It is good manners for the driver to try to release the port at the earliest opportunity after its preemption callback rejects a preemption attempt. Note that if a preemption callback is happy for preemption to go ahead, there is no need to release the port; it is done automatically. This function may not block, as it may be called from interrupt context. If the device driver does not support preemption, pf can be NULL. The wake-up ("kick") callback function, kf, is called when the port is available to be claimed for exclusive access; that is, parport_claim is guaranteed to succeed when called from inside the wake-up callback function. If the driver wants to claim the port it should do so; otherwise, it need not take any action. This function may not block, as it may be called from interrupt context. If the device driver does not want to be explicitly invited to claim the port in this way, kf can be NULL. The interrupt handler, irq_func, is called when an interrupt arrives from the parallel port. Note that if a device driver wants to use interrupts it should use parport_enable_irq, and can also check the irq member of the parport structure representing the port. The parallel port (lowlevel) driver is the one that has called request_irq and whose interrupt handler is called first. This handler does whatever needs to be done to the hardware to acknowledge the interrupt (for PC-style ports there is nothing special to be done). It then tells the IEEE 1284 code about the interrupt, which may involve reacting to an IEEE 1284 event depending on the current IEEE 1284 phase. After this, it calls irq_func. Needless to say, irq_func will be called from interrupt context, and may not block. The PARPORT_DEV_EXCL flag is for preventing port sharing, and so should only be used when sharing the port with other device drivers is impossible and would lead to incorrect behaviour. Use it sparingly! Normally, flags will be zero. This function returns a pointer to a structure that represents the device on the port, or NULL if there is not enough memory to allocate space for that structure. COPYRIGHT
Kernel Hackers Manual 2.6. July 2010 PARPORT_REGISTER_DEV(9)

Check Out this Related Man Page

IEEE1284_CONTROL(3)						     Functions						       IEEE1284_CONTROL(3)

NAME
ieee1284_read_control, ieee1284_write_control, ieee1284_frob_control, ieee1284_do_nack_handshake - manipulate control lines SYNOPSIS
#include <ieee1284.h> int ieee1284_read_control(struct parport *port); void ieee1284_write_control(struct parport *port, unsigned char ct); void ieee1284_frob_control(struct parport *port, unsigned char mask, unsigned char val); int ieee1284_do_nack_handshake(struct parport *port, unsigned char ct_before, unsigned char ct_after, struct timeval *timeout); DESCRIPTION
There are four control lines, three of which are usually inverted on PC-style ports. Where they differ, libieee1284 operates on the IEEE 1284 values, not the PC-style inverted values. The control lines are represented by the following enumeration: enum ieee1284_control_bits { C1284_NSTROBE = 0x01, C1284_NAUTOFD = 0x02, C1284_NINIT = 0x04, C1284_NSELECTIN = 0x08, /* To convert those values into PC-style register values, use this: */ C1284_INVERTED = (C1284_NSTROBE| C1284_NAUTOFD| C1284_NSELECTIN), }; These functions all act on the parallel port associated with port, which must be claimed. The current values on the control lines are available by calling ieee1284_read_control, and may be set by calling ieee1284_write_control. To adjust the values on a set of control lines, use ieee1284_frob_control. The effect of this can be expressed by: ctr = ((ctr & ~mask) ^ val); that is, the bits in mask are unset, and then those in val are inverted. The special function ieee1284_do_nack_handshake is for responding very quickly in a protocol where the peripheral sets nAck and the host must respond by setting a control line. Its operation, which relies on the host machine knowing which interrupt nAck generates, is as follows: 1. Set the control lines as indicated in ct_before. 2. Wait for nAck interrupt. If timeout elapses, return E1284_TIMEDOUT. 3. Set the control lines as indicated in ct_after. On Linux using the ppdev driver, this is performed by the device driver in the kernel, and so is faster than normally possible in a user-space library. RETURN VALUE
The return value of ieee1284_read_control, if non-negative, is a number representing the value on the control lines. Possible error codes for ieee1284_read_control: E1284_NOTAVAIL The control lines of this port are not accessible by the application. E1284_INVALIDPORT The port parameter is invalid (for instance, perhaps it is not claimed). Possible error codes for ieee1284_do_nack_handshake: E1284_OK The handshake was successful. E1284_NOTAVAIL This operation is not available on this port type or system. This could be because port interrupts are not available, or because the underlying device driver does not support the operation. E1284_INVALIDPORT The port parameter is invalid (for instance, perhaps it is not claimed). AUTHOR
Tim Waugh <twaugh@redhat.com> Author. COPYRIGHT
Copyright (C) 2001-2003 Tim Waugh 09/18/2007 IEEE1284_CONTROL(3)
Man Page