Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
class.c File Reference
#include <linux/device.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/kdev_t.h>
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/genhd.h>
#include <linux/mutex.h>
#include "base.h"

Go to the source code of this file.

Data Structures

struct  class_compat
 

Macros

#define to_class_attr(_attr)   container_of(_attr, struct class_attribute, attr)
 

Functions

int class_create_file (struct class *cls, const struct class_attribute *attr)
 
void class_remove_file (struct class *cls, const struct class_attribute *attr)
 
int __class_register (struct class *cls, struct lock_class_key *key)
 
 EXPORT_SYMBOL_GPL (__class_register)
 
void class_unregister (struct class *cls)
 
: pointer to a string for the name of this class.

class_create - create a struct class structure : pointer to the module that is to "own" this struct class

: the lock_class_key for this class; used by mutex lock debugging

This is used to create a struct class pointer that can then be used in calls to device_create().

Returns &struct class pointer on success, or ERR_PTR() on error.

Note, the pointer created here is to be destroyed when finished by making a call to class_destroy().

struct class__class_create (struct module *owner, const char *name, struct lock_class_key *key)
 
 EXPORT_SYMBOL_GPL (__class_create)
 
void class_destroy (struct class *cls)
 
void class_dev_iter_init (struct class_dev_iter *iter, struct class *class, struct device *start, const struct device_type *type)
 
 EXPORT_SYMBOL_GPL (class_dev_iter_init)
 
struct deviceclass_dev_iter_next (struct class_dev_iter *iter)
 
 EXPORT_SYMBOL_GPL (class_dev_iter_next)
 
void class_dev_iter_exit (struct class_dev_iter *iter)
 
 EXPORT_SYMBOL_GPL (class_dev_iter_exit)
 
int class_for_each_device (struct class *class, struct device *start, void *data, int(*fn)(struct device *, void *))
 
 EXPORT_SYMBOL_GPL (class_for_each_device)
 
struct deviceclass_find_device (struct class *class, struct device *start, void *data, int(*match)(struct device *, void *))
 
 EXPORT_SYMBOL_GPL (class_find_device)
 
int class_interface_register (struct class_interface *class_intf)
 
void class_interface_unregister (struct class_interface *class_intf)
 
ssize_t show_class_attr_string (struct class *class, struct class_attribute *attr, char *buf)
 
 EXPORT_SYMBOL_GPL (show_class_attr_string)
 
: the name of the class

class_compat_register - register a compatibility class

Compatibility class are meant as a temporary user-space compatibility workaround when converting a family of class devices to a bus devices.

struct class_compatclass_compat_register (const char *name)
 
 EXPORT_SYMBOL_GPL (class_compat_register)
 
void class_compat_unregister (struct class_compat *cls)
 
 EXPORT_SYMBOL_GPL (class_compat_unregister)
 
int class_compat_create_link (struct class_compat *cls, struct device *dev, struct device *device_link)
 
 EXPORT_SYMBOL_GPL (class_compat_create_link)
 
void class_compat_remove_link (struct class_compat *cls, struct device *dev, struct device *device_link)
 
 EXPORT_SYMBOL_GPL (class_compat_remove_link)
 
int __init classes_init (void)
 
 EXPORT_SYMBOL_GPL (class_create_file)
 
 EXPORT_SYMBOL_GPL (class_remove_file)
 
 EXPORT_SYMBOL_GPL (class_unregister)
 
 EXPORT_SYMBOL_GPL (class_destroy)
 
 EXPORT_SYMBOL_GPL (class_interface_register)
 
 EXPORT_SYMBOL_GPL (class_interface_unregister)
 

Macro Definition Documentation

#define to_class_attr (   _attr)    container_of(_attr, struct class_attribute, attr)

Definition at line 24 of file class.c.

Function Documentation

struct class* __class_create ( struct module owner,
const char name,
struct lock_class_key key 
)
read

Definition at line 249 of file class.c.

int __class_register ( struct class cls,
struct lock_class_key key 
)

Definition at line 176 of file class.c.

