Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
firmware_class.c File Reference
#include <linux/capability.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/timer.h>
#include <linux/vmalloc.h>
#include <linux/interrupt.h>
#include <linux/bitops.h>
#include <linux/mutex.h>
#include <linux/workqueue.h>
#include <linux/highmem.h>
#include <linux/firmware.h>
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/file.h>
#include <linux/list.h>
#include <linux/async.h>
#include <linux/pm.h>
#include <linux/suspend.h>
#include <linux/syscore_ops.h>
#include <generated/utsrelease.h>
#include "base.h"

Go to the source code of this file.

Data Structures

struct  firmware_cache
 
struct  firmware_buf
 
struct  fw_cache_entry
 
struct  firmware_priv
 
struct  fw_name_devm
 
struct  firmware_work
 

Macros

#define to_fwbuf(d)   container_of(d, struct firmware_buf, ref)
 
#define FW_LOADER_NO_CACHE   0
 
#define FW_LOADER_START_CACHE   1
 
#define PAGE_KERNEL_RO   PAGE_KERNEL
 

Enumerations

enum  { FW_STATUS_LOADING, FW_STATUS_DONE, FW_STATUS_ABORT }
 
enum  fw_buf_fmt { VMALLOC_BUF, PAGE_BUF }
 

Functions

 MODULE_AUTHOR ("Manuel Estrada Sainz")
 
 MODULE_DESCRIPTION ("Multi purpose firmware loading support")
 
 MODULE_LICENSE ("GPL")
 
: name of firmware file

request_firmware_nowait - asynchronous version of request_firmware : module requesting the firmware : sends uevent to copy the firmware image if this flag is non-zero else the firmware copy must be done manually.

: device for which firmware is being loaded : allocation flags : will be passed over to , and may be NULL if firmware request fails. : function will be called asynchronously when the firmware request is over.

Caller must hold the reference count of .

Asynchronous variant of request_firmware() for user contexts:

  • sleep for as small periods as possible since it may increase kernel boot time of built-in device drivers requesting firmware in their ->probe() methods, if is GFP_KERNEL.
  • can't sleep at all if is GFP_ATOMIC.
int request_firmware_nowait (struct module *module, bool uevent, const char *name, struct device *device, gfp_t gfp, void *context, void(*cont)(const struct firmware *fw, void *context))
 
int cache_firmware (const char *fw_name)
 
int uncache_firmware (const char *fw_name)
 
 fs_initcall (firmware_class_init)
 
 module_exit (firmware_class_exit)
 
 EXPORT_SYMBOL (release_firmware)
 
 EXPORT_SYMBOL (request_firmware)
 
 EXPORT_SYMBOL (request_firmware_nowait)
 
 EXPORT_SYMBOL_GPL (cache_firmware)
 
 EXPORT_SYMBOL_GPL (uncache_firmware)
 
will be used as $FIRMWARE in the uevent environment and
should be distinctive enough not to be confused with any other
firmware image for this or any other device.

Caller must hold the reference count of .

int request_firmware (const struct firmware **firmware_p, const char *name, struct device *device)
 
void release_firmware (const struct firmware *fw)
 

Macro Definition Documentation

#define FW_LOADER_NO_CACHE   0

Definition at line 160 of file firmware_class.c.

#define FW_LOADER_START_CACHE   1

Definition at line 161 of file firmware_class.c.

#define PAGE_KERNEL_RO   PAGE_KERNEL

Definition at line 434 of file firmware_class.c.

#define to_fwbuf (   d)    container_of(d, struct firmware_buf, ref)

Definition at line 158 of file firmware_class.c.

Enumeration Type Documentation

anonymous enum
Enumerator:
FW_STATUS_LOADING 
FW_STATUS_DONE 
FW_STATUS_ABORT 

Definition at line 85 of file firmware_class.c.

enum fw_buf_fmt
Enumerator:
VMALLOC_BUF 
PAGE_BUF 

Definition at line 91 of file firmware_class.c.

Function Documentation

int cache_firmware ( const char fw_name)

cache_firmware - cache one firmware image in kernel memory space : the firmware image name

Cache firmware in kernel memory so that drivers can use it when system isn't ready for them to request firmware image from userspace. Once it returns successfully, driver can use request_firmware or its nowait version to get the cached firmware without any interacting with userspace

Return 0 if the firmware image has been cached successfully Return !0 otherwise

Definition at line 1120 of file firmware_class.c.

EXPORT_SYMBOL ( release_firmware  )
EXPORT_SYMBOL ( request_firmware  )
EXPORT_SYMBOL ( request_firmware_nowait  )
EXPORT_SYMBOL_GPL ( cache_firmware  )
EXPORT_SYMBOL_GPL ( uncache_firmware  )
fs_initcall ( firmware_class_init  )
MODULE_AUTHOR ( "Manuel Estrada Sainz"  )
MODULE_DESCRIPTION ( "Multi purpose firmware loading support )
module_exit ( firmware_class_exit  )
MODULE_LICENSE ( "GPL"  )
void release_firmware ( const struct firmware fw)

release_firmware: - release the resource associated with a firmware image : firmware resource to release

Definition at line 997 of file firmware_class.c.

int request_firmware ( const struct firmware **  firmware_p,
const char name,
struct device device 
)

Definition at line 968 of file firmware_class.c.

int request_firmware_nowait ( struct module module,
bool  uevent,
const char name,
struct device device,
gfp_t  gfp,
void context,
void(*)(const struct firmware *fw, void *context cont 
)

Definition at line 1077 of file firmware_class.c.

int uncache_firmware ( const char fw_name)

uncache_firmware - remove one cached firmware image : the firmware image name

Uncache one firmware image which has been cached successfully before.

Return 0 if the firmware cache has been removed successfully Return !0 otherwise

Definition at line 1147 of file firmware_class.c.