<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
	"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>

<book id="LinuxKernelAPI">
 <bookinfo>
  <title>The Linux Kernel API</title>
  
  <legalnotice>
   <para>
     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.
   </para>
      
   <para>
     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.
   </para>
      
   <para>
     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
   </para>
      
   <para>
     For more details see the file COPYING in the source
     distribution of Linux.
   </para>
  </legalnotice>
 </bookinfo>

<toc></toc>

  <chapter id="adt">
     <title>Data Types</title>
     <sect1><title>Doubly Linked Lists</title>
<!-- include/linux/list.h -->
<refentry id="API-list-add">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_add</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_add</refname>
 <refpurpose>
  add a new entry
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_add </function></funcdef>
   <paramdef>struct list_head * <parameter>new</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     new entry to be added
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     list head to add it after
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Insert a new entry after the specified head.
   This is good for implementing stacks.
</para>
</refsect1>
</refentry>

<refentry id="API-list-add-tail">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_add_tail</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_add_tail</refname>
 <refpurpose>
     add a new entry
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_add_tail </function></funcdef>
   <paramdef>struct list_head * <parameter>new</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     new entry to be added
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     list head to add it before
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Insert a new entry before the specified head.
   This is useful for implementing queues.
</para>
</refsect1>
</refentry>

<refentry id="API-list-del">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_del</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_del</refname>
 <refpurpose>
     deletes entry from list.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_del </function></funcdef>
   <paramdef>struct list_head * <parameter>entry</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>entry</parameter></term>
   <listitem>
    <para>
     the element to delete from the list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Note</title>
<para>
   <function>list_empty</function> on entry does not return true after this, the entry is
   in an undefined state.
</para>
</refsect1>
</refentry>

<refentry id="API-list-replace">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_replace</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_replace</refname>
 <refpurpose>
     replace old entry by new one
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_replace </function></funcdef>
   <paramdef>struct list_head * <parameter>old</parameter></paramdef>
   <paramdef>struct list_head * <parameter>new</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>old</parameter></term>
   <listitem>
    <para>
     the element to be replaced
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     the new element to insert
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   If <parameter>old</parameter> was empty, it will be overwritten.
</para>
</refsect1>
</refentry>

<refentry id="API-list-del-init">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_del_init</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_del_init</refname>
 <refpurpose>
     deletes entry from list and reinitialize it.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_del_init </function></funcdef>
   <paramdef>struct list_head * <parameter>entry</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>entry</parameter></term>
   <listitem>
    <para>
     the element to delete from the list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-move">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_move</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_move</refname>
 <refpurpose>
     delete from one list and add as another's head
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_move </function></funcdef>
   <paramdef>struct list_head * <parameter>list</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>list</parameter></term>
   <listitem>
    <para>
     the entry to move
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head that will precede our entry
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-move-tail">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_move_tail</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_move_tail</refname>
 <refpurpose>
     delete from one list and add as another's tail
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_move_tail </function></funcdef>
   <paramdef>struct list_head * <parameter>list</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>list</parameter></term>
   <listitem>
    <para>
     the entry to move
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head that will follow our entry
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-is-last">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_is_last</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_is_last</refname>
 <refpurpose>
     tests whether <parameter>list</parameter> is the last entry in list <parameter>head</parameter>
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>list_is_last </function></funcdef>
   <paramdef>const struct list_head * <parameter>list</parameter></paramdef>
   <paramdef>const struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>list</parameter></term>
   <listitem>
    <para>
     the entry to test
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head of the list
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-empty">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_empty</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_empty</refname>
 <refpurpose>
     tests whether a list is empty
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>list_empty </function></funcdef>
   <paramdef>const struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the list to test.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-empty-careful">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_empty_careful</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_empty_careful</refname>
 <refpurpose>
     tests whether a list is empty and not being modified
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>list_empty_careful </function></funcdef>
   <paramdef>const struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the list to test
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   tests whether a list is empty _and_ checks that no other CPU might be
   in the process of modifying either member (next or prev)
</para>
</refsect1>
<refsect1>
<title>NOTE</title>
<para>
   using <function>list_empty_careful</function> without synchronization
   can only be safe if the only activity that can happen
   to the list entry is <function>list_del_init</function>. Eg. it cannot be used
   if another CPU could re-<function>list_add</function> it.
</para>
</refsect1>
</refentry>

<refentry id="API-list-is-singular">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_is_singular</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_is_singular</refname>
 <refpurpose>
     tests whether a list has just one entry.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>list_is_singular </function></funcdef>
   <paramdef>const struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the list to test.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-cut-position">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_cut_position</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_cut_position</refname>
 <refpurpose>
     cut a list into two
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_cut_position </function></funcdef>
   <paramdef>struct list_head * <parameter>list</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
   <paramdef>struct list_head * <parameter>entry</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>list</parameter></term>
   <listitem>
    <para>
     a new list to add all removed entries
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     a list with entries
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>entry</parameter></term>
   <listitem>
    <para>
     an entry within head, could be the head itself
     and if so we won't cut the list
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This helper moves the initial part of <parameter>head</parameter>, up to and
   including <parameter>entry</parameter>, from <parameter>head</parameter> to <parameter>list</parameter>. You should
   pass on <parameter>entry</parameter> an element you know is on <parameter>head</parameter>. <parameter>list</parameter>
   should be an empty list or a list you do not care about
   losing its data.
</para>
</refsect1>
</refentry>

<refentry id="API-list-splice">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_splice</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_splice</refname>
 <refpurpose>
     join two lists, this is designed for stacks
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_splice </function></funcdef>
   <paramdef>const struct list_head * <parameter>list</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>list</parameter></term>
   <listitem>
    <para>
     the new list to add.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the place to add it in the first list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-splice-tail">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_splice_tail</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_splice_tail</refname>
 <refpurpose>
     join two lists, each list being a queue
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_splice_tail </function></funcdef>
   <paramdef>struct list_head * <parameter>list</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>list</parameter></term>
   <listitem>
    <para>
     the new list to add.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the place to add it in the first list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-splice-init">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_splice_init</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_splice_init</refname>
 <refpurpose>
     join two lists and reinitialise the emptied list.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_splice_init </function></funcdef>
   <paramdef>struct list_head * <parameter>list</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>list</parameter></term>
   <listitem>
    <para>
     the new list to add.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the place to add it in the first list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The list at <parameter>list</parameter> is reinitialised
</para>
</refsect1>
</refentry>

<refentry id="API-list-splice-tail-init">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_splice_tail_init</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_splice_tail_init</refname>
 <refpurpose>
     join two lists and reinitialise the emptied list
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>list_splice_tail_init </function></funcdef>
   <paramdef>struct list_head * <parameter>list</parameter></paramdef>
   <paramdef>struct list_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>list</parameter></term>
   <listitem>
    <para>
     the new list to add.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the place to add it in the first list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Each of the lists is a queue.
   The list at <parameter>list</parameter> is reinitialised
</para>
</refsect1>
</refentry>

<refentry id="API-list-entry">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_entry</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_entry</refname>
 <refpurpose>
     get the struct for this entry
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_entry </function></funcdef>
   <paramdef> <parameter>ptr</parameter></paramdef>
   <paramdef> <parameter>type</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ptr</parameter></term>
   <listitem>
    <para>
     the <structname>struct list_head</structname> pointer.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>type</parameter></term>
   <listitem>
    <para>
     the type of the struct this is embedded in.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the list_struct within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-first-entry">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_first_entry</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_first_entry</refname>
 <refpurpose>
     get the first element from a list
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_first_entry </function></funcdef>
   <paramdef> <parameter>ptr</parameter></paramdef>
   <paramdef> <parameter>type</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ptr</parameter></term>
   <listitem>
    <para>
     the list head to take the element from.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>type</parameter></term>
   <listitem>
    <para>
     the type of the struct this is embedded in.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the list_struct within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Note, that list is expected to be not empty.
</para>
</refsect1>
</refentry>

<refentry id="API-list-for-each">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_for_each</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_for_each</refname>
 <refpurpose>
     iterate over a list
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the <structname>struct list_head</structname> to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API---list-for-each">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__list_for_each</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__list_for_each</refname>
 <refpurpose>
     iterate over a list
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>__list_for_each </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the <structname>struct list_head</structname> to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This variant differs from <function>list_for_each</function> in that it's the
   simplest possible list iteration code, no prefetching is done.
   Use this for code that knows the list to be very short (empty
   or 1 entry) most of the time.
</para>
</refsect1>
</refentry>

<refentry id="API-list-for-each-prev">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_for_each_prev</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_for_each_prev</refname>
 <refpurpose>
     iterate over a list backwards
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_prev </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the <structname>struct list_head</structname> to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-for-each-safe">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_for_each_safe</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_for_each_safe</refname>
 <refpurpose>
     iterate over a list safe against removal of list entry
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_safe </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>n</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the <structname>struct list_head</structname> to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     another <structname>struct list_head</structname> to use as temporary storage
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-for-each-prev-safe">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_for_each_prev_safe</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_for_each_prev_safe</refname>
 <refpurpose>
     iterate over a list backwards safe against removal of list entry
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_prev_safe </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>n</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the <structname>struct list_head</structname> to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     another <structname>struct list_head</structname> to use as temporary storage
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-for-each-entry">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_for_each_entry</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_for_each_entry</refname>
 <refpurpose>
     iterate over list of given type
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_entry </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the type * to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the list_struct within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-for-each-entry-reverse">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_for_each_entry_reverse</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_for_each_entry_reverse</refname>
 <refpurpose>
     iterate backwards over list of given type.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_entry_reverse </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the type * to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the list_struct within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-prepare-entry">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_prepare_entry</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_prepare_entry</refname>
 <refpurpose>
     prepare a pos entry for use in <function>list_for_each_entry_continue</function>
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_prepare_entry </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the type * to use as a start point
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head of the list
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the list_struct within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Prepares a pos entry for use as a start point in <function>list_for_each_entry_continue</function>.
</para>
</refsect1>
</refentry>

<refentry id="API-list-for-each-entry-continue">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_for_each_entry_continue</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_for_each_entry_continue</refname>
 <refpurpose>
     continue iteration over list of given type
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_entry_continue </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the type * to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the list_struct within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Continue to iterate over list of given type, continuing after
   the current position.
</para>
</refsect1>
</refentry>

<refentry id="API-list-for-each-entry-continue-reverse">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_for_each_entry_continue_reverse</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_for_each_entry_continue_reverse</refname>
 <refpurpose>
     iterate backwards from the given point
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_entry_continue_reverse </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the type * to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the list_struct within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Start to iterate over list of given type backwards, continuing after
   the current position.
</para>
</refsect1>
</refentry>

<refentry id="API-list-for-each-entry-from">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_for_each_entry_from</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_for_each_entry_from</refname>
 <refpurpose>
     iterate over list of given type from the current point
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_entry_from </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the type * to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the list_struct within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Iterate over list of given type, continuing from current position.
</para>
</refsect1>
</refentry>

<refentry id="API-list-for-each-entry-safe">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_for_each_entry_safe</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_for_each_entry_safe</refname>
 <refpurpose>
     iterate over list of given type safe against removal of list entry
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_entry_safe </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>n</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the type * to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     another type * to use as temporary storage
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the list_struct within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-list-for-each-entry-safe-continue">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_for_each_entry_safe_continue</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_for_each_entry_safe_continue</refname>
 <refpurpose>
   </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_entry_safe_continue </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>n</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the type * to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     another type * to use as temporary storage
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the list_struct within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Iterate over list of given type, continuing after current point,
   safe against removal of list entry.
</para>
</refsect1>
</refentry>

<refentry id="API-list-for-each-entry-safe-from">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_for_each_entry_safe_from</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_for_each_entry_safe_from</refname>
 <refpurpose>
   </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_entry_safe_from </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>n</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the type * to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     another type * to use as temporary storage
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the list_struct within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Iterate over list of given type from current point, safe against
   removal of list entry.
</para>
</refsect1>
</refentry>

<refentry id="API-list-for-each-entry-safe-reverse">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>list_for_each_entry_safe_reverse</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>list_for_each_entry_safe_reverse</refname>
 <refpurpose>
   </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>list_for_each_entry_safe_reverse </function></funcdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>n</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the type * to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     another type * to use as temporary storage
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the list_struct within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Iterate backwards over list of given type, safe against removal
   of list entry.
</para>
</refsect1>
</refentry>

<refentry id="API-hlist-for-each-entry">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>hlist_for_each_entry</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>hlist_for_each_entry</refname>
 <refpurpose>
     iterate over list of given type
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>hlist_for_each_entry </function></funcdef>
   <paramdef> <parameter>tpos</parameter></paramdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>tpos</parameter></term>
   <listitem>
    <para>
     the type * to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the <structname>struct hlist_node</structname> to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the hlist_node within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-hlist-for-each-entry-continue">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>hlist_for_each_entry_continue</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>hlist_for_each_entry_continue</refname>
 <refpurpose>
     iterate over a hlist continuing after current point
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>hlist_for_each_entry_continue </function></funcdef>
   <paramdef> <parameter>tpos</parameter></paramdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>tpos</parameter></term>
   <listitem>
    <para>
     the type * to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the <structname>struct hlist_node</structname> to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the hlist_node within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-hlist-for-each-entry-from">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>hlist_for_each_entry_from</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>hlist_for_each_entry_from</refname>
 <refpurpose>
     iterate over a hlist continuing from current point
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>hlist_for_each_entry_from </function></funcdef>
   <paramdef> <parameter>tpos</parameter></paramdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>tpos</parameter></term>
   <listitem>
    <para>
     the type * to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the <structname>struct hlist_node</structname> to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the hlist_node within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-hlist-for-each-entry-safe">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>hlist_for_each_entry_safe</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>hlist_for_each_entry_safe</refname>
 <refpurpose>
     iterate over list of given type safe against removal of list entry
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>hlist_for_each_entry_safe </function></funcdef>
   <paramdef> <parameter>tpos</parameter></paramdef>
   <paramdef> <parameter>pos</parameter></paramdef>
   <paramdef> <parameter>n</parameter></paramdef>
   <paramdef> <parameter>head</parameter></paramdef>
   <paramdef> <parameter>member</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>tpos</parameter></term>
   <listitem>
    <para>
     the type * to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     the <structname>struct hlist_node</structname> to use as a loop cursor.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     another <structname>struct hlist_node</structname> to use as temporary storage
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     the head for your list.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>member</parameter></term>
   <listitem>
    <para>
     the name of the hlist_node within the struct.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

     </sect1>
  </chapter>

  <chapter id="libc">
     <title>Basic C Library Functions</title>

     <para>
       When writing drivers, you cannot in general use routines which are
       from the C Library.  Some of the functions have been found generally
       useful and they are listed below.  The behaviour of these functions
       may vary slightly from those defined by ANSI, and these deviations
       are noted in the text.
     </para>

     <sect1><title>String Conversions</title>
<!-- lib/vsprintf.c -->
<refentry id="API-simple-strtoll">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>simple_strtoll</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>simple_strtoll</refname>
 <refpurpose>
  convert a string to a signed long long
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>long long <function>simple_strtoll </function></funcdef>
   <paramdef>const char * <parameter>cp</parameter></paramdef>
   <paramdef>char ** <parameter>endp</parameter></paramdef>
   <paramdef>unsigned int <parameter>base</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cp</parameter></term>
   <listitem>
    <para>
     The start of the string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>endp</parameter></term>
   <listitem>
    <para>
     A pointer to the end of the parsed string will be placed here
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>base</parameter></term>
   <listitem>
    <para>
     The number base to use
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<!-- lib/vsprintf.c -->
<refentry id="API-simple-strtoul">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>simple_strtoul</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>simple_strtoul</refname>
 <refpurpose>
  convert a string to an unsigned long
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>simple_strtoul </function></funcdef>
   <paramdef>const char * <parameter>cp</parameter></paramdef>
   <paramdef>char ** <parameter>endp</parameter></paramdef>
   <paramdef>unsigned int <parameter>base</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cp</parameter></term>
   <listitem>
    <para>
     The start of the string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>endp</parameter></term>
   <listitem>
    <para>
     A pointer to the end of the parsed string will be placed here
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>base</parameter></term>
   <listitem>
    <para>
     The number base to use
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-simple-strtol">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>simple_strtol</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>simple_strtol</refname>
 <refpurpose>
     convert a string to a signed long
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>long <function>simple_strtol </function></funcdef>
   <paramdef>const char * <parameter>cp</parameter></paramdef>
   <paramdef>char ** <parameter>endp</parameter></paramdef>
   <paramdef>unsigned int <parameter>base</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cp</parameter></term>
   <listitem>
    <para>
     The start of the string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>endp</parameter></term>
   <listitem>
    <para>
     A pointer to the end of the parsed string will be placed here
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>base</parameter></term>
   <listitem>
    <para>
     The number base to use
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-simple-strtoull">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>simple_strtoull</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>simple_strtoull</refname>
 <refpurpose>
     convert a string to an unsigned long long
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long long <function>simple_strtoull </function></funcdef>
   <paramdef>const char * <parameter>cp</parameter></paramdef>
   <paramdef>char ** <parameter>endp</parameter></paramdef>
   <paramdef>unsigned int <parameter>base</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cp</parameter></term>
   <listitem>
    <para>
     The start of the string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>endp</parameter></term>
   <listitem>
    <para>
     A pointer to the end of the parsed string will be placed here
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>base</parameter></term>
   <listitem>
    <para>
     The number base to use
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strict-strtoul">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strict_strtoul</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strict_strtoul</refname>
 <refpurpose>
     convert a string to an unsigned long strictly
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>strict_strtoul </function></funcdef>
   <paramdef>const char * <parameter>cp</parameter></paramdef>
   <paramdef>unsigned int <parameter>base</parameter></paramdef>
   <paramdef>unsigned long * <parameter>res</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cp</parameter></term>
   <listitem>
    <para>
     The string to be converted
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>base</parameter></term>
   <listitem>
    <para>
     The number base to use
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>res</parameter></term>
   <listitem>
    <para>
     The converted result value
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   strict_strtoul converts a string to an unsigned long only if the
   string is really an unsigned long string, any string containing
   any invalid char at the tail will be rejected and -EINVAL is returned,
   only a newline char at the tail is acceptible because people generally
</para>
</refsect1>
<refsect1>
<title>change a module parameter in the following way</title>
<para>
   </para><para>

   echo 1024 &gt; /sys/module/e1000/parameters/copybreak
   </para><para>

   echo will append a newline to the tail.
   </para><para>

   It returns 0 if conversion is successful and *res is set to the converted
   value, otherwise it returns -EINVAL and *res is set to 0.
   </para><para>

   simple_strtoul just ignores the successive invalid characters and
   return the converted value of prefix part of the string.
</para>
</refsect1>
</refentry>

<refentry id="API-strict-strtol">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strict_strtol</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strict_strtol</refname>
 <refpurpose>
     convert a string to a long strictly
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>strict_strtol </function></funcdef>
   <paramdef>const char * <parameter>cp</parameter></paramdef>
   <paramdef>unsigned int <parameter>base</parameter></paramdef>
   <paramdef>long * <parameter>res</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cp</parameter></term>
   <listitem>
    <para>
     The string to be converted
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>base</parameter></term>
   <listitem>
    <para>
     The number base to use
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>res</parameter></term>
   <listitem>
    <para>
     The converted result value
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   strict_strtol is similiar to strict_strtoul, but it allows the first
   character of a string is '-'.
   </para><para>

   It returns 0 if conversion is successful and *res is set to the converted
   value, otherwise it returns -EINVAL and *res is set to 0.
</para>
</refsect1>
</refentry>

<refentry id="API-strict-strtoull">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strict_strtoull</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strict_strtoull</refname>
 <refpurpose>
     convert a string to an unsigned long long strictly
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>strict_strtoull </function></funcdef>
   <paramdef>const char * <parameter>cp</parameter></paramdef>
   <paramdef>unsigned int <parameter>base</parameter></paramdef>
   <paramdef>unsigned long long * <parameter>res</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cp</parameter></term>
   <listitem>
    <para>
     The string to be converted
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>base</parameter></term>
   <listitem>
    <para>
     The number base to use
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>res</parameter></term>
   <listitem>
    <para>
     The converted result value
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   strict_strtoull converts a string to an unsigned long long only if the
   string is really an unsigned long long string, any string containing
   any invalid char at the tail will be rejected and -EINVAL is returned,
   only a newline char at the tail is acceptible because people generally
</para>
</refsect1>
<refsect1>
<title>change a module parameter in the following way</title>
<para>
   </para><para>

   echo 1024 &gt; /sys/module/e1000/parameters/copybreak
   </para><para>

   echo will append a newline to the tail of the string.
   </para><para>

   It returns 0 if conversion is successful and *res is set to the converted
   value, otherwise it returns -EINVAL and *res is set to 0.
   </para><para>

   simple_strtoull just ignores the successive invalid characters and
   return the converted value of prefix part of the string.
</para>
</refsect1>
</refentry>

<refentry id="API-strict-strtoll">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strict_strtoll</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strict_strtoll</refname>
 <refpurpose>
     convert a string to a long long strictly
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>strict_strtoll </function></funcdef>
   <paramdef>const char * <parameter>cp</parameter></paramdef>
   <paramdef>unsigned int <parameter>base</parameter></paramdef>
   <paramdef>long long * <parameter>res</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cp</parameter></term>
   <listitem>
    <para>
     The string to be converted
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>base</parameter></term>
   <listitem>
    <para>
     The number base to use
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>res</parameter></term>
   <listitem>
    <para>
     The converted result value
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   strict_strtoll is similiar to strict_strtoull, but it allows the first
   character of a string is '-'.
   </para><para>

   It returns 0 if conversion is successful and *res is set to the converted
   value, otherwise it returns -EINVAL and *res is set to 0.
</para>
</refsect1>
</refentry>

<refentry id="API-vsnprintf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vsnprintf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vsnprintf</refname>
 <refpurpose>
     Format a string and place it in a buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>vsnprintf </function></funcdef>
   <paramdef>char * <parameter>buf</parameter></paramdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef>va_list <parameter>args</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     The buffer to place the result into
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     The size of the buffer, including the trailing null space
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     The format string to use
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     Arguments for the format string
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function follows C99 vsnprintf, but has some extensions:
   <constant>pS</constant> output the name of a text symbol with offset
   <constant>ps</constant> output the name of a text symbol without offset
   <constant>pF</constant> output the name of a function pointer with its offset
   <constant>pf</constant> output the name of a function pointer without its offset
   <constant>pR</constant> output the address range in a struct resource
   <constant>n</constant> is ignored
   </para><para>

   The return value is the number of characters which would
   be generated for the given input, excluding the trailing
   '\0', as per ISO C99. If you want to have the exact
   number of characters written into <parameter>buf</parameter> as return value
   (not including the trailing '\0'), use <function>vscnprintf</function>. If the
   return is greater than or equal to <parameter>size</parameter>, the resulting
   string is truncated.
   </para><para>

   Call this function if you are already dealing with a va_list.
   You probably want <function>snprintf</function> instead.
</para>
</refsect1>
</refentry>

<refentry id="API-vscnprintf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vscnprintf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vscnprintf</refname>
 <refpurpose>
     Format a string and place it in a buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>vscnprintf </function></funcdef>
   <paramdef>char * <parameter>buf</parameter></paramdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef>va_list <parameter>args</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     The buffer to place the result into
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     The size of the buffer, including the trailing null space
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     The format string to use
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     Arguments for the format string
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The return value is the number of characters which have been written into
   the <parameter>buf</parameter> not including the trailing '\0'. If <parameter>size</parameter> is &lt;= 0 the function
   returns 0.
   </para><para>

   Call this function if you are already dealing with a va_list.
   You probably want <function>scnprintf</function> instead.
   </para><para>

   See the <function>vsnprintf</function> documentation for format string extensions over C99.
</para>
</refsect1>
</refentry>

<refentry id="API-snprintf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>snprintf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>snprintf</refname>
 <refpurpose>
     Format a string and place it in a buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>snprintf </function></funcdef>
   <paramdef>char * <parameter>buf</parameter></paramdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef> <parameter>...</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     The buffer to place the result into
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     The size of the buffer, including the trailing null space
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     The format string to use
     @...: Arguments for the format string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>...</parameter></term>
   <listitem>
    <para>
     variable arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The return value is the number of characters which would be
   generated for the given input, excluding the trailing null,
   as per ISO C99.  If the return is greater than or equal to
   <parameter>size</parameter>, the resulting string is truncated.
   </para><para>

   See the <function>vsnprintf</function> documentation for format string extensions over C99.
</para>
</refsect1>
</refentry>

<refentry id="API-scnprintf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>scnprintf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>scnprintf</refname>
 <refpurpose>
     Format a string and place it in a buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>scnprintf </function></funcdef>
   <paramdef>char * <parameter>buf</parameter></paramdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef> <parameter>...</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     The buffer to place the result into
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     The size of the buffer, including the trailing null space
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     The format string to use
     @...: Arguments for the format string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>...</parameter></term>
   <listitem>
    <para>
     variable arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The return value is the number of characters written into <parameter>buf</parameter> not including
   the trailing '\0'. If <parameter>size</parameter> is &lt;= 0 the function returns 0.
</para>
</refsect1>
</refentry>

<refentry id="API-vsprintf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vsprintf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vsprintf</refname>
 <refpurpose>
     Format a string and place it in a buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>vsprintf </function></funcdef>
   <paramdef>char * <parameter>buf</parameter></paramdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef>va_list <parameter>args</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     The buffer to place the result into
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     The format string to use
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     Arguments for the format string
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The function returns the number of characters written
   into <parameter>buf</parameter>. Use <function>vsnprintf</function> or <function>vscnprintf</function> in order to avoid
   buffer overflows.
   </para><para>

   Call this function if you are already dealing with a va_list.
   You probably want <function>sprintf</function> instead.
   </para><para>

   See the <function>vsnprintf</function> documentation for format string extensions over C99.
</para>
</refsect1>
</refentry>

<refentry id="API-sprintf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>sprintf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>sprintf</refname>
 <refpurpose>
     Format a string and place it in a buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>sprintf </function></funcdef>
   <paramdef>char * <parameter>buf</parameter></paramdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef> <parameter>...</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     The buffer to place the result into
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     The format string to use
     @...: Arguments for the format string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>...</parameter></term>
   <listitem>
    <para>
     variable arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The function returns the number of characters written
   into <parameter>buf</parameter>. Use <function>snprintf</function> or <function>scnprintf</function> in order to avoid
   buffer overflows.
   </para><para>

   See the <function>vsnprintf</function> documentation for format string extensions over C99.
</para>
</refsect1>
</refentry>

<refentry id="API-vbin-printf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vbin_printf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vbin_printf</refname>
 <refpurpose>
     Parse a format string and place args' binary value in a buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>vbin_printf </function></funcdef>
   <paramdef>u32 * <parameter>bin_buf</parameter></paramdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef>va_list <parameter>args</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>bin_buf</parameter></term>
   <listitem>
    <para>
     The buffer to place args' binary value
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     The size of the buffer(by words(32bits), not characters)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     The format string to use
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     Arguments for the format string
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The format follows C99 vsnprintf, except <constant>n</constant> is ignored, and its argument
   is skiped.
   </para><para>

   The return value is the number of words(32bits) which would be generated for
   the given input.
</para>
</refsect1>
<refsect1>
<title>NOTE</title>
<para>
   If the return value is greater than <parameter>size</parameter>, the resulting bin_buf is NOT
   valid for <function>bstr_printf</function>.
</para>
</refsect1>
</refentry>

<refentry id="API-bstr-printf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bstr_printf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bstr_printf</refname>
 <refpurpose>
     Format a string from binary arguments and place it in a buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>bstr_printf </function></funcdef>
   <paramdef>char * <parameter>buf</parameter></paramdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef>const u32 * <parameter>bin_buf</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     The buffer to place the result into
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     The size of the buffer, including the trailing null space
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     The format string to use
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>bin_buf</parameter></term>
   <listitem>
    <para>
     Binary arguments for the format string
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function like C99 vsnprintf, but the difference is that vsnprintf gets
   arguments from stack, and bstr_printf gets arguments from <parameter>bin_buf</parameter> which is
   a binary buffer that generated by vbin_printf.
   </para><para>

   The format follows C99 vsnprintf, but has some extensions:
   see vsnprintf comment for details.
   </para><para>

   The return value is the number of characters which would
   be generated for the given input, excluding the trailing
   '\0', as per ISO C99. If you want to have the exact
   number of characters written into <parameter>buf</parameter> as return value
   (not including the trailing '\0'), use <function>vscnprintf</function>. If the
   return is greater than or equal to <parameter>size</parameter>, the resulting
   string is truncated.
