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

Go to the source code of this file.

Data Structures

struct  platform_device
 
struct  platform_device_info
 
struct  platform_driver
 
struct  early_platform_driver
 

Macros

#define PLATFORM_DEVID_NONE   (-1)
 
#define PLATFORM_DEVID_AUTO   (-2)
 
#define platform_get_device_id(pdev)   ((pdev)->id_entry)
 
#define to_platform_device(x)   container_of((x), struct platform_device, dev)
 

Functions

int platform_device_register (struct platform_device *)
 
void platform_device_unregister (struct platform_device *)
 
void arch_setup_pdev_archdata (struct platform_device *)
 
struct resourceplatform_get_resource (struct platform_device *, unsigned int, unsigned int)
 
int platform_get_irq (struct platform_device *, unsigned int)
 
struct resourceplatform_get_resource_byname (struct platform_device *, unsigned int, const char *)
 
int platform_get_irq_byname (struct platform_device *, const char *)
 
int platform_add_devices (struct platform_device **, int)
 
struct platform_deviceplatform_device_register_full (const struct platform_device_info *pdevinfo)
 

Variables

struct bus_type platform_bus_type
 
struct device platform_bus
 

: base name of the device we're adding

platform_device_register_data - add a platform-level device with platform-specific data : parent device for the device we're adding

: instance id : platform specific data for this platform device : size of platform specific data

This function creates a simple platform device that requires minimal resource and memory management. Canned release function freeing memory allocated for the device allows drivers using such devices to be unloaded without waiting for the last reference to the device to be dropped.

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

#define module_platform_driver(__platform_driver)
 
#define EARLY_PLATFORM_ID_UNSET   -2
 
#define EARLY_PLATFORM_ID_ERROR   -3
 
#define early_platform_init(class_string, platdrv)   early_platform_init_buffer(class_string, platdrv, NULL, 0)
 
#define early_platform_init_buffer(class_string, platdrv, buf, bufsiz)
 
#define platform_pm_suspend   NULL
 
#define platform_pm_resume   NULL
 
#define platform_pm_freeze   NULL
 
#define platform_pm_thaw   NULL
 
#define platform_pm_poweroff   NULL
 
#define platform_pm_restore   NULL
 
#define USE_PLATFORM_PM_SLEEP_OPS
 
struct platform_deviceplatform_device_alloc (const char *name, int id)
 
int platform_device_add_resources (struct platform_device *pdev, const struct resource *res, unsigned int num)
 
int platform_device_add_data (struct platform_device *pdev, const void *data, size_t size)
 
int platform_device_add (struct platform_device *pdev)
 
void platform_device_del (struct platform_device *pdev)
 
void platform_device_put (struct platform_device *pdev)
 
int platform_driver_register (struct platform_driver *)
 
void platform_driver_unregister (struct platform_driver *)
 
int platform_driver_probe (struct platform_driver *driver, int(*probe)(struct platform_device *))
 
struct platform_deviceplatform_create_bundle (struct platform_driver *driver, int(*probe)(struct platform_device *), struct resource *res, unsigned int n_res, const void *data, size_t size)
 
int early_platform_driver_register (struct early_platform_driver *epdrv, char *buf)
 
void early_platform_add_devices (struct platform_device **devs, int num)
 
void early_platform_driver_register_all (char *class_str)
 
int early_platform_driver_probe (char *class_str, int nr_probe, int user_only)
 
void early_platform_cleanup (void)
 

Macro Definition Documentation

#define EARLY_PLATFORM_ID_ERROR   -3

Definition at line 222 of file platform_device.h.

#define EARLY_PLATFORM_ID_UNSET   -2

Definition at line 221 of file platform_device.h.

#define early_platform_init (   class_string,
  platdrv 
)    early_platform_init_buffer(class_string, platdrv, NULL, 0)

Definition at line 238 of file platform_device.h.

#define early_platform_init_buffer (   class_string,
  platdrv,
  buf,
  bufsiz 
)
Value:
static __initdata struct early_platform_driver early_driver = { \
.class_str = class_string, \
.buffer = buf, \
.bufsize = bufsiz, \
.pdrv = platdrv, \
.requested_id = EARLY_PLATFORM_ID_UNSET, \
}; \
static int __init early_platform_driver_setup_func(char *buffer) \
{ \
return early_platform_driver_register(&early_driver, buffer); \
} \
early_param(class_string, early_platform_driver_setup_func)

