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; |
atomic64_xchg — xchg atomic64 variable
u64 atomic64_xchg ( | ptr, | |
new_val); |
atomic64_t * | ptr; |
u64 | new_val; |
atomic64_set — set atomic64 variable
void atomic64_set ( | ptr, | |
new_val); |
atomic64_t * | ptr; |
u64 | new_val; |
atomic64_add_return — add and return
u64 atomic64_add_return ( | delta, | |
ptr); |
u64 | delta; |
atomic64_t * | ptr; |
atomic64_add — add integer to atomic64 variable
void atomic64_add ( | delta, | |
ptr); |
u64 | delta; |
atomic64_t * | ptr; |
atomic64_sub — subtract the atomic64 variable
void atomic64_sub ( | delta, | |
ptr); |
u64 | delta; |
atomic64_t * | ptr; |
atomic64_sub_and_test — subtract value from variable and test result
int atomic64_sub_and_test ( | delta, | |
ptr); |
u64 | delta; |
atomic64_t * | ptr; |
atomic64_dec_and_test — decrement and test
int atomic64_dec_and_test ( | ptr); |
atomic64_t * | ptr; |
atomic64_inc_and_test — increment and test
int atomic64_inc_and_test ( | ptr); |
atomic64_t * | ptr; |
atomic64_add_negative — add and test if negative
int atomic64_add_negative ( | delta, | |
ptr); |
u64 | delta; |
atomic64_t * | ptr; |
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))
unsigned 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; |
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; |
struct sched_param * | param; |
__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; |
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.
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.
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 rb_node node;
ktime_t _expires;
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
}; red black tree node for time ordered insertion
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;
clockid_t index;
struct rb_root active;
struct rb_node * first;
ktime_t resolution;
ktime_t (* get_time) (void);
ktime_t softirq_time;
#ifdef CONFIG_HIGH_RES_TIMERS
ktime_t offset;
#endif
}; per cpu clock base
clock type index for per_cpu support when moving a timer to a base on another cpu.
red black tree root node for the active timers
pointer to the timer node which expires first
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; |
Forces execution of the workqueue and blocks until its completion. This is typically used in driver shutdown handlers.
We sleep until all works which were queued on entry have been handled, but we are not livelocked by new incoming ones.
This function used to run the workqueues itself. Now we just wait for the helper threads to do it.
flush_work — block until a work_struct's callback has terminated
int flush_work ( | work); |
struct work_struct * | work; |
cancel_work_sync — block until a work_struct's callback has terminated
int cancel_work_sync ( | work); |
struct work_struct * | work; |
Returns true if work was pending.
cancel_work_sync will cancel the work if it is queued. If the work's
callback appears to be running, cancel_work_sync will block until it
has completed.
It is possible to use this function if the work re-queues itself. It can
cancel the work even if it migrates to another workqueue, however in that
case it only guarantees that work->func has completed on the last queued
workqueue.
cancel_work_sync(delayed_work->work) should be used only if ->timer is not pending, otherwise it goes into a busy-wait loop until the timer expires.
The caller must ensure that workqueue_struct on which this work was last queued can't be destroyed before this function returns.
cancel_delayed_work_sync — reliably kill off a delayed work.
int 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; |
flush_delayed_work — block until a dwork_struct's callback has terminated
void flush_delayed_work ( | dwork); |
struct delayed_work * | dwork; |
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; |
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; |
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.
sys_tgkill — send signal to one specific thread
long sys_tgkill ( | tgid, | |
| pid, | ||
sig); |
pid_t | tgid; |
pid_t | pid; |
int | sig; |
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 — create a kthread.
struct task_struct * kthread_create ( | threadfn, | |
| data, | ||
| namefmt[], | ||
...); |
int (* | threadfn |
void * | data; |
const char | namefmt[]; |
| ...; |
threadfnthe function to run until signal_pending(current).
data
data ptr for threadfn.
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, kthread_create_on_cpu.
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 noone 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 ( | k, | |
cpu); |
struct task_struct * | k; |
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.
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; |
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.
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; |
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_sem. 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 release_console_sem and will send it to the
consoles before releasing the semaphore.
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.
acquire_console_sem — lock the console system for exclusive use.
void acquire_console_sem ( | void); |
| void; |
release_console_sem — unlock the console system
void release_console_sem ( | void); |
| void; |
Releases the semaphore which the caller holds on the console system and the console driver list.
While the semaphore was held, console output may have been buffered
by printk. If this is the case, release_console_sem emits
the output prior to releasing the semaphore.
If there is output waiting for klogd, we wake it up.
release_console_sem 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; |
orderly_poweroff — Trigger an orderly system poweroff
int orderly_poweroff ( | force); |
bool | force; |
synchronize_rcu — wait until a grace period has elapsed.
void synchronize_rcu ( | void); |
| void; |
synchronize_sched — wait until an rcu-sched grace period has elapsed.
void synchronize_sched ( | void); |
| void; |
Control will return to the caller some time after a full rcu-sched
grace period has elapsed, in other words after all currently executing
rcu-sched read-side critical sections have completed. These read-side
critical sections are delimited by rcu_read_lock_sched and
rcu_read_unlock_sched, and may be nested. Note that preempt_disable,
local_irq_disable, and so on may be used in place of
rcu_read_lock_sched.
This means that all preempt_disable code sequences, including NMI and hardware-interrupt handlers, in progress on entry will have completed before this primitive returns. However, this does not guarantee that softirq handlers will have completed, since in some kernels, these handlers can run in process context, and can block.
This primitive provides the guarantees made by the (now removed)
synchronize_kernel API. In contrast, synchronize_rcu only
guarantees that rcu_read_lock sections will have completed.
In “classic RCU”, these two guarantees happen to be one and
the same, but can differ in realtime RCU implementations.
synchronize_rcu_bh — wait until an rcu_bh grace period has elapsed.
void synchronize_rcu_bh ( | void); |
| void; |
Control will return to the caller some time after a full rcu_bh grace
period has elapsed, in other words after all currently executing rcu_bh
read-side critical sections have completed. RCU read-side critical
sections are delimited by rcu_read_lock_bh and rcu_read_unlock_bh,
and may be nested.
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
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 |
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 |
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; |
struct driver_attribute * | attr; |
driver_remove_file — remove sysfs file for driver.
void driver_remove_file ( | drv, | |
attr); |
struct device_driver * | drv; |
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; |
struct device_attribute * | attr; |
device_remove_file — remove sysfs attribute file.
void device_remove_file ( | dev, | |
attr); |
struct device * | dev; |
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; |
struct bin_attribute * | attr; |
device_remove_bin_file — remove sysfs binary attribute file
void device_remove_bin_file ( | dev, | |
attr); |
struct device * | dev; |
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 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 |
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 |
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.
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.
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.
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; |
char * | new_name; |
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 |
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 |
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 —
int request_firmware_nowait ( | module, | |
| uevent, | ||
| name, | ||
| device, | ||
| context, | ||
cont); |
struct module * | module; |
int | uevent; |
const char * | name; |
struct device * | device; |
void * | context; |
void (* | cont |
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
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 auxillary driver
int sysdev_driver_register ( | cls, | |
drv); |
struct sysdev_class * | cls; |
struct sysdev_driver * | drv; |
sysdev_driver_unregister — Remove an auxillary 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; |
sysdev_suspend — Suspend all system devices.
int sysdev_suspend ( | state); |
pm_message_t | state; |
We perform an almost identical operation as sysdev_shutdown
above, though calling ->suspend instead. Interrupts are disabled
when this called. Devices are responsible for both saving state and
quiescing or powering down the device.
This is only called by the device PM core, so we let them handle all synchronization.
sysdev_resume — Bring system devices back to life.
int sysdev_resume ( | void); |
| void; |
platform_get_resource — get a resource for a device
struct resource * platform_get_resource ( | dev, | |
| type, | ||
num); |
struct platform_device * | dev; |
unsigned int | type; |
unsigned int | num; |
platform_get_irq — get an IRQ for a device
int platform_get_irq ( | dev, | |
num); |
struct platform_device * | dev; |
unsigned int | num; |
platform_get_resource_byname — get a resource for a device by name
struct resource * platform_get_resource_byname ( | dev, | |
| type, | ||
name); |
struct platform_device * | dev; |
unsigned int | type; |
const char * | name; |
platform_get_irq_byname — get an IRQ for a device
int platform_get_irq_byname ( | dev, | |
name); |
struct platform_device * | dev; |
const char * | name; |
platform_add_devices — add a numbers of platform devices
int platform_add_devices ( | devs, | |
num); |
struct platform_device ** | devs; |
int | num; |
platform_device_alloc —
struct platform_device * platform_device_alloc ( | name, | |
id); |
const char * | name; |
int | id; |
platform_device_add_resources —
int platform_device_add_resources ( | pdev, | |
| res, | ||
num); |
struct platform_device * | pdev; |
struct resource * | res; |
unsigned int | num; |
platform_device_add_data —
int platform_device_add_data ( | pdev, | |
| data, | ||
size); |
struct platform_device * | pdev; |
const void * | data; |
size_t | size; |
platform_device_add — add a platform device to device hierarchy
int platform_device_add ( | pdev); |
struct platform_device * | pdev; |
platform_device_del — remove a platform-level device
void platform_device_del ( | pdev); |
struct platform_device * | pdev; |
platform_device_register — add a platform-level device
int platform_device_register ( | pdev); |
struct platform_device * | pdev; |
platform_device_unregister — unregister a platform-level device
void platform_device_unregister ( | pdev); |
struct platform_device * | pdev; |
platform_device_register_simple —
struct platform_device * platform_device_register_simple ( | name, | |
| id, | ||
| res, | ||
num); |
const char * | name; |
int | id; |
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”.
platform_driver_register —
int platform_driver_register ( | drv); |
struct platform_driver * | drv; |
platform_driver_unregister —
void platform_driver_unregister ( | drv); |
struct platform_driver * | drv; |
platform_driver_probe — register driver for non-hotpluggable device
int __init_or_module platform_driver_probe ( | drv, | |
probe); |
struct platform_driver * | drv; |
int (* | probe |
drvplatform driver structure
probethe driver probe routine, probably from an __init section
Use this instead of platform_driver_register when you know the device
is not hotpluggable and has already been registered, and you want to
remove its run-once probe infrastructure from memory after the driver
has bound to the device.
One typical use for this would be with drivers for controllers integrated into system-on-chip processors, where the controller devices have been configured as part of board setup.
Returns zero if the driver registered and bound to a device, else returns a negative error code and with the driver not registered.
bus_for_each_dev — device iterator.
int bus_for_each_dev ( | bus, | |
| start, | ||
| data, | ||
fn); |
struct bus_type * | bus; |
struct device * | start; |
void * | data; |
int (* | fn |
busbus type.
startdevice to start iterating from.
datadata for the callback.
fnfunction to be called for each device.
bus_find_device — device iterator for locating a particular device.
struct device * bus_find_device ( | bus, | |
| start, | ||
| data, | ||
match); |
struct bus_type * | bus; |
struct device * | start; |
void * | data; |
int (* | match |
busbus type
startDevice to begin with
dataData to pass to match function
matchCallback function to check device
This is similar to the bus_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.
bus_find_device_by_name — device iterator for locating a particular device of a specific name
struct device * bus_find_device_by_name ( | bus, | |
| start, | ||
name); |
struct bus_type * | bus; |
struct device * | start; |
const char * | name; |
bus_for_each_drv — driver iterator
int bus_for_each_drv ( | bus, | |
| start, | ||
| data, | ||
fn); |
struct bus_type * | bus; |
struct device_driver * | start; |
void * | data; |
int (* | fn |
busbus we're dealing with.
startdriver to start iterating on.
datadata to pass to the callback.
fnfunction to call for each driver.
This is nearly identical to the device iterator above.
We iterate over each driver that belongs to bus, and call
fn for each. If fn returns anything but 0, we break out
and return it. If start is not NULL, we use it as the head
of the list.
we don't return the driver that returns a non-zero value, nor do we leave the reference count incremented for that driver. If the caller needs to know that info, it must set it in the callback. It must also be sure to increment the refcount so it doesn't disappear before returning to the caller.
bus_rescan_devices — rescan devices on the bus for possible drivers
int bus_rescan_devices ( | bus); |
struct bus_type * | bus; |
device_reprobe — remove driver for a device and probe for a new driver
int device_reprobe ( | dev); |
struct device * | dev; |
dpm_resume_noirq — Execute “early resume” callbacks for non-sysdev devices.
void dpm_resume_noirq ( | state); |
pm_message_t | state; |
dpm_resume_end — Execute “resume” callbacks and complete system transition.
void dpm_resume_end ( | state); |
pm_message_t | state; |
dpm_suspend_noirq — Execute “late suspend” callbacks for non-sysdev devices.
int dpm_suspend_noirq ( | state); |
pm_message_t | state; |
acpi_bus_register_driver — register a driver with the ACPI bus
int acpi_bus_register_driver ( | driver); |
struct acpi_driver * | driver; |
acpi_bus_unregister_driver — unregisters a driver with the APIC bus
void acpi_bus_unregister_driver ( | driver); |
struct acpi_driver * | driver; |
pnp_register_protocol — adds a pnp protocol to the pnp layer
int pnp_register_protocol ( | protocol); |
struct pnp_protocol * | protocol; |
pnp_unregister_protocol — removes a pnp protocol from the pnp layer
void pnp_unregister_protocol ( | protocol); |
struct pnp_protocol * | protocol; |
pnp_request_card_device — Searches for a PnP device under the specified card
struct pnp_dev * pnp_request_card_device ( | clink, | |
| id, | ||
from); |
struct pnp_card_link * | clink; |
const char * | id; |
struct pnp_dev * | from; |
pnp_release_card_device — call this when the driver no longer needs the device
void pnp_release_card_device ( | dev); |
struct pnp_dev * | dev; |
pnp_register_card_driver — registers a PnP card driver with the PnP Layer
int pnp_register_card_driver ( | drv); |
struct pnp_card_driver * | drv; |
pnp_unregister_card_driver — unregisters a PnP card driver from the PnP Layer
void pnp_unregister_card_driver ( | drv); |
struct pnp_card_driver * | drv; |
pnp_add_id — adds an EISA id to the specified device
struct pnp_id * pnp_add_id ( | dev, | |
id); |
struct pnp_dev * | dev; |
char * | id; |
pnp_start_dev — low-level start of the PnP device
int pnp_start_dev ( | dev); |
struct pnp_dev * | dev; |
pnp_stop_dev — low-level disable of the PnP device
int pnp_stop_dev ( | dev); |
struct pnp_dev * | dev; |
pnp_activate_dev — activates a PnP device for use
int pnp_activate_dev ( | dev); |
struct pnp_dev * | dev; |
uio_event_notify — trigger an interrupt event
void uio_event_notify ( | info); |
struct uio_info * | info; |
__uio_register_device — register a new userspace IO device
int __uio_register_device ( | owner, | |
| parent, | ||
info); |
struct module * | owner; |
struct device * | parent; |
struct uio_info * | info; |
uio_unregister_device — unregister a industrial IO device
void uio_unregister_device ( | info); |
struct uio_info * | info; |
struct uio_mem — description of a UIO memory region
struct uio_mem {
const char * name;
unsigned long addr;
unsigned long size;
int memtype;
void __iomem * internal_addr;
struct uio_map * map;
}; struct uio_port — description of a UIO port region
struct uio_port {
const char * name;
unsigned long start;
unsigned long size;
int porttype;
struct uio_portio * portio;
}; struct uio_info — UIO device capabilities
struct uio_info {
struct uio_device * uio_dev;
const char * name;
const char * version;
struct uio_mem mem[MAX_UIO_MAPS];
struct uio_port port[MAX_UIO_PORT_REGIONS];
long irq;
unsigned long irq_flags;
void * priv;
irqreturn_t (* handler) (int irq, struct uio_info *dev_info);
int (* mmap) (struct uio_info *info, struct vm_area_struct *vma);
int (* open) (struct uio_info *info, struct inode *inode);
int (* release) (struct uio_info *info, struct inode *inode);
int (* irqcontrol) (struct uio_info *info, s32 irq_on);
}; the UIO device this info belongs to
device name
device driver version
list of mappable memory regions, size==0 for end of list
list of port regions, size==0 for end of list
interrupt number or UIO_IRQ_CUSTOM
flags for request_irq
optional private data
the device's irq handler
mmap operation for this uio device
open operation for this uio device
release operation for this uio device
disable/enable irqs when 0/1 is written to /dev/uioX
Table of Contents
parport_open
parport_yield — relinquish a parallel port temporarily
int parport_yield ( | dev); |
struct pardevice * | dev; |
This function relinquishes the port if it would be helpful to other
drivers to do so. Afterwards it tries to reclaim the port using
parport_claim, and the return value is the same as for
parport_claim. If it fails, the port is left unclaimed and it is
the driver's responsibility to reclaim the port.
The parport_yield and parport_yield_blocking functions are for
marking points in the driver at which other drivers may claim the
port and use their devices. Yielding the port is similar to
releasing it and reclaiming it, but is more efficient because no
action is taken if there are no other devices needing the port. In
fact, nothing is done even if there are other devices waiting but
the current device is still within its “timeslice”. The default
timeslice is half a second, but it can be adjusted via the /proc
interface.
parport_yield_blocking — relinquish a parallel port temporarily
int parport_yield_blocking ( | dev); |
struct pardevice * | dev; |
parport_wait_event — wait for an event on a parallel port
int parport_wait_event ( | port, | |
timeout); |
struct parport * | port; |
signed long | timeout; |
This function waits for up to timeout jiffies for an
interrupt to occur on a parallel port. If the port timeout is
set to zero, it returns immediately.
If an interrupt occurs before the timeout period elapses, this function returns zero immediately. If it times out, it returns one. An error code less than zero indicates an error (most likely a pending signal), and the calling code should finish what it's doing as soon as it can.