</para>
</refsect1>
</refentry>

<refentry id="API-bprintf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bprintf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bprintf</refname>
 <refpurpose>
     Parse a format string and place args' binary value in a buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>bprintf </function></funcdef>
   <paramdef>u32 * <parameter>bin_buf</parameter></paramdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef> <parameter>...</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>bin_buf</parameter></term>
   <listitem>
    <para>
     The buffer to place args' binary value
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     The size of the buffer(by words(32bits), not characters)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     The format string to use
     @...: Arguments for the format string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>...</parameter></term>
   <listitem>
    <para>
     variable arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The function returns the number of words(u32) written
   into <parameter>bin_buf</parameter>.
</para>
</refsect1>
</refentry>

<refentry id="API-vsscanf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vsscanf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vsscanf</refname>
 <refpurpose>
     Unformat a buffer into a list of arguments
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>vsscanf </function></funcdef>
   <paramdef>const char * <parameter>buf</parameter></paramdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef>va_list <parameter>args</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     input buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     format of buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-sscanf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>sscanf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>sscanf</refname>
 <refpurpose>
     Unformat a buffer into a list of arguments
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>sscanf </function></funcdef>
   <paramdef>const char * <parameter>buf</parameter></paramdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef> <parameter>...</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     input buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     formatting of buffer
     @...:	resulting arguments
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>...</parameter></term>
   <listitem>
    <para>
     variable arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

     </sect1>
     <sect1><title>String Manipulation</title>
<!-- All functions are exported at now
X!Ilib/string.c
 -->
<!-- lib/string.c -->
<refentry id="API-strnicmp">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strnicmp</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strnicmp</refname>
 <refpurpose>
  Case insensitive, length-limited string comparison
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>strnicmp </function></funcdef>
   <paramdef>const char * <parameter>s1</parameter></paramdef>
   <paramdef>const char * <parameter>s2</parameter></paramdef>
   <paramdef>size_t <parameter>len</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s1</parameter></term>
   <listitem>
    <para>
     One string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>s2</parameter></term>
   <listitem>
    <para>
     The other string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     the maximum number of characters to compare
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strcpy">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strcpy</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strcpy</refname>
 <refpurpose>
     Copy a <constant>NUL</constant> terminated string
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>char * <function>strcpy </function></funcdef>
   <paramdef>char * <parameter>dest</parameter></paramdef>
   <paramdef>const char * <parameter>src</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dest</parameter></term>
   <listitem>
    <para>
     Where to copy the string to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     Where to copy the string from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strncpy">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strncpy</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strncpy</refname>
 <refpurpose>
     Copy a length-limited, <constant>NUL-terminated</constant> string
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>char * <function>strncpy </function></funcdef>
   <paramdef>char * <parameter>dest</parameter></paramdef>
   <paramdef>const char * <parameter>src</parameter></paramdef>
   <paramdef>size_t <parameter>count</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dest</parameter></term>
   <listitem>
    <para>
     Where to copy the string to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     Where to copy the string from
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     The maximum number of bytes to copy
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The result is not <constant>NUL-terminated</constant> if the source exceeds
   <parameter>count</parameter> bytes.
   </para><para>

   In the case where the length of <parameter>src</parameter> is less than  that  of
   count, the remainder of <parameter>dest</parameter> will be padded with <constant>NUL</constant>.
</para>
</refsect1>
</refentry>

<refentry id="API-strlcpy">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strlcpy</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strlcpy</refname>
 <refpurpose>
     Copy a <constant>NUL</constant> terminated string into a sized buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>size_t <function>strlcpy </function></funcdef>
   <paramdef>char * <parameter>dest</parameter></paramdef>
   <paramdef>const char * <parameter>src</parameter></paramdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dest</parameter></term>
   <listitem>
    <para>
     Where to copy the string to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     Where to copy the string from
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     size of destination buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>BSD</title>
<para>
   the result is always a valid
   NUL-terminated string that fits in the buffer (unless,
   of course, the buffer size is zero). It does not pad
   out the result like <function>strncpy</function> does.
</para>
</refsect1>
</refentry>

<refentry id="API-strcat">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strcat</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strcat</refname>
 <refpurpose>
     Append one <constant>NUL-terminated</constant> string to another
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>char * <function>strcat </function></funcdef>
   <paramdef>char * <parameter>dest</parameter></paramdef>
   <paramdef>const char * <parameter>src</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dest</parameter></term>
   <listitem>
    <para>
     The string to be appended to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     The string to append to it
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strncat">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strncat</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strncat</refname>
 <refpurpose>
     Append a length-limited, <constant>NUL-terminated</constant> string to another
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>char * <function>strncat </function></funcdef>
   <paramdef>char * <parameter>dest</parameter></paramdef>
   <paramdef>const char * <parameter>src</parameter></paramdef>
   <paramdef>size_t <parameter>count</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dest</parameter></term>
   <listitem>
    <para>
     The string to be appended to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     The string to append to it
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     The maximum numbers of bytes to copy
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Note that in contrast to <function>strncpy</function>, <function>strncat</function> ensures the result is
   terminated.
</para>
</refsect1>
</refentry>

<refentry id="API-strlcat">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strlcat</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strlcat</refname>
 <refpurpose>
     Append a length-limited, <constant>NUL-terminated</constant> string to another
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>size_t <function>strlcat </function></funcdef>
   <paramdef>char * <parameter>dest</parameter></paramdef>
   <paramdef>const char * <parameter>src</parameter></paramdef>
   <paramdef>size_t <parameter>count</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dest</parameter></term>
   <listitem>
    <para>
     The string to be appended to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     The string to append to it
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     The size of the destination buffer.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strcmp">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strcmp</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strcmp</refname>
 <refpurpose>
     Compare two strings
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>strcmp </function></funcdef>
   <paramdef>const char * <parameter>cs</parameter></paramdef>
   <paramdef>const char * <parameter>ct</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cs</parameter></term>
   <listitem>
    <para>
     One string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ct</parameter></term>
   <listitem>
    <para>
     Another string
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strncmp">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strncmp</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strncmp</refname>
 <refpurpose>
     Compare two length-limited strings
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>strncmp </function></funcdef>
   <paramdef>const char * <parameter>cs</parameter></paramdef>
   <paramdef>const char * <parameter>ct</parameter></paramdef>
   <paramdef>size_t <parameter>count</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cs</parameter></term>
   <listitem>
    <para>
     One string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ct</parameter></term>
   <listitem>
    <para>
     Another string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     The maximum number of bytes to compare
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strchr">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strchr</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strchr</refname>
 <refpurpose>
     Find the first occurrence of a character in a string
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>char * <function>strchr </function></funcdef>
   <paramdef>const char * <parameter>s</parameter></paramdef>
   <paramdef>int <parameter>c</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     The string to be searched
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>c</parameter></term>
   <listitem>
    <para>
     The character to search for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strrchr">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strrchr</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strrchr</refname>
 <refpurpose>
     Find the last occurrence of a character in a string
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>char * <function>strrchr </function></funcdef>
   <paramdef>const char * <parameter>s</parameter></paramdef>
   <paramdef>int <parameter>c</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     The string to be searched
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>c</parameter></term>
   <listitem>
    <para>
     The character to search for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strnchr">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strnchr</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strnchr</refname>
 <refpurpose>
     Find a character in a length limited string
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>char * <function>strnchr </function></funcdef>
   <paramdef>const char * <parameter>s</parameter></paramdef>
   <paramdef>size_t <parameter>count</parameter></paramdef>
   <paramdef>int <parameter>c</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     The string to be searched
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     The number of characters to be searched
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>c</parameter></term>
   <listitem>
    <para>
     The character to search for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strstrip">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strstrip</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strstrip</refname>
 <refpurpose>
     Removes leading and trailing whitespace from <parameter>s</parameter>.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>char * <function>strstrip </function></funcdef>
   <paramdef>char * <parameter>s</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     The string to be stripped.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Note that the first trailing whitespace is replaced with a <constant>NUL-terminator</constant>
   in the given string <parameter>s</parameter>. Returns a pointer to the first non-whitespace
   character in <parameter>s</parameter>.
</para>
</refsect1>
</refentry>

<refentry id="API-strlen">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strlen</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strlen</refname>
 <refpurpose>
     Find the length of a string
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>size_t <function>strlen </function></funcdef>
   <paramdef>const char * <parameter>s</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     The string to be sized
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strnlen">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strnlen</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strnlen</refname>
 <refpurpose>
     Find the length of a length-limited string
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>size_t <function>strnlen </function></funcdef>
   <paramdef>const char * <parameter>s</parameter></paramdef>
   <paramdef>size_t <parameter>count</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     The string to be sized
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     The maximum number of bytes to search
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strspn">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strspn</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strspn</refname>
 <refpurpose>
     Calculate the length of the initial substring of <parameter>s</parameter> which only contain letters in <parameter>accept</parameter>
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>size_t <function>strspn </function></funcdef>
   <paramdef>const char * <parameter>s</parameter></paramdef>
   <paramdef>const char * <parameter>accept</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     The string to be searched
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>accept</parameter></term>
   <listitem>
    <para>
     The string to search for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strcspn">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strcspn</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strcspn</refname>
 <refpurpose>
     Calculate the length of the initial substring of <parameter>s</parameter> which does not contain letters in <parameter>reject</parameter>
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>size_t <function>strcspn </function></funcdef>
   <paramdef>const char * <parameter>s</parameter></paramdef>
   <paramdef>const char * <parameter>reject</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     The string to be searched
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>reject</parameter></term>
   <listitem>
    <para>
     The string to avoid
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strpbrk">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strpbrk</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strpbrk</refname>
 <refpurpose>
     Find the first occurrence of a set of characters
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>char * <function>strpbrk </function></funcdef>
   <paramdef>const char * <parameter>cs</parameter></paramdef>
   <paramdef>const char * <parameter>ct</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cs</parameter></term>
   <listitem>
    <para>
     The string to be searched
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ct</parameter></term>
   <listitem>
    <para>
     The characters to search for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-strsep">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strsep</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strsep</refname>
 <refpurpose>
     Split a string into tokens
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>char * <function>strsep </function></funcdef>
   <paramdef>char ** <parameter>s</parameter></paramdef>
   <paramdef>const char * <parameter>ct</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     The string to be searched
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ct</parameter></term>
   <listitem>
    <para>
     The characters to search for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   <function>strsep</function> updates <parameter>s</parameter> to point after the token, ready for the next call.
   </para><para>

   It returns empty tokens, too, behaving exactly like the libc function
   of that name. In fact, it was stolen from glibc2 and de-fancy-fied.
   Same semantics, slimmer shape. ;)
</para>
</refsect1>
</refentry>

<refentry id="API-sysfs-streq">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>sysfs_streq</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>sysfs_streq</refname>
 <refpurpose>
     return true if strings are equal, modulo trailing newline
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>bool <function>sysfs_streq </function></funcdef>
   <paramdef>const char * <parameter>s1</parameter></paramdef>
   <paramdef>const char * <parameter>s2</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s1</parameter></term>
   <listitem>
    <para>
     one string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>s2</parameter></term>
   <listitem>
    <para>
     another string
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This routine returns true iff two strings are equal, treating both
   NUL and newline-then-NUL as equivalent string terminations.  It's
   geared for use with sysfs input strings, which generally terminate
   with newlines but are compared against values without newlines.
</para>
</refsect1>
</refentry>

<refentry id="API-memset">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>memset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>memset</refname>
 <refpurpose>
     Fill a region of memory with the given value
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>memset </function></funcdef>
   <paramdef>void * <parameter>s</parameter></paramdef>
   <paramdef>int <parameter>c</parameter></paramdef>
   <paramdef>size_t <parameter>count</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     Pointer to the start of the area.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>c</parameter></term>
   <listitem>
    <para>
     The byte to fill the area with
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     The size of the area.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Do not use <function>memset</function> to access IO space, use <function>memset_io</function> instead.
</para>
</refsect1>
</refentry>

<refentry id="API-memcpy">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>memcpy</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>memcpy</refname>
 <refpurpose>
     Copy one area of memory to another
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>memcpy </function></funcdef>
   <paramdef>void * <parameter>dest</parameter></paramdef>
   <paramdef>const void * <parameter>src</parameter></paramdef>
   <paramdef>size_t <parameter>count</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dest</parameter></term>
   <listitem>
    <para>
     Where to copy to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     Where to copy from
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     The size of the area.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   You should not use this function to access IO space, use <function>memcpy_toio</function>
   or <function>memcpy_fromio</function> instead.
</para>
</refsect1>
</refentry>

<refentry id="API-memmove">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>memmove</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>memmove</refname>
 <refpurpose>
     Copy one area of memory to another
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>memmove </function></funcdef>
   <paramdef>void * <parameter>dest</parameter></paramdef>
   <paramdef>const void * <parameter>src</parameter></paramdef>
   <paramdef>size_t <parameter>count</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dest</parameter></term>
   <listitem>
    <para>
     Where to copy to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     Where to copy from
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     The size of the area.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Unlike <function>memcpy</function>, <function>memmove</function> copes with overlapping areas.
</para>
</refsect1>
</refentry>

<refentry id="API-memcmp">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>memcmp</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>memcmp</refname>
 <refpurpose>
     Compare two areas of memory
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>memcmp </function></funcdef>
   <paramdef>const void * <parameter>cs</parameter></paramdef>
   <paramdef>const void * <parameter>ct</parameter></paramdef>
   <paramdef>size_t <parameter>count</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cs</parameter></term>
   <listitem>
    <para>
     One area of memory
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ct</parameter></term>
   <listitem>
    <para>
     Another area of memory
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     The size of the area.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-memscan">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>memscan</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>memscan</refname>
 <refpurpose>
     Find a character in an area of memory.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>memscan </function></funcdef>
   <paramdef>void * <parameter>addr</parameter></paramdef>
   <paramdef>int <parameter>c</parameter></paramdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     The memory area
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>c</parameter></term>
   <listitem>
    <para>
     The byte to search for
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     The size of the area.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   returns the address of the first occurrence of <parameter>c</parameter>, or 1 byte past
   the area if <parameter>c</parameter> is not found
</para>
</refsect1>
</refentry>

<refentry id="API-strstr">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strstr</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strstr</refname>
 <refpurpose>
     Find the first substring in a <constant>NUL</constant> terminated string
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>char * <function>strstr </function></funcdef>
   <paramdef>const char * <parameter>s1</parameter></paramdef>
   <paramdef>const char * <parameter>s2</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s1</parameter></term>
   <listitem>
    <para>
     The string to be searched
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>s2</parameter></term>
   <listitem>
    <para>
     The string to search for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-memchr">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>memchr</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>memchr</refname>
 <refpurpose>
     Find a character in an area of memory.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>memchr </function></funcdef>
   <paramdef>const void * <parameter>s</parameter></paramdef>
   <paramdef>int <parameter>c</parameter></paramdef>
   <paramdef>size_t <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     The memory area
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>c</parameter></term>
   <listitem>
    <para>
     The byte to search for
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     The size of the area.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   returns the address of the first occurrence of <parameter>c</parameter>, or <constant>NULL</constant>
   if <parameter>c</parameter> is not found
</para>
</refsect1>
</refentry>

     </sect1>
     <sect1><title>Bit Operations</title>
<!-- arch/x86/include/asm/bitops.h -->
<refentry id="API-set-bit">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>set_bit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>set_bit</refname>
 <refpurpose>
  Atomically set a bit in memory
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>set_bit </function></funcdef>
   <paramdef>unsigned int <parameter>nr</parameter></paramdef>
   <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nr</parameter></term>
   <listitem>
    <para>
     the bit to set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     the address to start counting from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function is atomic and may not be reordered.  See <function>__set_bit</function>
   if you do not require the atomic guarantees.
</para>
</refsect1>
<refsect1>
<title>Note</title>
<para>
   there are no guarantees that this function will not be reordered
   on non x86 architectures, so if you are writing portable code,
   make sure not to rely on its reordering guarantees.
   </para><para>

   Note that <parameter>nr</parameter> may be almost arbitrarily large; this function is not
   restricted to acting on a single-word quantity.
</para>
</refsect1>
</refentry>

<refentry id="API---set-bit">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__set_bit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__set_bit</refname>
 <refpurpose>
     Set a bit in memory
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>__set_bit </function></funcdef>
   <paramdef>int <parameter>nr</parameter></paramdef>
   <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nr</parameter></term>
   <listitem>
    <para>
     the bit to set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     the address to start counting from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Unlike <function>set_bit</function>, this function is non-atomic and may be reordered.
   If it's called on the same region of memory simultaneously, the effect
   may be that only one operation succeeds.
</para>
</refsect1>
</refentry>

<refentry id="API-clear-bit">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>clear_bit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>clear_bit</refname>
 <refpurpose>
     Clears a bit in memory
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>clear_bit </function></funcdef>
   <paramdef>int <parameter>nr</parameter></paramdef>
   <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nr</parameter></term>
   <listitem>
    <para>
     Bit to clear
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     Address to start counting from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   <function>clear_bit</function> is atomic and may not be reordered.  However, it does
   not contain a memory barrier, so if it is used for locking purposes,
   you should call <function>smp_mb__before_clear_bit</function> and/or <function>smp_mb__after_clear_bit</function>
   in order to ensure changes are visible on other processors.
</para>
</refsect1>
</refentry>

<refentry id="API---change-bit">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__change_bit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__change_bit</refname>
 <refpurpose>
     Toggle a bit in memory
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>__change_bit </function></funcdef>
   <paramdef>int <parameter>nr</parameter></paramdef>
   <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nr</parameter></term>
   <listitem>
    <para>
     the bit to change
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     the address to start counting from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Unlike <function>change_bit</function>, this function is non-atomic and may be reordered.
   If it's called on the same region of memory simultaneously, the effect
   may be that only one operation succeeds.
</para>
</refsect1>
</refentry>

<refentry id="API-change-bit">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>change_bit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>change_bit</refname>
 <refpurpose>
     Toggle a bit in memory
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>change_bit </function></funcdef>
   <paramdef>int <parameter>nr</parameter></paramdef>
   <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nr</parameter></term>
   <listitem>
    <para>
     Bit to change
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     Address to start counting from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   <function>change_bit</function> is atomic and may not be reordered.
   Note that <parameter>nr</parameter> may be almost arbitrarily large; this function is not
   restricted to acting on a single-word quantity.
</para>
</refsect1>
</refentry>

<refentry id="API-test-and-set-bit">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>test_and_set_bit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>test_and_set_bit</refname>
 <refpurpose>
     Set a bit and return its old value
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>test_and_set_bit </function></funcdef>
   <paramdef>int <parameter>nr</parameter></paramdef>
   <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nr</parameter></term>
   <listitem>
    <para>
     Bit to set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     Address to count from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This operation is atomic and cannot be reordered.
   It also implies a memory barrier.
</para>
</refsect1>
</refentry>

<refentry id="API-test-and-set-bit-lock">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>test_and_set_bit_lock</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>test_and_set_bit_lock</refname>
 <refpurpose>
     Set a bit and return its old value for lock
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>test_and_set_bit_lock </function></funcdef>
   <paramdef>int <parameter>nr</parameter></paramdef>
   <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nr</parameter></term>
   <listitem>
    <para>
     Bit to set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     Address to count from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This is the same as test_and_set_bit on x86.
</para>
</refsect1>
</refentry>

<refentry id="API---test-and-set-bit">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__test_and_set_bit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__test_and_set_bit</refname>
 <refpurpose>
     Set a bit and return its old value
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>__test_and_set_bit </function></funcdef>
   <paramdef>int <parameter>nr</parameter></paramdef>
   <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nr</parameter></term>
   <listitem>
    <para>
     Bit to set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     Address to count from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This operation is non-atomic and can be reordered.
   If two examples of this operation race, one can appear to succeed
   but actually fail.  You must protect multiple accesses with a lock.
</para>
</refsect1>
</refentry>

<refentry id="API-test-and-clear-bit">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>test_and_clear_bit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>test_and_clear_bit</refname>
 <refpurpose>
     Clear a bit and return its old value
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>test_and_clear_bit </function></funcdef>
   <paramdef>int <parameter>nr</parameter></paramdef>
   <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nr</parameter></term>
   <listitem>
    <para>
     Bit to clear
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     Address to count from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This operation is atomic and cannot be reordered.
   It also implies a memory barrier.
</para>
</refsect1>
</refentry>

<refentry id="API---test-and-clear-bit">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__test_and_clear_bit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__test_and_clear_bit</refname>
 <refpurpose>
     Clear a bit and return its old value
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>__test_and_clear_bit </function></funcdef>
   <paramdef>int <parameter>nr</parameter></paramdef>
   <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nr</parameter></term>
   <listitem>
    <para>
     Bit to clear
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     Address to count from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This operation is non-atomic and can be reordered.
   If two examples of this operation race, one can appear to succeed
   but actually fail.  You must protect multiple accesses with a lock.
</para>
</refsect1>
</refentry>

<refentry id="API-test-and-change-bit">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>test_and_change_bit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>test_and_change_bit</refname>
 <refpurpose>
     Change a bit and return its old value
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>test_and_change_bit </function></funcdef>
   <paramdef>int <parameter>nr</parameter></paramdef>
   <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nr</parameter></term>
   <listitem>
    <para>
     Bit to change
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     Address to count from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This operation is atomic and cannot be reordered.
   It also implies a memory barrier.
</para>
</refsect1>
</refentry>

<refentry id="API-test-bit">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>test_bit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>test_bit</refname>
 <refpurpose>
     Determine whether a bit is set
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>test_bit </function></funcdef>
   <paramdef>int <parameter>nr</parameter></paramdef>
   <paramdef>const volatile unsigned long * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nr</parameter></term>
   <listitem>
    <para>
     bit number to test
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     Address to start counting from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API---ffs">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__ffs</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__ffs</refname>
 <refpurpose>
     find first set bit in word
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>__ffs </function></funcdef>
   <paramdef>unsigned long <parameter>word</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>word</parameter></term>
   <listitem>
    <para>
     The word to search
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Undefined if no bit exists, so code should check against 0 first.
</para>
</refsect1>
</refentry>

<refentry id="API-ffz">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ffz</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ffz</refname>
 <refpurpose>
     find first zero bit in word
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>ffz </function></funcdef>
   <paramdef>unsigned long <parameter>word</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>word</parameter></term>
   <listitem>
    <para>
     The word to search
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Undefined if no zero exists, so code should check against ~0UL first.
</para>
</refsect1>
</refentry>

<refentry id="API-ffs">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ffs</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ffs</refname>
 <refpurpose>
     find first set bit in word
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ffs </function></funcdef>
   <paramdef>int <parameter>x</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>x</parameter></term>
   <listitem>
    <para>
     the word to search
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This is defined the same way as the libc and compiler builtin ffs
   routines, therefore differs in spirit from the other bitops.
   </para><para>

   ffs(value) returns 0 if value is 0 or the position of the first
   set bit if value is nonzero. The first (least significant) bit
   is at position 1.
</para>
</refsect1>
</refentry>

<refentry id="API-fls">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>fls</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>fls</refname>
 <refpurpose>
     find last set bit in word
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>fls </function></funcdef>
   <paramdef>int <parameter>x</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>x</parameter></term>
   <listitem>
    <para>
     the word to search
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This is defined in a similar way as the libc and compiler builtin
   ffs, but returns the position of the most significant set bit.
   </para><para>

   fls(value) returns 0 if value is 0 or the position of the last
   set bit if value is nonzero. The last (most significant) bit is
   at position 32.
</para>
</refsect1>
</refentry>

     </sect1>
  </chapter>

  <chapter id="kernel-lib">
     <title>Basic Kernel Library Functions</title>

     <para>
       The Linux kernel provides more basic utility functions.
     </para>

     <sect1><title>Bitmap Operations</title>
<!-- lib/bitmap.c -->
<refentry id="API---bitmap-shift-right">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__bitmap_shift_right</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__bitmap_shift_right</refname>
 <refpurpose>
  logical right shift of the bits in a bitmap
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>__bitmap_shift_right </function></funcdef>
   <paramdef>unsigned long * <parameter>dst</parameter></paramdef>
   <paramdef>const unsigned long * <parameter>src</parameter></paramdef>
   <paramdef>int <parameter>shift</parameter></paramdef>
   <paramdef>int <parameter>bits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dst</parameter></term>
   <listitem>
    <para>
     destination bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     source bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>shift</parameter></term>
   <listitem>
    <para>
     shift by this many bits
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>bits</parameter></term>
   <listitem>
    <para>
     bitmap size, in bits
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Shifting right (dividing) means moving bits in the MS -&gt; LS bit
   direction.  Zeros are fed into the vacated MS positions and the
   LS bits shifted off the bottom are lost.
</para>
</refsect1>
</refentry>

<refentry id="API---bitmap-shift-left">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__bitmap_shift_left</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__bitmap_shift_left</refname>
 <refpurpose>
     logical left shift of the bits in a bitmap
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>__bitmap_shift_left </function></funcdef>
   <paramdef>unsigned long * <parameter>dst</parameter></paramdef>
   <paramdef>const unsigned long * <parameter>src</parameter></paramdef>
   <paramdef>int <parameter>shift</parameter></paramdef>
   <paramdef>int <parameter>bits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dst</parameter></term>
   <listitem>
    <para>
     destination bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     source bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>shift</parameter></term>
   <listitem>
    <para>
     shift by this many bits
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>bits</parameter></term>
   <listitem>
    <para>
     bitmap size, in bits
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Shifting left (multiplying) means moving bits in the LS -&gt; MS
   direction.  Zeros are fed into the vacated LS bit positions
   and those MS bits shifted off the top are lost.
</para>
</refsect1>
</refentry>

<refentry id="API-bitmap-scnprintf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_scnprintf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_scnprintf</refname>
 <refpurpose>
     convert bitmap to an ASCII hex string.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>bitmap_scnprintf </function></funcdef>
   <paramdef>char * <parameter>buf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
   <paramdef>const unsigned long * <parameter>maskp</parameter></paramdef>
   <paramdef>int <parameter>nmaskbits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     byte buffer into which string is placed
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     reserved size of <parameter>buf</parameter>, in bytes
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>maskp</parameter></term>
   <listitem>
    <para>
     pointer to bitmap to convert
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nmaskbits</parameter></term>
   <listitem>
    <para>
     size of bitmap, in bits
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Exactly <parameter>nmaskbits</parameter> bits are displayed.  Hex digits are grouped into
   comma-separated sets of eight digits per set.
</para>
</refsect1>
</refentry>

<refentry id="API---bitmap-parse">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__bitmap_parse</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__bitmap_parse</refname>
 <refpurpose>
     convert an ASCII hex string into a bitmap.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>__bitmap_parse </function></funcdef>
   <paramdef>const char * <parameter>buf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
   <paramdef>int <parameter>is_user</parameter></paramdef>
   <paramdef>unsigned long * <parameter>maskp</parameter></paramdef>
   <paramdef>int <parameter>nmaskbits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     pointer to buffer containing string.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     buffer size in bytes.  If string is smaller than this
     then it must be terminated with a \0.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>is_user</parameter></term>
   <listitem>
    <para>
     location of buffer, 0 indicates kernel space
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>maskp</parameter></term>
   <listitem>
    <para>
     pointer to bitmap array that will contain result.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nmaskbits</parameter></term>
   <listitem>
    <para>
     size of bitmap, in bits.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Commas group hex digits into chunks.  Each chunk defines exactly 32
   bits of the resultant bitmask.  No chunk may specify a value larger
   than 32 bits (<constant>-EOVERFLOW</constant>), and if a chunk specifies a smaller value
   then leading 0-bits are prepended.  <constant>-EINVAL</constant> is returned for illegal
   characters and for grouping errors such as <quote>1,,5</quote>, <quote>,44</quote>, <quote>,</quote> and "".
   Leading and trailing whitespace accepted, but not embedded whitespace.
</para>
</refsect1>
</refentry>

<refentry id="API-bitmap-parse-user">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_parse_user</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_parse_user</refname>
 <refpurpose>
   </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>bitmap_parse_user </function></funcdef>
   <paramdef>const char __user * <parameter>ubuf</parameter></paramdef>
   <paramdef>unsigned int <parameter>ulen</parameter></paramdef>
   <paramdef>unsigned long * <parameter>maskp</parameter></paramdef>
   <paramdef>int <parameter>nmaskbits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ubuf</parameter></term>
   <listitem>
    <para>
     pointer to user buffer containing string.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ulen</parameter></term>
   <listitem>
    <para>
     buffer size in bytes.  If string is smaller than this
     then it must be terminated with a \0.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>maskp</parameter></term>
   <listitem>
    <para>
     pointer to bitmap array that will contain result.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nmaskbits</parameter></term>
   <listitem>
    <para>
     size of bitmap, in bits.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Wrapper for <function>__bitmap_parse</function>, providing it with user buffer.
   </para><para>

   We cannot have this as an inline function in bitmap.h because it needs
   linux/uaccess.h to get the <function>access_ok</function> declaration and this causes
   cyclic dependencies.
