This file contains the code to connect this package to the usb-core, so that it is informed about the connection/disconnection of elomax units. More...
Functions | |
int | elomax_driver_construct (void) |
Announce this driver to the usb-core, so that it is informed about the connection and disconnection of elomax units on the usb-bus. | |
void | elomax_driver_destruct (void) |
Tell the usb-core about the removal of this driver, so that it is no longer informed about the connection and disconnection of elomax units on the usb-bus. | |
struct elomax_instance * | elomax_driver_instance_from_minor (unsigned int minor) |
Tell the instance belonging to a device-file with the given minor. |
This file contains the code to connect this package to the usb-core, so that it is informed about the connection/disconnection of elomax units.
When this driver is loaded into the kernel, it announces its 'driver table' (a struct usb_driver) to the usb-core by calling usb_register(). This table contains amongst other the VendorId, ProductId pairs of the units serviced, together with the functions to call upon connection and disconnection of such a unit.
Upon connection of an elomax unit, the usb-core creates a struct usb_interface for that unit. This struct contains usb-core specific information about the state of the unit. With this struct, the usb-core calls the elomax_driver_probe() function.
The elomax_driver_probe() function creates an instance for this connected unit (by calling elomax_instance_construct()). In this struct, this package keeps the unit specific data. Since this struct is an extension to the usb-core's struct, the probe function connects the instance to the usb-core's struct by calling usb_set_intfdata().
The opposite occurs when the usb-core detects the disconnection of an unit. By the 'driver table' the usb-core knows to call the elomax_driver_disconnect() function. It supplies the struct usb_interface as a parameter.
With this parameter, the elomax_driver_disconnect() can find its own elomax_instance and destructs it (by calling elomax_instance_destruct()). It sets the reference in the struct usb_interface to NULL via the usb_set_intfdata() function.
For every connected elomax unit, the usb-core maintains a struct usb_interface and this package maintains an elomax_instance. The struct usb_interface keeps a pointer to the struct elomax_instance, which is set via usb_setintfdata().
After connection of a unit, the usb-core arranges the following:
int elomax_driver_construct | ( | void | ) |
Announce this driver to the usb-core, so that it is informed about the connection and disconnection of elomax units on the usb-bus.
This function calls usb_register() with its 'driver table' as parameter. Since the driver table contains references to the elomax_driver_probe() and elomax_driver_disconnect() function, and to the 'id table' containing the VendorId, ProductId pairs of the units which this driver can service, this driver gets informed about the connection/disconnection of these units.
void elomax_driver_destruct | ( | void | ) |
Tell the usb-core about the removal of this driver, so that it is no longer informed about the connection and disconnection of elomax units on the usb-bus.
This function calls usb_deregister(), so that the usb-core knows that this driver is no longer in operation.
struct elomax_instance* elomax_driver_instance_from_minor | ( | unsigned int | minor | ) | [read] |
Tell the instance belonging to a device-file with the given minor.
This function calls usb_find_interface() to find the struct usb_interface belonging to the given minor. This interface can tell the corresponding elomax_instance via usb_get_intfdata.
There is NO error checking in this function.
[in] | minor | The minor of the file for which the corresponding elomax_instance must be found. |