Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
transport_class.h File Reference
#include <linux/device.h>
#include <linux/bug.h>
#include <linux/attribute_container.h>

Go to the source code of this file.

Data Structures

struct  transport_class
 
struct  anon_transport_class
 
struct  transport_container
 

Macros

#define DECLARE_TRANSPORT_CLASS(cls, nm, su, rm, cfg)
 
#define DECLARE_ANON_TRANSPORT_CLASS(cls, mtch, cfg)
 
#define class_to_transport_class(x)   container_of(x, struct transport_class, class)
 
#define attribute_container_to_transport_container(x)   container_of(x, struct transport_container, ac)
 

Functions

void transport_remove_device (struct device *)
 
void transport_add_device (struct device *)
 
void transport_setup_device (struct device *)
 
void transport_configure_device (struct device *)
 
void transport_destroy_device (struct device *)
 
int transport_class_register (struct transport_class *)
 
int anon_transport_class_register (struct anon_transport_class *)
 
void transport_class_unregister (struct transport_class *)
 
void anon_transport_class_unregister (struct anon_transport_class *)
 

Macro Definition Documentation

#define attribute_container_to_transport_container (   x)    container_of(x, struct transport_container, ac)

Definition at line 62 of file transport_class.h.

#define class_to_transport_class (   x)    container_of(x, struct transport_class, class)

Definition at line 54 of file transport_class.h.

#define DECLARE_ANON_TRANSPORT_CLASS (   cls,
  mtch,
  cfg 
)
Value:
struct anon_transport_class cls = { \
.tclass = { \
.configure = cfg, \
}, \
. container = { \
.match = mtch, \
}, \
}

Definition at line 44 of file transport_class.h.

#define DECLARE_TRANSPORT_CLASS (   cls,
  nm,
  su,
  rm,
  cfg 
)
Value:
struct transport_class cls = { \
.class = { \
.name = nm, \
}, \
.setup = su, \
.remove = rm, \
.configure = cfg, \
}

Definition at line 28 of file transport_class.h.

Function Documentation

int anon_transport_class_register ( struct anon_transport_class atc)

anon_transport_class_register - register an anonymous class

: The anon transport class to register

The anonymous transport class contains both a transport class and a container. The idea of an anonymous class is that it never actually has any device attributes associated with it (and thus saves on container storage). So it can only be used for triggering events. Use prezero and then use DECLARE_ANON_TRANSPORT_CLASS() to initialise the anon transport class storage.

Definition at line 88 of file transport_class.c.

void anon_transport_class_unregister ( struct anon_transport_class atc)

anon_transport_class_unregister - unregister an anon class

: Pointer to the anon transport class to unregister

Must be called prior to deallocating the memory for the anon transport class.

Definition at line 110 of file transport_class.c.

void transport_add_device ( struct device dev)

transport_add_device - declare a new dev for transport class association

: the generic device representing the entity being added

Usually, dev represents some component in the HBA system (either the HBA itself or a device remote across the HBA bus). This routine is simply a trigger point used to add the device to the system and register attributes for it.

Definition at line 177 of file transport_class.c.

int transport_class_register ( struct transport_class tclass)

transport_class_register - register an initial transport class

: a pointer to the transport class structure to be initialised

The transport class contains an embedded class which is used to identify it. The caller should initialise this structure with zeros and then generic class must have been initialised with the actual transport class unique name. There's a macro DECLARE_TRANSPORT_CLASS() to do this (declared classes still must be registered).

Returns 0 on success or error on failure.

Definition at line 48 of file transport_class.c.

void transport_class_unregister ( struct transport_class tclass)

transport_class_unregister - unregister a previously registered class

: The transport class to unregister

Must be called prior to deallocating the memory for the transport class.

Definition at line 62 of file transport_class.c.

void transport_configure_device ( struct device dev)

transport_configure_device - configure an already set up device

: generic device representing device to be configured

The idea of configure is simply to provide a point within the setup process to allow the transport class to extract information from a device after it has been setup. This is used in SCSI because we have to have a setup device to begin using the HBA, but after we send the initial inquiry, we use configure to extract the device parameters. The device need not have been added to be configured.

Definition at line 208 of file transport_class.c.

void transport_destroy_device ( struct device dev)

transport_destroy_device - destroy a removed device

: device to eliminate from the transport class.

This call triggers the elimination of storage associated with the transport classdev. Note: all it really does is relinquish a reference to the classdev. The memory will not be freed until the last reference goes to zero. Note also that the classdev retains a reference count on dev, so dev too will remain for as long as the transport class device remains around.

Definition at line 276 of file transport_class.c.

void transport_remove_device ( struct device dev)

transport_remove_device - remove the visibility of a device

: generic device to remove

This call removes the visibility of the device (to the user from sysfs), but does not destroy it. To eliminate a device entirely you must also call transport_destroy_device. If you don't need to do remove and destroy as separate operations, use transport_unregister_device() (see transport_class.h) which will perform both calls for you.

Definition at line 247 of file transport_class.c.

void transport_setup_device ( struct device dev)

transport_setup_device - declare a new dev for transport class association but don't make it visible yet. : the generic device representing the entity being added

Usually, dev represents some component in the HBA system (either the HBA itself or a device remote across the HBA bus). This routine is simply a trigger point to see if any set of transport classes wishes to associate with the added device. This allocates storage for the class device and initialises it, but does not yet add it to the system or add attributes to it (you do this with transport_add_device). If you have no need for a separate setup and add operations, use transport_register_device (see transport_class.h).

Definition at line 145 of file transport_class.c.