</para>
</refsect1>
</refentry>

<refentry id="API-bitmap-scnlistprintf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_scnlistprintf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_scnlistprintf</refname>
 <refpurpose>
     convert bitmap to list format ASCII string
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>bitmap_scnlistprintf </function></funcdef>
   <paramdef>char * <parameter>buf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
   <paramdef>const unsigned long * <parameter>maskp</parameter></paramdef>
   <paramdef>int <parameter>nmaskbits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     byte buffer into which string is placed
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     reserved size of <parameter>buf</parameter>, in bytes
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>maskp</parameter></term>
   <listitem>
    <para>
     pointer to bitmap to convert
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nmaskbits</parameter></term>
   <listitem>
    <para>
     size of bitmap, in bits
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Output format is a comma-separated list of decimal numbers and
   ranges.  Consecutively set bits are shown as two hyphen-separated
   decimal numbers, the smallest and largest bit numbers set in
   the range.  Output format is compatible with the format
   accepted as input by <function>bitmap_parselist</function>.
   </para><para>

   The return value is the number of characters which would be
   generated for the given input, excluding the trailing '\0', as
   per ISO C99.
</para>
</refsect1>
</refentry>

<refentry id="API-bitmap-parselist">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_parselist</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_parselist</refname>
 <refpurpose>
     convert list format ASCII string to bitmap
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>bitmap_parselist </function></funcdef>
   <paramdef>const char * <parameter>bp</parameter></paramdef>
   <paramdef>unsigned long * <parameter>maskp</parameter></paramdef>
   <paramdef>int <parameter>nmaskbits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>bp</parameter></term>
   <listitem>
    <para>
     read nul-terminated user string from this buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>maskp</parameter></term>
   <listitem>
    <para>
     write resulting mask here
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nmaskbits</parameter></term>
   <listitem>
    <para>
     number of bits in mask to be written
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Input format is a comma-separated list of decimal numbers and
   ranges.  Consecutively set bits are shown as two hyphen-separated
   decimal numbers, the smallest and largest bit numbers set in
   the range.
   </para><para>

   Returns 0 on success, -errno on invalid input strings.
</para>
</refsect1>
<refsect1>
<title>Error values</title>
<para>
   <constant>-EINVAL</constant>: second number in range smaller than first
   <constant>-EINVAL</constant>: invalid character in string
   <constant>-ERANGE</constant>: bit number specified too large for mask
</para>
</refsect1>
</refentry>

<refentry id="API-bitmap-remap">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_remap</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_remap</refname>
 <refpurpose>
     Apply map defined by a pair of bitmaps to another bitmap
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>bitmap_remap </function></funcdef>
   <paramdef>unsigned long * <parameter>dst</parameter></paramdef>
   <paramdef>const unsigned long * <parameter>src</parameter></paramdef>
   <paramdef>const unsigned long * <parameter>old</parameter></paramdef>
   <paramdef>const unsigned long * <parameter>new</parameter></paramdef>
   <paramdef>int <parameter>bits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dst</parameter></term>
   <listitem>
    <para>
     remapped result
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     subset to be remapped
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>old</parameter></term>
   <listitem>
    <para>
     defines domain of map
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     defines range of map
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>bits</parameter></term>
   <listitem>
    <para>
     number of bits in each of these bitmaps
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Let <parameter>old</parameter> and <parameter>new</parameter> define a mapping of bit positions, such that
   whatever position is held by the n-th set bit in <parameter>old</parameter> is mapped
   to the n-th set bit in <parameter>new</parameter>.  In the more general case, allowing
   for the possibility that the weight 'w' of <parameter>new</parameter> is less than the
   weight of <parameter>old</parameter>, map the position of the n-th set bit in <parameter>old</parameter> to
   the position of the m-th set bit in <parameter>new</parameter>, where m == n % w.
   </para><para>

   If either of the <parameter>old</parameter> and <parameter>new</parameter> bitmaps are empty, or if <parameter>src</parameter> and
   <parameter>dst</parameter> point to the same location, then this routine copies <parameter>src</parameter>
   to <parameter>dst</parameter>.
   </para><para>

   The positions of unset bits in <parameter>old</parameter> are mapped to themselves
   (the identify map).
   </para><para>

   Apply the above specified mapping to <parameter>src</parameter>, placing the result in
   <parameter>dst</parameter>, clearing any bits previously set in <parameter>dst</parameter>.
   </para><para>

   For example, lets say that <parameter>old</parameter> has bits 4 through 7 set, and
   <parameter>new</parameter> has bits 12 through 15 set.  This defines the mapping of bit
   position 4 to 12, 5 to 13, 6 to 14 and 7 to 15, and of all other
   bit positions unchanged.  So if say <parameter>src</parameter> comes into this routine
   with bits 1, 5 and 7 set, then <parameter>dst</parameter> should leave with bits 1,
   13 and 15 set.
</para>
</refsect1>
</refentry>

<refentry id="API-bitmap-bitremap">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_bitremap</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_bitremap</refname>
 <refpurpose>
     Apply map defined by a pair of bitmaps to a single bit
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>bitmap_bitremap </function></funcdef>
   <paramdef>int <parameter>oldbit</parameter></paramdef>
   <paramdef>const unsigned long * <parameter>old</parameter></paramdef>
   <paramdef>const unsigned long * <parameter>new</parameter></paramdef>
   <paramdef>int <parameter>bits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>oldbit</parameter></term>
   <listitem>
    <para>
     bit position to be mapped
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>old</parameter></term>
   <listitem>
    <para>
     defines domain of map
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     defines range of map
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>bits</parameter></term>
   <listitem>
    <para>
     number of bits in each of these bitmaps
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Let <parameter>old</parameter> and <parameter>new</parameter> define a mapping of bit positions, such that
   whatever position is held by the n-th set bit in <parameter>old</parameter> is mapped
   to the n-th set bit in <parameter>new</parameter>.  In the more general case, allowing
   for the possibility that the weight 'w' of <parameter>new</parameter> is less than the
   weight of <parameter>old</parameter>, map the position of the n-th set bit in <parameter>old</parameter> to
   the position of the m-th set bit in <parameter>new</parameter>, where m == n % w.
   </para><para>

   The positions of unset bits in <parameter>old</parameter> are mapped to themselves
   (the identify map).
   </para><para>

   Apply the above specified mapping to bit position <parameter>oldbit</parameter>, returning
   the new bit position.
   </para><para>

   For example, lets say that <parameter>old</parameter> has bits 4 through 7 set, and
   <parameter>new</parameter> has bits 12 through 15 set.  This defines the mapping of bit
   position 4 to 12, 5 to 13, 6 to 14 and 7 to 15, and of all other
   bit positions unchanged.  So if say <parameter>oldbit</parameter> is 5, then this routine
   returns 13.
</para>
</refsect1>
</refentry>