Definition at line 242 of file platform_device.h.

#define module_platform_driver (   __platform_driver)
Value:

Definition at line 202 of file platform_device.h.

#define PLATFORM_DEVID_AUTO   (-2)

Definition at line 18 of file platform_device.h.

#define PLATFORM_DEVID_NONE   (-1)

Definition at line 17 of file platform_device.h.

#define platform_get_device_id (   pdev)    ((pdev)->id_entry)

Definition at line 39 of file platform_device.h.

#define platform_pm_freeze   NULL

Definition at line 277 of file platform_device.h.

#define platform_pm_poweroff   NULL

Definition at line 279 of file platform_device.h.

#define platform_pm_restore   NULL

Definition at line 280 of file platform_device.h.

#define platform_pm_resume   NULL

Definition at line 268 of file platform_device.h.

#define platform_pm_suspend   NULL

Definition at line 267 of file platform_device.h.

#define platform_pm_thaw   NULL

Definition at line 278 of file platform_device.h.

#define to_platform_device (   x)    container_of((x), struct platform_device, dev)

Definition at line 41 of file platform_device.h.

#define USE_PLATFORM_PM_SLEEP_OPS

Definition at line 292 of file platform_device.h.

Function Documentation

void arch_setup_pdev_archdata ( struct platform_device pdev)

arch_setup_pdev_archdata - Allow manipulation of archdata before its used : platform device

This is called before platform_device_add() such that any pdev_archdata may be setup before the platform_notifier is called. So if a user needs to manipulate any relevant information in the pdev_archdata they can do:

platform_devic_alloc()
... manipulate ...
platform_device_add()

And if they don't care they can just call platform_device_register() and everything will just work out.

Definition at line 755 of file setup-common.c.

void early_platform_add_devices ( struct platform_device **  devs,
int  num 
)

early_platform_add_devices - adds a number of early platform devices : array of early platform devices to add : number of early platform devices in array

Used by early architecture code to register early platform devices and their platform data.

Definition at line 984 of file platform.c.

void early_platform_cleanup ( void  )

early_platform_cleanup - clean up early platform code

Definition at line 1190 of file platform.c.

int early_platform_driver_probe ( char class_str,
int  nr_probe,
int  user_only 
)

early_platform_driver_probe - probe a class of registered drivers : string to identify early platform driver class : number of platform devices to successfully probe before exiting : only probe user specified early platform devices

Used by architecture code to probe registered early platform drivers within a certain class. For probe to happen a registered early platform device matching a registered early platform driver is needed.

Definition at line 1165 of file platform.c.

int early_platform_driver_register ( struct early_platform_driver epdrv,
char buf 
)

early_platform_driver_register - register early platform driver : early_platform driver structure : string passed from early_param()

Helper function for early_platform_init() / early_platform_init_buffer()

Definition at line 927 of file platform.c.

void early_platform_driver_register_all ( char class_str)

early_platform_driver_register_all - register early platform drivers : string to identify early platform driver class

Used by architecture code to register all early platform drivers for a certain class. If omitted then only early platform drivers with matching kernel command line class parameters will be registered.

Definition at line 1010 of file platform.c.

int platform_add_devices ( struct platform_device **  devs,
int  num 
)

platform_add_devices - add a numbers of platform devices : array of platform devices to add : number of platform devices in array

Definition at line 143 of file platform.c.

struct platform_device* platform_create_bundle ( struct platform_driver driver,
int(*)(struct platform_device *)  probe,
struct resource res,
unsigned int  n_res,
const void data,
size_t  size 
)
read

platform_create_bundle - register driver and create corresponding device : platform driver structure : the driver probe routine, probably from an __init section : set of resources that needs to be allocated for the device : number of resources : platform specific data for this platform device : size of platform specific data

Use this in legacy-style modules that probe hardware directly and register a single platform device and corresponding platform driver.

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

Definition at line 599 of file platform.c.

