Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
driver.c File Reference
#include <linux/device.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/string.h>
#include "base.h"

Go to the source code of this file.

Functions

int driver_for_each_device (struct device_driver *drv, struct device *start, void *data, int(*fn)(struct device *, void *))
 
 EXPORT_SYMBOL_GPL (driver_for_each_device)
 
struct devicedriver_find_device (struct device_driver *drv, struct device *start, void *data, int(*match)(struct device *dev, void *data))
 
 EXPORT_SYMBOL_GPL (driver_find_device)
 
int driver_create_file (struct device_driver *drv, const struct driver_attribute *attr)
 
 EXPORT_SYMBOL_GPL (driver_create_file)
 
void driver_remove_file (struct device_driver *drv, const struct driver_attribute *attr)
 
 EXPORT_SYMBOL_GPL (driver_remove_file)
 
int driver_register (struct device_driver *drv)
 
 EXPORT_SYMBOL_GPL (driver_register)
 
void driver_unregister (struct device_driver *drv)
 
 EXPORT_SYMBOL_GPL (driver_unregister)
 
: name of the driver.

driver_find - locate driver on a bus by its name.

: bus to scan for the driver.

Call kset_find_obj() to iterate over list of drivers on a bus to find driver by name. Return driver if found.

This routine provides no locking to prevent the driver it returns from being unregistered or unloaded while the caller is using it. The caller is responsible for preventing this.

struct device_driverdriver_find (const char *name, struct bus_type *bus)
 
 EXPORT_SYMBOL_GPL (driver_find)
 

Function Documentation

int driver_create_file ( struct device_driver drv,
const struct driver_attribute attr 
)

driver_create_file - create sysfs file for driver. : driver. : driver attribute descriptor.

Definition at line 101 of file driver.c.

struct device_driver* driver_find ( const char name,
struct bus_type bus 
)
read

Definition at line 227 of file driver.c.

struct device* driver_find_device ( struct device_driver drv,
struct device start,
void data,
int(*)(struct device *dev, void *data match 
)
read

driver_find_device - device iterator for locating a particular device. : The device's driver : Device to begin with : Data to pass to match function : Callback function to check device

This is similar to the driver_for_each_device() function above, but it returns a reference to a device that is 'found' for later use, as determined by the callback.

The callback should return 0 if the device doesn't match and non-zero if it does. If the callback returns non-zero, this function will return to the caller and not iterate over any more devices.

Definition at line 76 of file driver.c.

int driver_for_each_device ( struct device_driver drv,
struct device start,
void data,
int(*)(struct device *, void *)  fn 
)

Definition at line 42 of file driver.c.

int driver_register ( struct device_driver drv)

driver_register - register driver with bus : driver to register

We pass off most of the work to the bus_add_driver() call, since most of the things we have to do deal with the bus structures.

Definition at line 164 of file driver.c.

void driver_remove_file ( struct device_driver drv,
const struct driver_attribute attr 
)

driver_remove_file - remove sysfs file for driver. : driver. : driver attribute descriptor.

Definition at line 118 of file driver.c.

void driver_unregister ( struct device_driver drv)

driver_unregister - remove driver from system. : driver.

Again, we pass off most of the work to the bus-level call.

Definition at line 204 of file driver.c.

EXPORT_SYMBOL_GPL ( driver_for_each_device  )
EXPORT_SYMBOL_GPL ( driver_find_device  )
EXPORT_SYMBOL_GPL ( driver_create_file  )
EXPORT_SYMBOL_GPL ( driver_remove_file  )
EXPORT_SYMBOL_GPL ( driver_register  )
EXPORT_SYMBOL_GPL ( driver_unregister  )
EXPORT_SYMBOL_GPL ( driver_find  )