int class_compat_create_link ( struct class_compat cls,
struct device dev,
struct device device_link 
)

class_compat_create_link - create a compatibility class device link to a bus device : the compatibility class : the target bus device : an optional device to which a "device" link should be created

Definition at line 553 of file class.c.

struct class_compat* class_compat_register ( const char name)
read

Definition at line 519 of file class.c.

void class_compat_remove_link ( struct class_compat cls,
struct device dev,
struct device device_link 
)

class_compat_remove_link - remove a compatibility class device link to a bus device : the compatibility class : the target bus device : an optional device to which a "device" link was previously created

Definition at line 586 of file class.c.

void class_compat_unregister ( struct class_compat cls)

class_compat_unregister - unregister a compatibility class : the class to unregister

Definition at line 539 of file class.c.

int class_create_file ( struct class cls,
const struct class_attribute attr 
)

Definition at line 102 of file class.c.

void class_destroy ( struct class cls)

class_destroy - destroys a struct class structure : pointer to the struct class that is to be destroyed

Note, the pointer to be destroyed must have been created with a call to class_create().

Definition at line 284 of file class.c.

void class_dev_iter_exit ( struct class_dev_iter iter)

class_dev_iter_exit - finish iteration : class iterator to finish

Finish an iteration. Always call this function after iteration is complete whether the iteration ran till the end or not.

Definition at line 351 of file class.c.

void class_dev_iter_init ( struct class_dev_iter iter,
struct class class,
struct device start,
const struct device_type type 
)

Definition at line 304 of file class.c.

struct device* class_dev_iter_next ( struct class_dev_iter iter)
read

class_dev_iter_next - iterate to the next device : class iterator to proceed

Proceed to the next device and return it. Returns NULL if iteration is complete.

The returned device is referenced and won't be released till iterator is proceed to the next device or exited. The caller is free to do whatever it wants to do with the device including calling back into class code.

Definition at line 328 of file class.c.

struct device* class_find_device ( struct class class,
struct device start,
void data,
int(*)(struct device *, void *)  match 
)
read

Definition at line 422 of file class.c.

int class_for_each_device ( struct class class,
struct device start,
void data,
int(*)(struct device *, void *)  fn 
)

Definition at line 375 of file class.c.

int class_interface_register ( struct class_interface class_intf)

Definition at line 450 of file class.c.

void class_interface_unregister ( struct class_interface class_intf)

Definition at line 476 of file class.c.

void class_remove_file ( struct class cls,
const struct class_attribute attr 
)

Definition at line 113 of file class.c.

void class_unregister ( struct class cls)

Definition at line 222 of file class.c.

int __init classes_init ( void  )

Definition at line 595 of file class.c.

EXPORT_SYMBOL_GPL ( __class_register  )
EXPORT_SYMBOL_GPL ( __class_create  )
EXPORT_SYMBOL_GPL ( class_dev_iter_init  )
EXPORT_SYMBOL_GPL ( class_dev_iter_next  )
EXPORT_SYMBOL_GPL ( class_dev_iter_exit  )
EXPORT_SYMBOL_GPL ( class_for_each_device  )
EXPORT_SYMBOL_GPL ( class_find_device  )
EXPORT_SYMBOL_GPL ( show_class_attr_string  )
EXPORT_SYMBOL_GPL ( class_compat_register  )
EXPORT_SYMBOL_GPL ( class_compat_unregister  )
EXPORT_SYMBOL_GPL ( class_compat_create_link  )
EXPORT_SYMBOL_GPL ( class_compat_remove_link  )
EXPORT_SYMBOL_GPL ( class_create_file  )
EXPORT_SYMBOL_GPL ( class_remove_file  )
EXPORT_SYMBOL_GPL ( class_unregister  )
EXPORT_SYMBOL_GPL ( class_destroy  )
EXPORT_SYMBOL_GPL ( class_interface_register  )
EXPORT_SYMBOL_GPL ( class_interface_unregister  )
ssize_t show_class_attr_string ( struct class class,
struct class_attribute attr,
char buf 
)

Definition at line 498 of file class.c.