Table of Contents
1, the device layer registration, cancellation function
1.2、platform_device_unregister
2, driver layer registration cancellation function
2.2、platform_driver_ unregister
3, access to resources function
3.3、platform_get_resource_byname
4, allocate memory resources function
1, the device layer registration, cancellation function
1.1、platform_device_register
Prototype: int platform_device_register (struct platform_device * pdev )
Function: a platform device up to the kernel
parameters: PDEV: To register platform device structured pointer
Return Value: 0: registration is successful; negative: Registration Failure
1.2、platform_device_unregister
Prototype: void platform_device_unregister (struct platform_device * pdev )
Function: Unregister a device from the platform kernel
parameters: PDEV: To log-structured pointer platform device
Return Value: None
1.3、platform_add_devices
Prototype: int platform_add_devices (struct platform_device ** devs , int num)
function: once up to the kernel num platforms equipment
parameters: devs is the device to register array platform
Return: 0: registration is successful; negative: Registration Failed
2, driver layer registration cancellation function
2.1、platform_driver_register
int platform_driver_register (struct platform_driver * drv)
function: a platform to drive up to the kernel. Thus when the platform is raised to match the device probe function kernel execution platform driving structure
parameters: DRV: to drive the platform structure pointer register
Return Value: 0: registration is successful; negative: Registration Failure
2.2、platform_driver_ unregister
void platform_driver_ unregister (struct platform_driver * drv )
function: cancellation of a platform device drivers from the kernel, device platform has been matched so when thrown kernel execution platform-driven structure
remove function
parameters: drv: drive platform structure pointer to be registered
3, access to resources function
3.1、platform_get_resource
Prototype:
struct platform_get_resource Resource * (dev * struct platform_device, type unsigned int, unsigned int NUM)
Function:
by detecting function pointer with a device for the specified type of device resource structure of the address structure. This function is the detection function of the drive layer makes
with
the parameters: dev: device pointer is in fact the probe function arguments
type: Resource type
num: the same resource, the subscript number renumbered, and resource array device layer is not identical. (It is to be noted)
Return Value: first address resource structure array structure corresponding to the device layer resources. NULL: Failed
3.2、platform_get_irq
Prototype: int platform_get_irq (struct platform_device * dev , unsigned int num)
Function: Specifies the number obtained by the device structure pointer device interrupts the starting number resource
parameters:
dev: device pointer is in fact a probe function parameters
num: similar resource re the subscript number after number, the resource array and the device layer is not identical. (Keep this in mind)
Return value:> 0: interrupt start numbering resources; -ENXIO: Failed
3.3、platform_get_resource_byname
Prototype:
struct Resource * platform_get_resource_byname (struct platform_device * dev,
unsigned int of the type, const char * name)
Function: Get specify the name of the device structure specifies the type of resource structure memory address via the device pointer
parameters:
dev: device pointer, is in fact a probe function parameter
name: resource name
return value: first address resource structure array structure corresponding to the device layer resources. NULL: Failed
3.4、platform_get_irq_byname
Prototype: int platform_get_irq_byname (struct platform_device * dev , const char * name)
Function: Specifies the name of the device structure obtained by the pointer device interrupts the starting number resource
parameters:
dev: device pointer is in fact a probe function parameter
name: interrupt resource name
returns:> 0: interrupt start numbering resources; -ENXIO: failed
4, allocate memory resources function
4.1、request_region
Prototype:
#define the request_region (Start, n-, name) __request_region (& ioport_resource, (Start), (n-), (name), 0)
function: the kernel application period of the IO port ( IORESOURCE_IO type) (not used)
Parameters:
Start : starting address
n: continuous size
name: user name, registration for the kernel.
Return Value:
Non-NULL: Successful applicants resource structure memory address * Resource struct
NULL: IO port resources application has been occupied by others, the application fails.
4.2、request_mem_region
Prototype:
#define request_mem_region (Start, n-, name) __request_region (& iomem_resource, (Start), (n-), (name), 0)
function: to apply the kernel memory section IO ( IORESOURCE_MEM type)
parameters:
Start: start address
n: continuous size
name: user name, registration for the kernel.
Return Value:
Non-NULL: Successful applicants resource structure memory address * Resource struct
NULL: IO memory resources of the application have been occupied by others, the application fails.
This macro uses very much in the actual programming.
4.3、devm_request_region
Prototype:
#define devm_request_region (dev, Start, n-, name) \
__devm_request_region (dev, & ioport_resource, (Start), (n-), (name))
Function: the kernel application period of the IO port ( IORESOURCE_IO type), the function and request_region same
parameters:
dev: device pointer, struct * device
start: start address
n: continuous size
name: user name, registration for the kernel.
Return Value:
Non-NULL: Successful applicants resource structure memory address * Resource struct
NULL: IO port resources application has been occupied by others, the application fails.
4.4、devm_request_mem_region
Prototype:
#define devm_request_mem_region (dev, Start, n-, name) \
__devm_request_region (dev, & iomem_resource, (Start), (n-), (name))
Function: the kernel application period IO memory ( IORESOURCE_MEM type) ( used to apply IO register )
parameters:
dev: device pointer, struct * device
start: start address
n: continuous size
name: user name, registration for the kernel.
Return Value:
Non-NULL: Successful applicants resource structure memory address * Resource struct
NULL: IO memory resources of the application have been occupied by others, the application fails.
This macro uses very much in the actual programming.
5, free up memory resources
5.1、release_region
Prototype:
#define release_region (Start, n-) __release_region (& ioport_resource, (Start), (n-))
Function: Io release port space period used request_region application.
parameter:start: start address
n: Continuous Size
5.2、release_ mem_region
#define release_mem_region (start, n) __release_region (& iomem_resource, (start), (n))
function: the release period using request_mem_region Io application memory space.
Parameters:
Start: start address
n: Continuous Size
5.3、devm_release_region
__devm_release_region (dev, & ioport_resource, ( start), (n))
This macro previous release_region same, but more a pointer device dev parameter of type struct device *
5.4、devm_release_mem_region
devm_release_mem_region #define (dev, Start, n-) \
__devm_release_region (dev, & iomem_resource, (Start), (n-))
This macro previous release_mem_region same, but more a pointer device dev parameter of type struct device *