<refentry id="API-bitmap-onto">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_onto</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_onto</refname>
 <refpurpose>
     translate one bitmap relative to another
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>bitmap_onto </function></funcdef>
   <paramdef>unsigned long * <parameter>dst</parameter></paramdef>
   <paramdef>const unsigned long * <parameter>orig</parameter></paramdef>
   <paramdef>const unsigned long * <parameter>relmap</parameter></paramdef>
   <paramdef>int <parameter>bits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dst</parameter></term>
   <listitem>
    <para>
     resulting translated bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>orig</parameter></term>
   <listitem>
    <para>
     original untranslated bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>relmap</parameter></term>
   <listitem>
    <para>
     bitmap relative to which translated
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>bits</parameter></term>
   <listitem>
    <para>
     number of bits in each of these bitmaps
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Set the n-th bit of <parameter>dst</parameter> iff there exists some m such that the
   n-th bit of <parameter>relmap</parameter> is set, the m-th bit of <parameter>orig</parameter> is set, and
   the n-th bit of <parameter>relmap</parameter> is also the m-th _set_ bit of <parameter>relmap</parameter>.
   (If you understood the previous sentence the first time your
   read it, you're overqualified for your current job.)
   </para><para>

   In other words, <parameter>orig</parameter> is mapped onto (surjectively) <parameter>dst</parameter>,
   using the the map { &lt;n, m&gt; | the n-th bit of <parameter>relmap</parameter> is the
   m-th set bit of <parameter>relmap</parameter> }.
   </para><para>

   Any set bits in <parameter>orig</parameter> above bit number W, where W is the
   weight of (number of set bits in) <parameter>relmap</parameter> are mapped nowhere.
   In particular, if for all bits m set in <parameter>orig</parameter>, m &gt;= W, then
   <parameter>dst</parameter> will end up empty.  In situations where the possibility
   of such an empty result is not desired, one way to avoid it is
   to use the <function>bitmap_fold</function> operator, below, to first fold the
   <parameter>orig</parameter> bitmap over itself so that all its set bits x are in the
   range 0 &lt;= x &lt; W.  The <function>bitmap_fold</function> operator does this by
   setting the bit (m % W) in <parameter>dst</parameter>, for each bit (m) set in <parameter>orig</parameter>.
   </para><para>

   Example [1] for <function>bitmap_onto</function>:
   Let's say <parameter>relmap</parameter> has bits 30-39 set, and <parameter>orig</parameter> has bits
   1, 3, 5, 7, 9 and 11 set.  Then on return from this routine,
   <parameter>dst</parameter> will have bits 31, 33, 35, 37 and 39 set.
   </para><para>

   When bit 0 is set in <parameter>orig</parameter>, it means turn on the bit in
   <parameter>dst</parameter> corresponding to whatever is the first bit (if any)
   that is turned on in <parameter>relmap</parameter>.  Since bit 0 was off in the
   above example, we leave off that bit (bit 30) in <parameter>dst</parameter>.
   </para><para>

   When bit 1 is set in <parameter>orig</parameter> (as in the above example), it
   means turn on the bit in <parameter>dst</parameter> corresponding to whatever
   is the second bit that is turned on in <parameter>relmap</parameter>.  The second
   bit in <parameter>relmap</parameter> that was turned on in the above example was
   bit 31, so we turned on bit 31 in <parameter>dst</parameter>.
   </para><para>

   Similarly, we turned on bits 33, 35, 37 and 39 in <parameter>dst</parameter>,
   because they were the 4th, 6th, 8th and 10th set bits
   set in <parameter>relmap</parameter>, and the 4th, 6th, 8th and 10th bits of
   <parameter>orig</parameter> (i.e. bits 3, 5, 7 and 9) were also set.
   </para><para>

   When bit 11 is set in <parameter>orig</parameter>, it means turn on the bit in
   <parameter>dst</parameter> corresponding to whatever is the twelth bit that is
   turned on in <parameter>relmap</parameter>.  In the above example, there were
   only ten bits turned on in <parameter>relmap</parameter> (30..39), so that bit
   11 was set in <parameter>orig</parameter> had no affect on <parameter>dst</parameter>.
   </para><para>

   Example [2] for <function>bitmap_fold</function> + <function>bitmap_onto</function>:
   Let's say <parameter>relmap</parameter> has these ten bits set:
   40 41 42 43 45 48 53 61 74 95
   (for the curious, that's 40 plus the first ten terms of the
   Fibonacci sequence.)
   </para><para>

   Further lets say we use the following code, invoking
   <function>bitmap_fold</function> then bitmap_onto, as suggested above to
   avoid the possitility of an empty <parameter>dst</parameter> result:
   </para><para>

   unsigned long *tmp;	// a temporary bitmap's bits
   </para><para>

   bitmap_fold(tmp, orig, bitmap_weight(relmap, bits), bits);
   bitmap_onto(dst, tmp, relmap, bits);
   </para><para>

   Then this table shows what various values of <parameter>dst</parameter> would be, for
   various <parameter>orig</parameter>'s.  I list the zero-based positions of each set bit.
   The tmp column shows the intermediate result, as computed by
   using <function>bitmap_fold</function> to fold the <parameter>orig</parameter> bitmap modulo ten
   (the weight of <parameter>relmap</parameter>).
   </para><para>

   <parameter>orig</parameter>           tmp            <parameter>dst</parameter>
   0                0             40
   1                1             41
   9                9             95
   10               0             40 (*)
   1 3 5 7          1 3 5 7       41 43 48 61
   0 1 2 3 4        0 1 2 3 4     40 41 42 43 45
   0 9 18 27        0 9 8 7       40 61 74 95
   0 10 20 30       0             40
   0 11 22 33       0 1 2 3       40 41 42 43
   0 12 24 36       0 2 4 6       40 42 45 53
   78 102 211       1 2 8         41 42 74 (*)
   </para><para>

   (*) For these marked lines, if we hadn't first done <function>bitmap_fold</function>
   into tmp, then the <parameter>dst</parameter> result would have been empty.
   </para><para>

   If either of <parameter>orig</parameter> or <parameter>relmap</parameter> is empty (no set bits), then <parameter>dst</parameter>
   will be returned empty.
   </para><para>

   If (as explained above) the only set bits in <parameter>orig</parameter> are in positions
   m where m &gt;= W, (where W is the weight of <parameter>relmap</parameter>) then <parameter>dst</parameter> will
   once again be returned empty.
   </para><para>

   All bits in <parameter>dst</parameter> not set by the above rule are cleared.
</para>
</refsect1>
</refentry>

<refentry id="API-bitmap-fold">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_fold</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_fold</refname>
 <refpurpose>
     fold larger bitmap into smaller, modulo specified size
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>bitmap_fold </function></funcdef>
   <paramdef>unsigned long * <parameter>dst</parameter></paramdef>
   <paramdef>const unsigned long * <parameter>orig</parameter></paramdef>
   <paramdef>int <parameter>sz</parameter></paramdef>
   <paramdef>int <parameter>bits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dst</parameter></term>
   <listitem>
    <para>
     resulting smaller bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>orig</parameter></term>
   <listitem>
    <para>
     original larger bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>sz</parameter></term>
   <listitem>
    <para>
     specified size
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>bits</parameter></term>
   <listitem>
    <para>
     number of bits in each of these bitmaps
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   For each bit oldbit in <parameter>orig</parameter>, set bit oldbit mod <parameter>sz</parameter> in <parameter>dst</parameter>.
   Clear all other bits in <parameter>dst</parameter>.  See further the comment and
   Example [2] for <function>bitmap_onto</function> for why and how to use this.
</para>
</refsect1>
</refentry>

<refentry id="API-bitmap-find-free-region">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_find_free_region</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_find_free_region</refname>
 <refpurpose>
     find a contiguous aligned mem region
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>bitmap_find_free_region </function></funcdef>
   <paramdef>unsigned long * <parameter>bitmap</parameter></paramdef>
   <paramdef>int <parameter>bits</parameter></paramdef>
   <paramdef>int <parameter>order</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>bitmap</parameter></term>
   <listitem>
    <para>
     array of unsigned longs corresponding to the bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>bits</parameter></term>
   <listitem>
    <para>
     number of bits in the bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>order</parameter></term>
   <listitem>
    <para>
     region size (log base 2 of number of bits) to find
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Find a region of free (zero) bits in a <parameter>bitmap</parameter> of <parameter>bits</parameter> bits and
   allocate them (set them to one).  Only consider regions of length
   a power (<parameter>order</parameter>) of two, aligned to that power of two, which
   makes the search algorithm much faster.
   </para><para>

   Return the bit offset in bitmap of the allocated region,
   or -errno on failure.
</para>
</refsect1>
</refentry>

<refentry id="API-bitmap-release-region">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_release_region</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_release_region</refname>
 <refpurpose>
     release allocated bitmap region
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>bitmap_release_region </function></funcdef>
   <paramdef>unsigned long * <parameter>bitmap</parameter></paramdef>
   <paramdef>int <parameter>pos</parameter></paramdef>
   <paramdef>int <parameter>order</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>bitmap</parameter></term>
   <listitem>
    <para>
     array of unsigned longs corresponding to the bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     beginning of bit region to release
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>order</parameter></term>
   <listitem>
    <para>
     region size (log base 2 of number of bits) to release
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This is the complement to <function>__bitmap_find_free_region</function> and releases
   the found region (by clearing it in the bitmap).
   </para><para>

   No return value.
</para>
</refsect1>
</refentry>

<refentry id="API-bitmap-allocate-region">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_allocate_region</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_allocate_region</refname>
 <refpurpose>
     allocate bitmap region
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>bitmap_allocate_region </function></funcdef>
   <paramdef>unsigned long * <parameter>bitmap</parameter></paramdef>
   <paramdef>int <parameter>pos</parameter></paramdef>
   <paramdef>int <parameter>order</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>bitmap</parameter></term>
   <listitem>
    <para>
     array of unsigned longs corresponding to the bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     beginning of bit region to allocate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>order</parameter></term>
   <listitem>
    <para>
     region size (log base 2 of number of bits) to allocate
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Allocate (set bits in) a specified region of a bitmap.
   </para><para>

   Return 0 on success, or <constant>-EBUSY</constant> if specified region wasn't
   free (not all bits were zero).
</para>
</refsect1>
</refentry>

<refentry id="API-bitmap-copy-le">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_copy_le</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_copy_le</refname>
 <refpurpose>
     copy a bitmap, putting the bits into little-endian order.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>bitmap_copy_le </function></funcdef>
   <paramdef>void * <parameter>dst</parameter></paramdef>
   <paramdef>const unsigned long * <parameter>src</parameter></paramdef>
   <paramdef>int <parameter>nbits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dst</parameter></term>
   <listitem>
    <para>
     destination buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     bitmap to copy
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nbits</parameter></term>
   <listitem>
    <para>
     number of bits in the bitmap
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Require nbits % BITS_PER_LONG == 0.
</para>
</refsect1>
</refentry>

<!-- lib/bitmap.c -->
<refentry id="API-bitmap-pos-to-ord">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_pos_to_ord</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_pos_to_ord</refname>
 <refpurpose>
   </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>bitmap_pos_to_ord </function></funcdef>
   <paramdef>const unsigned long * <parameter>buf</parameter></paramdef>
   <paramdef>int <parameter>pos</parameter></paramdef>
   <paramdef>int <parameter>bits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     pointer to a bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     a bit position in <parameter>buf</parameter> (0 &lt;= <parameter>pos</parameter> &lt; <parameter>bits</parameter>)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>bits</parameter></term>
   <listitem>
    <para>
     number of valid bit positions in <parameter>buf</parameter>
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Map the bit at position <parameter>pos</parameter> in <parameter>buf</parameter> (of length <parameter>bits</parameter>) to the
   ordinal of which set bit it is.  If it is not set or if <parameter>pos</parameter>
   is not a valid bit position, map to -1.
   </para><para>

   If for example, just bits 4 through 7 are set in <parameter>buf</parameter>, then <parameter>pos</parameter>
   values 4 through 7 will get mapped to 0 through 3, respectively,
   and other <parameter>pos</parameter> values will get mapped to 0.  When <parameter>pos</parameter> value 7
   gets mapped to (returns) <parameter>ord</parameter> value 3 in this example, that means
   that bit 7 is the 3rd (starting with 0th) set bit in <parameter>buf</parameter>.
   </para><para>

   The bit positions 0 through <parameter>bits</parameter> are valid positions in <parameter>buf</parameter>.
</para>
</refsect1>
</refentry>

<refentry id="API-bitmap-ord-to-pos">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>bitmap_ord_to_pos</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>bitmap_ord_to_pos</refname>
 <refpurpose>
   </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>bitmap_ord_to_pos </function></funcdef>
   <paramdef>const unsigned long * <parameter>buf</parameter></paramdef>
   <paramdef>int <parameter>ord</parameter></paramdef>
   <paramdef>int <parameter>bits</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     pointer to bitmap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ord</parameter></term>
   <listitem>
    <para>
     ordinal bit position (n-th set bit, n &gt;= 0)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>bits</parameter></term>
   <listitem>
    <para>
     number of valid bit positions in <parameter>buf</parameter>
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Map the ordinal offset of bit <parameter>ord</parameter> in <parameter>buf</parameter> to its position in <parameter>buf</parameter>.
   Value of <parameter>ord</parameter> should be in range 0 &lt;= <parameter>ord</parameter> &lt; weight(buf), else
   results are undefined.
   </para><para>

   If for example, just bits 4 through 7 are set in <parameter>buf</parameter>, then <parameter>ord</parameter>
   values 0 through 3 will get mapped to 4 through 7, respectively,
   and all other <parameter>ord</parameter> values return undefined values.  When <parameter>ord</parameter> value 3
   gets mapped to (returns) <parameter>pos</parameter> value 7 in this example, that means
   that the 3rd set bit (starting with 0th) is at position 7 in <parameter>buf</parameter>.
   </para><para>

   The bit positions 0 through <parameter>bits</parameter> are valid positions in <parameter>buf</parameter>.
</para>
</refsect1>
</refentry>

     </sect1>

     <sect1><title>Command-line Parsing</title>
<!-- lib/cmdline.c -->
<refentry id="API-get-option">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>get_option</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>get_option</refname>
 <refpurpose>
  Parse integer from an option string
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>get_option </function></funcdef>
   <paramdef>char ** <parameter>str</parameter></paramdef>
   <paramdef>int * <parameter>pint</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>str</parameter></term>
   <listitem>
    <para>
     option string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pint</parameter></term>
   <listitem>
    <para>
     (output) integer value parsed from <parameter>str</parameter>
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Read an int from an option string; if available accept a subsequent
   comma as well.
</para>
</refsect1>
<refsect1>
<title>Return values</title>
<para>
   0 - no int in string
   1 - int found, no subsequent comma
   2 - int found including a subsequent comma
   3 - hyphen found to denote a range
</para>
</refsect1>
</refentry>

<refentry id="API-get-options">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>get_options</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>get_options</refname>
 <refpurpose>
     Parse a string into a list of integers
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>char * <function>get_options </function></funcdef>
   <paramdef>const char * <parameter>str</parameter></paramdef>
   <paramdef>int <parameter>nints</parameter></paramdef>
   <paramdef>int * <parameter>ints</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>str</parameter></term>
   <listitem>
    <para>
     String to be parsed
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nints</parameter></term>
   <listitem>
    <para>
     size of integer array
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ints</parameter></term>
   <listitem>
    <para>
     integer array
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function parses a string containing a comma-separated
   list of integers, a hyphen-separated range of _positive_ integers,
   or a combination of both.  The parse halts when the array is
   full, or when no more numbers can be retrieved from the
   string.
   </para><para>

   Return value is the character in the string which caused
   the parse to end (typically a null terminator, if <parameter>str</parameter> is
   completely parseable).
</para>
</refsect1>
</refentry>

<refentry id="API-memparse">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>memparse</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>memparse</refname>
 <refpurpose>
     parse a string with mem suffixes into a number
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long long <function>memparse </function></funcdef>
   <paramdef>const char * <parameter>ptr</parameter></paramdef>
   <paramdef>char ** <parameter>retptr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ptr</parameter></term>
   <listitem>
    <para>
     Where parse begins
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>retptr</parameter></term>
   <listitem>
    <para>
     (output) Optional pointer to next char after parse completes
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Parses a string into a number.  The number stored at <parameter>ptr</parameter> is
   potentially suffixed with <constant>K</constant> (for kilobytes, or 1024 bytes),
   <constant>M</constant> (for megabytes, or 1048576 bytes), or <constant>G</constant> (for gigabytes, or
   1073741824).  If the number is suffixed with K, M, or G, then
   the return value is the number multiplied by one kilobyte, one
   megabyte, or one gigabyte, respectively.
</para>
</refsect1>
</refentry>

     </sect1>

     <sect1 id="crc"><title>CRC Functions</title>
<!-- lib/crc7.c -->
<refentry id="API-crc7">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>crc7</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>crc7</refname>
 <refpurpose>
  update the CRC7 for the data buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>u8 <function>crc7 </function></funcdef>
   <paramdef>u8 <parameter>crc</parameter></paramdef>
   <paramdef>const u8 * <parameter>buffer</parameter></paramdef>
   <paramdef>size_t <parameter>len</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>crc</parameter></term>
   <listitem>
    <para>
     previous CRC7 value
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buffer</parameter></term>
   <listitem>
    <para>
     data pointer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     number of bytes in the buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Context</title>
<para>
   any
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the updated CRC7 value.
</para>
</refsect1>
</refentry>

<!-- lib/crc16.c -->
<refentry id="API-crc16">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>crc16</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>crc16</refname>
 <refpurpose>
  compute the CRC-16 for the data buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>u16 <function>crc16 </function></funcdef>
   <paramdef>u16 <parameter>crc</parameter></paramdef>
   <paramdef>u8 const * <parameter>buffer</parameter></paramdef>
   <paramdef>size_t <parameter>len</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>crc</parameter></term>
   <listitem>
    <para>
     previous CRC value
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buffer</parameter></term>
   <listitem>
    <para>
     data pointer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     number of bytes in the buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the updated CRC value.
</para>
</refsect1>
</refentry>

<!-- lib/crc-itu-t.c -->
<refentry id="API-crc-itu-t">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>crc_itu_t</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>crc_itu_t</refname>
 <refpurpose>
  Compute the CRC-ITU-T for the data buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>u16 <function>crc_itu_t </function></funcdef>
   <paramdef>u16 <parameter>crc</parameter></paramdef>
   <paramdef>const u8 * <parameter>buffer</parameter></paramdef>
   <paramdef>size_t <parameter>len</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>crc</parameter></term>
   <listitem>
    <para>
     previous CRC value
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buffer</parameter></term>
   <listitem>
    <para>
     data pointer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     number of bytes in the buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the updated CRC value
</para>
</refsect1>
</refentry>

<!-- lib/crc32.c -->
<refentry id="API-crc32-le">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>crc32_le</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>crc32_le</refname>
 <refpurpose>
  Calculate bitwise little-endian Ethernet AUTODIN II CRC32
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>u32 __pure <function>crc32_le </function></funcdef>
   <paramdef>u32 <parameter>crc</parameter></paramdef>
   <paramdef>unsigned char const * <parameter>p</parameter></paramdef>
   <paramdef>size_t <parameter>len</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>crc</parameter></term>
   <listitem>
    <para>
     seed value for computation.  ~0 for Ethernet, sometimes 0 for
     other uses, or the previous crc32 value if computing incrementally.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>p</parameter></term>
   <listitem>
    <para>
     pointer to buffer over which CRC is run
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     length of buffer <parameter>p</parameter>
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-crc32-be">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>crc32_be</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>crc32_be</refname>
 <refpurpose>
     Calculate bitwise big-endian Ethernet AUTODIN II CRC32
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>u32 __pure <function>crc32_be </function></funcdef>
   <paramdef>u32 <parameter>crc</parameter></paramdef>
   <paramdef>unsigned char const * <parameter>p</parameter></paramdef>
   <paramdef>size_t <parameter>len</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>crc</parameter></term>
   <listitem>
    <para>
     seed value for computation.  ~0 for Ethernet, sometimes 0 for
     other uses, or the previous crc32 value if computing incrementally.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>p</parameter></term>
   <listitem>
    <para>
     pointer to buffer over which CRC is run
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     length of buffer <parameter>p</parameter>
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<!-- lib/crc-ccitt.c -->
<refentry id="API-crc-ccitt">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>crc_ccitt</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>crc_ccitt</refname>
 <refpurpose>
  recompute the CRC for the data buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>u16 <function>crc_ccitt </function></funcdef>
   <paramdef>u16 <parameter>crc</parameter></paramdef>
   <paramdef>u8 const * <parameter>buffer</parameter></paramdef>
   <paramdef>size_t <parameter>len</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>crc</parameter></term>
   <listitem>
    <para>
     previous CRC value
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buffer</parameter></term>
   <listitem>
    <para>
     data pointer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     number of bytes in the buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

     </sect1>
  </chapter>

  <chapter id="mm">
     <title>Memory Management in Linux</title>
     <sect1><title>The Slab Cache</title>
<!-- include/linux/slab.h -->
<refentry id="API-kcalloc">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kcalloc</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kcalloc</refname>
 <refpurpose>
  allocate memory for an array. The memory is set to zero.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>kcalloc </function></funcdef>
   <paramdef>size_t <parameter>n</parameter></paramdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>gfp_t <parameter>flags</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     number of elements.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     element size.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>flags</parameter></term>
   <listitem>
    <para>
     the type of memory to allocate.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The <parameter>flags</parameter> argument may be one of:
   </para><para>

   <constant>GFP_USER</constant> - Allocate memory on behalf of user.  May sleep.
   </para><para>

   <constant>GFP_KERNEL</constant> - Allocate normal kernel ram.  May sleep.
   </para><para>

   <constant>GFP_ATOMIC</constant> - Allocation will not sleep.  May use emergency pools.
   For example, use this inside interrupt handlers.
   </para><para>

   <constant>GFP_HIGHUSER</constant> - Allocate pages from high memory.
   </para><para>

   <constant>GFP_NOIO</constant> - Do not do any I/O at all while trying to get memory.
   </para><para>

   <constant>GFP_NOFS</constant> - Do not make any fs calls while trying to get memory.
   </para><para>

   <constant>GFP_NOWAIT</constant> - Allocation will not sleep.
   </para><para>

   <constant>GFP_THISNODE</constant> - Allocate node-local memory only.
   </para><para>

   <constant>GFP_DMA</constant> - Allocation suitable for DMA.
   Should only be used for <function>kmalloc</function> caches. Otherwise, use a
   slab created with SLAB_DMA.
   </para><para>

   Also it is possible to set different flags by OR'ing
   in one or more of the following additional <parameter>flags</parameter>:
   </para><para>

   <constant>__GFP_COLD</constant> - Request cache-cold pages instead of
   trying to return cache-warm pages.
   </para><para>

   <constant>__GFP_HIGH</constant> - This allocation has high priority and may use emergency pools.
   </para><para>

   <constant>__GFP_NOFAIL</constant> - Indicate that this allocation is in no way allowed to fail
   (think twice before using).
   </para><para>

   <constant>__GFP_NORETRY</constant> - If memory is not immediately available,
   then give up at once.
   </para><para>

   <constant>__GFP_NOWARN</constant> - If allocation fails, don't issue any warnings.
   </para><para>

   <constant>__GFP_REPEAT</constant> - If allocation fails initially, try once more before failing.
   </para><para>

   There are other flags available as well, but these are not intended
   for general use, and so are not documented here. For a full list of
   potential flags, always refer to linux/gfp.h.
</para>
</refsect1>
</refentry>

<refentry id="API-kmalloc-node">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kmalloc_node</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kmalloc_node</refname>
 <refpurpose>
     allocate memory from a specific node
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>kmalloc_node </function></funcdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>gfp_t <parameter>flags</parameter></paramdef>
   <paramdef>int <parameter>node</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     how many bytes of memory are required.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>flags</parameter></term>
   <listitem>
    <para>
     the type of memory to allocate (see kcalloc).
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>node</parameter></term>
   <listitem>
    <para>
     node to allocate from.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   <function>kmalloc</function> for non-local nodes, used to allocate from a specific node
   if available. Equivalent to <function>kmalloc</function> in the non-NUMA single-node
   case.
</para>
</refsect1>
</refentry>

<refentry id="API-kzalloc">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kzalloc</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kzalloc</refname>
 <refpurpose>
     allocate memory. The memory is set to zero.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>kzalloc </function></funcdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>gfp_t <parameter>flags</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     how many bytes of memory are required.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>flags</parameter></term>
   <listitem>
    <para>
     the type of memory to allocate (see kmalloc).
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-kzalloc-node">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kzalloc_node</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kzalloc_node</refname>
 <refpurpose>
     allocate zeroed memory from a particular memory node.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>kzalloc_node </function></funcdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>gfp_t <parameter>flags</parameter></paramdef>
   <paramdef>int <parameter>node</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     how many bytes of memory are required.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>flags</parameter></term>
   <listitem>
    <para>
     the type of memory to allocate (see kmalloc).
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>node</parameter></term>
   <listitem>
    <para>
     memory node from which to allocate
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<!-- mm/slab.c -->
<refentry id="API-kmem-cache-create">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kmem_cache_create</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kmem_cache_create</refname>
 <refpurpose>
  Create a cache.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct kmem_cache * <function>kmem_cache_create </function></funcdef>
   <paramdef>const char * <parameter>name</parameter></paramdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>size_t <parameter>align</parameter></paramdef>
   <paramdef>unsigned long <parameter>flags</parameter></paramdef>
   <paramdef>void (*<parameter>ctor</parameter>)
     <funcparams>void *</funcparams></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>name</parameter></term>
   <listitem>
    <para>
     A string which is used in /proc/slabinfo to identify this cache.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     The size of objects to be created in this cache.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>align</parameter></term>
   <listitem>
    <para>
     The required alignment for the objects.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>flags</parameter></term>
   <listitem>
    <para>
     SLAB flags
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ctor</parameter></term>
   <listitem>
    <para>
     A constructor for the objects.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns a ptr to the cache on success, NULL on failure.
   Cannot be called within a int, but can be interrupted.
   The <parameter>ctor</parameter> is run when new pages are allocated by the cache.
   </para><para>

   <parameter>name</parameter> must be valid until the cache is destroyed. This implies that
   the module calling this has to destroy the cache before getting unloaded.
   Note that <function>kmem_cache_name</function> is not guaranteed to return the same pointer,
   therefore applications must manage it themselves.
   </para><para>

   The flags are
   </para><para>

   <constant>SLAB_POISON</constant> - Poison the slab with a known test pattern (a5a5a5a5)
   to catch references to uninitialised memory.
   </para><para>

   <constant>SLAB_RED_ZONE</constant> - Insert `Red' zones around the allocated memory to check
   for buffer overruns.
   </para><para>

   <constant>SLAB_HWCACHE_ALIGN</constant> - Align the objects in this cache to a hardware
   cacheline.  This can be beneficial if you're counting cycles as closely
   as davem.
</para>
</refsect1>
</refentry>

<refentry id="API-kmem-cache-shrink">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kmem_cache_shrink</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kmem_cache_shrink</refname>
 <refpurpose>
     Shrink a cache.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>kmem_cache_shrink </function></funcdef>
   <paramdef>struct kmem_cache * <parameter>cachep</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cachep</parameter></term>
   <listitem>
    <para>
     The cache to shrink.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Releases as many slabs as possible for a cache.
   To help debugging, a zero exit status indicates all slabs were released.
</para>
</refsect1>
</refentry>

<refentry id="API-kmem-cache-destroy">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kmem_cache_destroy</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kmem_cache_destroy</refname>
 <refpurpose>
     delete a cache
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kmem_cache_destroy </function></funcdef>
   <paramdef>struct kmem_cache * <parameter>cachep</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cachep</parameter></term>
   <listitem>
    <para>
     the cache to destroy
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Remove a <structname>struct kmem_cache</structname> object from the slab cache.
   </para><para>

   It is expected this function will be called by a module when it is
   unloaded.  This will remove the cache completely, and avoid a duplicate
   cache being allocated each time a module is loaded and unloaded, if the
   module doesn't have persistent in-kernel storage across loads and unloads.
   </para><para>

   The cache must be empty before calling this function.
   </para><para>

   The caller must guarantee that noone will allocate memory from the cache
   during the <function>kmem_cache_destroy</function>.
</para>
</refsect1>
</refentry>

<refentry id="API-kmem-cache-alloc">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kmem_cache_alloc</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kmem_cache_alloc</refname>
 <refpurpose>
     Allocate an object
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>kmem_cache_alloc </function></funcdef>
   <paramdef>struct kmem_cache * <parameter>cachep</parameter></paramdef>
   <paramdef>gfp_t <parameter>flags</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cachep</parameter></term>
   <listitem>
    <para>
     The cache to allocate from.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>flags</parameter></term>
   <listitem>
    <para>
     See <function>kmalloc</function>.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Allocate an object from this cache.  The flags are only relevant
   if the cache has no available objects.
</para>
</refsect1>
</refentry>

<refentry id="API-kmem-cache-free">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kmem_cache_free</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kmem_cache_free</refname>
 <refpurpose>
     Deallocate an object
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kmem_cache_free </function></funcdef>
   <paramdef>struct kmem_cache * <parameter>cachep</parameter></paramdef>
   <paramdef>void * <parameter>objp</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cachep</parameter></term>
   <listitem>
    <para>
     The cache the allocation was from.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>objp</parameter></term>
   <listitem>
    <para>
     The previously allocated object.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Free an object which was previously allocated from this
   cache.
</para>
</refsect1>
</refentry>

<refentry id="API-kfree">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kfree</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kfree</refname>
 <refpurpose>
     free previously allocated memory
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kfree </function></funcdef>
   <paramdef>const void * <parameter>objp</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>objp</parameter></term>
   <listitem>
    <para>
     pointer returned by kmalloc.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   If <parameter>objp</parameter> is NULL, no operation is performed.
   </para><para>

   Don't free memory not originally allocated by <function>kmalloc</function>
   or you will run into trouble.
</para>
</refsect1>
</refentry>

<refentry id="API-ksize">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ksize</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ksize</refname>
 <refpurpose>
     get the actual amount of memory allocated for a given object
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>size_t <function>ksize </function></funcdef>
   <paramdef>const void * <parameter>objp</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>objp</parameter></term>
   <listitem>
    <para>
     Pointer to the object
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   kmalloc may internally round up allocations and return more memory
   than requested. <function>ksize</function> can be used to determine the actual amount of
   memory allocated. The caller may use this additional memory, even though
   a smaller amount of memory was initially specified with the kmalloc call.
   The caller must guarantee that objp points to a valid object previously
   allocated with either <function>kmalloc</function> or <function>kmem_cache_alloc</function>. The object
   must not be freed during the duration of the call.
</para>
</refsect1>
</refentry>

     </sect1>
     <sect1><title>User Space Memory Access</title>
<!-- arch/x86/include/asm/uaccess_32.h -->
<refentry id="API---copy-to-user-inatomic">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__copy_to_user_inatomic</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__copy_to_user_inatomic</refname>
 <refpurpose>
  Copy a block of data into user space, with less checking.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long __must_check <function>__copy_to_user_inatomic </function></funcdef>
   <paramdef>void __user * <parameter>to</parameter></paramdef>
   <paramdef>const void * <parameter>from</parameter></paramdef>
   <paramdef>unsigned long <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>to</parameter></term>
   <listitem>
    <para>
     Destination address, in user space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>from</parameter></term>
   <listitem>
    <para>
     Source address, in kernel space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     Number of bytes to copy.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Context</title>
<para>
   User context only.
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Copy data from kernel space to user space.  Caller must check
   the specified block with <function>access_ok</function> before calling this function.
   The caller should also make sure he pins the user space address
   so that we don't result in page fault and sleep.
   </para><para>

   Here we special-case 1, 2 and 4-byte copy_*_user invocations.  On a fault
   we return the initial request size (1, 2 or 4), as copy_*_user should do.
   If a store crosses a page boundary and gets a fault, the x86 will not write
   anything, so this is accurate.
</para>
</refsect1>
</refentry>

<refentry id="API---copy-to-user">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__copy_to_user</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__copy_to_user</refname>
 <refpurpose>
     Copy a block of data into user space, with less checking.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long __must_check <function>__copy_to_user </function></funcdef>
   <paramdef>void __user * <parameter>to</parameter></paramdef>
   <paramdef>const void * <parameter>from</parameter></paramdef>
   <paramdef>unsigned long <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>to</parameter></term>
   <listitem>
    <para>
     Destination address, in user space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>from</parameter></term>
   <listitem>
    <para>
     Source address, in kernel space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     Number of bytes to copy.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Context</title>
<para>
   User context only.  This function may sleep.
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Copy data from kernel space to user space.  Caller must check
   the specified block with <function>access_ok</function> before calling this function.
   </para><para>

   Returns number of bytes that could not be copied.
   On success, this will be zero.
</para>
</refsect1>
</refentry>

<refentry id="API---copy-from-user">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__copy_from_user</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__copy_from_user</refname>
 <refpurpose>
     Copy a block of data from user space, with less checking.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>__copy_from_user </function></funcdef>
   <paramdef>void * <parameter>to</parameter></paramdef>
   <paramdef>const void __user * <parameter>from</parameter></paramdef>
   <paramdef>unsigned long <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>to</parameter></term>
   <listitem>
    <para>
     Destination address, in kernel space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>from</parameter></term>
   <listitem>
    <para>
     Source address, in user space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     Number of bytes to copy.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Context</title>
<para>
   User context only.  This function may sleep.
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Copy data from user space to kernel space.  Caller must check
   the specified block with <function>access_ok</function> before calling this function.
   </para><para>

   Returns number of bytes that could not be copied.
   On success, this will be zero.
   </para><para>

   If some data could not be copied, this function will pad the copied
   data to the requested size using zero bytes.
   </para><para>

   An alternate version - <function>__copy_from_user_inatomic</function> - may be called from
   atomic context and will fail rather than sleep.  In this case the
   uncopied bytes will *NOT* be padded with zeros.  See fs/filemap.h
   for explanation of why this is needed.
</para>
</refsect1>
</refentry>

<refentry id="API-strlen-user">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strlen_user</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strlen_user</refname>
 <refpurpose>
     Get the size of a string in user space.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef> <function>strlen_user </function></funcdef>
   <paramdef> <parameter>str</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>str</parameter></term>
   <listitem>
    <para>
     The string to measure.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Context</title>
<para>
   User context only.  This function may sleep.
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Get the size of a NUL-terminated string in user space.
   </para><para>

   Returns the size of the string INCLUDING the terminating NUL.
   On exception, returns 0.
   </para><para>

   If there is a limit on the length of a valid string, you may wish to
   consider using <function>strnlen_user</function> instead.
</para>
</refsect1>
</refentry>

<!-- arch/x86/lib/usercopy_32.c -->
<refentry id="API---strncpy-from-user">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__strncpy_from_user</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__strncpy_from_user</refname>
 <refpurpose>
  Copy a NUL terminated string from userspace, with less checking.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>long <function>__strncpy_from_user </function></funcdef>
   <paramdef>char * <parameter>dst</parameter></paramdef>
   <paramdef>const char __user * <parameter>src</parameter></paramdef>
   <paramdef>long <parameter>count</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dst</parameter></term>
   <listitem>
    <para>
     Destination address, in kernel space.  This buffer must be at
     least <parameter>count</parameter> bytes long.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     Source address, in user space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     Maximum number of bytes to copy, including the trailing NUL.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Copies a NUL-terminated string from userspace to kernel space.
   Caller must check the specified block with <function>access_ok</function> before calling
   this function.
   </para><para>

   On success, returns the length of the string (not including the trailing
   NUL).
   </para><para>

   If access to userspace fails, returns -EFAULT (some data may have been
   copied).
   </para><para>

   If <parameter>count</parameter> is smaller than the length of the string, copies <parameter>count</parameter> bytes
   and returns <parameter>count</parameter>.
</para>
</refsect1>
</refentry>

<refentry id="API-strncpy-from-user">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strncpy_from_user</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strncpy_from_user</refname>
 <refpurpose>
     Copy a NUL terminated string from userspace.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>long <function>strncpy_from_user </function></funcdef>
   <paramdef>char * <parameter>dst</parameter></paramdef>
   <paramdef>const char __user * <parameter>src</parameter></paramdef>
   <paramdef>long <parameter>count</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dst</parameter></term>
   <listitem>
    <para>
     Destination address, in kernel space.  This buffer must be at
     least <parameter>count</parameter> bytes long.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>src</parameter></term>
   <listitem>
    <para>
     Source address, in user space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     Maximum number of bytes to copy, including the trailing NUL.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Copies a NUL-terminated string from userspace to kernel space.
   </para><para>

   On success, returns the length of the string (not including the trailing
   NUL).
   </para><para>

   If access to userspace fails, returns -EFAULT (some data may have been
   copied).
   </para><para>

   If <parameter>count</parameter> is smaller than the length of the string, copies <parameter>count</parameter> bytes
   and returns <parameter>count</parameter>.
</para>
</refsect1>
</refentry>

<refentry id="API-clear-user">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>clear_user</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>clear_user</refname>
 <refpurpose>
     Zero a block of memory in user space.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>clear_user </function></funcdef>
   <paramdef>void __user * <parameter>to</parameter></paramdef>
   <paramdef>unsigned long <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>to</parameter></term>
   <listitem>
    <para>
     Destination address, in user space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     Number of bytes to zero.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Zero a block of memory in user space.
   </para><para>

   Returns number of bytes that could not be cleared.
   On success, this will be zero.
</para>
</refsect1>
</refentry>

<refentry id="API---clear-user">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__clear_user</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__clear_user</refname>
 <refpurpose>
     Zero a block of memory in user space, with less checking.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>__clear_user </function></funcdef>
   <paramdef>void __user * <parameter>to</parameter></paramdef>
   <paramdef>unsigned long <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>to</parameter></term>
   <listitem>
    <para>
     Destination address, in user space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     Number of bytes to zero.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Zero a block of memory in user space.  Caller must check
   the specified block with <function>access_ok</function> before calling this function.
   </para><para>

   Returns number of bytes that could not be cleared.
   On success, this will be zero.
</para>
</refsect1>
</refentry>

<refentry id="API-strnlen-user">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>strnlen_user</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>strnlen_user</refname>
 <refpurpose>
     Get the size of a string in user space.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>long <function>strnlen_user </function></funcdef>
   <paramdef>const char __user * <parameter>s</parameter></paramdef>
   <paramdef>long <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     The string to measure.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     The maximum valid length
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Get the size of a NUL-terminated string in user space.
   </para><para>

   Returns the size of the string INCLUDING the terminating NUL.
   On exception, returns 0.
   If the string is too long, returns a value greater than <parameter>n</parameter>.
</para>
</refsect1>
</refentry>

<refentry id="API-copy-to-user">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>copy_to_user</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>copy_to_user</refname>
 <refpurpose>
     Copy a block of data into user space.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>copy_to_user </function></funcdef>
   <paramdef>void __user * <parameter>to</parameter></paramdef>
   <paramdef>const void * <parameter>from</parameter></paramdef>
   <paramdef>unsigned long <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>to</parameter></term>
   <listitem>
    <para>
     Destination address, in user space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>from</parameter></term>
   <listitem>
    <para>
     Source address, in kernel space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     Number of bytes to copy.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Context</title>
<para>
   User context only.  This function may sleep.
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Copy data from kernel space to user space.
   </para><para>

   Returns number of bytes that could not be copied.
   On success, this will be zero.
</para>
</refsect1>
</refentry>

<refentry id="API-copy-from-user">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>copy_from_user</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>copy_from_user</refname>
 <refpurpose>
     Copy a block of data from user space.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>copy_from_user </function></funcdef>
   <paramdef>void * <parameter>to</parameter></paramdef>
   <paramdef>const void __user * <parameter>from</parameter></paramdef>
   <paramdef>unsigned long <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>to</parameter></term>
   <listitem>
    <para>
     Destination address, in kernel space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>from</parameter></term>
   <listitem>
    <para>
     Source address, in user space.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     Number of bytes to copy.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Context</title>
<para>
   User context only.  This function may sleep.
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Copy data from user space to kernel space.
   </para><para>

   Returns number of bytes that could not be copied.
   On success, this will be zero.
   </para><para>

   If some data could not be copied, this function will pad the copied
   data to the requested size using zero bytes.
</para>
</refsect1>
</refentry>

     </sect1>
     <sect1><title>More Memory Management Functions</title>
<!-- mm/readahead.c -->
<refentry id="API-read-cache-pages">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>read_cache_pages</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>read_cache_pages</refname>
 <refpurpose>
  populate an address space with some pages &amp; start reads against them
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>read_cache_pages </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>struct list_head * <parameter>pages</parameter></paramdef>
   <paramdef>int (*<parameter>filler</parameter>)
     <funcparams>void *, struct page *</funcparams></paramdef>
   <paramdef>void * <parameter>data</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     the address_space
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pages</parameter></term>
   <listitem>
    <para>
     The address of a list_head which contains the target pages.  These
     pages have their -&gt;index populated and are otherwise uninitialised.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>filler</parameter></term>
   <listitem>
    <para>
     callback routine for filling a single page.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>data</parameter></term>
   <listitem>
    <para>
     private data for the callback routine.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Hides the details of the LRU cache etc from the filesystems.
</para>
</refsect1>
</refentry>

<refentry id="API-page-cache-sync-readahead">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>page_cache_sync_readahead</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>page_cache_sync_readahead</refname>
 <refpurpose>
     generic file readahead
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>page_cache_sync_readahead </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>struct file_ra_state * <parameter>ra</parameter></paramdef>
   <paramdef>struct file * <parameter>filp</parameter></paramdef>
   <paramdef>pgoff_t <parameter>offset</parameter></paramdef>
   <paramdef>unsigned long <parameter>req_size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     address_space which holds the pagecache and I/O vectors
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ra</parameter></term>
   <listitem>
    <para>
     file_ra_state which holds the readahead state
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>filp</parameter></term>
   <listitem>
    <para>
     passed on to -&gt;<function>readpage</function> and -&gt;<function>readpages</function>
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>offset</parameter></term>
   <listitem>
    <para>
     start offset into <parameter>mapping</parameter>, in pagecache page-sized units
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>req_size</parameter></term>
   <listitem>
    <para>
     hint: total size of the read which the caller is performing in
     pagecache pages
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   <function>page_cache_sync_readahead</function> should be called when a cache miss happened:
   it will submit the read.  The readahead logic may decide to piggyback more
   pages onto the read request if access patterns suggest it will improve
   performance.
</para>
</refsect1>
</refentry>

<refentry id="API-page-cache-async-readahead">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>page_cache_async_readahead</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>page_cache_async_readahead</refname>
 <refpurpose>
     file readahead for marked pages
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>page_cache_async_readahead </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>struct file_ra_state * <parameter>ra</parameter></paramdef>
   <paramdef>struct file * <parameter>filp</parameter></paramdef>
   <paramdef>struct page * <parameter>page</parameter></paramdef>
   <paramdef>pgoff_t <parameter>offset</parameter></paramdef>
   <paramdef>unsigned long <parameter>req_size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     address_space which holds the pagecache and I/O vectors
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ra</parameter></term>
   <listitem>
    <para>
     file_ra_state which holds the readahead state
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>filp</parameter></term>
   <listitem>
    <para>
     passed on to -&gt;<function>readpage</function> and -&gt;<function>readpages</function>
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>page</parameter></term>
   <listitem>
    <para>
     the page at <parameter>offset</parameter> which has the PG_readahead flag set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>offset</parameter></term>
   <listitem>
    <para>
     start offset into <parameter>mapping</parameter>, in pagecache page-sized units
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>req_size</parameter></term>
   <listitem>
    <para>
     hint: total size of the read which the caller is performing in
     pagecache pages
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   <function>page_cache_async_ondemand</function> should be called when a page is used which
   has the PG_readahead flag; this is a marker to suggest that the application
   has used up enough of the readahead window that we should start pulling in
   more pages.
</para>
</refsect1>
</refentry>

<!-- mm/filemap.c -->
<refentry id="API-filemap-flush">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>filemap_flush</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>filemap_flush</refname>
 <refpurpose>
  mostly a non-blocking flush
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>filemap_flush </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     target address_space
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This is a mostly non-blocking flush.  Not suitable for data-integrity
   purposes - I/O may not be started against all dirty pages.
</para>
</refsect1>
</refentry>

<refentry id="API-filemap-fdatawait-range">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>filemap_fdatawait_range</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>filemap_fdatawait_range</refname>
 <refpurpose>
     wait for all under-writeback pages to complete in a given range
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>filemap_fdatawait_range </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>loff_t <parameter>start</parameter></paramdef>
   <paramdef>loff_t <parameter>end</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     address space structure to wait for
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>start</parameter></term>
   <listitem>
    <para>
     offset in bytes where the range starts
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>end</parameter></term>
   <listitem>
    <para>
     offset in bytes where the range ends (inclusive)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Walk the list of under-writeback pages of the given address space
   in the given range and wait for all of them.
   </para><para>

   This is just a simple wrapper so that callers don't have to convert offsets
   to page indexes themselves
</para>
</refsect1>
</refentry>

<refentry id="API-filemap-fdatawait">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>filemap_fdatawait</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>filemap_fdatawait</refname>
 <refpurpose>
     wait for all under-writeback pages to complete
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>filemap_fdatawait </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     address space structure to wait for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Walk the list of under-writeback pages of the given address space
   and wait for all of them.
</para>
</refsect1>
</refentry>

<refentry id="API-filemap-write-and-wait-range">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>filemap_write_and_wait_range</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>filemap_write_and_wait_range</refname>
 <refpurpose>
     write out &amp; wait on a file range
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>filemap_write_and_wait_range </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>loff_t <parameter>lstart</parameter></paramdef>
   <paramdef>loff_t <parameter>lend</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     the address_space for the pages
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>lstart</parameter></term>
   <listitem>
    <para>
     offset in bytes where the range starts
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>lend</parameter></term>
   <listitem>
    <para>
     offset in bytes where the range ends (inclusive)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Write out and wait upon file offsets lstart-&gt;lend, inclusive.
   </para><para>

   Note that `lend' is inclusive (describes the last byte to be written) so
   that this function can be used to write to the very end-of-file (end = -1).
</para>
</refsect1>
</refentry>

<refentry id="API-add-to-page-cache-locked">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>add_to_page_cache_locked</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>add_to_page_cache_locked</refname>
 <refpurpose>
     add a locked page to the pagecache
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>add_to_page_cache_locked </function></funcdef>
   <paramdef>struct page * <parameter>page</parameter></paramdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>pgoff_t <parameter>offset</parameter></paramdef>
   <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>page</parameter></term>
   <listitem>
    <para>
     page to add
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     the page's address_space
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>offset</parameter></term>
   <listitem>
    <para>
     page index
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>gfp_mask</parameter></term>
   <listitem>
    <para>
     page allocation mode
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function is used to add a page to the pagecache. It must be locked.
   This function does not add the page to the LRU.  The caller must do that.
</para>
</refsect1>
</refentry>

<refentry id="API-add-page-wait-queue">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>add_page_wait_queue</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>add_page_wait_queue</refname>
 <refpurpose>
     Add an arbitrary waiter to a page's wait queue
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>add_page_wait_queue </function></funcdef>
   <paramdef>struct page * <parameter>page</parameter></paramdef>
   <paramdef>wait_queue_t * <parameter>waiter</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>page</parameter></term>
   <listitem>
    <para>
     Page defining the wait queue of interest
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>waiter</parameter></term>
   <listitem>
    <para>
     Waiter to add to the queue
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Add an arbitrary <parameter>waiter</parameter> to the wait queue for the nominated <parameter>page</parameter>.
</para>
</refsect1>
</refentry>

<refentry id="API-unlock-page">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>unlock_page</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>unlock_page</refname>
 <refpurpose>
     unlock a locked page
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>unlock_page </function></funcdef>
   <paramdef>struct page * <parameter>page</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>page</parameter></term>
   <listitem>
    <para>
     the page
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Unlocks the page and wakes up sleepers in <function>___wait_on_page_locked</function>.
   Also wakes sleepers in <function>wait_on_page_writeback</function> because the wakeup
   mechananism between PageLocked pages and PageWriteback pages is shared.
   But that's OK - sleepers in <function>wait_on_page_writeback</function> just go back to sleep.
   </para><para>

   The mb is necessary to enforce ordering between the clear_bit and the read
   of the waitqueue (to avoid SMP races with a parallel <function>wait_on_page_locked</function>).
</para>
</refsect1>
</refentry>

<refentry id="API-end-page-writeback">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>end_page_writeback</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>end_page_writeback</refname>
 <refpurpose>
     end writeback against a page
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>end_page_writeback </function></funcdef>
   <paramdef>struct page * <parameter>page</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>page</parameter></term>
   <listitem>
    <para>
     the page
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API---lock-page">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__lock_page</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__lock_page</refname>
 <refpurpose>
     get a lock on the page, assuming we need to sleep to get it
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>__lock_page </function></funcdef>
   <paramdef>struct page * <parameter>page</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>page</parameter></term>
   <listitem>
    <para>
     the page to lock
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Ugly. Running <function>sync_page</function> in state TASK_UNINTERRUPTIBLE is scary.  If some
   random driver's requestfn sets TASK_RUNNING, we could busywait.  However
   chances are that on the second loop, the block layer's plug list is empty,
   so <function>sync_page</function> will then return in state TASK_UNINTERRUPTIBLE.
</para>
</refsect1>
</refentry>

<refentry id="API-find-get-page">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>find_get_page</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>find_get_page</refname>
 <refpurpose>
     find and get a page reference
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct page * <function>find_get_page </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>pgoff_t <parameter>offset</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     the address_space to search
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>offset</parameter></term>
   <listitem>
    <para>
     the page index
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Is there a pagecache struct page at the given (mapping, offset) tuple?
   If yes, increment its refcount and return it; if no, return NULL.
</para>
</refsect1>
</refentry>

<refentry id="API-find-lock-page">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>find_lock_page</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>find_lock_page</refname>
 <refpurpose>
     locate, pin and lock a pagecache page
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct page * <function>find_lock_page </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>pgoff_t <parameter>offset</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     the address_space to search
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>offset</parameter></term>
   <listitem>
    <para>
     the page index
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Locates the desired pagecache page, locks it, increments its reference
   count and returns its address.
   </para><para>

   Returns zero if the page was not present. <function>find_lock_page</function> may sleep.
</para>
</refsect1>
</refentry>

<refentry id="API-find-or-create-page">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>find_or_create_page</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>find_or_create_page</refname>
 <refpurpose>
     locate or add a pagecache page
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct page * <function>find_or_create_page </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>pgoff_t <parameter>index</parameter></paramdef>
   <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     the page's address_space
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>index</parameter></term>
   <listitem>
    <para>
     the page's index into the mapping
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>gfp_mask</parameter></term>
   <listitem>
    <para>
     page allocation mode
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Locates a page in the pagecache.  If the page is not present, a new page
   is allocated using <parameter>gfp_mask</parameter> and is added to the pagecache and to the VM's
   LRU list.  The returned page is locked and has its reference count
   incremented.
   </para><para>

   <function>find_or_create_page</function> may sleep, even if <parameter>gfp_flags</parameter> specifies an atomic
   allocation!
   </para><para>

   <function>find_or_create_page</function> returns the desired page's address, or zero on
   memory exhaustion.
</para>
</refsect1>
</refentry>

<refentry id="API-find-get-pages-contig">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>find_get_pages_contig</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>find_get_pages_contig</refname>
 <refpurpose>
     gang contiguous pagecache lookup
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned <function>find_get_pages_contig </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>pgoff_t <parameter>index</parameter></paramdef>
   <paramdef>unsigned int <parameter>nr_pages</parameter></paramdef>
   <paramdef>struct page ** <parameter>pages</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     The address_space to search
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>index</parameter></term>
   <listitem>
    <para>
     The starting page index
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nr_pages</parameter></term>
   <listitem>
    <para>
     The maximum number of pages
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pages</parameter></term>
   <listitem>
    <para>
     Where the resulting pages are placed
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   <function>find_get_pages_contig</function> works exactly like <function>find_get_pages</function>, except
   that the returned number of pages are guaranteed to be contiguous.
   </para><para>

   <function>find_get_pages_contig</function> returns the number of pages which were found.
</para>
</refsect1>
</refentry>

<refentry id="API-find-get-pages-tag">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>find_get_pages_tag</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>find_get_pages_tag</refname>
 <refpurpose>
     find and return pages that match <parameter>tag</parameter>
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned <function>find_get_pages_tag </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>pgoff_t * <parameter>index</parameter></paramdef>
   <paramdef>int <parameter>tag</parameter></paramdef>
   <paramdef>unsigned int <parameter>nr_pages</parameter></paramdef>
   <paramdef>struct page ** <parameter>pages</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     the address_space to search
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>index</parameter></term>
   <listitem>
    <para>
     the starting page index
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>tag</parameter></term>
   <listitem>
    <para>
     the tag index
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nr_pages</parameter></term>
   <listitem>
    <para>
     the maximum number of pages
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pages</parameter></term>
   <listitem>
    <para>
     where the resulting pages are placed
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Like find_get_pages, except we only return pages which are tagged with
   <parameter>tag</parameter>.   We update <parameter>index</parameter> to index the next page for the traversal.
</para>
</refsect1>
</refentry>

<refentry id="API-grab-cache-page-nowait">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>grab_cache_page_nowait</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>grab_cache_page_nowait</refname>
 <refpurpose>
     returns locked page at given index in given cache
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct page * <function>grab_cache_page_nowait </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>pgoff_t <parameter>index</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     target address_space
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>index</parameter></term>
   <listitem>
    <para>
     the page index
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Same as <function>grab_cache_page</function>, but do not wait if the page is unavailable.
   This is intended for speculative data generators, where the data can
   be regenerated if the page couldn't be grabbed.  This routine should
   be safe to call while holding the lock for another page.
   </para><para>

   Clear __GFP_FS when allocating the page to avoid recursion into the fs
   and deadlock against the caller's locked page.
</para>
</refsect1>
</refentry>

<refentry id="API-generic-file-aio-read">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>generic_file_aio_read</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>generic_file_aio_read</refname>
 <refpurpose>
     generic filesystem read routine
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>ssize_t <function>generic_file_aio_read </function></funcdef>
   <paramdef>struct kiocb * <parameter>iocb</parameter></paramdef>
   <paramdef>const struct iovec * <parameter>iov</parameter></paramdef>
   <paramdef>unsigned long <parameter>nr_segs</parameter></paramdef>
   <paramdef>loff_t <parameter>pos</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>iocb</parameter></term>
   <listitem>
    <para>
     kernel I/O control block
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>iov</parameter></term>
   <listitem>
    <para>
     io vector request
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nr_segs</parameter></term>
   <listitem>
    <para>
     number of segments in the iovec
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     current file position
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This is the <quote><function>read</function></quote> routine for all filesystems
   that can use the page cache directly.
</para>
</refsect1>
</refentry>

<refentry id="API-filemap-fault">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>filemap_fault</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>filemap_fault</refname>
 <refpurpose>
     read in file data for page fault handling
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>filemap_fault </function></funcdef>
   <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef>
   <paramdef>struct vm_fault * <parameter>vmf</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>vma</parameter></term>
   <listitem>
    <para>
     vma in which the fault was taken
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>vmf</parameter></term>
   <listitem>
    <para>
     struct vm_fault containing details of the fault
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   <function>filemap_fault</function> is invoked via the vma operations vector for a
   mapped memory region to read in file data during a page fault.
   </para><para>

   The goto's are kind of ugly, but this streamlines the normal case of having
   it in the page cache, and handles the special cases reasonably without
   having a lot of duplicated code.
</para>
</refsect1>
</refentry>

<refentry id="API-read-cache-page-async">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>read_cache_page_async</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>read_cache_page_async</refname>
 <refpurpose>
     read into page cache, fill it if needed
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct page * <function>read_cache_page_async </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>pgoff_t <parameter>index</parameter></paramdef>
   <paramdef>int (*<parameter>filler</parameter>)
     <funcparams>void *,struct page*</funcparams></paramdef>
   <paramdef>void * <parameter>data</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     the page's address_space
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>index</parameter></term>
   <listitem>
    <para>
     the page index
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>filler</parameter></term>
   <listitem>
    <para>
     function to perform the read
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>data</parameter></term>
   <listitem>
    <para>
     destination for read data
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Same as read_cache_page, but don't wait for page to become unlocked
   after submitting it to the filler.
   </para><para>

   Read into the page cache. If a page already exists, and <function>PageUptodate</function> is
   not set, try to fill the page but don't wait for it to become unlocked.
   </para><para>

   If the page does not get brought uptodate, return -EIO.
</para>
</refsect1>
</refentry>

<refentry id="API-read-cache-page">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>read_cache_page</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>read_cache_page</refname>
 <refpurpose>
     read into page cache, fill it if needed
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct page * <function>read_cache_page </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>pgoff_t <parameter>index</parameter></paramdef>
   <paramdef>int (*<parameter>filler</parameter>)
     <funcparams>void *,struct page*</funcparams></paramdef>
   <paramdef>void * <parameter>data</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     the page's address_space
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>index</parameter></term>
   <listitem>
    <para>
     the page index
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>filler</parameter></term>
   <listitem>
    <para>
     function to perform the read
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>data</parameter></term>
   <listitem>
    <para>
     destination for read data
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Read into the page cache. If a page already exists, and <function>PageUptodate</function> is
   not set, try to fill the page then wait for it to become unlocked.
   </para><para>

   If the page does not get brought uptodate, return -EIO.
</para>
</refsect1>
</refentry>

<refentry id="API---generic-file-aio-write">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__generic_file_aio_write</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__generic_file_aio_write</refname>
 <refpurpose>
     write data to a file
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>ssize_t <function>__generic_file_aio_write </function></funcdef>
   <paramdef>struct kiocb * <parameter>iocb</parameter></paramdef>
   <paramdef>const struct iovec * <parameter>iov</parameter></paramdef>
   <paramdef>unsigned long <parameter>nr_segs</parameter></paramdef>
   <paramdef>loff_t * <parameter>ppos</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>iocb</parameter></term>
   <listitem>
    <para>
     IO state structure (file, offset, etc.)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>iov</parameter></term>
   <listitem>
    <para>
     vector with data to write
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nr_segs</parameter></term>
   <listitem>
    <para>
     number of segments in the vector
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ppos</parameter></term>
   <listitem>
    <para>
     position where to write
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function does all the work needed for actually writing data to a
   file. It does all basic checks, removes SUID from the file, updates
   modification times and calls proper subroutines depending on whether we
   do direct IO or a standard buffered write.
   </para><para>

   It expects i_mutex to be grabbed unless we work on a block device or similar
   object which does not need locking at all.
   </para><para>

   This function does *not* take care of syncing data in case of O_SYNC write.
   A caller has to handle it. This is mainly due to the fact that we want to
   avoid syncing under i_mutex.
</para>
</refsect1>
</refentry>

<refentry id="API-generic-file-aio-write">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>generic_file_aio_write</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>generic_file_aio_write</refname>
 <refpurpose>
     write data to a file
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>ssize_t <function>generic_file_aio_write </function></funcdef>
   <paramdef>struct kiocb * <parameter>iocb</parameter></paramdef>
   <paramdef>const struct iovec * <parameter>iov</parameter></paramdef>
   <paramdef>unsigned long <parameter>nr_segs</parameter></paramdef>
   <paramdef>loff_t <parameter>pos</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>iocb</parameter></term>
   <listitem>
    <para>
     IO state structure
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>iov</parameter></term>
   <listitem>
    <para>
     vector with data to write
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nr_segs</parameter></term>
   <listitem>
    <para>
     number of segments in the vector
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pos</parameter></term>
   <listitem>
    <para>
     position in file where to write
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This is a wrapper around <function>__generic_file_aio_write</function> to be used by most
   filesystems. It takes care of syncing the file in case of O_SYNC file
   and acquires i_mutex as needed.
</para>
</refsect1>
</refentry>

<refentry id="API-try-to-release-page">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>try_to_release_page</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>try_to_release_page</refname>
 <refpurpose>
     release old fs-specific metadata on a page
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>try_to_release_page </function></funcdef>
   <paramdef>struct page * <parameter>page</parameter></paramdef>
   <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>page</parameter></term>
   <listitem>
    <para>
     the page which the kernel is trying to free
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>gfp_mask</parameter></term>
   <listitem>
    <para>
     memory allocation flags (and I/O mode)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The address_space is to try to release any data against the page
   (presumably at page-&gt;private).  If the release was successful, return `1'.
   Otherwise return zero.
   </para><para>

   This may also be called if PG_fscache is set on a page, indicating that the
   page is known to the local caching routines.
   </para><para>

   The <parameter>gfp_mask</parameter> argument specifies whether I/O may be performed to release
   this page (__GFP_IO), and whether the call may block (__GFP_WAIT &amp; __GFP_FS).
</para>
</refsect1>
</refentry>

<!-- mm/memory.c -->
<refentry id="API-zap-vma-ptes">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>zap_vma_ptes</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>zap_vma_ptes</refname>
 <refpurpose>
  remove ptes mapping the vma
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>zap_vma_ptes </function></funcdef>
   <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef>
   <paramdef>unsigned long <parameter>address</parameter></paramdef>
   <paramdef>unsigned long <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>vma</parameter></term>
   <listitem>
    <para>
     vm_area_struct holding ptes to be zapped
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>address</parameter></term>
   <listitem>
    <para>
     starting address of pages to zap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     number of bytes to zap
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function only unmaps ptes assigned to VM_PFNMAP vmas.
   </para><para>

   The entire address range must be fully contained within the vma.
   </para><para>

   Returns 0 if successful.
</para>
</refsect1>
</refentry>

<refentry id="API-get-user-pages">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>get_user_pages</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>get_user_pages</refname>
 <refpurpose>
     pin user pages in memory
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>get_user_pages </function></funcdef>
   <paramdef>struct task_struct * <parameter>tsk</parameter></paramdef>
   <paramdef>struct mm_struct * <parameter>mm</parameter></paramdef>
   <paramdef>unsigned long <parameter>start</parameter></paramdef>
   <paramdef>int <parameter>nr_pages</parameter></paramdef>
   <paramdef>int <parameter>write</parameter></paramdef>
   <paramdef>int <parameter>force</parameter></paramdef>
   <paramdef>struct page ** <parameter>pages</parameter></paramdef>
   <paramdef>struct vm_area_struct ** <parameter>vmas</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>tsk</parameter></term>
   <listitem>
    <para>
     task_struct of target task
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>mm</parameter></term>
   <listitem>
    <para>
     mm_struct of target mm
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>start</parameter></term>
   <listitem>
    <para>
     starting user address
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nr_pages</parameter></term>
   <listitem>
    <para>
     number of pages from start to pin
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>write</parameter></term>
   <listitem>
    <para>
     whether pages will be written to by the caller
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>force</parameter></term>
   <listitem>
    <para>
     whether to force write access even if user mapping is
     readonly. This will result in the page being COWed even
     in MAP_SHARED mappings. You do not want this.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pages</parameter></term>
   <listitem>
    <para>
     array that receives pointers to the pages pinned.
     Should be at least nr_pages long. Or NULL, if caller
     only intends to ensure the pages are faulted in.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>vmas</parameter></term>
   <listitem>
    <para>
     array of pointers to vmas corresponding to each page.
     Or NULL if the caller does not require them.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns number of pages pinned. This may be fewer than the number
   requested. If nr_pages is 0 or negative, returns 0. If no pages
   were pinned, returns -errno. Each page returned must be released
   with a <function>put_page</function> call when it is finished with. vmas will only
   remain valid while mmap_sem is held.
   </para><para>

   Must be called with mmap_sem held for read or write.
   </para><para>

   get_user_pages walks a process's page tables and takes a reference to
   each struct page that each user address corresponds to at a given
   instant. That is, it takes the page that would be accessed if a user
   thread accesses the given user virtual address at that instant.
   </para><para>

   This does not guarantee that the page exists in the user mappings when
   get_user_pages returns, and there may even be a completely different
   page there in some cases (eg. if mmapped pagecache has been invalidated
   and subsequently re faulted). However it does guarantee that the page
   won't be freed completely. And mostly callers simply care that the page
   contains data that was valid *at some point in time*. Typically, an IO
   or similar operation cannot guarantee anything stronger anyway because
   locks can't be held over the syscall boundary.
   </para><para>

   If write=0, the page must not be written to. If the page is written to,
   set_page_dirty (or set_page_dirty_lock, as appropriate) must be called
   after the page is finished with, and before put_page is called.
   </para><para>

   get_user_pages is typically used for fewer-copy IO operations, to get a
   handle on the memory by some means other than accesses via the user virtual
   addresses. The pages may be submitted for DMA to devices or accessed via
   their kernel linear mapping (via the kmap APIs). Care should be taken to
   use the correct cache flushing APIs.
   </para><para>

   See also get_user_pages_fast, for performance critical applications.
</para>
</refsect1>
</refentry>

<refentry id="API-vm-insert-page">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vm_insert_page</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vm_insert_page</refname>
 <refpurpose>
     insert single page into user vma
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>vm_insert_page </function></funcdef>
   <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef>
   <paramdef>unsigned long <parameter>addr</parameter></paramdef>
   <paramdef>struct page * <parameter>page</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>vma</parameter></term>
   <listitem>
    <para>
     user vma to map to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     target user address of this page
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>page</parameter></term>
   <listitem>
    <para>
     source kernel page
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This allows drivers to insert individual pages they've allocated
   into a user vma.
   </para><para>

   The page has to be a nice clean _individual_ kernel allocation.
   If you allocate a compound page, you need to have marked it as
   such (__GFP_COMP), or manually just split the page up yourself
   (see <function>split_page</function>).
   </para><para>

   NOTE! Traditionally this was done with <quote><function>remap_pfn_range</function></quote> which
   took an arbitrary page protection parameter. This doesn't allow
   that. Your vma protection will have to be set up correctly, which
   means that if you want a shared writable mapping, you'd better
   ask for a shared writable mapping!
   </para><para>

   The page does not need to be reserved.
</para>
</refsect1>
</refentry>

<refentry id="API-vm-insert-pfn">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vm_insert_pfn</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vm_insert_pfn</refname>
 <refpurpose>
     insert single pfn into user vma
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>vm_insert_pfn </function></funcdef>
   <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef>
   <paramdef>unsigned long <parameter>addr</parameter></paramdef>
   <paramdef>unsigned long <parameter>pfn</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>vma</parameter></term>
   <listitem>
    <para>
     user vma to map to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     target user address of this page
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pfn</parameter></term>
   <listitem>
    <para>
     source kernel pfn
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Similar to vm_inert_page, this allows drivers to insert individual pages
   they've allocated into a user vma. Same comments apply.
   </para><para>

   This function should only be called from a vm_ops-&gt;fault handler, and
   in that case the handler should return NULL.
   </para><para>

   vma cannot be a COW mapping.
   </para><para>

   As this is called only for pages that do not currently exist, we
   do not need to flush old virtual caches or the TLB.
</para>
</refsect1>
</refentry>

<refentry id="API-remap-pfn-range">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>remap_pfn_range</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>remap_pfn_range</refname>
 <refpurpose>
     remap kernel memory to userspace
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>remap_pfn_range </function></funcdef>
   <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef>
   <paramdef>unsigned long <parameter>addr</parameter></paramdef>
   <paramdef>unsigned long <parameter>pfn</parameter></paramdef>
   <paramdef>unsigned long <parameter>size</parameter></paramdef>
   <paramdef>pgprot_t <parameter>prot</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>vma</parameter></term>
   <listitem>
    <para>
     user vma to map to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     target user address to start at
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pfn</parameter></term>
   <listitem>
    <para>
     physical address of kernel memory
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     size of map area
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>prot</parameter></term>
   <listitem>
    <para>
     page protection flags for this mapping
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Note</title>
<para>
   this is only safe if the mm semaphore is held when called.
</para>
</refsect1>
</refentry>

<refentry id="API-unmap-mapping-range">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>unmap_mapping_range</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>unmap_mapping_range</refname>
 <refpurpose>
     unmap the portion of all mmaps in the specified address_space corresponding to the specified page range in the underlying file.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>unmap_mapping_range </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>loff_t const <parameter>holebegin</parameter></paramdef>
   <paramdef>loff_t const <parameter>holelen</parameter></paramdef>
   <paramdef>int <parameter>even_cows</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     the address space containing mmaps to be unmapped.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>holebegin</parameter></term>
   <listitem>
    <para>
     byte in first page to unmap, relative to the start of
     the underlying file.  This will be rounded down to a PAGE_SIZE
     boundary.  Note that this is different from <function>truncate_pagecache</function>, which
     must keep the partial page.  In contrast, we must get rid of
     partial pages.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>holelen</parameter></term>
   <listitem>
    <para>
     size of prospective hole in bytes.  This will be rounded
     up to a PAGE_SIZE boundary.  A holelen of zero truncates to the
     end of the file.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>even_cows</parameter></term>
   <listitem>
    <para>
     1 when truncating a file, unmap even private COWed pages;
     but 0 when invalidating pagecache, don't throw away private data.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-follow-pfn">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>follow_pfn</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>follow_pfn</refname>
 <refpurpose>
     look up PFN at a user virtual address
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>follow_pfn </function></funcdef>
   <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef>
   <paramdef>unsigned long <parameter>address</parameter></paramdef>
   <paramdef>unsigned long * <parameter>pfn</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>vma</parameter></term>
   <listitem>
    <para>
     memory mapping
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>address</parameter></term>
   <listitem>
    <para>
     user virtual address
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pfn</parameter></term>
   <listitem>
    <para>
     location to store found PFN
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Only IO mappings and raw PFN mappings are allowed.
   </para><para>

   Returns zero and the pfn at <parameter>pfn</parameter> on success, -ve otherwise.
</para>
</refsect1>
</refentry>

<!-- mm/vmalloc.c -->
<refentry id="API-vm-unmap-aliases">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vm_unmap_aliases</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vm_unmap_aliases</refname>
 <refpurpose>
  unmap outstanding lazy aliases in the vmap layer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>vm_unmap_aliases </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   The vmap/vmalloc layer lazily flushes kernel virtual mappings primarily
   to amortize TLB flushing overheads. What this means is that any page you
   have now, may, in a former life, have been mapped into kernel virtual
   address by the vmap layer and so there might be some CPUs with TLB entries
   still referencing that page (additional to the regular 1:1 kernel mapping).
   </para><para>

   vm_unmap_aliases flushes all such lazy mappings. After it returns, we can
   be sure that none of the pages we have control over will have any aliases
   from the vmap layer.
</para>
</refsect1>
</refentry>

<refentry id="API-vm-unmap-ram">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vm_unmap_ram</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vm_unmap_ram</refname>
 <refpurpose>
     unmap linear kernel address space set up by vm_map_ram
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>vm_unmap_ram </function></funcdef>
   <paramdef>const void * <parameter>mem</parameter></paramdef>
   <paramdef>unsigned int <parameter>count</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mem</parameter></term>
   <listitem>
    <para>
     the pointer returned by vm_map_ram
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     the count passed to that vm_map_ram call (cannot unmap partial)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-vm-map-ram">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vm_map_ram</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vm_map_ram</refname>
 <refpurpose>
     map pages linearly into kernel virtual address (vmalloc space)
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>vm_map_ram </function></funcdef>
   <paramdef>struct page ** <parameter>pages</parameter></paramdef>
   <paramdef>unsigned int <parameter>count</parameter></paramdef>
   <paramdef>int <parameter>node</parameter></paramdef>
   <paramdef>pgprot_t <parameter>prot</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pages</parameter></term>
   <listitem>
    <para>
     an array of pointers to the pages to be mapped
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     number of pages
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>node</parameter></term>
   <listitem>
    <para>
     prefer to allocate data structures on this node
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>prot</parameter></term>
   <listitem>
    <para>
     memory protection to use. PAGE_KERNEL for regular RAM
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Returns</title>
<para>
   a pointer to the address that has been mapped, or <constant>NULL</constant> on failure
</para>
</refsect1>
</refentry>

<refentry id="API-vfree">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vfree</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vfree</refname>
 <refpurpose>
     release memory allocated by <function>vmalloc</function>
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>vfree </function></funcdef>
   <paramdef>const void * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     memory base address
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Free the virtually continuous memory area starting at <parameter>addr</parameter>, as
   obtained from <function>vmalloc</function>, <function>vmalloc_32</function> or <function>__vmalloc</function>. If <parameter>addr</parameter> is
   NULL, no operation is performed.
   </para><para>

   Must not be called in interrupt context.
</para>
</refsect1>
</refentry>

<refentry id="API-vunmap">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vunmap</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vunmap</refname>
 <refpurpose>
     release virtual mapping obtained by <function>vmap</function>
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>vunmap </function></funcdef>
   <paramdef>const void * <parameter>addr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     memory base address
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Free the virtually contiguous memory area starting at <parameter>addr</parameter>,
   which was created from the page array passed to <function>vmap</function>.
   </para><para>

   Must not be called in interrupt context.
</para>
</refsect1>
</refentry>

<refentry id="API-vmap">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vmap</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vmap</refname>
 <refpurpose>
     map an array of pages into virtually contiguous space
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>vmap </function></funcdef>
   <paramdef>struct page ** <parameter>pages</parameter></paramdef>
   <paramdef>unsigned int <parameter>count</parameter></paramdef>
   <paramdef>unsigned long <parameter>flags</parameter></paramdef>
   <paramdef>pgprot_t <parameter>prot</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pages</parameter></term>
   <listitem>
    <para>
     array of page pointers
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     number of pages to map
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>flags</parameter></term>
   <listitem>
    <para>
     vm_area-&gt;flags
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>prot</parameter></term>
   <listitem>
    <para>
     page protection for the mapping
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Maps <parameter>count</parameter> pages from <parameter>pages</parameter> into contiguous kernel virtual
   space.
</para>
</refsect1>
</refentry>

<refentry id="API-vmalloc">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vmalloc</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vmalloc</refname>
 <refpurpose>
     allocate virtually contiguous memory
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>vmalloc </function></funcdef>
   <paramdef>unsigned long <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     allocation size
     Allocate enough pages to cover <parameter>size</parameter> from the page level
     allocator and map them into contiguous kernel virtual space.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   For tight control over page level allocator and protection flags
   use <function>__vmalloc</function> instead.
</para>
</refsect1>
</refentry>

<refentry id="API-vmalloc-user">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vmalloc_user</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vmalloc_user</refname>
 <refpurpose>
     allocate zeroed virtually contiguous memory for userspace
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>vmalloc_user </function></funcdef>
   <paramdef>unsigned long <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     allocation size
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The resulting memory area is zeroed so it can be mapped to userspace
   without leaking data.
</para>
</refsect1>
</refentry>

<refentry id="API-vmalloc-node">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vmalloc_node</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vmalloc_node</refname>
 <refpurpose>
     allocate memory on a specific node
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>vmalloc_node </function></funcdef>
   <paramdef>unsigned long <parameter>size</parameter></paramdef>
   <paramdef>int <parameter>node</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     allocation size
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>node</parameter></term>
   <listitem>
    <para>
     numa node
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Allocate enough pages to cover <parameter>size</parameter> from the page level
   allocator and map them into contiguous kernel virtual space.
   </para><para>

   For tight control over page level allocator and protection flags
   use <function>__vmalloc</function> instead.
</para>
</refsect1>
</refentry>

<refentry id="API-vmalloc-32">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vmalloc_32</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vmalloc_32</refname>
 <refpurpose>
     allocate virtually contiguous memory (32bit addressable)
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>vmalloc_32 </function></funcdef>
   <paramdef>unsigned long <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     allocation size
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Allocate enough 32bit PA addressable pages to cover <parameter>size</parameter> from the
   page level allocator and map them into contiguous kernel virtual space.
</para>
</refsect1>
</refentry>

<refentry id="API-vmalloc-32-user">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vmalloc_32_user</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vmalloc_32_user</refname>
 <refpurpose>
     allocate zeroed virtually contiguous 32bit memory
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>vmalloc_32_user </function></funcdef>
   <paramdef>unsigned long <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     allocation size
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The resulting memory area is 32bit addressable and zeroed so it can be
   mapped to userspace without leaking data.
</para>
</refsect1>
</refentry>

<refentry id="API-remap-vmalloc-range">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>remap_vmalloc_range</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>remap_vmalloc_range</refname>
 <refpurpose>
     map vmalloc pages to userspace
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>remap_vmalloc_range </function></funcdef>
   <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef>
   <paramdef>void * <parameter>addr</parameter></paramdef>
   <paramdef>unsigned long <parameter>pgoff</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>vma</parameter></term>
   <listitem>
    <para>
     vma to cover (map full range of vma)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>addr</parameter></term>
   <listitem>
    <para>
     vmalloc memory
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pgoff</parameter></term>
   <listitem>
    <para>
     number of pages into addr before first page to map
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Returns</title>
<para>
   0 for success, -Exxx on failure
   </para><para>

   This function checks that addr is a valid vmalloc'ed area, and
   that it is big enough to cover the vma. Will return failure if
   that criteria isn't met.
   </para><para>

   Similar to <function>remap_pfn_range</function> (see mm/memory.c)
</para>
</refsect1>
</refentry>

<refentry id="API-alloc-vm-area">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>alloc_vm_area</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>alloc_vm_area</refname>
 <refpurpose>
     allocate a range of kernel address space
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct vm_struct * <function>alloc_vm_area </function></funcdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     size of the area
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Returns</title>
<para>
   NULL on failure, vm_struct on success
   </para><para>

   This function reserves a range of kernel address space, and
   allocates pagetables to map that range.  No actual mappings
   are created.  If the kernel address space is not shared
   between processes, it syncs the pagetable across all
   processes.
</para>
</refsect1>
</refentry>

<!-- mm/page_alloc.c -->
<refentry id="API-find-next-best-node">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>find_next_best_node</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>find_next_best_node</refname>
 <refpurpose>
  find the next node that should appear in a given node's fallback list
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>find_next_best_node </function></funcdef>
   <paramdef>int <parameter>node</parameter></paramdef>
   <paramdef>nodemask_t * <parameter>used_node_mask</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>node</parameter></term>
   <listitem>
    <para>
     node whose fallback list we're appending
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>used_node_mask</parameter></term>
   <listitem>
    <para>
     nodemask_t of already used nodes
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   We use a number of factors to determine which is the next node that should
   appear on a given node's fallback list.  The node should not have appeared
   already in <parameter>node</parameter>'s fallback list, and it should be the next closest node
   according to the distance array (which contains arbitrary distance values
   from each node to each node in the system), and should also prefer nodes
   with no CPUs, since presumably they'll have very little allocation pressure
   on them otherwise.
   It returns -1 if no node is found.
</para>
</refsect1>
</refentry>

<refentry id="API-free-bootmem-with-active-regions">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>free_bootmem_with_active_regions</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>free_bootmem_with_active_regions</refname>
 <refpurpose>
     Call free_bootmem_node for each active range
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>free_bootmem_with_active_regions </function></funcdef>
   <paramdef>int <parameter>nid</parameter></paramdef>
   <paramdef>unsigned long <parameter>max_low_pfn</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nid</parameter></term>
   <listitem>
    <para>
     The node to free memory on. If MAX_NUMNODES, all nodes are freed.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>max_low_pfn</parameter></term>
   <listitem>
    <para>
     The highest PFN that will be passed to free_bootmem_node
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   If an architecture guarantees that all ranges registered with
   <function>add_active_ranges</function> contain no holes and may be freed, this
   this function may be used instead of calling <function>free_bootmem</function> manually.
</para>
</refsect1>
</refentry>

<refentry id="API-sparse-memory-present-with-active-regions">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>sparse_memory_present_with_active_regions</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>sparse_memory_present_with_active_regions</refname>
 <refpurpose>
     Call memory_present for each active range
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>sparse_memory_present_with_active_regions </function></funcdef>
   <paramdef>int <parameter>nid</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nid</parameter></term>
   <listitem>
    <para>
     The node to call memory_present for. If MAX_NUMNODES, all nodes will be used.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   If an architecture guarantees that all ranges registered with
   <function>add_active_ranges</function> contain no holes and may be freed, this
   function may be used instead of calling <function>memory_present</function> manually.
</para>
</refsect1>
</refentry>

<refentry id="API-get-pfn-range-for-nid">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>get_pfn_range_for_nid</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>get_pfn_range_for_nid</refname>
 <refpurpose>
     Return the start and end page frames for a node
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void __meminit <function>get_pfn_range_for_nid </function></funcdef>
   <paramdef>unsigned int <parameter>nid</parameter></paramdef>
   <paramdef>unsigned long * <parameter>start_pfn</parameter></paramdef>
   <paramdef>unsigned long * <parameter>end_pfn</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nid</parameter></term>
   <listitem>
    <para>
     The nid to return the range for. If MAX_NUMNODES, the min and max PFN are returned.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>start_pfn</parameter></term>
   <listitem>
    <para>
     Passed by reference. On return, it will have the node start_pfn.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>end_pfn</parameter></term>
   <listitem>
    <para>
     Passed by reference. On return, it will have the node end_pfn.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   It returns the start and end page frame of a node based on information
   provided by an arch calling <function>add_active_range</function>. If called for a node
   with no available memory, a warning is printed and the start and end
   PFNs will be 0.
</para>
</refsect1>
</refentry>

<refentry id="API-absent-pages-in-range">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>absent_pages_in_range</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>absent_pages_in_range</refname>
 <refpurpose>
     Return number of page frames in holes within a range
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>absent_pages_in_range </function></funcdef>
   <paramdef>unsigned long <parameter>start_pfn</parameter></paramdef>
   <paramdef>unsigned long <parameter>end_pfn</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>start_pfn</parameter></term>
   <listitem>
    <para>
     The start PFN to start searching for holes
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>end_pfn</parameter></term>
   <listitem>
    <para>
     The end PFN to stop searching for holes
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   It returns the number of pages frames in memory holes within a range.
</para>
</refsect1>
</refentry>

<refentry id="API-add-active-range">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>add_active_range</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>add_active_range</refname>
 <refpurpose>
     Register a range of PFNs backed by physical memory
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>add_active_range </function></funcdef>
   <paramdef>unsigned int <parameter>nid</parameter></paramdef>
   <paramdef>unsigned long <parameter>start_pfn</parameter></paramdef>
   <paramdef>unsigned long <parameter>end_pfn</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nid</parameter></term>
   <listitem>
    <para>
     The node ID the range resides on
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>start_pfn</parameter></term>
   <listitem>
    <para>
     The start PFN of the available physical memory
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>end_pfn</parameter></term>
   <listitem>
    <para>
     The end PFN of the available physical memory
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   These ranges are stored in an early_node_map[] and later used by
   <function>free_area_init_nodes</function> to calculate zone sizes and holes. If the
   range spans a memory hole, it is up to the architecture to ensure
   the memory is not freed by the bootmem allocator. If possible
   the range being registered will be merged with existing ranges.
</para>
</refsect1>
</refentry>

<refentry id="API-remove-active-range">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>remove_active_range</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>remove_active_range</refname>
 <refpurpose>
     Shrink an existing registered range of PFNs
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>remove_active_range </function></funcdef>
   <paramdef>unsigned int <parameter>nid</parameter></paramdef>
   <paramdef>unsigned long <parameter>start_pfn</parameter></paramdef>
   <paramdef>unsigned long <parameter>end_pfn</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nid</parameter></term>
   <listitem>
    <para>
     The node id the range is on that should be shrunk
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>start_pfn</parameter></term>
   <listitem>
    <para>
     The new PFN of the range
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>end_pfn</parameter></term>
   <listitem>
    <para>
     The new PFN of the range
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   i386 with NUMA use <function>alloc_remap</function> to store a node_mem_map on a local node.
   The map is kept near the end physical page range that has already been
   registered. This function allows an arch to shrink an existing registered
   range.
</para>
</refsect1>
</refentry>

<refentry id="API-remove-all-active-ranges">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>remove_all_active_ranges</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>remove_all_active_ranges</refname>
 <refpurpose>
     Remove all currently registered regions
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>remove_all_active_ranges </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   During discovery, it may be found that a table like SRAT is invalid
   and an alternative discovery method must be used. This function removes
   all currently registered regions.
</para>
</refsect1>
</refentry>

<refentry id="API-find-min-pfn-with-active-regions">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>find_min_pfn_with_active_regions</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>find_min_pfn_with_active_regions</refname>
 <refpurpose>
     Find the minimum PFN registered
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>find_min_pfn_with_active_regions </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   It returns the minimum PFN based on information provided via
   <function>add_active_range</function>.
</para>
</refsect1>
</refentry>

<refentry id="API-free-area-init-nodes">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>free_area_init_nodes</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>free_area_init_nodes</refname>
 <refpurpose>
     Initialise all pg_data_t and zone data
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>free_area_init_nodes </function></funcdef>
   <paramdef>unsigned long * <parameter>max_zone_pfn</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>max_zone_pfn</parameter></term>
   <listitem>
    <para>
     an array of max PFNs for each zone
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This will call <function>free_area_init_node</function> for each active node in the system.
   Using the page ranges provided by <function>add_active_range</function>, the size of each
   zone in each node and their holes is calculated. If the maximum PFN
   between two adjacent zones match, it is assumed that the zone is empty.
   For example, if arch_max_dma_pfn == arch_max_dma32_pfn, it is assumed
   that arch_max_dma32_pfn has no pages. It is also assumed that a zone
   starts where the previous one ended. For example, ZONE_DMA32 starts
   at arch_max_dma_pfn.
</para>
</refsect1>
</refentry>

<refentry id="API-set-dma-reserve">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>set_dma_reserve</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>set_dma_reserve</refname>
 <refpurpose>
     set the specified number of pages reserved in the first zone
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>set_dma_reserve </function></funcdef>
   <paramdef>unsigned long <parameter>new_dma_reserve</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>new_dma_reserve</parameter></term>
   <listitem>
    <para>
     The number of pages to mark reserved
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The per-cpu batchsize and zone watermarks are determined by present_pages.
   In the DMA zone, a significant percentage may be consumed by kernel image
   and other unfreeable allocations which can skew the watermarks badly. This
   function may optionally be used to account for unfreeable pages in the
   first zone (e.g., ZONE_DMA). The effect will be lower watermarks and
   smaller per-cpu batchsize.
</para>
</refsect1>
</refentry>

<refentry id="API-setup-per-zone-wmarks">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>setup_per_zone_wmarks</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>setup_per_zone_wmarks</refname>
 <refpurpose>
     called when min_free_kbytes changes or when memory is hot-{added|removed}
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>setup_per_zone_wmarks </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   Ensures that the watermark[min,low,high] values for each zone are set
   correctly with respect to min_free_kbytes.
</para>
</refsect1>
</refentry>

<refentry id="API-get-pageblock-flags-group">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>get_pageblock_flags_group</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>get_pageblock_flags_group</refname>
 <refpurpose>
     Return the requested group of flags for the pageblock_nr_pages block of pages
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>get_pageblock_flags_group </function></funcdef>
   <paramdef>struct page * <parameter>page</parameter></paramdef>
   <paramdef>int <parameter>start_bitidx</parameter></paramdef>
   <paramdef>int <parameter>end_bitidx</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>page</parameter></term>
   <listitem>
    <para>
     The page within the block of interest
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>start_bitidx</parameter></term>
   <listitem>
    <para>
     The first bit of interest to retrieve
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>end_bitidx</parameter></term>
   <listitem>
    <para>
     The last bit of interest
     returns pageblock_bits flags
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-set-pageblock-flags-group">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>set_pageblock_flags_group</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>set_pageblock_flags_group</refname>
 <refpurpose>
     Set the requested group of flags for a pageblock_nr_pages block of pages
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>set_pageblock_flags_group </function></funcdef>
   <paramdef>struct page * <parameter>page</parameter></paramdef>
   <paramdef>unsigned long <parameter>flags</parameter></paramdef>
   <paramdef>int <parameter>start_bitidx</parameter></paramdef>
   <paramdef>int <parameter>end_bitidx</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>page</parameter></term>
   <listitem>
    <para>
     The page within the block of interest
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>flags</parameter></term>
   <listitem>
    <para>
     The flags to set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>start_bitidx</parameter></term>
   <listitem>
    <para>
     The first bit of interest
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>end_bitidx</parameter></term>
   <listitem>
    <para>
     The last bit of interest
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<!-- mm/mempool.c -->
<refentry id="API-mempool-create">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>mempool_create</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>mempool_create</refname>
 <refpurpose>
  create a memory pool
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>mempool_t * <function>mempool_create </function></funcdef>
   <paramdef>int <parameter>min_nr</parameter></paramdef>
   <paramdef>mempool_alloc_t * <parameter>alloc_fn</parameter></paramdef>
   <paramdef>mempool_free_t * <parameter>free_fn</parameter></paramdef>
   <paramdef>void * <parameter>pool_data</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>min_nr</parameter></term>
   <listitem>
    <para>
     the minimum number of elements guaranteed to be
     allocated for this pool.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>alloc_fn</parameter></term>
   <listitem>
    <para>
     user-defined element-allocation function.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>free_fn</parameter></term>
   <listitem>
    <para>
     user-defined element-freeing function.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pool_data</parameter></term>
   <listitem>
    <para>
     optional private data available to the user-defined functions.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   this function creates and allocates a guaranteed size, preallocated
   memory pool. The pool can be used from the <function>mempool_alloc</function> and <function>mempool_free</function>
   functions. This function might sleep. Both the <function>alloc_fn</function> and the <function>free_fn</function>
   functions might sleep - as long as the <function>mempool_alloc</function> function is not called
   from IRQ contexts.
</para>
</refsect1>
</refentry>

<refentry id="API-mempool-resize">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>mempool_resize</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>mempool_resize</refname>
 <refpurpose>
     resize an existing memory pool
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>mempool_resize </function></funcdef>
   <paramdef>mempool_t * <parameter>pool</parameter></paramdef>
   <paramdef>int <parameter>new_min_nr</parameter></paramdef>
   <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pool</parameter></term>
   <listitem>
    <para>
     pointer to the memory pool which was allocated via
     <function>mempool_create</function>.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>new_min_nr</parameter></term>
   <listitem>
    <para>
     the new minimum number of elements guaranteed to be
     allocated for this pool.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>gfp_mask</parameter></term>
   <listitem>
    <para>
     the usual allocation bitmask.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function shrinks/grows the pool. In the case of growing,
   it cannot be guaranteed that the pool will be grown to the new
   size immediately, but new <function>mempool_free</function> calls will refill it.
   </para><para>

   Note, the caller must guarantee that no mempool_destroy is called
   while this function is running. <function>mempool_alloc</function> &amp; <function>mempool_free</function>
   might be called (eg. from IRQ contexts) while this function executes.
</para>
</refsect1>
</refentry>

<refentry id="API-mempool-destroy">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>mempool_destroy</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>mempool_destroy</refname>
 <refpurpose>
     deallocate a memory pool
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>mempool_destroy </function></funcdef>
   <paramdef>mempool_t * <parameter>pool</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pool</parameter></term>
   <listitem>
    <para>
     pointer to the memory pool which was allocated via
     <function>mempool_create</function>.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   this function only sleeps if the <function>free_fn</function> function sleeps. The caller
   has to guarantee that all elements have been returned to the pool (ie:
   freed) prior to calling <function>mempool_destroy</function>.
</para>
</refsect1>
</refentry>

<refentry id="API-mempool-alloc">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>mempool_alloc</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>mempool_alloc</refname>
 <refpurpose>
     allocate an element from a specific memory pool
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>mempool_alloc </function></funcdef>
   <paramdef>mempool_t * <parameter>pool</parameter></paramdef>
   <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pool</parameter></term>
   <listitem>
    <para>
     pointer to the memory pool which was allocated via
     <function>mempool_create</function>.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>gfp_mask</parameter></term>
   <listitem>
    <para>
     the usual allocation bitmask.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   this function only sleeps if the <function>alloc_fn</function> function sleeps or
   returns NULL. Note that due to preallocation, this function
   *never* fails when called from process contexts. (it might
   fail if called from an IRQ context.)
</para>
</refsect1>
</refentry>

<refentry id="API-mempool-free">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>mempool_free</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>mempool_free</refname>
 <refpurpose>
     return an element to the pool.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>mempool_free </function></funcdef>
   <paramdef>void * <parameter>element</parameter></paramdef>
   <paramdef>mempool_t * <parameter>pool</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>element</parameter></term>
   <listitem>
    <para>
     pool element pointer.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pool</parameter></term>
   <listitem>
    <para>
     pointer to the memory pool which was allocated via
     <function>mempool_create</function>.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   this function only sleeps if the <function>free_fn</function> function sleeps.
</para>
</refsect1>
</refentry>

<!-- mm/dmapool.c -->
<refentry id="API-dma-pool-create">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>dma_pool_create</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>dma_pool_create</refname>
 <refpurpose>
  Creates a pool of consistent memory blocks, for dma.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct dma_pool * <function>dma_pool_create </function></funcdef>
   <paramdef>const char * <parameter>name</parameter></paramdef>
   <paramdef>struct device * <parameter>dev</parameter></paramdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>size_t <parameter>align</parameter></paramdef>
   <paramdef>size_t <parameter>boundary</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>name</parameter></term>
   <listitem>
    <para>
     name of pool, for diagnostics
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     device that will be doing the DMA
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     size of the blocks in this pool.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>align</parameter></term>
   <listitem>
    <para>
     alignment requirement for blocks; must be a power of two
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>boundary</parameter></term>
   <listitem>
    <para>
     returned blocks won't cross this power of two boundary
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Context</title>
<para>
   !<function>in_interrupt</function>
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns a dma allocation pool with the requested characteristics, or
   null if one can't be created.  Given one of these pools, <function>dma_pool_alloc</function>
   may be used to allocate memory.  Such memory will all have <quote>consistent</quote>
   DMA mappings, accessible by the device and its driver without using
   cache flushing primitives.  The actual size of blocks allocated may be
   larger than requested because of alignment.
   </para><para>

   If <parameter>boundary</parameter> is nonzero, objects returned from <function>dma_pool_alloc</function> won't
   cross that size boundary.  This is useful for devices which have
   addressing restrictions on individual DMA transfers, such as not crossing
   boundaries of 4KBytes.
</para>
</refsect1>
</refentry>

<refentry id="API-dma-pool-destroy">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>dma_pool_destroy</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>dma_pool_destroy</refname>
 <refpurpose>
     destroys a pool of dma memory blocks.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>dma_pool_destroy </function></funcdef>
   <paramdef>struct dma_pool * <parameter>pool</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pool</parameter></term>
   <listitem>
    <para>
     dma pool that will be destroyed
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Context</title>
<para>
   !<function>in_interrupt</function>
</para>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Caller guarantees that no more memory from the pool is in use,
   and that nothing will try to use the pool after this call.
</para>
</refsect1>
</refentry>

<refentry id="API-dma-pool-alloc">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>dma_pool_alloc</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>dma_pool_alloc</refname>
 <refpurpose>
     get a block of consistent memory
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>dma_pool_alloc </function></funcdef>
   <paramdef>struct dma_pool * <parameter>pool</parameter></paramdef>
   <paramdef>gfp_t <parameter>mem_flags</parameter></paramdef>
   <paramdef>dma_addr_t * <parameter>handle</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pool</parameter></term>
   <listitem>
    <para>
     dma pool that will produce the block
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>mem_flags</parameter></term>
   <listitem>
    <para>
     GFP_* bitmask
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>handle</parameter></term>
   <listitem>
    <para>
     pointer to dma address of block
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This returns the kernel virtual address of a currently unused block,
   and reports its dma address through the handle.
   If such a memory block can't be allocated, <constant>NULL</constant> is returned.
</para>
</refsect1>
</refentry>

<refentry id="API-dma-pool-free">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>dma_pool_free</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>dma_pool_free</refname>
 <refpurpose>
     put block back into dma pool
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>dma_pool_free </function></funcdef>
   <paramdef>struct dma_pool * <parameter>pool</parameter></paramdef>
   <paramdef>void * <parameter>vaddr</parameter></paramdef>
   <paramdef>dma_addr_t <parameter>dma</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pool</parameter></term>
   <listitem>
    <para>
     the dma pool holding the block
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>vaddr</parameter></term>
   <listitem>
    <para>
     virtual address of block
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dma</parameter></term>
   <listitem>
    <para>
     dma address of block
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Caller promises neither device nor driver will again touch this block
   unless it is first re-allocated.
</para>
</refsect1>
</refentry>

<refentry id="API-dmam-pool-create">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>dmam_pool_create</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>dmam_pool_create</refname>
 <refpurpose>
     Managed <function>dma_pool_create</function>
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct dma_pool * <function>dmam_pool_create </function></funcdef>
   <paramdef>const char * <parameter>name</parameter></paramdef>
   <paramdef>struct device * <parameter>dev</parameter></paramdef>
   <paramdef>size_t <parameter>size</parameter></paramdef>
   <paramdef>size_t <parameter>align</parameter></paramdef>
   <paramdef>size_t <parameter>allocation</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>name</parameter></term>
   <listitem>
    <para>
     name of pool, for diagnostics
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     device that will be doing the DMA
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     size of the blocks in this pool.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>align</parameter></term>
   <listitem>
    <para>
     alignment requirement for blocks; must be a power of two
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>allocation</parameter></term>
   <listitem>
    <para>
     returned blocks won't cross this boundary (or zero)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Managed <function>dma_pool_create</function>.  DMA pool created with this function is
   automatically destroyed on driver detach.
</para>
</refsect1>
</refentry>

<refentry id="API-dmam-pool-destroy">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>dmam_pool_destroy</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>dmam_pool_destroy</refname>
 <refpurpose>
     Managed <function>dma_pool_destroy</function>
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>dmam_pool_destroy </function></funcdef>
   <paramdef>struct dma_pool * <parameter>pool</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pool</parameter></term>
   <listitem>
    <para>
     dma pool that will be destroyed
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Managed <function>dma_pool_destroy</function>.
</para>
</refsect1>
</refentry>

<!-- mm/page-writeback.c -->
<refentry id="API-balance-dirty-pages-ratelimited-nr">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>balance_dirty_pages_ratelimited_nr</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>balance_dirty_pages_ratelimited_nr</refname>
 <refpurpose>
  balance dirty memory state
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>balance_dirty_pages_ratelimited_nr </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>unsigned long <parameter>nr_pages_dirtied</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     address_space which was dirtied
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>nr_pages_dirtied</parameter></term>
   <listitem>
    <para>
     number of pages which the caller has just dirtied
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Processes which are dirtying memory should call in here once for each page
   which was newly dirtied.  The function will periodically check the system's
   dirty state and will initiate writeback if needed.
   </para><para>

   On really big machines, get_writeback_state is expensive, so try to avoid
   calling it too often (ratelimiting).  But once we're over the dirty memory
   limit we decrease the ratelimiting by a lot, to prevent individual processes
   from overshooting the limit by (ratelimit_pages) each.
</para>
</refsect1>
</refentry>

<refentry id="API-write-cache-pages">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>write_cache_pages</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>write_cache_pages</refname>
 <refpurpose>
     walk the list of dirty pages of the given address space and write all of them.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>write_cache_pages </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>struct writeback_control * <parameter>wbc</parameter></paramdef>
   <paramdef>writepage_t <parameter>writepage</parameter></paramdef>
   <paramdef>void * <parameter>data</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     address space structure to write
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>wbc</parameter></term>
   <listitem>
    <para>
     subtract the number of written pages from *<parameter>wbc</parameter>-&gt;nr_to_write
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>writepage</parameter></term>
   <listitem>
    <para>
     function called for each page
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>data</parameter></term>
   <listitem>
    <para>
     data passed to writepage function
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   If a page is already under I/O, <function>write_cache_pages</function> skips it, even
   if it's dirty.  This is desirable behaviour for memory-cleaning writeback,
   but it is INCORRECT for data-integrity system calls such as <function>fsync</function>.  <function>fsync</function>
   and <function>msync</function> need to guarantee that all the data which was dirty at the time
   the call was made get new I/O started against them.  If wbc-&gt;sync_mode is
   WB_SYNC_ALL then we were called for data integrity and we must wait for
   existing IO to complete.
</para>
</refsect1>
</refentry>

<refentry id="API-generic-writepages">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>generic_writepages</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>generic_writepages</refname>
 <refpurpose>
     walk the list of dirty pages of the given address space and <function>writepage</function> all of them.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>generic_writepages </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>struct writeback_control * <parameter>wbc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     address space structure to write
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>wbc</parameter></term>
   <listitem>
    <para>
     subtract the number of written pages from *<parameter>wbc</parameter>-&gt;nr_to_write
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This is a library function, which implements the <function>writepages</function>
   address_space_operation.
</para>
</refsect1>
</refentry>

<refentry id="API-write-one-page">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>write_one_page</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>write_one_page</refname>
 <refpurpose>
     write out a single page and optionally wait on I/O
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>write_one_page </function></funcdef>
   <paramdef>struct page * <parameter>page</parameter></paramdef>
   <paramdef>int <parameter>wait</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>page</parameter></term>
   <listitem>
    <para>
     the page to write
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>wait</parameter></term>
   <listitem>
    <para>
     if true, wait on writeout
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The page must be locked by the caller and will be unlocked upon return.
   </para><para>

   <function>write_one_page</function> returns a negative error code if I/O failed.
</para>
</refsect1>
</refentry>

<!-- mm/truncate.c -->
<refentry id="API-truncate-inode-pages-range">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>truncate_inode_pages_range</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>truncate_inode_pages_range</refname>
 <refpurpose>
  truncate range of pages specified by start &amp; end byte offsets
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>truncate_inode_pages_range </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>loff_t <parameter>lstart</parameter></paramdef>
   <paramdef>loff_t <parameter>lend</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     mapping to truncate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>lstart</parameter></term>
   <listitem>
    <para>
     offset from which to truncate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>lend</parameter></term>
   <listitem>
    <para>
     offset to which to truncate
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Truncate the page cache, removing the pages that are between
   specified offsets (and zeroing out partial page
   (if lstart is not page aligned)).
   </para><para>

   Truncate takes two passes - the first pass is nonblocking.  It will not
   block on page locks and it will not block on writeback.  The second pass
   will wait.  This is to prevent as much IO as possible in the affected region.
   The first pass will remove most pages, so the search cost of the second pass
   is low.
   </para><para>

   When looking at page-&gt;index outside the page lock we need to be careful to
   copy it into a local to avoid races (it could change at any time).
   </para><para>

   We pass down the cache-hot hint to the page freeing code.  Even if the
   mapping is large, it is probably the case that the final pages are the most
   recently touched, and freeing happens in ascending file offset order.
</para>
</refsect1>
</refentry>

<refentry id="API-truncate-inode-pages">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>truncate_inode_pages</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>truncate_inode_pages</refname>
 <refpurpose>
     truncate *all* the pages from an offset
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>truncate_inode_pages </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>loff_t <parameter>lstart</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     mapping to truncate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>lstart</parameter></term>
   <listitem>
    <para>
     offset from which to truncate
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Called under (and serialised by) inode-&gt;i_mutex.
</para>
</refsect1>
</refentry>

<refentry id="API-invalidate-mapping-pages">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>invalidate_mapping_pages</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>invalidate_mapping_pages</refname>
 <refpurpose>
     Invalidate all the unlocked pages of one inode
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>invalidate_mapping_pages </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>pgoff_t <parameter>start</parameter></paramdef>
   <paramdef>pgoff_t <parameter>end</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     the address_space which holds the pages to invalidate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>start</parameter></term>
   <listitem>
    <para>
     the offset 'from' which to invalidate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>end</parameter></term>
   <listitem>
    <para>
     the offset 'to' which to invalidate (inclusive)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function only removes the unlocked pages, if you want to
   remove all the pages of one inode, you must call truncate_inode_pages.
   </para><para>

   <function>invalidate_mapping_pages</function> will not block on IO activity. It will not
   invalidate pages which are dirty, locked, under writeback or mapped into
   pagetables.
</para>
</refsect1>
</refentry>

<refentry id="API-invalidate-inode-pages2-range">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>invalidate_inode_pages2_range</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>invalidate_inode_pages2_range</refname>
 <refpurpose>
     remove range of pages from an address_space
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>invalidate_inode_pages2_range </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
   <paramdef>pgoff_t <parameter>start</parameter></paramdef>
   <paramdef>pgoff_t <parameter>end</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     the address_space
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>start</parameter></term>
   <listitem>
    <para>
     the page offset 'from' which to invalidate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>end</parameter></term>
   <listitem>
    <para>
     the page offset 'to' which to invalidate (inclusive)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Any pages which are found to be mapped into pagetables are unmapped prior to
   invalidation.
   </para><para>

   Returns -EBUSY if any pages could not be invalidated.
</para>
</refsect1>
</refentry>

<refentry id="API-invalidate-inode-pages2">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>invalidate_inode_pages2</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>invalidate_inode_pages2</refname>
 <refpurpose>
     remove all pages from an address_space
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>invalidate_inode_pages2 </function></funcdef>
   <paramdef>struct address_space * <parameter>mapping</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>mapping</parameter></term>
   <listitem>
    <para>
     the address_space
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Any pages which are found to be mapped into pagetables are unmapped prior to
   invalidation.
   </para><para>

   Returns -EIO if any pages could not be invalidated.
</para>
</refsect1>
</refentry>

<refentry id="API-truncate-pagecache">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>truncate_pagecache</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>truncate_pagecache</refname>
 <refpurpose>
     unmap and remove pagecache that has been truncated
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>truncate_pagecache </function></funcdef>
   <paramdef>struct inode * <parameter>inode</parameter></paramdef>
   <paramdef>loff_t <parameter>old</parameter></paramdef>
   <paramdef>loff_t <parameter>new</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>inode</parameter></term>
   <listitem>
    <para>
     inode
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>old</parameter></term>
   <listitem>
    <para>
     old file offset
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     new file offset
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   inode's new i_size must already be written before truncate_pagecache
   is called.
   </para><para>

   This function should typically be called before the filesystem
   releases resources associated with the freed range (eg. deallocates
   blocks). This way, pagecache will always stay logically coherent
   with on-disk format, and the filesystem would not have to deal with
   situations such as writepage being called for a page that has already
   had its underlying blocks deallocated.
</para>
</refsect1>
</refentry>

<refentry id="API-vmtruncate">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>vmtruncate</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>vmtruncate</refname>
 <refpurpose>
     unmap mappings <quote>freed</quote> by <function>truncate</function> syscall
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>vmtruncate </function></funcdef>
   <paramdef>struct inode * <parameter>inode</parameter></paramdef>
   <paramdef>loff_t <parameter>offset</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>inode</parameter></term>
   <listitem>
    <para>
     inode of the file used
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>offset</parameter></term>
   <listitem>
    <para>
     file offset to start truncating
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   NOTE! We have to be ready to update the memory sharing
   between the file and the memory map for a potential last
   incomplete page.  Ugly, but necessary.
</para>
</refsect1>
</refentry>

     </sect1>
  </chapter>


  <chapter id="ipc">
     <title>Kernel IPC facilities</title>

     <sect1><title>IPC utilities</title>
<!-- ipc/util.c -->
<refentry id="API-ipc-init">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_init</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_init</refname>
 <refpurpose>
  initialise IPC subsystem
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ipc_init </function></funcdef>
   <paramdef> <parameter>void</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>void</parameter></term>
   <listitem>
    <para>
     no arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   </para><para>

   The various system5 IPC resources (semaphores, messages and shared
   memory) are initialised
   A callback routine is registered into the memory hotplug notifier
</para>
</refsect1>
<refsect1>
<title>chain</title>
<para>
   since msgmni scales to lowmem this callback routine will be
   called upon successful memory add / remove to recompute msmgni.
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-init-ids">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_init_ids</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_init_ids</refname>
 <refpurpose>
     initialise IPC identifiers
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ipc_init_ids </function></funcdef>
   <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ids</parameter></term>
   <listitem>
    <para>
     Identifier set
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Set up the sequence range to use for the ipc identifier range (limited
   below IPCMNI) then initialise the ids idr.
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-init-proc-interface">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_init_proc_interface</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_init_proc_interface</refname>
 <refpurpose>
     Create a proc interface for sysipc types using a seq_file interface.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ipc_init_proc_interface </function></funcdef>
   <paramdef>const char * <parameter>path</parameter></paramdef>
   <paramdef>const char * <parameter>header</parameter></paramdef>
   <paramdef>int <parameter>ids</parameter></paramdef>
   <paramdef>int (*<parameter>show</parameter>)
     <funcparams>struct seq_file *, void *</funcparams></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>path</parameter></term>
   <listitem>
    <para>
     Path in procfs
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>header</parameter></term>
   <listitem>
    <para>
     Banner to be printed at the beginning of the file.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ids</parameter></term>
   <listitem>
    <para>
     ipc id table to iterate.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>show</parameter></term>
   <listitem>
    <para>
     show routine.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-ipc-findkey">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_findkey</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_findkey</refname>
 <refpurpose>
     find a key in an ipc identifier set
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct kern_ipc_perm * <function>ipc_findkey </function></funcdef>
   <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef>
   <paramdef>key_t <parameter>key</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ids</parameter></term>
   <listitem>
    <para>
     Identifier set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>key</parameter></term>
   <listitem>
    <para>
     The key to find
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Requires ipc_ids.rw_mutex locked.
   Returns the LOCKED pointer to the ipc structure if found or NULL
   if not.
   If key is found ipc points to the owning ipc structure
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-get-maxid">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_get_maxid</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_get_maxid</refname>
 <refpurpose>
     get the last assigned id
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ipc_get_maxid </function></funcdef>
   <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ids</parameter></term>
   <listitem>
    <para>
     IPC identifier set
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Called with ipc_ids.rw_mutex held.
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-addid">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_addid</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_addid</refname>
 <refpurpose>
     add an IPC identifier
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ipc_addid </function></funcdef>
   <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef>
   <paramdef>struct kern_ipc_perm * <parameter>new</parameter></paramdef>
   <paramdef>int <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ids</parameter></term>
   <listitem>
    <para>
     IPC identifier set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     new IPC permission set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     limit for the number of used ids
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Add an entry 'new' to the IPC ids idr. The permissions object is
   initialised and the first free entry is set up and the id assigned
   is returned. The 'new' entry is returned in a locked state on success.
   On failure the entry is not locked and a negative err-code is returned.
   </para><para>

   Called with ipc_ids.rw_mutex held as a writer.
</para>
</refsect1>
</refentry>

<refentry id="API-ipcget-new">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipcget_new</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipcget_new</refname>
 <refpurpose>
     create a new ipc object
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ipcget_new </function></funcdef>
   <paramdef>struct ipc_namespace * <parameter>ns</parameter></paramdef>
   <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef>
   <paramdef>struct ipc_ops * <parameter>ops</parameter></paramdef>
   <paramdef>struct ipc_params * <parameter>params</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ns</parameter></term>
   <listitem>
    <para>
     namespace
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ids</parameter></term>
   <listitem>
    <para>
     IPC identifer set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ops</parameter></term>
   <listitem>
    <para>
     the actual creation routine to call
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>params</parameter></term>
   <listitem>
    <para>
     its parameters
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This routine is called by sys_msgget, <function>sys_semget</function> and <function>sys_shmget</function>
   when the key is IPC_PRIVATE.
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-check-perms">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_check_perms</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_check_perms</refname>
 <refpurpose>
     check security and permissions for an IPC
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ipc_check_perms </function></funcdef>
   <paramdef>struct kern_ipc_perm * <parameter>ipcp</parameter></paramdef>
   <paramdef>struct ipc_ops * <parameter>ops</parameter></paramdef>
   <paramdef>struct ipc_params * <parameter>params</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ipcp</parameter></term>
   <listitem>
    <para>
     ipc permission set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ops</parameter></term>
   <listitem>
    <para>
     the actual security routine to call
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>params</parameter></term>
   <listitem>
    <para>
     its parameters
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This routine is called by <function>sys_msgget</function>, <function>sys_semget</function> and <function>sys_shmget</function>
   when the key is not IPC_PRIVATE and that key already exists in the
   ids IDR.
   </para><para>

   On success, the IPC id is returned.
   </para><para>

   It is called with ipc_ids.rw_mutex and ipcp-&gt;lock held.
</para>
</refsect1>
</refentry>

<refentry id="API-ipcget-public">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipcget_public</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipcget_public</refname>
 <refpurpose>
     get an ipc object or create a new one
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ipcget_public </function></funcdef>
   <paramdef>struct ipc_namespace * <parameter>ns</parameter></paramdef>
   <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef>
   <paramdef>struct ipc_ops * <parameter>ops</parameter></paramdef>
   <paramdef>struct ipc_params * <parameter>params</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ns</parameter></term>
   <listitem>
    <para>
     namespace
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ids</parameter></term>
   <listitem>
    <para>
     IPC identifer set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ops</parameter></term>
   <listitem>
    <para>
     the actual creation routine to call
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>params</parameter></term>
   <listitem>
    <para>
     its parameters
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This routine is called by sys_msgget, <function>sys_semget</function> and <function>sys_shmget</function>
   when the key is not IPC_PRIVATE.
   It adds a new entry if the key is not found and does some permission
   / security checkings if the key is found.
   </para><para>

   On success, the ipc id is returned.
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-rmid">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_rmid</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_rmid</refname>
 <refpurpose>
     remove an IPC identifier
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ipc_rmid </function></funcdef>
   <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef>
   <paramdef>struct kern_ipc_perm * <parameter>ipcp</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ids</parameter></term>
   <listitem>
    <para>
     IPC identifier set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ipcp</parameter></term>
   <listitem>
    <para>
     ipc perm structure containing the identifier to remove
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   ipc_ids.rw_mutex (as a writer) and the spinlock for this ID are held
   before this function is called, and remain locked on the exit.
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-alloc">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_alloc</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_alloc</refname>
 <refpurpose>
     allocate ipc space
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void* <function>ipc_alloc </function></funcdef>
   <paramdef>int <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     size desired
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Allocate memory from the appropriate pools and return a pointer to it.
   NULL is returned if the allocation fails
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-free">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_free</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_free</refname>
 <refpurpose>
     free ipc space
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ipc_free </function></funcdef>
   <paramdef>void * <parameter>ptr</parameter></paramdef>
   <paramdef>int <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ptr</parameter></term>
   <listitem>
    <para>
     pointer returned by ipc_alloc
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     size of block
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Free a block created with <function>ipc_alloc</function>. The caller must know the size
   used in the allocation call.
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-rcu-alloc">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_rcu_alloc</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_rcu_alloc</refname>
 <refpurpose>
     allocate ipc and rcu space
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void* <function>ipc_rcu_alloc </function></funcdef>
   <paramdef>int <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     size desired
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Allocate memory for the rcu header structure +  the object.
   Returns the pointer to the object.
   NULL is returned if the allocation fails. 
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-schedule-free">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_schedule_free</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_schedule_free</refname>
 <refpurpose>
     free ipc + rcu space
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ipc_schedule_free </function></funcdef>
   <paramdef>struct rcu_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     RCU callback structure for queued work
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Since RCU callback function is called in bh,
   we need to defer the vfree to <function>schedule_work</function>.
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-immediate-free">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_immediate_free</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_immediate_free</refname>
 <refpurpose>
     free ipc + rcu space
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ipc_immediate_free </function></funcdef>
   <paramdef>struct rcu_head * <parameter>head</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>head</parameter></term>
   <listitem>
    <para>
     RCU callback structure that contains pointer to be freed
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Free from the RCU callback context.
</para>
</refsect1>
</refentry>

<refentry id="API-ipcperms">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipcperms</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipcperms</refname>
 <refpurpose>
     check IPC permissions
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ipcperms </function></funcdef>
   <paramdef>struct kern_ipc_perm * <parameter>ipcp</parameter></paramdef>
   <paramdef>short <parameter>flag</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ipcp</parameter></term>
   <listitem>
    <para>
     IPC permission set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>flag</parameter></term>
   <listitem>
    <para>
     desired permission set.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Check user, group, other permissions for access
   to ipc resources. return 0 if allowed
</para>
</refsect1>
</refentry>

<refentry id="API-kernel-to-ipc64-perm">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kernel_to_ipc64_perm</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kernel_to_ipc64_perm</refname>
 <refpurpose>
     convert kernel ipc permissions to user
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kernel_to_ipc64_perm </function></funcdef>
   <paramdef>struct kern_ipc_perm * <parameter>in</parameter></paramdef>
   <paramdef>struct ipc64_perm * <parameter>out</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>in</parameter></term>
   <listitem>
    <para>
     kernel permissions
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>out</parameter></term>
   <listitem>
    <para>
     new style IPC permissions
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Turn the kernel object <parameter>in</parameter> into a set of permissions descriptions
   for returning to userspace (<parameter>out</parameter>).
</para>
</refsect1>
</refentry>

<refentry id="API-ipc64-perm-to-ipc-perm">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc64_perm_to_ipc_perm</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc64_perm_to_ipc_perm</refname>
 <refpurpose>
     convert new ipc permissions to old
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ipc64_perm_to_ipc_perm </function></funcdef>
   <paramdef>struct ipc64_perm * <parameter>in</parameter></paramdef>
   <paramdef>struct ipc_perm * <parameter>out</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>in</parameter></term>
   <listitem>
    <para>
     new style IPC permissions
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>out</parameter></term>
   <listitem>
    <para>
     old style IPC permissions
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Turn the new style permissions object <parameter>in</parameter> into a compatibility
   object and store it into the <parameter>out</parameter> pointer.
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-lock">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_lock</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_lock</refname>
 <refpurpose>
     Lock an ipc structure without rw_mutex held
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct kern_ipc_perm * <function>ipc_lock </function></funcdef>
   <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef>
   <paramdef>int <parameter>id</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ids</parameter></term>
   <listitem>
    <para>
     IPC identifier set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>id</parameter></term>
   <listitem>
    <para>
     ipc id to look for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Look for an id in the ipc ids idr and lock the associated ipc object.
   </para><para>

   The ipc object is locked on exit.
</para>
</refsect1>
</refentry>

<refentry id="API-ipcget">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipcget</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipcget</refname>
 <refpurpose>
     Common sys_*<function>get</function> code
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ipcget </function></funcdef>
   <paramdef>struct ipc_namespace * <parameter>ns</parameter></paramdef>
   <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef>
   <paramdef>struct ipc_ops * <parameter>ops</parameter></paramdef>
   <paramdef>struct ipc_params * <parameter>params</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ns</parameter></term>
   <listitem>
    <para>
     namsepace
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ids</parameter></term>
   <listitem>
    <para>
     IPC identifier set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ops</parameter></term>
   <listitem>
    <para>
     operations to be called on ipc object creation, permission checks
     and further checks
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>params</parameter></term>
   <listitem>
    <para>
     the parameters needed by the previous operations.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Common routine called by <function>sys_msgget</function>, <function>sys_semget</function> and <function>sys_shmget</function>.
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-update-perm">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_update_perm</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_update_perm</refname>
 <refpurpose>
     update the permissions of an IPC.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ipc_update_perm </function></funcdef>
   <paramdef>struct ipc64_perm * <parameter>in</parameter></paramdef>
   <paramdef>struct kern_ipc_perm * <parameter>out</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>in</parameter></term>
   <listitem>
    <para>
     the permission given as input.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>out</parameter></term>
   <listitem>
    <para>
     the permission of the ipc to set.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-ipcctl-pre-down">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipcctl_pre_down</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipcctl_pre_down</refname>
 <refpurpose>
     retrieve an ipc and check permissions for some IPC_XXX cmd
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct kern_ipc_perm * <function>ipcctl_pre_down </function></funcdef>
   <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef>
   <paramdef>int <parameter>id</parameter></paramdef>
   <paramdef>int <parameter>cmd</parameter></paramdef>
   <paramdef>struct ipc64_perm * <parameter>perm</parameter></paramdef>
   <paramdef>int <parameter>extra_perm</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ids</parameter></term>
   <listitem>
    <para>
     the table of ids where to look for the ipc
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>id</parameter></term>
   <listitem>
    <para>
     the id of the ipc to retrieve
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     the cmd to check
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>perm</parameter></term>
   <listitem>
    <para>
     the permission to set
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>extra_perm</parameter></term>
   <listitem>
    <para>
     one extra permission parameter used by msq
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function does some common audit and permissions check for some IPC_XXX
   cmd and is called from semctl_down, shmctl_down and msgctl_down.
   It must be called without any lock held and
   - retrieves the ipc with the given id in the given table.
   - performs some audit and permission check, depending on the given cmd
   - returns the ipc with both ipc and rw_mutex locks held in case of success
   or an err-code without any lock held otherwise.
</para>
</refsect1>
</refentry>

<refentry id="API-ipc-parse-version">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>ipc_parse_version</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>ipc_parse_version</refname>
 <refpurpose>
     IPC call version
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ipc_parse_version </function></funcdef>
   <paramdef>int * <parameter>cmd</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     pointer to command
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Return IPC_64 for new style IPC and IPC_OLD for old style IPC. 
   The <parameter>cmd</parameter> value is turned from an encoding command and version into
   just the command code.
</para>
</refsect1>
</refentry>

     </sect1>
  </chapter>

  <chapter id="kfifo">
     <title>FIFO Buffer</title>
     <sect1><title>kfifo interface</title>
<!-- include/linux/kfifo.h -->
<refentry id="API---kfifo-reset">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__kfifo_reset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__kfifo_reset</refname>
 <refpurpose>
  removes the entire FIFO contents, no locking version
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>__kfifo_reset </function></funcdef>
   <paramdef>struct kfifo * <parameter>fifo</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>fifo</parameter></term>
   <listitem>
    <para>
     the fifo to be emptied.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-kfifo-reset">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kfifo_reset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kfifo_reset</refname>
 <refpurpose>
     removes the entire FIFO contents
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kfifo_reset </function></funcdef>
   <paramdef>struct kfifo * <parameter>fifo</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>fifo</parameter></term>
   <listitem>
    <para>
     the fifo to be emptied.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-kfifo-put">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kfifo_put</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kfifo_put</refname>
 <refpurpose>
     puts some data into the FIFO
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>kfifo_put </function></funcdef>
   <paramdef>struct kfifo * <parameter>fifo</parameter></paramdef>
   <paramdef>const unsigned char * <parameter>buffer</parameter></paramdef>
   <paramdef>unsigned int <parameter>len</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>fifo</parameter></term>
   <listitem>
    <para>
     the fifo to be used.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buffer</parameter></term>
   <listitem>
    <para>
     the data to be added.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     the length of the data to be added.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function copies at most <parameter>len</parameter> bytes from the <parameter>buffer</parameter> into
   the FIFO depending on the free space, and returns the number of
   bytes copied.
</para>
</refsect1>
</refentry>

<refentry id="API-kfifo-get">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kfifo_get</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kfifo_get</refname>
 <refpurpose>
     gets some data from the FIFO
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>kfifo_get </function></funcdef>
   <paramdef>struct kfifo * <parameter>fifo</parameter></paramdef>
   <paramdef>unsigned char * <parameter>buffer</parameter></paramdef>
   <paramdef>unsigned int <parameter>len</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>fifo</parameter></term>
   <listitem>
    <para>
     the fifo to be used.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buffer</parameter></term>
   <listitem>
    <para>
     where the data must be copied.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     the size of the destination buffer.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function copies at most <parameter>len</parameter> bytes from the FIFO into the
   <parameter>buffer</parameter> and returns the number of copied bytes.
</para>
</refsect1>
</refentry>

<refentry id="API---kfifo-len">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__kfifo_len</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__kfifo_len</refname>
 <refpurpose>
     returns the number of bytes available in the FIFO, no locking version
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>__kfifo_len </function></funcdef>
   <paramdef>struct kfifo * <parameter>fifo</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>fifo</parameter></term>
   <listitem>
    <para>
     the fifo to be used.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-kfifo-len">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kfifo_len</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kfifo_len</refname>
 <refpurpose>
     returns the number of bytes available in the FIFO
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>kfifo_len </function></funcdef>
   <paramdef>struct kfifo * <parameter>fifo</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>fifo</parameter></term>
   <listitem>
    <para>
     the fifo to be used.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<!-- kernel/kfifo.c -->
<refentry id="API-kfifo-init">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kfifo_init</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kfifo_init</refname>
 <refpurpose>
  allocates a new FIFO using a preallocated buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct kfifo * <function>kfifo_init </function></funcdef>
   <paramdef>unsigned char * <parameter>buffer</parameter></paramdef>
   <paramdef>unsigned int <parameter>size</parameter></paramdef>
   <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef>
   <paramdef>spinlock_t * <parameter>lock</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buffer</parameter></term>
   <listitem>
    <para>
     the preallocated buffer to be used.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     the size of the internal buffer, this have to be a power of 2.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>gfp_mask</parameter></term>
   <listitem>
    <para>
     get_free_pages mask, passed to <function>kmalloc</function>
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>lock</parameter></term>
   <listitem>
    <para>
     the lock to be used to protect the fifo buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Do NOT pass the kfifo to <function>kfifo_free</function> after use! Simply free the
   <structname>struct kfifo</structname> with <function>kfree</function>.
</para>
</refsect1>
</refentry>

<refentry id="API-kfifo-alloc">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kfifo_alloc</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kfifo_alloc</refname>
 <refpurpose>
     allocates a new FIFO and its internal buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct kfifo * <function>kfifo_alloc </function></funcdef>
   <paramdef>unsigned int <parameter>size</parameter></paramdef>
   <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef>
   <paramdef>spinlock_t * <parameter>lock</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     the size of the internal buffer to be allocated.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>gfp_mask</parameter></term>
   <listitem>
    <para>
     get_free_pages mask, passed to <function>kmalloc</function>
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>lock</parameter></term>
   <listitem>
    <para>
     the lock to be used to protect the fifo buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The size will be rounded-up to a power of 2.
</para>
</refsect1>
</refentry>

<refentry id="API-kfifo-free">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>kfifo_free</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>kfifo_free</refname>
 <refpurpose>
     frees the FIFO
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>kfifo_free </function></funcdef>
   <paramdef>struct kfifo * <parameter>fifo</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>fifo</parameter></term>
   <listitem>
    <para>
     the fifo to be freed.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API---kfifo-put">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__kfifo_put</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__kfifo_put</refname>
 <refpurpose>
     puts some data into the FIFO, no locking version
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>__kfifo_put </function></funcdef>
   <paramdef>struct kfifo * <parameter>fifo</parameter></paramdef>
   <paramdef>const unsigned char * <parameter>buffer</parameter></paramdef>
   <paramdef>unsigned int <parameter>len</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>fifo</parameter></term>
   <listitem>
    <para>
     the fifo to be used.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buffer</parameter></term>
   <listitem>
    <para>
     the data to be added.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     the length of the data to be added.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function copies at most <parameter>len</parameter> bytes from the <parameter>buffer</parameter> into
   the FIFO depending on the free space, and returns the number of
   bytes copied.
   </para><para>

   Note that with only one concurrent reader and one concurrent
   writer, you don't need extra locking to use these functions.
</para>
</refsect1>
</refentry>

<refentry id="API---kfifo-get">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__kfifo_get</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__kfifo_get</refname>
 <refpurpose>
     gets some data from the FIFO, no locking version
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>__kfifo_get </function></funcdef>
   <paramdef>struct kfifo * <parameter>fifo</parameter></paramdef>
   <paramdef>unsigned char * <parameter>buffer</parameter></paramdef>
   <paramdef>unsigned int <parameter>len</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>fifo</parameter></term>
   <listitem>
    <para>
     the fifo to be used.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buffer</parameter></term>
   <listitem>
    <para>
     where the data must be copied.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     the size of the destination buffer.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function copies at most <parameter>len</parameter> bytes from the FIFO into the
   <parameter>buffer</parameter> and returns the number of copied bytes.
   </para><para>

   Note that with only one concurrent reader and one concurrent
   writer, you don't need extra locking to use these functions.
</para>
</refsect1>
</refentry>

     </sect1>
  </chapter>

  <chapter id="relayfs">
     <title>relay interface support</title>

     <para>
	Relay interface support
	is designed to provide an efficient mechanism for tools and
	facilities to relay large amounts of data from kernel space to
	user space.
     </para>

     <sect1><title>relay interface</title>
<!-- kernel/relay.c -->
<refentry id="API-relay-buf-full">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_buf_full</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_buf_full</refname>
 <refpurpose>
  boolean, is the channel buffer full?
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>relay_buf_full </function></funcdef>
   <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     channel buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns 1 if the buffer is full, 0 otherwise.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-reset">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_reset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_reset</refname>
 <refpurpose>
     reset the channel
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>relay_reset </function></funcdef>
   <paramdef>struct rchan * <parameter>chan</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>chan</parameter></term>
   <listitem>
    <para>
     the channel
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This has the effect of erasing all data from all channel buffers
   and restarting the channel in its initial state.  The buffers
   are not freed, so any mappings are still in effect.
   </para><para>

   NOTE. Care should be taken that the channel isn't actually
   being used by anything when this call is made.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-open">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_open</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_open</refname>
 <refpurpose>
     create a new relay channel
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct rchan * <function>relay_open </function></funcdef>
   <paramdef>const char * <parameter>base_filename</parameter></paramdef>
   <paramdef>struct dentry * <parameter>parent</parameter></paramdef>
   <paramdef>size_t <parameter>subbuf_size</parameter></paramdef>
   <paramdef>size_t <parameter>n_subbufs</parameter></paramdef>
   <paramdef>struct rchan_callbacks * <parameter>cb</parameter></paramdef>
   <paramdef>void * <parameter>private_data</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>base_filename</parameter></term>
   <listitem>
    <para>
     base name of files to create, <constant>NULL</constant> for buffering only
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>parent</parameter></term>
   <listitem>
    <para>
     dentry of parent directory, <constant>NULL</constant> for root directory or buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>subbuf_size</parameter></term>
   <listitem>
    <para>
     size of sub-buffers
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n_subbufs</parameter></term>
   <listitem>
    <para>
     number of sub-buffers
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>cb</parameter></term>
   <listitem>
    <para>
     client callback functions
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>private_data</parameter></term>
   <listitem>
    <para>
     user-defined data
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns channel pointer if successful, <constant>NULL</constant> otherwise.
   </para><para>

   Creates a channel buffer for each cpu using the sizes and
   attributes specified.  The created channel buffer files
   will be named base_filename0...base_filenameN-1.  File
   permissions will be <constant>S_IRUSR</constant>.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-switch-subbuf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_switch_subbuf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_switch_subbuf</refname>
 <refpurpose>
     switch to a new sub-buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>size_t <function>relay_switch_subbuf </function></funcdef>
   <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef>
   <paramdef>size_t <parameter>length</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     channel buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>length</parameter></term>
   <listitem>
    <para>
     size of current event
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns either the length passed in or 0 if full.
   </para><para>

   Performs sub-buffer-switch tasks such as invoking callbacks,
   updating padding counts, waking up readers, etc.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-subbufs-consumed">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_subbufs_consumed</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_subbufs_consumed</refname>
 <refpurpose>
     update the buffer's sub-buffers-consumed count
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>relay_subbufs_consumed </function></funcdef>
   <paramdef>struct rchan * <parameter>chan</parameter></paramdef>
   <paramdef>unsigned int <parameter>cpu</parameter></paramdef>
   <paramdef>size_t <parameter>subbufs_consumed</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>chan</parameter></term>
   <listitem>
    <para>
     the channel
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>cpu</parameter></term>
   <listitem>
    <para>
     the cpu associated with the channel buffer to update
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>subbufs_consumed</parameter></term>
   <listitem>
    <para>
     number of sub-buffers to add to current buf's count
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Adds to the channel buffer's consumed sub-buffer count.
   subbufs_consumed should be the number of sub-buffers newly consumed,
   not the total consumed.
   </para><para>

   NOTE. Kernel clients don't need to call this function if the channel
   mode is 'overwrite'.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-close">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_close</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_close</refname>
 <refpurpose>
     close the channel
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>relay_close </function></funcdef>
   <paramdef>struct rchan * <parameter>chan</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>chan</parameter></term>
   <listitem>
    <para>
     the channel
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Closes all channel buffers and frees the channel.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-flush">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_flush</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_flush</refname>
 <refpurpose>
     close the channel
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>relay_flush </function></funcdef>
   <paramdef>struct rchan * <parameter>chan</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>chan</parameter></term>
   <listitem>
    <para>
     the channel
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Flushes all channel buffers, i.e. forces buffer switch.
</para>
</refsect1>
</refentry>

<!-- kernel/relay.c -->
<refentry id="API-relay-mmap-buf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_mmap_buf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_mmap_buf</refname>
 <refpurpose>
  mmap channel buffer to process address space
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>relay_mmap_buf </function></funcdef>
   <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef>
   <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     relay channel buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>vma</parameter></term>
   <listitem>
    <para>
     vm_area_struct describing memory to be mapped
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns 0 if ok, negative on error
   </para><para>

   Caller should already have grabbed mmap_sem.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-alloc-buf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_alloc_buf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_alloc_buf</refname>
 <refpurpose>
     allocate a channel buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void * <function>relay_alloc_buf </function></funcdef>
   <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef>
   <paramdef>size_t * <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     the buffer struct
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     total size of the buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns a pointer to the resulting buffer, <constant>NULL</constant> if unsuccessful. The
   passed in size will get page aligned, if it isn't already.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-create-buf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_create_buf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_create_buf</refname>
 <refpurpose>
     allocate and initialize a channel buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct rchan_buf * <function>relay_create_buf </function></funcdef>
   <paramdef>struct rchan * <parameter>chan</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>chan</parameter></term>
   <listitem>
    <para>
     the relay channel
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns channel buffer if successful, <constant>NULL</constant> otherwise.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-destroy-channel">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_destroy_channel</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_destroy_channel</refname>
 <refpurpose>
     free the channel struct
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>relay_destroy_channel </function></funcdef>
   <paramdef>struct kref * <parameter>kref</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kref</parameter></term>
   <listitem>
    <para>
     target kernel reference that contains the relay channel
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Should only be called from <function>kref_put</function>.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-destroy-buf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_destroy_buf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_destroy_buf</refname>
 <refpurpose>
     destroy an rchan_buf struct and associated buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>relay_destroy_buf </function></funcdef>
   <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     the buffer struct
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-relay-remove-buf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_remove_buf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_remove_buf</refname>
 <refpurpose>
     remove a channel buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>relay_remove_buf </function></funcdef>
   <paramdef>struct kref * <parameter>kref</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>kref</parameter></term>
   <listitem>
    <para>
     target kernel reference that contains the relay buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Removes the file from the fileystem, which also frees the
   rchan_buf_struct and the channel buffer.  Should only be called from
   <function>kref_put</function>.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-buf-empty">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_buf_empty</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_buf_empty</refname>
 <refpurpose>
     boolean, is the channel buffer empty?
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>relay_buf_empty </function></funcdef>
   <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     channel buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns 1 if the buffer is empty, 0 otherwise.
</para>
</refsect1>
</refentry>

<refentry id="API-wakeup-readers">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>wakeup_readers</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>wakeup_readers</refname>
 <refpurpose>
     wake up readers waiting on a channel
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>wakeup_readers </function></funcdef>
   <paramdef>unsigned long <parameter>data</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>data</parameter></term>
   <listitem>
    <para>
     contains the channel buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This is the timer function used to defer reader waking.
</para>
</refsect1>
</refentry>

<refentry id="API---relay-reset">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__relay_reset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__relay_reset</refname>
 <refpurpose>
     reset a channel buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>__relay_reset </function></funcdef>
   <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef>
   <paramdef>unsigned int <parameter>init</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     the channel buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>init</parameter></term>
   <listitem>
    <para>
     1 if this is a first-time initialization
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   See <function>relay_reset</function> for description of effect.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-close-buf">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_close_buf</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_close_buf</refname>
 <refpurpose>
     close a channel buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>relay_close_buf </function></funcdef>
   <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     channel buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Marks the buffer finalized and restores the default callbacks.
   The channel buffer and channel buffer data structure are then freed
   automatically when the last reference is given up.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-hotcpu-callback">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_hotcpu_callback</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_hotcpu_callback</refname>
 <refpurpose>
     CPU hotplug callback
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int __cpuinit <function>relay_hotcpu_callback </function></funcdef>
   <paramdef>struct notifier_block * <parameter>nb</parameter></paramdef>
   <paramdef>unsigned long <parameter>action</parameter></paramdef>
   <paramdef>void * <parameter>hcpu</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>nb</parameter></term>
   <listitem>
    <para>
     notifier block
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>action</parameter></term>
   <listitem>
    <para>
     hotplug action to take
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>hcpu</parameter></term>
   <listitem>
    <para>
     CPU number
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns the success/failure of the operation. (<constant>NOTIFY_OK</constant>, <constant>NOTIFY_BAD</constant>)
</para>
</refsect1>
</refentry>

<refentry id="API-relay-late-setup-files">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_late_setup_files</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_late_setup_files</refname>
 <refpurpose>
     triggers file creation
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>relay_late_setup_files </function></funcdef>
   <paramdef>struct rchan * <parameter>chan</parameter></paramdef>
   <paramdef>const char * <parameter>base_filename</parameter></paramdef>
   <paramdef>struct dentry * <parameter>parent</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>chan</parameter></term>
   <listitem>
    <para>
     channel to operate on
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>base_filename</parameter></term>
   <listitem>
    <para>
     base name of files to create
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>parent</parameter></term>
   <listitem>
    <para>
     dentry of parent directory, <constant>NULL</constant> for root directory
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns 0 if successful, non-zero otherwise.
   </para><para>

   Use to setup files for a previously buffer-only channel.
   Useful to do early tracing in kernel, before VFS is up, for example.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-file-open">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_file_open</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_file_open</refname>
 <refpurpose>
     open file op for relay files
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>relay_file_open </function></funcdef>
   <paramdef>struct inode * <parameter>inode</parameter></paramdef>
   <paramdef>struct file * <parameter>filp</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>inode</parameter></term>
   <listitem>
    <para>
     the inode
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>filp</parameter></term>
   <listitem>
    <para>
     the file
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Increments the channel buffer refcount.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-file-mmap">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_file_mmap</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_file_mmap</refname>
 <refpurpose>
     mmap file op for relay files
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>relay_file_mmap </function></funcdef>
   <paramdef>struct file * <parameter>filp</parameter></paramdef>
   <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>filp</parameter></term>
   <listitem>
    <para>
     the file
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>vma</parameter></term>
   <listitem>
    <para>
     the vma describing what to map
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Calls upon <function>relay_mmap_buf</function> to map the file into user space.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-file-poll">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_file_poll</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_file_poll</refname>
 <refpurpose>
     poll file op for relay files
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>relay_file_poll </function></funcdef>
   <paramdef>struct file * <parameter>filp</parameter></paramdef>
   <paramdef>poll_table * <parameter>wait</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>filp</parameter></term>
   <listitem>
    <para>
     the file
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>wait</parameter></term>
   <listitem>
    <para>
     poll table
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Poll implemention.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-file-release">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_file_release</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_file_release</refname>
 <refpurpose>
     release file op for relay files
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>relay_file_release </function></funcdef>
   <paramdef>struct inode * <parameter>inode</parameter></paramdef>
   <paramdef>struct file * <parameter>filp</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>inode</parameter></term>
   <listitem>
    <para>
     the inode
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>filp</parameter></term>
   <listitem>
    <para>
     the file
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Decrements the channel refcount, as the filesystem is
   no longer using it.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-file-read-subbuf-avail">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_file_read_subbuf_avail</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_file_read_subbuf_avail</refname>
 <refpurpose>
     return bytes available in sub-buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>size_t <function>relay_file_read_subbuf_avail </function></funcdef>
   <paramdef>size_t <parameter>read_pos</parameter></paramdef>
   <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>read_pos</parameter></term>
   <listitem>
    <para>
     file read position
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     relay channel buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-relay-file-read-start-pos">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_file_read_start_pos</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_file_read_start_pos</refname>
 <refpurpose>
     find the first available byte to read
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>size_t <function>relay_file_read_start_pos </function></funcdef>
   <paramdef>size_t <parameter>read_pos</parameter></paramdef>
   <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>read_pos</parameter></term>
   <listitem>
    <para>
     file read position
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     relay channel buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   If the <parameter>read_pos</parameter> is in the middle of padding, return the
   position of the first actually available byte, otherwise
   return the original value.
</para>
</refsect1>
</refentry>

<refentry id="API-relay-file-read-end-pos">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>relay_file_read_end_pos</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>relay_file_read_end_pos</refname>
 <refpurpose>
     return the new read position
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>size_t <function>relay_file_read_end_pos </function></funcdef>
   <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef>
   <paramdef>size_t <parameter>read_pos</parameter></paramdef>
   <paramdef>size_t <parameter>count</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     relay channel buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>read_pos</parameter></term>
   <listitem>
    <para>
     file read position
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>count</parameter></term>
   <listitem>
    <para>
     number of bytes to be read
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

     </sect1>
  </chapter>

  <chapter id="modload">
     <title>Module Support</title>
     <sect1><title>Module Loading</title>
<!-- kernel/kmod.c -->
<refentry id="API---request-module">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__request_module</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__request_module</refname>
 <refpurpose>
  try to load a kernel module
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>__request_module </function></funcdef>
   <paramdef>bool <parameter>wait</parameter></paramdef>
   <paramdef>const char * <parameter>fmt</parameter></paramdef>
   <paramdef> <parameter>...</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>wait</parameter></term>
   <listitem>
    <para>
     wait (or not) for the operation to complete
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fmt</parameter></term>
   <listitem>
    <para>
     printf style format string for the name of the module
     @...: arguments as specified in the format string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>...</parameter></term>
   <listitem>
    <para>
     variable arguments
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Load a module using the user mode module loader. The function returns
   zero on success or a negative errno code on failure. Note that a
   successful module load does not mean the module did not then unload
   and exit on an error of its own. Callers must check that the service
   they requested is now available not blindly invoke it.
   </para><para>

   If module auto-loading support is disabled then this function
   becomes a no-operation.
</para>
</refsect1>
</refentry>

<refentry id="API-call-usermodehelper-setup">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>call_usermodehelper_setup</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>call_usermodehelper_setup</refname>
 <refpurpose>
     prepare to call a usermode helper
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct subprocess_info * <function>call_usermodehelper_setup </function></funcdef>
   <paramdef>char * <parameter>path</parameter></paramdef>
   <paramdef>char ** <parameter>argv</parameter></paramdef>
   <paramdef>char ** <parameter>envp</parameter></paramdef>
   <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>path</parameter></term>
   <listitem>
    <para>
     path to usermode executable
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>argv</parameter></term>
   <listitem>
    <para>
     arg vector for process
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>envp</parameter></term>
   <listitem>
    <para>
     environment for process
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>gfp_mask</parameter></term>
   <listitem>
    <para>
     gfp mask for memory allocation
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns either <constant>NULL</constant> on allocation failure, or a subprocess_info
   structure.  This should be passed to call_usermodehelper_exec to
   exec the process and free the structure.
</para>
</refsect1>
</refentry>

<refentry id="API-call-usermodehelper-setkeys">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>call_usermodehelper_setkeys</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>call_usermodehelper_setkeys</refname>
 <refpurpose>
     set the session keys for usermode helper
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>call_usermodehelper_setkeys </function></funcdef>
   <paramdef>struct subprocess_info * <parameter>info</parameter></paramdef>
   <paramdef>struct key * <parameter>session_keyring</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>info</parameter></term>
   <listitem>
    <para>
     a subprocess_info returned by call_usermodehelper_setup
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>session_keyring</parameter></term>
   <listitem>
    <para>
     the session keyring for the process
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-call-usermodehelper-setcleanup">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>call_usermodehelper_setcleanup</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>call_usermodehelper_setcleanup</refname>
 <refpurpose>
     set a cleanup function
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>call_usermodehelper_setcleanup </function></funcdef>
   <paramdef>struct subprocess_info * <parameter>info</parameter></paramdef>
   <paramdef>void (*<parameter>cleanup</parameter>)
     <funcparams>char **argv, char **envp</funcparams></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>info</parameter></term>
   <listitem>
    <para>
     a subprocess_info returned by call_usermodehelper_setup
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>cleanup</parameter></term>
   <listitem>
    <para>
     a cleanup function
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The cleanup function is just befor ethe subprocess_info is about to
   be freed.  This can be used for freeing the argv and envp.  The
   Function must be runnable in either a process context or the
   context in which call_usermodehelper_exec is called.
</para>
</refsect1>
</refentry>

<refentry id="API-call-usermodehelper-stdinpipe">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>call_usermodehelper_stdinpipe</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>call_usermodehelper_stdinpipe</refname>
 <refpurpose>
     set up a pipe to be used for stdin
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>call_usermodehelper_stdinpipe </function></funcdef>
   <paramdef>struct subprocess_info * <parameter>sub_info</parameter></paramdef>
   <paramdef>struct file ** <parameter>filp</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>sub_info</parameter></term>
   <listitem>
    <para>
     a subprocess_info returned by call_usermodehelper_setup
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>filp</parameter></term>
   <listitem>
    <para>
     set to the write-end of a pipe
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This constructs a pipe, and sets the read end to be the stdin of the
   subprocess, and returns the write-end in *<parameter>filp</parameter>.
</para>
</refsect1>
</refentry>

<refentry id="API-call-usermodehelper-exec">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>call_usermodehelper_exec</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>call_usermodehelper_exec</refname>
 <refpurpose>
     start a usermode application
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>call_usermodehelper_exec </function></funcdef>
   <paramdef>struct subprocess_info * <parameter>sub_info</parameter></paramdef>
   <paramdef>enum umh_wait <parameter>wait</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>sub_info</parameter></term>
   <listitem>
    <para>
     information about the subprocessa
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>wait</parameter></term>
   <listitem>
    <para>
     wait for the application to finish and return status.
     when -1 don't wait at all, but you get no useful error back when
     the program couldn't be exec'ed. This makes it safe to call
     from interrupt context.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Runs a user-space application.  The application is started
   asynchronously if wait is not set, and runs as a child of keventd.
   (ie. it runs with full root capabilities).
</para>
</refsect1>
</refentry>

<refentry id="API-call-usermodehelper-pipe">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>call_usermodehelper_pipe</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>call_usermodehelper_pipe</refname>
 <refpurpose>
     call a usermode helper process with a pipe stdin
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>call_usermodehelper_pipe </function></funcdef>
   <paramdef>char * <parameter>path</parameter></paramdef>
   <paramdef>char ** <parameter>argv</parameter></paramdef>
   <paramdef>char ** <parameter>envp</parameter></paramdef>
   <paramdef>struct file ** <parameter>filp</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>path</parameter></term>
   <listitem>
    <para>
     path to usermode executable
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>argv</parameter></term>
   <listitem>
    <para>
     arg vector for process
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>envp</parameter></term>
   <listitem>
    <para>
     environment for process
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>filp</parameter></term>
   <listitem>
    <para>
     set to the write-end of a pipe
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This is a simple wrapper which executes a usermode-helper function
   with a pipe as stdin.  It is implemented entirely in terms of
   lower-level call_usermodehelper_* functions.
</para>
</refsect1>
</refentry>

     </sect1>
     <sect1><title>Inter Module support</title>
        <para>
           Refer to the file kernel/module.c for more information.
        </para>
<!-- FIXME: Removed for now since no structured comments in source
X!Ekernel/module.c
-->
     </sect1>
  </chapter>

  <chapter id="hardware">
     <title>Hardware Interfaces</title>
     <sect1><title>Interrupt Handling</title>
<!-- kernel/irq/manage.c -->
<refentry id="API-synchronize-irq">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>synchronize_irq</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>synchronize_irq</refname>
 <refpurpose>
  wait for pending IRQ handlers (on other CPUs)
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>synchronize_irq </function></funcdef>
   <paramdef>unsigned int <parameter>irq</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>irq</parameter></term>
   <listitem>
    <para>
     interrupt number to wait for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function waits for any pending IRQ handlers for this interrupt
   to complete before returning. If you use this function while
   holding a resource the IRQ handler may need you will deadlock.
   </para><para>

   This function may be called - with care - from IRQ context.
</para>
</refsect1>
</refentry>

<refentry id="API-disable-irq-nosync">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>disable_irq_nosync</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>disable_irq_nosync</refname>
 <refpurpose>
     disable an irq without waiting
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>disable_irq_nosync </function></funcdef>
   <paramdef>unsigned int <parameter>irq</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>irq</parameter></term>
   <listitem>
    <para>
     Interrupt to disable
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Disable the selected interrupt line.  Disables and Enables are
   nested.
   Unlike <function>disable_irq</function>, this function does not ensure existing
   instances of the IRQ handler have completed before returning.
   </para><para>

   This function may be called from IRQ context.
</para>
</refsect1>
</refentry>

<refentry id="API-disable-irq">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>disable_irq</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>disable_irq</refname>
 <refpurpose>
     disable an irq and wait for completion
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>disable_irq </function></funcdef>
   <paramdef>unsigned int <parameter>irq</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>irq</parameter></term>
   <listitem>
    <para>
     Interrupt to disable
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Disable the selected interrupt line.  Enables and Disables are
   nested.
   This function waits for any pending IRQ handlers for this interrupt
   to complete before returning. If you use this function while
   holding a resource the IRQ handler may need you will deadlock.
   </para><para>

   This function may be called - with care - from IRQ context.
</para>
</refsect1>
</refentry>

<refentry id="API-enable-irq">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>enable_irq</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>enable_irq</refname>
 <refpurpose>
     enable handling of an irq
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>enable_irq </function></funcdef>
   <paramdef>unsigned int <parameter>irq</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>irq</parameter></term>
   <listitem>
    <para>
     Interrupt to enable
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Undoes the effect of one call to <function>disable_irq</function>.  If this
   matches the last disable, processing of interrupts on this
   IRQ line is re-enabled.
   </para><para>

   This function may be called from IRQ context only when
   desc-&gt;chip-&gt;bus_lock and desc-&gt;chip-&gt;bus_sync_unlock are NULL !
</para>
</refsect1>
</refentry>

<refentry id="API-set-irq-wake">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>set_irq_wake</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>set_irq_wake</refname>
 <refpurpose>
     control irq power management wakeup
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>set_irq_wake </function></funcdef>
   <paramdef>unsigned int <parameter>irq</parameter></paramdef>
   <paramdef>unsigned int <parameter>on</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>irq</parameter></term>
   <listitem>
    <para>
     interrupt to control
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>on</parameter></term>
   <listitem>
    <para>
     enable/disable power management wakeup
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Enable/disable power management wakeup mode, which is
   disabled by default.  Enables and disables must match,
   just as they match for non-wakeup mode support.
   </para><para>

   Wakeup mode lets this IRQ wake the system from sleep
   states like <quote>suspend to RAM</quote>.
</para>
</refsect1>
</refentry>

<refentry id="API-setup-irq">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>setup_irq</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>setup_irq</refname>
 <refpurpose>
     setup an interrupt
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>setup_irq </function></funcdef>
   <paramdef>unsigned int <parameter>irq</parameter></paramdef>
   <paramdef>struct irqaction * <parameter>act</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>irq</parameter></term>
   <listitem>
    <para>
     Interrupt line to setup
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>act</parameter></term>
   <listitem>
    <para>
     irqaction for the interrupt
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Used to statically setup interrupts in the early boot process.
</para>
</refsect1>
</refentry>

<refentry id="API-remove-irq">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>remove_irq</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>remove_irq</refname>
 <refpurpose>
     free an interrupt
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>remove_irq </function></funcdef>
   <paramdef>unsigned int <parameter>irq</parameter></paramdef>
   <paramdef>struct irqaction * <parameter>act</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>irq</parameter></term>
   <listitem>
    <para>
     Interrupt line to free
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>act</parameter></term>
   <listitem>
    <para>
     irqaction for the interrupt
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Used to remove interrupts statically setup by the early boot process.
</para>
</refsect1>
</refentry>

<refentry id="API-free-irq">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>free_irq</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>free_irq</refname>
 <refpurpose>
     free an interrupt allocated with request_irq
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>free_irq </function></funcdef>
   <paramdef>unsigned int <parameter>irq</parameter></paramdef>
   <paramdef>void * <parameter>dev_id</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>irq</parameter></term>
   <listitem>
    <para>
     Interrupt line to free
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev_id</parameter></term>
   <listitem>
    <para>
     Device identity to free
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Remove an interrupt handler. The handler is removed and if the
   interrupt line is no longer in use by any driver it is disabled.
   On a shared IRQ the caller must ensure the interrupt is disabled
   on the card it drives before calling this function. The function
   does not return until any executing interrupts for this IRQ
   have completed.
   </para><para>

   This function must not be called from interrupt context.
</para>
</refsect1>
</refentry>

<refentry id="API-request-threaded-irq">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>request_threaded_irq</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>request_threaded_irq</refname>
 <refpurpose>
     allocate an interrupt line
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>request_threaded_irq </function></funcdef>
   <paramdef>unsigned int <parameter>irq</parameter></paramdef>
   <paramdef>irq_handler_t <parameter>handler</parameter></paramdef>
   <paramdef>irq_handler_t <parameter>thread_fn</parameter></paramdef>
   <paramdef>unsigned long <parameter>irqflags</parameter></paramdef>
   <paramdef>const char * <parameter>devname</parameter></paramdef>
   <paramdef>void * <parameter>dev_id</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>irq</parameter></term>
   <listitem>
    <para>
     Interrupt line to allocate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>handler</parameter></term>
   <listitem>
    <para>
     Function to be called when the IRQ occurs.
     Primary handler for threaded interrupts
     If NULL and thread_fn != NULL the default
     primary handler is installed
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>thread_fn</parameter></term>
   <listitem>
    <para>
     Function called from the irq handler thread
     If NULL, no irq thread is created
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>irqflags</parameter></term>
   <listitem>
    <para>
     Interrupt type flags
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>devname</parameter></term>
   <listitem>
    <para>
     An ascii name for the claiming device
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev_id</parameter></term>
   <listitem>
    <para>
     A cookie passed back to the handler function
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This call allocates interrupt resources and enables the
   interrupt line and IRQ handling. From the point this
   call is made your handler function may be invoked. Since
   your handler function must clear any interrupt the board
   raises, you must take care both to initialise your hardware
   and to set up the interrupt handler in the right order.
   </para><para>

   If you want to set up a threaded irq handler for your device
   then you need to supply <parameter>handler</parameter> and <parameter>thread_fn</parameter>. <parameter>handler</parameter> ist
   still called in hard interrupt context and has to check
   whether the interrupt originates from the device. If yes it
   needs to disable the interrupt on the device and return
   IRQ_WAKE_THREAD which will wake up the handler thread and run
   <parameter>thread_fn</parameter>. This split handler design is necessary to support
   shared interrupts.
   </para><para>

   Dev_id must be globally unique. Normally the address of the
   device data structure is used as the cookie. Since the handler
   receives this value it makes sense to use it.
   </para><para>

   If your interrupt is shared you must pass a non NULL dev_id
   as this is required when freeing the interrupt.
</para>
</refsect1>
<refsect1>
<title>Flags</title>
<para>
   </para><para>

   IRQF_SHARED		Interrupt is shared
   IRQF_DISABLED	Disable local interrupts while processing
   IRQF_SAMPLE_RANDOM	The interrupt can be used for entropy
   IRQF_TRIGGER_*		Specify active edge(s) or level
</para>
</refsect1>
</refentry>

     </sect1>

     <sect1><title>DMA Channels</title>
<!-- kernel/dma.c -->
<refentry id="API-request-dma">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>request_dma</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>request_dma</refname>
 <refpurpose>
  request and reserve a system DMA channel
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>request_dma </function></funcdef>
   <paramdef>unsigned int <parameter>dmanr</parameter></paramdef>
   <paramdef>const char * <parameter>device_id</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dmanr</parameter></term>
   <listitem>
    <para>
     DMA channel number
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>device_id</parameter></term>
   <listitem>
    <para>
     reserving device ID string, used in /proc/dma
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-free-dma">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>free_dma</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>free_dma</refname>
 <refpurpose>
     free a reserved system DMA channel
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>free_dma </function></funcdef>
   <paramdef>unsigned int <parameter>dmanr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dmanr</parameter></term>
   <listitem>
    <para>
     DMA channel number
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

     </sect1>

     <sect1><title>Resources Management</title>
<!-- kernel/resource.c -->
<refentry id="API-insert-resource">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>insert_resource</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>insert_resource</refname>
 <refpurpose>
  Inserts a resource in the resource tree
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>insert_resource </function></funcdef>
   <paramdef>struct resource * <parameter>parent</parameter></paramdef>
   <paramdef>struct resource * <parameter>new</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>parent</parameter></term>
   <listitem>
    <para>
     parent of the new resource
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     new resource to insert
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns 0 on success, -EBUSY if the resource can't be inserted.
   </para><para>

   This function is equivalent to request_resource when no conflict
   happens. If a conflict happens, and the conflicting resources
   entirely fit within the range of the new resource, then the new
   resource is inserted and the conflicting resources become children of
   the new resource.
</para>
</refsect1>
</refentry>

<refentry id="API-insert-resource-expand-to-fit">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>insert_resource_expand_to_fit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>insert_resource_expand_to_fit</refname>
 <refpurpose>
     Insert a resource into the resource tree
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>insert_resource_expand_to_fit </function></funcdef>
   <paramdef>struct resource * <parameter>root</parameter></paramdef>
   <paramdef>struct resource * <parameter>new</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>root</parameter></term>
   <listitem>
    <para>
     root resource descriptor
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     new resource to insert
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Insert a resource into the resource tree, possibly expanding it in order
   to make it encompass any conflicting resources.
</para>
</refsect1>
</refentry>

<refentry id="API-resource-alignment">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>resource_alignment</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>resource_alignment</refname>
 <refpurpose>
     calculate resource's alignment
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>resource_size_t <function>resource_alignment </function></funcdef>
   <paramdef>struct resource * <parameter>res</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>res</parameter></term>
   <listitem>
    <para>
     resource pointer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns alignment on success, 0 (invalid alignment) on failure.
</para>
</refsect1>
</refentry>

<!-- kernel/resource.c -->
<refentry id="API-request-resource">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>request_resource</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>request_resource</refname>
 <refpurpose>
  request and reserve an I/O or memory resource
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>request_resource </function></funcdef>
   <paramdef>struct resource * <parameter>root</parameter></paramdef>
   <paramdef>struct resource * <parameter>new</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>root</parameter></term>
   <listitem>
    <para>
     root resource descriptor
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     resource descriptor desired by caller
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns 0 for success, negative error code on error.
</para>
</refsect1>
</refentry>

<refentry id="API-release-resource">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>release_resource</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>release_resource</refname>
 <refpurpose>
     release a previously reserved resource
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>release_resource </function></funcdef>
   <paramdef>struct resource * <parameter>old</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>old</parameter></term>
   <listitem>
    <para>
     resource pointer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-allocate-resource">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>allocate_resource</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>allocate_resource</refname>
 <refpurpose>
     allocate empty slot in the resource tree given range &amp; alignment
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>allocate_resource </function></funcdef>
   <paramdef>struct resource * <parameter>root</parameter></paramdef>
   <paramdef>struct resource * <parameter>new</parameter></paramdef>
   <paramdef>resource_size_t <parameter>size</parameter></paramdef>
   <paramdef>resource_size_t <parameter>min</parameter></paramdef>
   <paramdef>resource_size_t <parameter>max</parameter></paramdef>
   <paramdef>resource_size_t <parameter>align</parameter></paramdef>
   <paramdef>void (*<parameter>alignf</parameter>)
     <funcparams>void *, struct resource *, 				     resource_size_t, resource_size_t</funcparams></paramdef>
   <paramdef>void * <parameter>alignf_data</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>root</parameter></term>
   <listitem>
    <para>
     root resource descriptor
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>new</parameter></term>
   <listitem>
    <para>
     resource descriptor desired by caller
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     requested resource region size
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>min</parameter></term>
   <listitem>
    <para>
     minimum size to allocate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>max</parameter></term>
   <listitem>
    <para>
     maximum size to allocate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>align</parameter></term>
   <listitem>
    <para>
     alignment requested, in bytes
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>alignf</parameter></term>
   <listitem>
    <para>
     alignment function, optional, called if not NULL
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>alignf_data</parameter></term>
   <listitem>
    <para>
     arbitrary data to pass to the <parameter>alignf</parameter> function
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API-adjust-resource">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>adjust_resource</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>adjust_resource</refname>
 <refpurpose>
     modify a resource's start and size
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>adjust_resource </function></funcdef>
   <paramdef>struct resource * <parameter>res</parameter></paramdef>
   <paramdef>resource_size_t <parameter>start</parameter></paramdef>
   <paramdef>resource_size_t <parameter>size</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>res</parameter></term>
   <listitem>
    <para>
     resource to modify
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>start</parameter></term>
   <listitem>
    <para>
     new start value
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>size</parameter></term>
   <listitem>
    <para>
     new size
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Given an existing resource, change its start and size to match the
   arguments.  Returns 0 on success, -EBUSY if it can't fit.
   Existing children of the resource are assumed to be immutable.
</para>
</refsect1>
</refentry>

<refentry id="API---request-region">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__request_region</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__request_region</refname>
 <refpurpose>
     create a new busy resource region
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct resource * <function>__request_region </function></funcdef>
   <paramdef>struct resource * <parameter>parent</parameter></paramdef>
   <paramdef>resource_size_t <parameter>start</parameter></paramdef>
   <paramdef>resource_size_t <parameter>n</parameter></paramdef>
   <paramdef>const char * <parameter>name</parameter></paramdef>
   <paramdef>int <parameter>flags</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>parent</parameter></term>
   <listitem>
    <para>
     parent resource descriptor
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>start</parameter></term>
   <listitem>
    <para>
     resource start address
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     resource region size
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>name</parameter></term>
   <listitem>
    <para>
     reserving caller's ID string
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>flags</parameter></term>
   <listitem>
    <para>
     IO resource flags
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
</refentry>

<refentry id="API---check-region">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__check_region</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__check_region</refname>
 <refpurpose>
     check if a resource region is busy or free
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>__check_region </function></funcdef>
   <paramdef>struct resource * <parameter>parent</parameter></paramdef>
   <paramdef>resource_size_t <parameter>start</parameter></paramdef>
   <paramdef>resource_size_t <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>parent</parameter></term>
   <listitem>
    <para>
     parent resource descriptor
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>start</parameter></term>
   <listitem>
    <para>
     resource start address
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     resource region size
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns 0 if the region is free at the moment it is checked,
   returns <constant>-EBUSY</constant> if the region is busy.
</para>
</refsect1>
<refsect1>
<title>NOTE</title>
<para>
   This function is deprecated because its use is racy.
   Even if it returns 0, a subsequent call to <function>request_region</function>
   may fail because another driver etc. just allocated the region.
   Do NOT use it.  It will be removed from the kernel.
</para>
</refsect1>
</refentry>

<refentry id="API---release-region">
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>October 2009</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase>__release_region</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
 <refmiscinfo class="version">2.6.32-rc5</refmiscinfo>
</refmeta>
<refnamediv>
 <refname>__release_region</refname>
 <refpurpose>
     release a previously reserved resource region
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>__release_region </function></funcdef>
   <paramdef>struct resource * <parameter>parent</parameter></paramdef>
   <paramdef>resource_size_t <parameter>start</parameter></paramdef>
   <paramdef>resource_size_t <parameter>n</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>parent</parameter></term>
   <listitem>
    <para>
     parent resource descriptor
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>start</parameter></term>
   <listitem>
    <para>
     resource start address
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n</parameter></term>
   <listitem>
    <para>
     resource region size
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The described resource region must match a current