This documentation is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For more details see the file COPYING in the source distribution of Linux.
Table of Contents
parport_open
params field var value
i2c_new_device
Table of Contents
atomic_sub — subtract integer from atomic variable
void atomic_sub ( | i, | |
v); |
int i;atomic_t * v;atomic_sub_and_test — subtract value from variable and test result
int atomic_sub_and_test ( | i, | |
v); |
int i;atomic_t * v;atomic_add_negative — add and test if negative
int atomic_add_negative ( | i, | |
v); |
int i;atomic_t * v;atomic_add_return — add integer and return
int atomic_add_return ( | i, | |
v); |
int i;atomic_t * v;atomic_sub_return — subtract integer and return
int atomic_sub_return ( | i, | |
v); |
int i;atomic_t * v;atomic_add_unless — add unless the number is already a given value
int atomic_add_unless ( | v, | |
| a, | ||
u); |
atomic_t * v;int a;int u;struct task_cputime — collected CPU time counts
struct task_cputime {
cputime_t utime;
cputime_t stime;
unsigned long long sum_exec_runtime;
}; struct thread_group_cputimer — thread group interval timer counts
struct thread_group_cputimer {
struct task_cputime cputime;
int running;
spinlock_t lock;
}; pid_alive — check that a task structure is not stale
int pid_alive ( | p); |
struct task_struct * p;is_global_init — check if a task structure is init
int is_global_init ( | tsk); |
struct task_struct * tsk;wake_up_process — Wake up a specific process
int wake_up_process ( | p); |
struct task_struct * p;Attempt to wake up the nominated process and move it to the set of runnable processes. Returns 1 if the process was woken up, 0 if it was already running.
It may be assumed that this function implies a write memory barrier before changing the task state if and only if any tasks are woken up.
preempt_notifier_register — tell me when current is being preempted & rescheduled
void preempt_notifier_register ( | notifier); |
struct preempt_notifier * notifier;preempt_notifier_unregister — no longer interested in preemption notifications
void preempt_notifier_unregister ( | notifier); |
struct preempt_notifier * notifier;__wake_up — wake up threads blocked on a waitqueue.
void __wake_up ( | q, | |
| mode, | ||
| nr_exclusive, | ||
key); |
wait_queue_head_t * q;unsigned int mode;int nr_exclusive;void * key;__wake_up_sync_key — wake up threads blocked on a waitqueue.
void __wake_up_sync_key ( | q, | |
| mode, | ||
| nr_exclusive, | ||
key); |
wait_queue_head_t * q;unsigned int mode;int nr_exclusive;void * key;qthe waitqueue
modewhich threads
nr_exclusivehow many wake-one or wake-many threads to wake up
keyopaque value to be passed to wakeup targets
The sync wakeup differs that the waker knows that it will schedule away soon, so while the target thread will be woken up, it will not be migrated to another CPU - ie. the two threads are 'synchronized' with each other. This can prevent needless bouncing between CPUs.
On UP it can prevent extra preemption.
It may be assumed that this function implies a write memory barrier before changing the task state if and only if any tasks are woken up.
complete — signals a single thread waiting on this completion
void complete ( | x); |
struct completion * x;This will wake up a single thread waiting on this completion. Threads will be awakened in the same order in which they were queued.
See also complete_all, wait_for_completion and related routines.
It may be assumed that this function implies a write memory barrier before changing the task state if and only if any tasks are woken up.
complete_all — signals all threads waiting on this completion
void complete_all ( | x); |
struct completion * x;wait_for_completion — waits for completion of a task
void __sched wait_for_completion ( | x); |
struct completion * x;wait_for_completion_timeout — waits for completion of a task (w/timeout)
unsigned long __sched wait_for_completion_timeout ( | x, | |
timeout); |
struct completion * x;unsigned long timeout;wait_for_completion_interruptible — waits for completion of a task (w/intr)
int __sched wait_for_completion_interruptible ( | x); |
struct completion * x;wait_for_completion_interruptible_timeout — waits for completion (w/(to,intr))
long __sched wait_for_completion_interruptible_timeout ( | x, | |
timeout); |
struct completion * x;unsigned long timeout;wait_for_completion_killable — waits for completion of a task (killable)
int __sched wait_for_completion_killable ( | x); |
struct completion * x;wait_for_completion_killable_timeout — waits for completion of a task (w/(to,killable))
long __sched wait_for_completion_killable_timeout ( | x, | |
timeout); |
struct completion * x;unsigned long timeout;try_wait_for_completion — try to decrement a completion without blocking
bool try_wait_for_completion ( | x); |
struct completion * x;completion_done — Test to see if a completion has any waiters
bool completion_done ( | x); |
struct completion * x;task_nice — return the nice value of a given task.
int task_nice ( | p); |
const struct task_struct * p;sched_setscheduler — change the scheduling policy and/or RT priority of a thread.
int sched_setscheduler ( | p, | |
| policy, | ||
param); |
struct task_struct * p;int policy;const struct sched_param * param;yield_to — yield the current processor to another thread in your thread group, or accelerate that thread toward the processor it's on.
bool __sched yield_to ( | p, | |
preempt); |
struct task_struct * p;bool preempt;DECLARE_COMPLETION — declare and initialize a completion structure
DECLARE_COMPLETION ( | work); |
work;DECLARE_COMPLETION_ONSTACK — declare and initialize a completion structure
DECLARE_COMPLETION_ONSTACK ( | work); |
work;init_completion — Initialize a dynamically allocated completion
void init_completion ( | x); |
struct completion * x;__round_jiffies — function to round jiffies to a full second
unsigned long __round_jiffies ( | j, | |
cpu); |
unsigned long j;int cpu;jthe time in (absolute) jiffies that should be rounded
cputhe processor number on which the timeout will happen
__round_jiffies rounds an absolute time in the future (in jiffies)
up or down to (approximately) full seconds. This is useful for timers
for which the exact time they fire does not matter too much, as long as
they fire approximately every X seconds.
By rounding these timers to whole seconds, all such timers will fire at the same time, rather than at various times spread out. The goal of this is to have the CPU wake up less, which saves power.
The exact rounding is skewed for each processor to avoid all processors firing at the exact same time, which could lead to lock contention or spurious cache line bouncing.
The return value is the rounded version of the j parameter.
__round_jiffies_relative — function to round jiffies to a full second
unsigned long __round_jiffies_relative ( | j, | |
cpu); |
unsigned long j;int cpu;jthe time in (relative) jiffies that should be rounded
cputhe processor number on which the timeout will happen
__round_jiffies_relative rounds a time delta in the future (in jiffies)
up or down to (approximately) full seconds. This is useful for timers
for which the exact time they fire does not matter too much, as long as
they fire approximately every X seconds.
By rounding these timers to whole seconds, all such timers will fire at the same time, rather than at various times spread out. The goal of this is to have the CPU wake up less, which saves power.
The exact rounding is skewed for each processor to avoid all processors firing at the exact same time, which could lead to lock contention or spurious cache line bouncing.
The return value is the rounded version of the j parameter.
round_jiffies — function to round jiffies to a full second
unsigned long round_jiffies ( | j); |
unsigned long j;
round_jiffies rounds an absolute time in the future (in jiffies)
up or down to (approximately) full seconds. This is useful for timers
for which the exact time they fire does not matter too much, as long as
they fire approximately every X seconds.
By rounding these timers to whole seconds, all such timers will fire at the same time, rather than at various times spread out. The goal of this is to have the CPU wake up less, which saves power.
The return value is the rounded version of the j parameter.
round_jiffies_relative — function to round jiffies to a full second
unsigned long round_jiffies_relative ( | j); |
unsigned long j;
round_jiffies_relative rounds a time delta in the future (in jiffies)
up or down to (approximately) full seconds. This is useful for timers
for which the exact time they fire does not matter too much, as long as
they fire approximately every X seconds.
By rounding these timers to whole seconds, all such timers will fire at the same time, rather than at various times spread out. The goal of this is to have the CPU wake up less, which saves power.
The return value is the rounded version of the j parameter.
__round_jiffies_up — function to round jiffies up to a full second
unsigned long __round_jiffies_up ( | j, | |
cpu); |
unsigned long j;int cpu;__round_jiffies_up_relative — function to round jiffies up to a full second
unsigned long __round_jiffies_up_relative ( | j, | |
cpu); |
unsigned long j;int cpu;round_jiffies_up — function to round jiffies up to a full second
unsigned long round_jiffies_up ( | j); |
unsigned long j;round_jiffies_up_relative — function to round jiffies up to a full second
unsigned long round_jiffies_up_relative ( | j); |
unsigned long j;set_timer_slack — set the allowed slack for a timer
void set_timer_slack ( | timer, | |
slack_hz); |
struct timer_list * timer;int slack_hz;timerthe timer to be modified
slack_hzthe amount of time (in jiffies) allowed for rounding
Set the amount of time, in jiffies, that a certain timer has
in terms of slack. By setting this value, the timer subsystem
will schedule the actual timer somewhere between
the time mod_timer asks for, and that time plus the slack.
By setting the slack to -1, a percentage of the delay is used instead.
init_timer_key — initialize a timer
void init_timer_key ( | timer, | |
| name, | ||
key); |
struct timer_list * timer;const char * name;struct lock_class_key * key;mod_timer_pending — modify a pending timer's timeout
int mod_timer_pending ( | timer, | |
expires); |
struct timer_list * timer;unsigned long expires;mod_timer — modify a timer's timeout
int mod_timer ( | timer, | |
expires); |
struct timer_list * timer;unsigned long expires;
mod_timer is a more efficient way to update the expire field of an
active timer (if the timer is inactive it will be activated)
mod_timer(timer, expires) is equivalent to:
del_timer(timer); timer->expires = expires; add_timer(timer);
Note that if there are multiple unserialized concurrent users of the
same timer, then mod_timer is the only safe way to modify the timeout,
since add_timer cannot modify an already running timer.
The function returns whether it has modified a pending timer or not.
(ie. mod_timer of an inactive timer returns 0, mod_timer of an
active timer returns 1.)
mod_timer_pinned — modify a timer's timeout
int mod_timer_pinned ( | timer, | |
expires); |
struct timer_list * timer;unsigned long expires;
mod_timer_pinned is a way to update the expire field of an
active timer (if the timer is inactive it will be activated)
and not allow the timer to be migrated to a different CPU.
mod_timer_pinned(timer, expires) is equivalent to:
del_timer(timer); timer->expires = expires; add_timer(timer);
add_timer — start a timer
void add_timer ( | timer); |
struct timer_list * timer;The kernel will do a ->function(->data) callback from the timer interrupt at the ->expires point in the future. The current time is 'jiffies'.
The timer's ->expires, ->function (and if the handler uses it, ->data) fields must be set prior calling this function.
Timers with an ->expires field in the past will be executed in the next timer tick.
add_timer_on — start a timer on a particular CPU
void add_timer_on ( | timer, | |
cpu); |
struct timer_list * timer;int cpu;try_to_del_timer_sync — Try to deactivate a timer
int try_to_del_timer_sync ( | timer); |
struct timer_list * timer;del_timer_sync — deactivate a timer and wait for the handler to finish.
int del_timer_sync ( | timer); |
struct timer_list * timer;
This function only differs from del_timer on SMP: besides deactivating
the timer it also makes sure the handler has finished executing on other
CPUs.
Callers must prevent restarting of the timer,
otherwise this function is meaningless. It must not be called from
interrupt contexts. The caller must not hold locks which would prevent
completion of the timer's handler. The timer's handler must not call
add_timer_on. Upon exit the timer is not queued and the handler is
not running on any CPU.
You must not hold locks that are held in interrupt context while calling this function. Even if the lock has nothing to do with the timer in question. Here's why:
CPU0 CPU1
---- ----
<SOFTIRQ>
call_timer_fn;
base->running_timer = mytimer;
spin_lock_irq(somelock);
<IRQ>
spin_lock(somelock);
del_timer_sync(mytimer);
while (base->running_timer == mytimer);
Now del_timer_sync will never return and never release somelock.
The interrupt on the other CPU is waiting to grab somelock but
it has interrupted the softirq that CPU0 is waiting to finish.
The function returns whether it has deactivated a pending timer or not.
schedule_timeout — sleep until timeout
signed long __sched schedule_timeout ( | timeout); |
signed long timeout;
Make the current task sleep until timeout jiffies have
elapsed. The routine will return immediately unless
the current task state has been set (see set_current_state).
You can set the task state as follows -
TASK_UNINTERRUPTIBLE - at least timeout jiffies are guaranteed to
pass before the routine returns. The routine will return 0
TASK_INTERRUPTIBLE - the routine may return early if a signal is
delivered to the current task. In this case the remaining time
in jiffies will be returned, or 0 if the timer expired in time
The current task state is guaranteed to be TASK_RUNNING when this routine returns.
Specifying a timeout value of MAX_SCHEDULE_TIMEOUT will schedule
the CPU away without a bound on the timeout. In this case the return
value will be MAX_SCHEDULE_TIMEOUT.
In all cases the return value is guaranteed to be non-negative.
msleep — sleep safely even with waitqueue interruptions
void msleep ( | msecs); |
unsigned int msecs;wait_event — sleep until a condition gets true
wait_event ( | wq, | |
condition); |
wq; condition;wait_event_timeout — sleep until a condition gets true or a timeout elapses
wait_event_timeout ( | wq, | |
| condition, | ||
timeout); |
wq; condition; timeout;wqthe waitqueue to wait on
conditiona C expression for the event to wait for
timeouttimeout, in jiffies
The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
condition evaluates to true. The condition is checked each time
the waitqueue wq is woken up.
wake_up has to be called after changing any variable that could
change the result of the wait condition.
The function returns 0 if the timeout elapsed, and the remaining
jiffies if the condition evaluated to true before the timeout elapsed.
wait_event_interruptible — sleep until a condition gets true
wait_event_interruptible ( | wq, | |
condition); |
wq; condition;
The process is put to sleep (TASK_INTERRUPTIBLE) until the
condition evaluates to true or a signal is received.
The condition is checked each time the waitqueue wq is woken up.
wake_up has to be called after changing any variable that could
change the result of the wait condition.
The function will return -ERESTARTSYS if it was interrupted by a
signal and 0 if condition evaluated to true.
wait_event_interruptible_timeout — sleep until a condition gets true or a timeout elapses
wait_event_interruptible_timeout ( | wq, | |
| condition, | ||
timeout); |
wq; condition; timeout;wqthe waitqueue to wait on
conditiona C expression for the event to wait for
timeouttimeout, in jiffies
The process is put to sleep (TASK_INTERRUPTIBLE) until the
condition evaluates to true or a signal is received.
The condition is checked each time the waitqueue wq is woken up.
wake_up has to be called after changing any variable that could
change the result of the wait condition.
The function returns 0 if the timeout elapsed, -ERESTARTSYS if it
was interrupted by a signal, and the remaining jiffies otherwise
if the condition evaluated to true before the timeout elapsed.
wait_event_interruptible_locked — sleep until a condition gets true
wait_event_interruptible_locked ( | wq, | |
condition); |
wq; condition;
The process is put to sleep (TASK_INTERRUPTIBLE) until the
condition evaluates to true or a signal is received.
The condition is checked each time the waitqueue wq is woken up.
It must be called with wq.lock being held. This spinlock is
unlocked while sleeping but condition testing is done while lock
is held and when this macro exits the lock is held.
The lock is locked/unlocked using spin_lock/spin_unlock
functions which must match the way they are locked/unlocked outside
of this macro.
wake_up_locked has to be called after changing any variable that could
change the result of the wait condition.
The function will return -ERESTARTSYS if it was interrupted by a
signal and 0 if condition evaluated to true.
wait_event_interruptible_locked_irq — sleep until a condition gets true
wait_event_interruptible_locked_irq ( | wq, | |
condition); |
wq; condition;
The process is put to sleep (TASK_INTERRUPTIBLE) until the
condition evaluates to true or a signal is received.
The condition is checked each time the waitqueue wq is woken up.
It must be called with wq.lock being held. This spinlock is
unlocked while sleeping but condition testing is done while lock
is held and when this macro exits the lock is held.
The lock is locked/unlocked using spin_lock_irq/spin_unlock_irq
functions which must match the way they are locked/unlocked outside
of this macro.
wake_up_locked has to be called after changing any variable that could
change the result of the wait condition.
The function will return -ERESTARTSYS if it was interrupted by a
signal and 0 if condition evaluated to true.
wait_event_interruptible_exclusive_locked — sleep exclusively until a condition gets true
wait_event_interruptible_exclusive_locked ( | wq, | |
condition); |
wq; condition;
The process is put to sleep (TASK_INTERRUPTIBLE) until the
condition evaluates to true or a signal is received.
The condition is checked each time the waitqueue wq is woken up.
It must be called with wq.lock being held. This spinlock is
unlocked while sleeping but condition testing is done while lock
is held and when this macro exits the lock is held.
The lock is locked/unlocked using spin_lock/spin_unlock
functions which must match the way they are locked/unlocked outside
of this macro.
The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag set thus when other process waits process on the list if this process is awaken further processes are not considered.
wake_up_locked has to be called after changing any variable that could
change the result of the wait condition.
The function will return -ERESTARTSYS if it was interrupted by a
signal and 0 if condition evaluated to true.
wait_event_interruptible_exclusive_locked_irq — sleep until a condition gets true
wait_event_interruptible_exclusive_locked_irq ( | wq, | |
condition); |
wq; condition;
The process is put to sleep (TASK_INTERRUPTIBLE) until the
condition evaluates to true or a signal is received.
The condition is checked each time the waitqueue wq is woken up.
It must be called with wq.lock being held. This spinlock is
unlocked while sleeping but condition testing is done while lock
is held and when this macro exits the lock is held.
The lock is locked/unlocked using spin_lock_irq/spin_unlock_irq
functions which must match the way they are locked/unlocked outside
of this macro.
The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag set thus when other process waits process on the list if this process is awaken further processes are not considered.
wake_up_locked has to be called after changing any variable that could
change the result of the wait condition.
The function will return -ERESTARTSYS if it was interrupted by a
signal and 0 if condition evaluated to true.
wait_event_killable — sleep until a condition gets true
wait_event_killable ( | wq, | |
condition); |
wq; condition;
The process is put to sleep (TASK_KILLABLE) until the
condition evaluates to true or a signal is received.
The condition is checked each time the waitqueue wq is woken up.
wake_up has to be called after changing any variable that could
change the result of the wait condition.
The function will return -ERESTARTSYS if it was interrupted by a
signal and 0 if condition evaluated to true.
wait_on_bit — wait for a bit to be cleared
int wait_on_bit ( | word, | |
| bit, | ||
| action, | ||
mode); |
void * word;int bit;int (*action)
(void *);unsigned mode;wordthe word being waited on, a kernel virtual address
bitthe bit of the word being waited on
actionthe function used to sleep, which may take special actions
modethe task state to sleep in
There is a standard hashed waitqueue table for generic use. This
is the part of the hashtable's accessor API that waits on a bit.
For instance, if one were to have waiters on a bitflag, one would
call wait_on_bit in threads waiting for the bit to clear.
One uses wait_on_bit where one is waiting for the bit to clear,
but has no intention of setting it.
wait_on_bit_lock — wait for a bit to be cleared, when wanting to set it
int wait_on_bit_lock ( | word, | |
| bit, | ||
| action, | ||
mode); |
void * word;int bit;int (*action)
(void *);unsigned mode;wordthe word being waited on, a kernel virtual address
bitthe bit of the word being waited on
actionthe function used to sleep, which may take special actions
modethe task state to sleep in
There is a standard hashed waitqueue table for generic use. This
is the part of the hashtable's accessor API that waits on a bit
when one intends to set it, for instance, trying to lock bitflags.
For instance, if one were to have waiters trying to set bitflag
and waiting for it to clear before setting it, one would call
wait_on_bit in threads waiting to be able to set the bit.
One uses wait_on_bit_lock where one is waiting for the bit to
clear with the intention of setting it, and when done, clearing it.
finish_wait — clean up after waiting in a queue
void finish_wait ( | q, | |
wait); |
wait_queue_head_t * q;wait_queue_t * wait;abort_exclusive_wait — abort exclusive waiting in a queue
void abort_exclusive_wait ( | q, | |
| wait, | ||
| mode, | ||
key); |
wait_queue_head_t * q;wait_queue_t * wait;unsigned int mode;void * key;qwaitqueue waited on
waitwait descriptor
moderunstate of the waiter to be woken
key
key to identify a wait bit queue or NULL
Sets current thread back to running state and removes the wait descriptor from the given waitqueue if still queued.
Wakes up the next waiter if the caller is concurrently woken up through the queue.
This prevents waiter starvation where an exclusive waiter aborts and is woken up concurrently and no one wakes up the next waiter.
wake_up_bit — wake up a waiter on a bit
void wake_up_bit ( | word, | |
bit); |
void * word;int bit;wordthe word being waited on, a kernel virtual address
bitthe bit of the word being waited on
There is a standard hashed waitqueue table for generic use. This
is the part of the hashtable's accessor API that wakes up waiters
on a bit. For instance, if one were to have waiters on a bitflag,
one would call wake_up_bit after clearing the bit.
In order for this to function properly, as it uses waitqueue_active
internally, some kind of memory barrier must be done prior to calling
this. Typically, this will be smp_mb__after_clear_bit, but in some
cases where bitflags are manipulated non-atomically under a lock, one
may need to use a less regular barrier, such fs/inode.c's smp_mb,
because spin_unlock does not guarantee a memory barrier.
ktime_set — Set a ktime_t variable from a seconds/nanoseconds value
ktime_t ktime_set ( | secs, | |
nsecs); |
const long secs;const unsigned long nsecs;ktime_sub — subtract two ktime_t variables
ktime_t ktime_sub ( | lhs, | |
rhs); |
const ktime_t lhs;const ktime_t rhs;ktime_add — add two ktime_t variables
ktime_t ktime_add ( | add1, | |
add2); |
const ktime_t add1;const ktime_t add2;timespec_to_ktime — convert a timespec to ktime_t format
ktime_t timespec_to_ktime ( | ts); |
const struct timespec ts;timeval_to_ktime — convert a timeval to ktime_t format
ktime_t timeval_to_ktime ( | tv); |
const struct timeval tv;ktime_to_timespec — convert a ktime_t variable to timespec format
struct timespec ktime_to_timespec ( | kt); |
const ktime_t kt;ktime_to_timeval — convert a ktime_t variable to timeval format
struct timeval ktime_to_timeval ( | kt); |
const ktime_t kt;ktime_to_ns — convert a ktime_t variable to scalar nanoseconds
s64 ktime_to_ns ( | kt); |
const ktime_t kt;ktime_equal — Compares two ktime_t variables to see if they are equal
int ktime_equal ( | cmp1, | |
cmp2); |
const ktime_t cmp1;const ktime_t cmp2;struct hrtimer — the basic hrtimer structure
struct hrtimer {
struct timerqueue_node node;
ktime_t _softexpires;
enum hrtimer_restart (* function) (struct hrtimer *);
struct hrtimer_clock_base * base;
unsigned long state;
#ifdef CONFIG_TIMER_STATS
int start_pid;
void * start_site;
char start_comm[16];
#endif
}; timerqueue node, which also manages node.expires, the absolute expiry time in the hrtimers internal representation. The time is related to the clock on which the timer is based. Is setup by adding slack to the _softexpires value. For non range timers identical to _softexpires.
the absolute earliest expiry time of the hrtimer. The time which was given as expiry time when the timer was armed.
timer expiry callback function
pointer to the timer base (per cpu and per clock)
state information (See bit values above)
timer statistics field to store the pid of the task which started the timer
timer statistics field to store the site where the timer was started
timer statistics field to store the name of the process which started the timer
struct hrtimer_sleeper — simple sleeper structure
struct hrtimer_sleeper {
struct hrtimer timer;
struct task_struct * task;
}; struct hrtimer_clock_base — the timer base for a specific clock
struct hrtimer_clock_base {
struct hrtimer_cpu_base * cpu_base;
int index;
clockid_t clockid;
struct timerqueue_head active;
ktime_t resolution;
ktime_t (* get_time) (void);
ktime_t softirq_time;
ktime_t offset;
}; per cpu clock base
clock type index for per_cpu support when moving a timer to a base on another cpu.
clock id for per_cpu support
red black tree root node for the active timers
the resolution of the clock, in nanoseconds
function to retrieve the current time of the clock
the time when running the hrtimer queue in the softirq
offset of this clock to the monotonic base
ktime_add_ns — Add a scalar nanoseconds value to a ktime_t variable
ktime_t ktime_add_ns ( | kt, | |
nsec); |
const ktime_t kt;u64 nsec;ktime_sub_ns — Subtract a scalar nanoseconds value from a ktime_t variable
ktime_t ktime_sub_ns ( | kt, | |
nsec); |
const ktime_t kt;u64 nsec;hrtimer_forward — forward the timer expiry
u64 hrtimer_forward ( | timer, | |
| now, | ||
interval); |
struct hrtimer * timer;ktime_t now;ktime_t interval;hrtimer_start_range_ns — (re)start an hrtimer on the current CPU
int hrtimer_start_range_ns ( | timer, | |
| tim, | ||
| delta_ns, | ||
mode); |
struct hrtimer * timer;ktime_t tim;unsigned long delta_ns;const enum hrtimer_mode mode;hrtimer_start — (re)start an hrtimer on the current CPU
int hrtimer_start ( | timer, | |
| tim, | ||
mode); |
struct hrtimer * timer;ktime_t tim;const enum hrtimer_mode mode;hrtimer_try_to_cancel — try to deactivate a timer
int hrtimer_try_to_cancel ( | timer); |
struct hrtimer * timer;hrtimer_cancel — cancel a timer and wait for the handler to finish.
int hrtimer_cancel ( | timer); |
struct hrtimer * timer;hrtimer_get_remaining — get remaining time for the timer
ktime_t hrtimer_get_remaining ( | timer); |
const struct hrtimer * timer;hrtimer_init — initialize a timer to the given clock
void hrtimer_init ( | timer, | |
| clock_id, | ||
mode); |
struct hrtimer * timer;clockid_t clock_id;enum hrtimer_mode mode;hrtimer_get_res — get the timer resolution for a clock
int hrtimer_get_res ( | which_clock, | |
tp); |
const clockid_t which_clock;struct timespec * tp;schedule_hrtimeout_range — sleep until timeout
int __sched schedule_hrtimeout_range ( | expires, | |
| delta, | ||
mode); |
ktime_t * expires;unsigned long delta;const enum hrtimer_mode mode;expirestimeout value (ktime_t)
deltaslack in expires timeout (ktime_t)
modetimer mode, HRTIMER_MODE_ABS or HRTIMER_MODE_REL
Make the current task sleep until the given expiry time has
elapsed. The routine will return immediately unless
the current task state has been set (see set_current_state).
The delta argument gives the kernel the freedom to schedule the
actual wakeup to a time that is both power and performance friendly.
The kernel give the normal best effort behavior for “expires+delta”,
but may decide to fire the timer earlier, but no earlier than expires.
You can set the task state as follows -
TASK_UNINTERRUPTIBLE - at least timeout time is guaranteed to
pass before the routine returns.
TASK_INTERRUPTIBLE - the routine may return early if a signal is
delivered to the current task.
The current task state is guaranteed to be TASK_RUNNING when this routine returns.
Returns 0 when the timer has expired otherwise -EINTR
schedule_hrtimeout — sleep until timeout
int __sched schedule_hrtimeout ( | expires, | |
mode); |
ktime_t * expires;const enum hrtimer_mode mode;
Make the current task sleep until the given expiry time has
elapsed. The routine will return immediately unless
the current task state has been set (see set_current_state).
You can set the task state as follows -
TASK_UNINTERRUPTIBLE - at least timeout time is guaranteed to
pass before the routine returns.
TASK_INTERRUPTIBLE - the routine may return early if a signal is
delivered to the current task.
The current task state is guaranteed to be TASK_RUNNING when this routine returns.
Returns 0 when the timer has expired otherwise -EINTR
queue_work — queue work on a workqueue
int queue_work ( | wq, | |
work); |
struct workqueue_struct * wq;struct work_struct * work;queue_work_on — queue work on specific cpu
int queue_work_on ( | cpu, | |
| wq, | ||
work); |
int cpu;struct workqueue_struct * wq;struct work_struct * work;queue_delayed_work — queue work on a workqueue after delay
int queue_delayed_work ( | wq, | |
| dwork, | ||
delay); |
struct workqueue_struct * wq;struct delayed_work * dwork;unsigned long delay;queue_delayed_work_on — queue work on specific CPU after delay
int queue_delayed_work_on ( | cpu, | |
| wq, | ||
| dwork, | ||
delay); |
int cpu;struct workqueue_struct * wq;struct delayed_work * dwork;unsigned long delay;flush_workqueue — ensure that any scheduled work has run to completion.
void flush_workqueue ( | wq); |
struct workqueue_struct * wq;flush_work — wait for a work to finish executing the last queueing instance
bool flush_work ( | work); |
struct work_struct * work;
Wait until work has finished execution. This function considers
only the last queueing instance of work. If work has been
enqueued across different CPUs on a non-reentrant workqueue or on
multiple workqueues, work might still be executing on return on
some of the CPUs from earlier queueing.
If work was queued only on a non-reentrant, ordered or unbound
workqueue, work is guaranteed to be idle on return if it hasn't
been requeued since flush started.
flush_work_sync — wait until a work has finished execution
bool flush_work_sync ( | work); |
struct work_struct * work;cancel_work_sync — cancel a work and wait for it to finish
bool cancel_work_sync ( | work); |
struct work_struct * work;
Cancel work and wait for its execution to finish. This function
can be used even if the work re-queues itself or migrates to
another workqueue. On return from this function, work is
guaranteed to be not pending or executing on any CPU.
cancel_work_sync(delayed_work->work) must not be used for
delayed_work's. Use cancel_delayed_work_sync instead.
The caller must ensure that the workqueue on which work was last
queued can't be destroyed before this function returns.
flush_delayed_work — wait for a dwork to finish executing the last queueing
bool flush_delayed_work ( | dwork); |
struct delayed_work * dwork;flush_delayed_work_sync — wait for a dwork to finish
bool flush_delayed_work_sync ( | dwork); |
struct delayed_work * dwork;cancel_delayed_work_sync — cancel a delayed work and wait for it to finish
bool cancel_delayed_work_sync ( | dwork); |
struct delayed_work * dwork;schedule_work — put work task in global workqueue
int schedule_work ( | work); |
struct work_struct * work;schedule_delayed_work — put work task in global workqueue after delay
int schedule_delayed_work ( | dwork, | |
delay); |
struct delayed_work * dwork;unsigned long delay;schedule_delayed_work_on — queue work in global workqueue on CPU after delay
int schedule_delayed_work_on ( | cpu, | |
| dwork, | ||
delay); |
int cpu;struct delayed_work * dwork;unsigned long delay;flush_scheduled_work — ensure that any scheduled work has run to completion.
void flush_scheduled_work ( | void); |
void;
Forces execution of the kernel-global workqueue and blocks until its completion.
Think twice before calling this function! It's very easy to get into trouble if you don't take great care. Either of the following situations
One of the work items currently on the workqueue needs to acquire a lock held by your code or its caller.
Your code is running in the context of a work routine.
They will be detected by lockdep when they occur, but the first might not occur very often. It depends on what work items are on the workqueue and what locks they need, which you have no control over.
In most situations flushing the entire workqueue is overkill; you merely
need to know that a particular work item isn't queued and isn't running.
In such cases you should use cancel_delayed_work_sync or
cancel_work_sync instead.
execute_in_process_context — reliably execute the routine with user context
int execute_in_process_context ( | fn, | |
ew); |
work_func_t fn;struct execute_work * ew;fnthe function to execute
ewguaranteed storage for the execute work structure (must be available when the work executes)
destroy_workqueue — safely terminate a workqueue
void destroy_workqueue ( | wq); |
struct workqueue_struct * wq;workqueue_set_max_active — adjust max_active of a workqueue
void workqueue_set_max_active ( | wq, | |
max_active); |
struct workqueue_struct * wq;int max_active;workqueue_congested — test whether a workqueue is congested
bool workqueue_congested ( | cpu, | |
wq); |
unsigned int cpu;struct workqueue_struct * wq;work_cpu —
return the last known associated cpu for work
unsigned int work_cpu ( | work); |
struct work_struct * work;work_busy — test whether a work is currently pending or running
unsigned int work_busy ( | work); |
struct work_struct * work;reparent_to_kthreadd — Reparent the calling kernel thread to kthreadd
void reparent_to_kthreadd ( | void); |
void;
If a kernel thread is launched as a result of a system call, or if it ever exits, it should generally reparent itself to kthreadd so it isn't in the way of other processes and is correctly cleaned up on exit.
The various task state such as scheduling policy and priority may have been inherited from a user process, so we reset them to sane values here.
NOTE that reparent_to_kthreadd gives the caller full capabilities.
wait_task_stopped —
Wait for TASK_STOPPED or TASK_TRACED
int wait_task_stopped ( | wo, | |
| ptrace, | ||
p); |
struct wait_opts * wo;int ptrace;struct task_struct * p;task_clear_group_stop_trapping — clear group stop trapping bit
void task_clear_group_stop_trapping ( | task); |
struct task_struct * task;task_clear_group_stop_pending — clear pending group stop
void task_clear_group_stop_pending ( | task); |
struct task_struct * task;task_participate_group_stop — participate in a group stop
bool task_participate_group_stop ( | task); |
struct task_struct * task;do_notify_parent_cldstop — notify parent of stopped/continued state change
void do_notify_parent_cldstop ( | tsk, | |
| for_ptracer, | ||
why); |
struct task_struct * tsk;bool for_ptracer;int why;tsktask reporting the state change
for_ptracerthe notification is for ptracer
whyCLD_{CONTINUED|STOPPED|TRAPPED} to report
set_current_blocked — change current->blocked mask
void set_current_blocked ( | newset); |
const sigset_t * newset;sys_rt_sigprocmask — change the list of currently blocked signals
long sys_rt_sigprocmask ( | how, | |
| nset, | ||
| oset, | ||
sigsetsize); |
int how;sigset_t __user * nset;sigset_t __user * oset;size_t sigsetsize;sys_rt_sigpending — examine a pending signal that has been raised while blocked
long sys_rt_sigpending ( | set, | |
sigsetsize); |
sigset_t __user * set;size_t sigsetsize;do_sigtimedwait —
wait for queued signals specified in which
int do_sigtimedwait ( | which, | |
| info, | ||
ts); |
const sigset_t * which;siginfo_t * info;const struct timespec * ts;sys_rt_sigtimedwait —
synchronously wait for queued signals specified in uthese
long sys_rt_sigtimedwait ( | uthese, | |
| uinfo, | ||
| uts, | ||
sigsetsize); |
const sigset_t __user * uthese;siginfo_t __user * uinfo;const struct timespec __user * uts;size_t sigsetsize;sys_tgkill — send signal to one specific thread
long sys_tgkill ( | tgid, | |
| pid, | ||
sig); |
pid_t tgid;pid_t pid;int sig;sys_tkill — send signal to one specific task
long sys_tkill ( | pid, | |
sig); |
pid_t pid;int sig;sys_rt_sigqueueinfo — send signal information to a signal
long sys_rt_sigqueueinfo ( | pid, | |
| sig, | ||
uinfo); |
pid_t pid;int sig;siginfo_t __user * uinfo;sys_sigpending — examine pending signals
long sys_sigpending ( | set); |
old_sigset_t __user * set;sys_sigprocmask — examine and change blocked signals
long sys_sigprocmask ( | how, | |
| nset, | ||
oset); |
int how;old_sigset_t __user * nset;old_sigset_t __user * oset;sys_rt_sigaction — alter an action taken by a process
long sys_rt_sigaction ( | sig, | |
| act, | ||
| oact, | ||
sigsetsize); |
int sig;const struct sigaction __user * act;struct sigaction __user * oact;size_t sigsetsize;sys_rt_sigsuspend —
replace the signal mask for a value with the unewset value until a signal is received
long sys_rt_sigsuspend ( | unewset, | |
sigsetsize); |
sigset_t __user * unewset;size_t sigsetsize;kthread_run — create and wake a thread.
kthread_run ( | threadfn, | |
| data, | ||
| namefmt, | ||
...); |
threadfn; data; namefmt; ...;kthread_should_stop — should this kthread return now?
int kthread_should_stop ( | void); |
void;kthread_create_on_node — create a kthread.
struct task_struct * kthread_create_on_node ( | threadfn, | |
| data, | ||
| node, | ||
| namefmt[], | ||
...); |
int (*threadfn)
(void *data);void * data;int node;const char namefmt[]; ...;threadfnthe function to run until signal_pending(current).
data
data ptr for threadfn.
nodememory node number.
namefmt[]printf-style name for the thread.
...variable arguments
This helper function creates and names a kernel
thread. The thread will be stopped: use wake_up_process to start
it. See also kthread_run.
If thread is going to be bound on a particular cpu, give its node
in node, to get NUMA affinity for kthread stack, or else give -1.
When woken, the thread will run threadfn() with data as its
argument. threadfn() can either call do_exit directly if it is a
standalone thread for which no one will call kthread_stop, or
return when 'kthread_should_stop' is true (which means
kthread_stop has been called). The return value should be zero
or a negative error number; it will be passed to kthread_stop.
Returns a task_struct or ERR_PTR(-ENOMEM).
kthread_bind — bind a just-created kthread to a cpu.
void kthread_bind ( | p, | |
cpu); |
struct task_struct * p;unsigned int cpu;kthread_stop —
stop a thread created by kthread_create.
int kthread_stop ( | k); |
struct task_struct * k;
Sets kthread_should_stop for k to return true, wakes it, and
waits for it to exit. This can also be called after kthread_create
instead of calling wake_up_process: the thread will exit without
calling threadfn.
If threadfn may call do_exit itself, the caller must ensure
task_struct can't go away.
Returns the result of threadfn, or -EINTR if wake_up_process
was never called.
kthread_worker_fn — kthread function to process kthread_worker
int kthread_worker_fn ( | worker_ptr); |
void * worker_ptr;
This function can be used as threadfn to kthread_create or
kthread_run with worker_ptr argument pointing to an initialized
kthread_worker. The started kthread will process work_list until
the it is stopped with kthread_stop. A kthread can also call
this function directly after extra initialization.
Different kthreads can be used for the same kthread_worker as long as there's only one kthread attached to it at any given time. A kthread_worker without an attached kthread simply collects queued kthread_works.
queue_kthread_work — queue a kthread_work
bool queue_kthread_work ( | worker, | |
work); |
struct kthread_worker * worker;struct kthread_work * work;kobject_get_path — generate and return the path associated with a given kobj and kset pair.
char * kobject_get_path ( | kobj, | |
gfp_mask); |
struct kobject * kobj;gfp_t gfp_mask;kobject_set_name — Set the name of a kobject
int kobject_set_name ( | kobj, | |
| fmt, | ||
...); |
struct kobject * kobj;const char * fmt; ...;kobject_init — initialize a kobject structure
void kobject_init ( | kobj, | |
ktype); |
struct kobject * kobj;struct kobj_type * ktype;kobject_add — the main kobject add function
int kobject_add ( | kobj, | |
| parent, | ||
| fmt, | ||
...); |
struct kobject * kobj;struct kobject * parent;const char * fmt; ...;kobjthe kobject to add
parentpointer to the parent of the kobject.
fmtformat to name the kobject with.
...variable arguments
The kobject name is set and added to the kobject hierarchy in this function.
If parent is set, then the parent of the kobj will be set to it.
If parent is NULL, then the parent of the kobj will be set to the
kobject associted with the kset assigned to this kobject. If no kset
is assigned to the kobject, then the kobject will be located in the
root of the sysfs tree.
If this function returns an error, kobject_put must be called to
properly clean up the memory associated with the object.
Under no instance should the kobject that is passed to this function
be directly freed with a call to kfree, that can leak memory.
Note, no “add” uevent will be created with this call, the caller should set
up all of the necessary sysfs files for the object and then call
kobject_uevent with the UEVENT_ADD parameter to ensure that
userspace is properly notified of this kobject's creation.
kobject_init_and_add — initialize a kobject structure and add it to the kobject hierarchy
int kobject_init_and_add ( | kobj, | |
| ktype, | ||
| parent, | ||
| fmt, | ||
...); |
struct kobject * kobj;struct kobj_type * ktype;struct kobject * parent;const char * fmt; ...;kobject_rename — change the name of an object
int kobject_rename ( | kobj, | |
new_name); |
struct kobject * kobj;const char * new_name;kobject_del — unlink kobject from hierarchy.
void kobject_del ( | kobj); |
struct kobject * kobj;kobject_get — increment refcount for object.
struct kobject * kobject_get ( | kobj); |
struct kobject * kobj;kobject_put — decrement refcount for object.
void kobject_put ( | kobj); |
struct kobject * kobj;kobject_create_and_add — create a struct kobject dynamically and register it with sysfs
struct kobject * kobject_create_and_add ( | name, | |
parent); |
const char * name;struct kobject * parent;kset_create_and_add — create a struct kset dynamically and add it to sysfs
struct kset * kset_create_and_add ( | name, | |
| uevent_ops, | ||
parent_kobj); |
const char * name;const struct kset_uevent_ops * uevent_ops;struct kobject * parent_kobj;trace_printk — printf formatting in the ftrace buffer
trace_printk ( | fmt, | |
args...); |
fmt; args...;
__trace_printk is an internal function for trace_printk and
the ip is passed in via the trace_printk macro.
This function allows a kernel developer to debug fast path sections that printk is not appropriate for. By scattering in various printk like tracing in the code, a developer can quickly see where problems are occurring.
This is intended as a debugging tool for the developer only. Please refrain from leaving trace_printks scattered around in your code.
min_not_zero — return the minimum that is _not_ zero, unless both are zero
min_not_zero ( | x, | |
y); |
x; y;clamp — return a value clamped to a given range with strict typechecking
clamp ( | val, | |
| min, | ||
max); |
val; min; max;clamp_t — return a value clamped to a given range using a given type
clamp_t ( | type, | |
| val, | ||
| min, | ||
max); |
type; val; min; max;clamp_val — return a value clamped to a given range using val's type
clamp_val ( | val, | |
| min, | ||
max); |
val; min; max;container_of — cast a member of a structure out to the containing structure
container_of ( | ptr, | |
| type, | ||
member); |
ptr; type; member;BUILD_BUG_ON — break compile if a condition is true.
BUILD_BUG_ON ( | condition); |
condition;If you have some code which relies on certain constants being equal, or other compile-time-evaluated condition, you should use BUILD_BUG_ON to detect if someone changes it.
The implementation uses gcc's reluctance to create a negative array, but gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments to inline functions). So as a fallback we use the optimizer; if it can't prove the condition is false, it will cause a link error on the undefined “__build_bug_on_failed”. This error message can be harder to track down though, hence the two different methods.
printk — print a kernel message
int printk ( | fmt, | |
...); |
const char * fmt; ...;
This is printk. It can be called from any context. We want it to work.
We try to grab the console_lock. If we succeed, it's easy - we log the output and
call the console drivers. If we fail to get the semaphore we place the output
into the log buffer and return. The current holder of the console_sem will
notice the new output in console_unlock; and will send it to the
consoles before releasing the lock.
One effect of this deferred printing is that code which calls printk and
then changes console_loglevel may break. This is because console_loglevel
is inspected when the actual printing occurs.
console_lock — lock the console system for exclusive use.
void console_lock ( | void); |
void;console_trylock — try to lock the console system for exclusive use.
int console_trylock ( | void); |
void;console_unlock — unlock the console system
void console_unlock ( | void); |
void;
Releases the console_lock which the caller holds on the console system and the console driver list.
While the console_lock was held, console output may have been buffered
by printk. If this is the case, console_unlock; emits
the output prior to releasing the lock.
If there is output waiting for klogd, we wake it up.
console_unlock; may be called from any context.
console_conditional_schedule — yield the CPU if required
void __sched console_conditional_schedule ( | void); |
void;printk_timed_ratelimit — caller-controlled printk ratelimiting
bool printk_timed_ratelimit ( | caller_jiffies, | |
interval_msecs); |
unsigned long * caller_jiffies;unsigned int interval_msecs;kmsg_dump_register — register a kernel log dumper.
int kmsg_dump_register ( | dumper); |
struct kmsg_dumper * dumper;kmsg_dump_unregister — unregister a kmsg dumper.
int kmsg_dump_unregister ( | dumper); |
struct kmsg_dumper * dumper;orderly_poweroff — Trigger an orderly system poweroff
int orderly_poweroff ( | force); |
bool force;rcu_read_lock_bh_held — might we be in RCU-bh read-side critical section?
int rcu_read_lock_bh_held ( | void); |
void;
Check for bottom half being disabled, which covers both the
CONFIG_PROVE_RCU and not cases. Note that if someone uses
rcu_read_lock_bh, but then later enables BH, lockdep (if enabled)
will show the situation. This is useful for debug checks in functions
that require that they be called within an RCU read-side critical
section.
Check debug_lockdep_rcu_enabled to prevent false positives during boot.
init_rcu_head_on_stack — initialize on-stack rcu_head for debugobjects
void init_rcu_head_on_stack ( | head); |
struct rcu_head * head;This function informs debugobjects of a new rcu_head structure that has been allocated as an auto variable on the stack. This function is not required for rcu_head structures that are statically defined or that are dynamically allocated on the heap. This function has no effect for !CONFIG_DEBUG_OBJECTS_RCU_HEAD kernel builds.
destroy_rcu_head_on_stack — destroy on-stack rcu_head for debugobjects
void destroy_rcu_head_on_stack ( | head); |
struct rcu_head * head;
This function informs debugobjects that an on-stack rcu_head structure
is about to go out of scope. As with init_rcu_head_on_stack, this
function is not required for rcu_head structures that are statically
defined or that are dynamically allocated on the heap. Also as with
init_rcu_head_on_stack, this function has no effect for
!CONFIG_DEBUG_OBJECTS_RCU_HEAD kernel builds.
devres_alloc — Allocate device resource data
void * devres_alloc ( | release, | |
| size, | ||
gfp); |
dr_release_t release;size_t size;gfp_t gfp;releaseRelease function devres will be associated with
sizeAllocation size
gfpAllocation flags
devres_add — Register device resource
void devres_add ( | dev, | |
res); |
struct device * dev;void * res;devres_find — Find device resource
void * devres_find ( | dev, | |
| release, | ||
| match, | ||
match_data); |
struct device * dev;dr_release_t release;dr_match_t match;void * match_data;devDevice to lookup resource from
releaseLook for resources associated with this release function
matchMatch function (optional)
match_dataData for the match function
devres_get — Find devres, if non-existent, add one atomically
void * devres_get ( | dev, | |
| new_res, | ||
| match, | ||
match_data); |
struct device * dev;void * new_res;dr_match_t match;void * match_data;devDevice to lookup or add devres for
new_resPointer to new initialized devres to add if not found
matchMatch function (optional)
match_dataData for the match function
devres_remove — Find a device resource and remove it
void * devres_remove ( | dev, | |
| release, | ||
| match, | ||
match_data); |
struct device * dev;dr_release_t release;dr_match_t match;void * match_data;devDevice to find resource from
releaseLook for resources associated with this release function
matchMatch function (optional)
match_dataData for the match function
devres_destroy — Find a device resource and destroy it
int devres_destroy ( | dev, | |
| release, | ||
| match, | ||
match_data); |
struct device * dev;dr_release_t release;dr_match_t match;void * match_data;devDevice to find resource from
releaseLook for resources associated with this release function
matchMatch function (optional)
match_dataData for the match function
devres_open_group — Open a new devres group
void * devres_open_group ( | dev, | |
| id, | ||
gfp); |
struct device * dev;void * id;gfp_t gfp;devres_close_group — Close a devres group
void devres_close_group ( | dev, | |
id); |
struct device * dev;void * id;devres_remove_group — Remove a devres group
void devres_remove_group ( | dev, | |
id); |
struct device * dev;void * id;devres_release_group — Release resources in a devres group
int devres_release_group ( | dev, | |
id); |
struct device * dev;void * id;devm_kzalloc — Resource-managed kzalloc
void * devm_kzalloc ( | dev, | |
| size, | ||
gfp); |
struct device * dev;size_t size;gfp_t gfp;Table of Contents
struct bus_type — The bus type of the device
struct bus_type {
const char * name;
struct bus_attribute * bus_attrs;
struct device_attribute * dev_attrs;
struct driver_attribute * drv_attrs;
int (* match) (struct device *dev, struct device_driver *drv);
int (* uevent) (struct device *dev, struct kobj_uevent_env *env);
int (* probe) (struct device *dev);
int (* remove) (struct device *dev);
void (* shutdown) (struct device *dev);
int (* suspend) (struct device *dev, pm_message_t state);
int (* resume) (struct device *dev);
const struct dev_pm_ops * pm;
struct subsys_private * p;
}; The name of the bus.
Default attributes of the bus.
Default attributes of the devices on the bus.
Default attributes of the device drivers on the bus.
Called, perhaps multiple times, whenever a new device or driver is added for this bus. It should return a nonzero value if the given device can be handled by the given driver.
Called when a device is added, removed, or a few other things that generate uevents to add the environment variables.
Called when a new device or driver add to this bus, and callback the specific driver's probe to initial the matched device.
Called when a device removed from this bus.
Called at shut-down time to quiesce the device.
Called when a device on this bus wants to go to sleep mode.
Called to bring a device on this bus out of sleep mode.
Power management operations of this bus, callback the specific device driver's pm-ops.
The private data of the driver core, only the driver core can touch this.
A bus is a channel between the processor and one or more devices. For the purposes of the device model, all devices are connected via a bus, even if it is an internal, virtual, “platform” bus. Buses can plug into each other. A USB controller is usually a PCI device, for example. The device model represents the actual connections between buses and the devices they control. A bus is represented by the bus_type structure. It contains the name, the default attributes, the bus' methods, PM operations, and the driver core's private data.
struct device_driver — The basic device driver structure
struct device_driver {
const char * name;
struct bus_type * bus;
struct module * owner;
const char * mod_name;
bool suppress_bind_attrs;
const struct of_device_id * of_match_table;
int (* probe) (struct device *dev);
int (* remove) (struct device *dev);
void (* shutdown) (struct device *dev);
int (* suspend) (struct device *dev, pm_message_t state);
int (* resume) (struct device *dev);
const struct attribute_group ** groups;
const struct dev_pm_ops * pm;
struct driver_private * p;
}; Name of the device driver.
The bus which the device of this driver belongs to.
The module owner.
Used for built-in modules.
Disables bind/unbind via sysfs.
The open firmware table.
Called to query the existence of a specific device, whether this driver can work with it, and bind the driver to a specific device.
Called when the device is removed from the system to unbind a device from this driver.
Called at shut-down time to quiesce the device.
Called to put the device to sleep mode. Usually to a low power state.
Called to bring a device from sleep mode.
Default attributes that get created by the driver core automatically.
Power management operations of the device which matched this driver.
Driver core's private data, no one other than the driver core can touch this.
The device driver-model tracks all of the drivers known to the system. The main reason for this tracking is to enable the driver core to match up drivers with new devices. Once drivers are known objects within the system, however, a number of other things become possible. Device drivers can export information and configuration variables that are independent of any specific device.
struct class — device classes
struct class {
const char * name;
struct module * owner;
struct class_attribute * class_attrs;
struct device_attribute * dev_attrs;
struct bin_attribute * dev_bin_attrs;
struct kobject * dev_kobj;
int (* dev_uevent) (struct device *dev, struct kobj_uevent_env *env);
char *(* devnode) (struct device *dev, mode_t *mode);
void (* class_release) (struct class *class);
void (* dev_release) (struct device *dev);
int (* suspend) (struct device *dev, pm_message_t state);
int (* resume) (struct device *dev);
const struct kobj_ns_type_operations * ns_type;
const void *(* namespace) (struct device *dev);
const struct dev_pm_ops * pm;
struct subsys_private * p;
}; Name of the class.
The module owner.
Default attributes of this class.
Default attributes of the devices belong to the class.
Default binary attributes of the devices belong to the class.
The kobject that represents this class and links it into the hierarchy.
Called when a device is added, removed from this class, or a few other things that generate uevents to add the environment variables.
Callback to provide the devtmpfs.
Called to release this class.
Called to release the device.
Used to put the device to sleep mode, usually to a low power state.
Used to bring the device from the sleep mode.
Callbacks so sysfs can detemine namespaces.
Namespace of the device belongs to this class.
The default device power management operations of this class.
The private data of the driver core, no one other than the driver core can touch this.
A class is a higher-level view of a device that abstracts out low-level implementation details. Drivers may see a SCSI disk or an ATA disk, but, at the class level, they are all simply disks. Classes allow user space to work with devices based on what they do, rather than how they are connected or how they work.
struct device — The basic device structure
struct device {
struct device * parent;
struct device_private * p;
struct kobject kobj;
const char * init_name;
const struct device_type * type;
struct mutex mutex;
struct bus_type * bus;
struct device_driver * driver;
void * platform_data;
struct dev_pm_info power;
struct dev_power_domain * pwr_domain;
#ifdef CONFIG_NUMA
int numa_node;
#endif
u64 * dma_mask;
u64 coherent_dma_mask;
struct device_dma_parameters * dma_parms;
struct list_head dma_pools;
struct dma_coherent_mem * dma_mem;
struct dev_archdata archdata;
struct device_node * of_node;
dev_t devt;
spinlock_t devres_lock;
struct list_head devres_head;
struct klist_node knode_class;
struct class * class;
const struct attribute_group ** groups;
void (* release) (struct device *dev);
}; The device's “parent” device, the device to which it is attached. In most cases, a parent device is some sort of bus or host controller. If parent is NULL, the device, is a top-level device, which is not usually what you want.
Holds the private data of the driver core portions of the device. See the comment of the struct device_private for detail.
A top-level, abstract class from which other classes are derived.
Initial name of the device.
The type of device. This identifies the device type and carries type-specific information.
Mutex to synchronize calls to its driver.
Type of bus device is on.
Which driver has allocated this
Platform data specific to the device.
For device power management. See Documentation/power/devices.txt for details.
Provide callbacks that are executed during system suspend, hibernation, system resume and during runtime PM transitions along with subsystem-level and driver-level callbacks.
NUMA node this device is close to.
Dma mask (if dma'ble device).
Like dma_mask, but for alloc_coherent mapping as not all hardware supports 64-bit addresses for consistent allocations such descriptors.
A low level driver may set these to teach IOMMU code about segment limitations.
Dma pools (if dma'ble device).
Internal for coherent mem override.
For arch-specific additions.
Associated device tree node.
For creating the sysfs “dev”.
Spinlock to protect the resource of the device.
The resources list of the device.
The node used to add the device to the class list.
The class of the device.
Optional attribute groups.
Callback to free the device after all references have gone away. This should be set by the allocator of the device (i.e. the bus driver that discovered the device).
For devices on custom boards, as typical of embedded
and SOC based hardware, Linux often uses platform_data to point
to board-specific structures describing devices and how they
are wired. That can include what ports are available, chip
variants, which GPIO pins act in what additional roles, and so
on. This shrinks the “Board Support Packages” (BSPs) and
minimizes board-specific #ifdefs in drivers.
At the lowest level, every device in a Linux system is represented by an instance of struct device. The device structure contains the information that the device model core needs to model the system. Most subsystems, however, track additional information about the devices they host. As a result, it is rare for devices to be represented by bare device structures; instead, that structure, like kobject structures, is usually embedded within a higher-level representation of the device.
driver_for_each_device — Iterator for devices bound to a driver.
int driver_for_each_device ( | drv, | |
| start, | ||
| data, | ||
fn); |
struct device_driver * drv;struct device * start;void * data;int (*fn)
(struct device *, void *);driver_find_device — device iterator for locating a particular device.
struct device * driver_find_device ( | drv, | |
| start, | ||
| data, | ||
match); |
struct device_driver * drv;struct device * start;void * data;int (*match)
(struct device *dev, void *data);drvThe device's driver
startDevice to begin with
dataData to pass to match function
matchCallback 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 match 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.
driver_create_file — create sysfs file for driver.
int driver_create_file ( | drv, | |
attr); |
struct device_driver * drv;const struct driver_attribute * attr;driver_remove_file — remove sysfs file for driver.
void driver_remove_file ( | drv, | |
attr); |
struct device_driver * drv;const struct driver_attribute * attr;driver_add_kobj — add a kobject below the specified driver
int driver_add_kobj ( | drv, | |
| kobj, | ||
| fmt, | ||
...); |
struct device_driver * drv;struct kobject * kobj;const char * fmt; ...;get_driver — increment driver reference count.
struct device_driver * get_driver ( | drv); |
struct device_driver * drv;put_driver — decrement driver's refcount.
void put_driver ( | drv); |
struct device_driver * drv;driver_register — register driver with bus
int driver_register ( | drv); |
struct device_driver * drv;driver_unregister — remove driver from system.
void driver_unregister ( | drv); |
struct device_driver * drv;driver_find — locate driver on a bus by its name.
struct device_driver * driver_find ( | name, | |
bus); |
const char * name;struct bus_type * bus;dev_driver_string — Return a device's driver name, if at all possible
const char * dev_driver_string ( | dev); |
const struct device * dev;device_create_file — create sysfs attribute file for device.
int device_create_file ( | dev, | |
attr); |
struct device * dev;const struct device_attribute * attr;device_remove_file — remove sysfs attribute file.
void device_remove_file ( | dev, | |
attr); |
struct device * dev;const struct device_attribute * attr;device_create_bin_file — create sysfs binary attribute file for device.
int device_create_bin_file ( | dev, | |
attr); |
struct device * dev;const struct bin_attribute * attr;device_remove_bin_file — remove sysfs binary attribute file
void device_remove_bin_file ( | dev, | |
attr); |
struct device * dev;const struct bin_attribute * attr;device_schedule_callback_owner — helper to schedule a callback for a device
int device_schedule_callback_owner ( | dev, | |
| func, | ||
owner); |
struct device * dev;void (*func)
(struct device *);struct module * owner;devdevice.
funccallback function to invoke later.
ownermodule owning the callback routine
Attribute methods must not unregister themselves or their parent device (which would amount to the same thing). Attempts to do so will deadlock, since unregistration is mutually exclusive with driver callbacks.
Instead methods can call this routine, which will attempt to allocate
and schedule a workqueue request to call back func with dev as its
argument in the workqueue's process context. dev will be pinned until
func returns.
This routine is usually called via the inline device_schedule_callback,
which automatically sets owner to THIS_MODULE.
Returns 0 if the request was submitted, -ENOMEM if storage could not
be allocated, -ENODEV if a reference to owner isn't available.
device_initialize — init device structure.
void device_initialize ( | dev); |
struct device * dev;
This prepares the device for use by other layers by initializing
its fields.
It is the first half of device_register, if called by
that function, though it can also be called separately, so one
may use dev's fields. In particular, get_device/put_device
may be used for reference counting of dev after calling this
function.
dev_set_name — set a device name
int dev_set_name ( | dev, | |
| fmt, | ||
...); |
struct device * dev;const char * fmt; ...;device_add — add device to device hierarchy.
int device_add ( | dev); |
struct device * dev;
This is part 2 of device_register, though may be called
separately _iff_ device_initialize has been called separately.
This adds dev to the kobject hierarchy via kobject_add, adds it
to the global and sibling lists for the device, then
adds it to the other relevant subsystems of the driver model.
device_register — register a device with the system.
int device_register ( | dev); |
struct device * dev;This happens in two clean steps - initialize the device and add it to the system. The two steps can be called separately, but this is the easiest and most common. I.e. you should only call the two helpers separately if have a clearly defined need to use and refcount the device before it is added to the hierarchy.
get_device — increment reference count for device.
struct device * get_device ( | dev); |
struct device * dev;device_del — delete device from system.
void device_del ( | dev); |
struct device * dev;device_unregister — unregister device from system.
void device_unregister ( | dev); |
struct device * dev;
We do this in two parts, like we do device_register. First,
we remove it from all the subsystems with device_del, then
we decrement the reference count via put_device. If that
is the final reference count, the device will be cleaned up
via device_release above. Otherwise, the structure will
stick around until the final reference to the device is dropped.
device_for_each_child — device child iterator.
int device_for_each_child ( | parent, | |
| data, | ||
fn); |
struct device * parent;void * data;int (*fn)
(struct device *dev, void *data);device_find_child — device iterator for locating a particular device.
struct device * device_find_child ( | parent, | |
| data, | ||
match); |
struct device * parent;void * data;int (*match)
(struct device *dev, void *data);parentparent struct device
dataData to pass to match function
matchCallback function to check device
This is similar to the device_for_each_child function above, but it
returns a reference to a device that is 'found' for later use, as
determined by the match callback.
The callback should return 0 if the device doesn't match and non-zero if it does. If the callback returns non-zero and a reference to the current device can be obtained, this function will return to the caller and not iterate over any more devices.
__root_device_register — allocate and register a root device
struct device * __root_device_register ( | name, | |
owner); |
const char * name;struct module * owner;
This function allocates a root device and registers it
using device_register. In order to free the returned
device, use root_device_unregister.
Root devices are dummy devices which allow other devices to be grouped under /sys/devices. Use this function to allocate a root device and then use it as the parent of any device which should appear under /sys/devices/{name}
The /sys/devices/{name} directory will also contain a
'module' symlink which points to the owner directory
in sysfs.
Returns struct device pointer on success, or ERR_PTR on error.
root_device_unregister — unregister and free a root device
void root_device_unregister ( | dev); |
struct device * dev;device_create_vargs — creates a device and registers it with sysfs
struct device * device_create_vargs ( | class, | |
| parent, | ||
| devt, | ||
| drvdata, | ||
| fmt, | ||
args); |
struct class * class;struct device * parent;dev_t devt;void * drvdata;const char * fmt;va_list args;classpointer to the struct class that this device should be registered to
parentpointer to the parent struct device of this new device, if any
devtthe dev_t for the char device to be added
drvdatathe data to be added to the device for callbacks
fmtstring for the device's name
argsva_list for the device's name
This function can be used by char device classes. A struct device will be created in sysfs, registered to the specified class.
A “dev” file will be created, showing the dev_t for the device, if the dev_t is not 0,0. If a pointer to a parent struct device is passed in, the newly created struct device will be a child of that device in sysfs. The pointer to the struct device will be returned from the call. Any further sysfs files that might be required can be created using this pointer.
Returns struct device pointer on success, or ERR_PTR on error.
device_create — creates a device and registers it with sysfs
struct device * device_create ( | class, | |
| parent, | ||
| devt, | ||
| drvdata, | ||
| fmt, | ||
...); |
struct class * class;struct device * parent;dev_t devt;void * drvdata;const char * fmt; ...;classpointer to the struct class that this device should be registered to
parentpointer to the parent struct device of this new device, if any
devtthe dev_t for the char device to be added
drvdatathe data to be added to the device for callbacks
fmtstring for the device's name
...variable arguments
This function can be used by char device classes. A struct device will be created in sysfs, registered to the specified class.
A “dev” file will be created, showing the dev_t for the device, if the dev_t is not 0,0. If a pointer to a parent struct device is passed in, the newly created struct device will be a child of that device in sysfs. The pointer to the struct device will be returned from the call. Any further sysfs files that might be required can be created using this pointer.
Returns struct device pointer on success, or ERR_PTR on error.
device_destroy —
removes a device that was created with device_create
void device_destroy ( | class, | |
devt); |
struct class * class;dev_t devt;device_rename — renames a device
int device_rename ( | dev, | |
new_name); |
struct device * dev;const char * new_name;It is the responsibility of the caller to provide mutual exclusion between two different calls of device_rename on the same device to ensure that new_name is valid and won't conflict with other devices.
Don't call this function. Currently, the networking layer calls this function, but that will change. The following text from Kay Sievers offers
Renaming devices is racy at many levels, symlinks and other stuff are not replaced atomically, and you get a “move” uevent, but it's not easy to connect the event to the old and new device. Device nodes are not renamed at all, there isn't even support for that in the kernel now.
In the meantime, during renaming, your target name might be taken by another driver, creating conflicts. Or the old name is taken directly after you renamed it -- then you get events for the same DEVPATH, before you even see the “move” event. It's just a mess, and nothing new should ever rely on kernel device renaming. Besides that, it's not even implemented now for other things than (driver-core wise very simple) network devices.
We are currently about to change network renaming in udev to completely disallow renaming of devices in the same namespace as the kernel uses, because we can't solve the problems properly, that arise with swapping names of multiple interfaces without races. Means, renaming of eth[0-9]* will only be allowed to some other name than eth[0-9]*, for the aforementioned reasons.
Make up a “real” name in the driver before you register anything, or add some other attributes for userspace to find the device, or use udev to add symlinks -- but never rename kernel devices later, it's a complete mess. We don't even want to get into that and try to implement the missing pieces in the core. We really have other pieces to fix in the driver core mess. :)
device_move — moves a device to a new parent
int device_move ( | dev, | |
| new_parent, | ||
dpm_order); |
struct device * dev;struct device * new_parent;enum dpm_order dpm_order;__class_create — create a struct class structure
struct class * __class_create ( | owner, | |
| name, | ||
key); |
struct module * owner;const char * name;struct lock_class_key * key;class_destroy — destroys a struct class structure
void class_destroy ( | cls); |
struct class * cls;class_dev_iter_init — initialize class device iterator
void class_dev_iter_init ( | iter, | |
| class, | ||
| start, | ||
type); |
struct class_dev_iter * iter;struct class * class;struct device * start;const struct device_type * type;class_dev_iter_next — iterate to the next device
struct device * class_dev_iter_next ( | iter); |
struct class_dev_iter * iter;
Proceed iter 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.
class_dev_iter_exit — finish iteration
void class_dev_iter_exit ( | iter); |
struct class_dev_iter * iter;class_for_each_device — device iterator
int class_for_each_device ( | class, | |
| start, | ||
| data, | ||
fn); |
struct class * class;struct device * start;void * data;int (*fn)
(struct device *, void *);classthe class we're iterating
startthe device to start with in the list, if any.
datadata for the callback
fnfunction to be called for each device
Iterate over class's list of devices, and call fn for each,
passing it data. If start is set, the list iteration will start
there, otherwise if it is NULL, the iteration starts at the
beginning of the list.
We check the return of fn each time. If it returns anything
other than 0, we break out and return that value.
fn is allowed to do anything including calling back into class
code. There's no locking restriction.
class_find_device — device iterator for locating a particular device
struct device * class_find_device ( | class, | |
| start, | ||
| data, | ||
match); |
struct class * class;struct device * start;void * data;int (*match)
(struct device *, void *);classthe class we're iterating
startDevice to begin with
datadata for the match function
matchfunction to check device
This is similar to the class_for_each_dev function above, but it
returns a reference to a device that is 'found' for later use, as
determined by the match 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.
Note, you will need to drop the reference with put_device after use.
fn is allowed to do anything including calling back into class
code. There's no locking restriction.
class_compat_register — register a compatibility class
struct class_compat * class_compat_register ( | name); |
const char * name;class_compat_unregister — unregister a compatibility class
void class_compat_unregister ( | cls); |
struct class_compat * cls;class_compat_create_link — create a compatibility class device link to a bus device
int class_compat_create_link ( | cls, | |
| dev, | ||
device_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
void class_compat_remove_link ( | cls, | |
| dev, | ||
device_link); |
struct class_compat * cls;struct device * dev;struct device * device_link;request_firmware — send firmware request and wait for it
int request_firmware ( | firmware_p, | |
| name, | ||
device); |
const struct firmware ** firmware_p;const char * name;struct device * device;firmware_ppointer to firmware image
namename of firmware file
devicedevice for which firmware is being loaded
firmware_p will be used to return a firmware image by the name
of name for device device.
Should be called from user context where sleeping is allowed.
name 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.
release_firmware — release the resource associated with a firmware image
void release_firmware ( | fw); |
const struct firmware * fw;request_firmware_nowait — asynchronous version of request_firmware
int request_firmware_nowait ( | module, | |
| uevent, | ||
| name, | ||
| device, | ||
| gfp, | ||
| context, | ||
cont); |
struct module * module;bool uevent;const char * name;struct device * device;gfp_t gfp;void * context;void (*cont)
(const struct firmware *fw, void *context);modulemodule requesting the firmware
ueventsends uevent to copy the firmware image if this flag is non-zero else the firmware copy must be done manually.
namename of firmware file
devicedevice for which firmware is being loaded
gfpallocation flags
context
will be passed over to cont, and
fw may be NULL if firmware request fails.
contfunction will be called asynchronously when the firmware request is over.
transport_class_register — register an initial transport class
int transport_class_register ( | tclass); |
struct transport_class * tclass;
The transport class contains an embedded class which is used to
identify it. The caller should initialise this structure with
zeros and then generic class must have been initialised with the
actual transport class unique name. There's a macro
DECLARE_TRANSPORT_CLASS to do this (declared classes still must
be registered).
Returns 0 on success or error on failure.
transport_class_unregister — unregister a previously registered class
void transport_class_unregister ( | tclass); |
struct transport_class * tclass;anon_transport_class_register — register an anonymous class
int anon_transport_class_register ( | atc); |
struct anon_transport_class * atc;
The anonymous transport class contains both a transport class and a
container. The idea of an anonymous class is that it never
actually has any device attributes associated with it (and thus
saves on container storage). So it can only be used for triggering
events. Use prezero and then use DECLARE_ANON_TRANSPORT_CLASS to
initialise the anon transport class storage.
anon_transport_class_unregister — unregister an anon class
void anon_transport_class_unregister ( | atc); |
struct anon_transport_class * atc;transport_setup_device — declare a new dev for transport class association but don't make it visible yet.
void transport_setup_device ( | dev); |
struct device * dev;Usually, dev represents some component in the HBA system (either the HBA itself or a device remote across the HBA bus). This routine is simply a trigger point to see if any set of transport classes wishes to associate with the added device. This allocates storage for the class device and initialises it, but does not yet add it to the system or add attributes to it (you do this with transport_add_device). If you have no need for a separate setup and add operations, use transport_register_device (see transport_class.h).
transport_add_device — declare a new dev for transport class association
void transport_add_device ( | dev); |
struct device * dev;transport_configure_device — configure an already set up device
void transport_configure_device ( | dev); |
struct device * dev;The idea of configure is simply to provide a point within the setup process to allow the transport class to extract information from a device after it has been setup. This is used in SCSI because we have to have a setup device to begin using the HBA, but after we send the initial inquiry, we use configure to extract the device parameters. The device need not have been added to be configured.
transport_remove_device — remove the visibility of a device
void transport_remove_device ( | dev); |
struct device * dev;
This call removes the visibility of the device (to the user from
sysfs), but does not destroy it. To eliminate a device entirely
you must also call transport_destroy_device. If you don't need to
do remove and destroy as separate operations, use
transport_unregister_device (see transport_class.h) which will
perform both calls for you.
transport_destroy_device — destroy a removed device
void transport_destroy_device ( | dev); |
struct device * dev;This call triggers the elimination of storage associated with the transport classdev. Note: all it really does is relinquish a reference to the classdev. The memory will not be freed until the last reference goes to zero. Note also that the classdev retains a reference count on dev, so dev too will remain for as long as the transport class device remains around.
sysdev_driver_register — Register auxiliary driver
int sysdev_driver_register ( | cls, | |
drv); |
struct sysdev_class * cls;struct sysdev_driver * drv;sysdev_driver_unregister — Remove an auxiliary driver.
void sysdev_driver_unregister ( | cls, | |
drv); |
struct sysdev_class * cls;struct sysdev_driver * drv;sysdev_register — add a system device to the tree
int sysdev_register ( | sysdev); |
struct sys_device * sysdev;platform_device_register_simple — add a platform-level device and its resources
struct platform_device * platform_device_register_simple ( | name, | |
| id, | ||
| res, | ||
num); |
const char * name;int id;const struct resource * res;unsigned int num;namebase name of the device we're adding
idinstance id
resset of resources that needs to be allocated for the device
numnumber of resources
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.
This interface is primarily intended for use with legacy drivers which probe hardware directly. Because such drivers create sysfs device nodes themselves, rather than letting system infrastructure handle such device enumeration tasks, they don't fully conform to the Linux driver model. In particular, when such drivers are built as modules, they can't be “hotplugged”.
Returns struct platform_device pointer on success, or ERR_PTR on error.
platform_device_register_data — add a platform-level device with platform-specific data
struct platform_device * platform_device_register_data ( | parent, | |
| name, | ||
| id, | ||
| data, | ||
size); |
struct device * parent;const char * name;int id;const void * data;size_t size;parentparent device for the device we're adding
namebase name of the device we're adding
idinstance id
dataplatform specific data for this platform device
sizesize 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.