int platform_device_add ( struct platform_device pdev)

platform_device_add - add a platform device to device hierarchy : platform device we're adding

This is part 2 of platform_device_register(), though may be called separately iff pdev was allocated by platform_device_alloc().

Definition at line 279 of file platform.c.

int platform_device_add_data ( struct platform_device pdev,
const void data,
size_t  size 
)

platform_device_add_data - add platform-specific data to a platform device : platform device allocated by platform_device_alloc to add resources to : platform specific data for this platform device : size of platform specific data

Add a copy of platform specific data to the platform device's platform_data pointer. The memory associated with the platform data will be freed when the platform device is released.

Definition at line 255 of file platform.c.

int platform_device_add_resources ( struct platform_device pdev,
const struct resource res,
unsigned int  num 
)

platform_device_add_resources - add resources to a platform device : platform device allocated by platform_device_alloc to add resources to : set of resources that needs to be allocated for the device : number of resources

Add a copy of the resources to the platform device. The memory associated with the resources will be freed when the platform device is released.

Definition at line 227 of file platform.c.

struct platform_device* platform_device_alloc ( const char name,
int  id 
)
read

Definition at line 199 of file platform.c.

void platform_device_del ( struct platform_device pdev)

platform_device_del - remove a platform-level device : platform device we're removing

Note that this function will also release all memory- and port-based resources owned by the device (->resource). This function must only be externally called in error cases. All other usage is a bug.

Definition at line 370 of file platform.c.

void platform_device_put ( struct platform_device pdev)

platform_device_put - destroy a platform device : platform device to free

Free all memory associated with a platform device. This function must only be externally called in error cases. All other usage is a bug.

Definition at line 172 of file platform.c.

int platform_device_register ( struct platform_device pdev)

platform_device_register - add a platform-level device : platform device we're adding

Definition at line 397 of file platform.c.

struct platform_device* platform_device_register_full ( const struct platform_device_info pdevinfo)
read

platform_device_register_full - add a platform-level device with resources and platform-specific data

: data used to create device

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

Definition at line 428 of file platform.c.

void platform_device_unregister ( struct platform_device pdev)

platform_device_unregister - unregister a platform-level device : platform device we're unregistering

Unregistration is done in 2 steps. First we release all resources and remove it from the subsystem, then we drop reference count by calling platform_device_put().

Definition at line 413 of file platform.c.

int platform_driver_probe ( struct platform_driver drv,
int(*)(struct platform_device *)  probe 
)

platform_driver_probe - register driver for non-hotpluggable device : platform driver structure : the driver probe routine, probably from an __init section

Use this instead of platform_driver_register() when you know the device is not hotpluggable and has already been registered, and you want to remove its run-once probe() infrastructure from memory after the driver has bound to the device.

One typical use for this would be with drivers for controllers integrated into system-on-chip processors, where the controller devices have been configured as part of board setup.

Returns zero if the driver registered and bound to a device, else returns a negative error code and with the driver not registered.

Definition at line 554 of file platform.c.

int platform_driver_register ( struct platform_driver drv)

platform_driver_register - register a driver for platform-level devices : platform driver structure

Definition at line 513 of file platform.c.

void platform_driver_unregister ( struct platform_driver drv)

platform_driver_unregister - unregister a driver for platform-level devices : platform driver structure

Definition at line 531 of file platform.c.

int platform_get_irq ( struct platform_device dev,
unsigned int  num 
)

platform_get_irq - get an IRQ for a device : platform device : IRQ number index

Definition at line 84 of file platform.c.

int platform_get_irq_byname ( struct platform_device ,
const char  
)

Definition at line 129 of file platform.c.

struct resource* platform_get_resource ( struct platform_device dev,
unsigned int  type,
unsigned int  num 
)
read

platform_get_resource - get a resource for a device : platform device : resource type : resource index

Definition at line 64 of file platform.c.

struct resource* platform_get_resource_byname ( struct platform_device ,
unsigned  int,
const char  
)
read

Definition at line 105 of file platform.c.

Variable Documentation

struct device platform_bus

Definition at line 34 of file platform.c.

struct bus_type platform_bus_type

Definition at line 871 of file platform.c.