1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []> 4 5<book id="LinuxKernelAPI"> 6 <bookinfo> 7 <title>The Linux Kernel API</title> 8 9 <legalnotice> 10 <para> 11 This documentation is free software; you can redistribute 12 it and/or modify it under the terms of the GNU General Public 13 License as published by the Free Software Foundation; either 14 version 2 of the License, or (at your option) any later 15 version. 16 </para> 17 18 <para> 19 This program is distributed in the hope that it will be 20 useful, but WITHOUT ANY WARRANTY; without even the implied 21 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 See the GNU General Public License for more details. 23 </para> 24 25 <para> 26 You should have received a copy of the GNU General Public 27 License along with this program; if not, write to the Free 28 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 29 MA 02111-1307 USA 30 </para> 31 32 <para> 33 For more details see the file COPYING in the source 34 distribution of Linux. 35 </para> 36 </legalnotice> 37 </bookinfo> 38 39<toc></toc> 40 41 <chapter id="adt"> 42 <title>Data Types</title> 43 <sect1><title>Doubly Linked Lists</title> 44<!-- include/linux/list.h --> 45<refentry id="API-list-add"> 46<refentryinfo> 47 <title>LINUX</title> 48 <productname>Kernel Hackers Manual</productname> 49 <date>July 2017</date> 50</refentryinfo> 51<refmeta> 52 <refentrytitle><phrase>list_add</phrase></refentrytitle> 53 <manvolnum>9</manvolnum> 54 <refmiscinfo class="version">4.1.27</refmiscinfo> 55</refmeta> 56<refnamediv> 57 <refname>list_add</refname> 58 <refpurpose> 59 add a new entry 60 </refpurpose> 61</refnamediv> 62<refsynopsisdiv> 63 <title>Synopsis</title> 64 <funcsynopsis><funcprototype> 65 <funcdef>void <function>list_add </function></funcdef> 66 <paramdef>struct list_head * <parameter>new</parameter></paramdef> 67 <paramdef>struct list_head * <parameter>head</parameter></paramdef> 68 </funcprototype></funcsynopsis> 69</refsynopsisdiv> 70<refsect1> 71 <title>Arguments</title> 72 <variablelist> 73 <varlistentry> 74 <term><parameter>new</parameter></term> 75 <listitem> 76 <para> 77 new entry to be added 78 </para> 79 </listitem> 80 </varlistentry> 81 <varlistentry> 82 <term><parameter>head</parameter></term> 83 <listitem> 84 <para> 85 list head to add it after 86 </para> 87 </listitem> 88 </varlistentry> 89 </variablelist> 90</refsect1> 91<refsect1> 92<title>Description</title> 93<para> 94 Insert a new entry after the specified head. 95 This is good for implementing stacks. 96</para> 97</refsect1> 98</refentry> 99 100<refentry id="API-list-add-tail"> 101<refentryinfo> 102 <title>LINUX</title> 103 <productname>Kernel Hackers Manual</productname> 104 <date>July 2017</date> 105</refentryinfo> 106<refmeta> 107 <refentrytitle><phrase>list_add_tail</phrase></refentrytitle> 108 <manvolnum>9</manvolnum> 109 <refmiscinfo class="version">4.1.27</refmiscinfo> 110</refmeta> 111<refnamediv> 112 <refname>list_add_tail</refname> 113 <refpurpose> 114 add a new entry 115 </refpurpose> 116</refnamediv> 117<refsynopsisdiv> 118 <title>Synopsis</title> 119 <funcsynopsis><funcprototype> 120 <funcdef>void <function>list_add_tail </function></funcdef> 121 <paramdef>struct list_head * <parameter>new</parameter></paramdef> 122 <paramdef>struct list_head * <parameter>head</parameter></paramdef> 123 </funcprototype></funcsynopsis> 124</refsynopsisdiv> 125<refsect1> 126 <title>Arguments</title> 127 <variablelist> 128 <varlistentry> 129 <term><parameter>new</parameter></term> 130 <listitem> 131 <para> 132 new entry to be added 133 </para> 134 </listitem> 135 </varlistentry> 136 <varlistentry> 137 <term><parameter>head</parameter></term> 138 <listitem> 139 <para> 140 list head to add it before 141 </para> 142 </listitem> 143 </varlistentry> 144 </variablelist> 145</refsect1> 146<refsect1> 147<title>Description</title> 148<para> 149 Insert a new entry before the specified head. 150 This is useful for implementing queues. 151</para> 152</refsect1> 153</refentry> 154 155<refentry id="API---list-del-entry"> 156<refentryinfo> 157 <title>LINUX</title> 158 <productname>Kernel Hackers Manual</productname> 159 <date>July 2017</date> 160</refentryinfo> 161<refmeta> 162 <refentrytitle><phrase>__list_del_entry</phrase></refentrytitle> 163 <manvolnum>9</manvolnum> 164 <refmiscinfo class="version">4.1.27</refmiscinfo> 165</refmeta> 166<refnamediv> 167 <refname>__list_del_entry</refname> 168 <refpurpose> 169 deletes entry from list. 170 </refpurpose> 171</refnamediv> 172<refsynopsisdiv> 173 <title>Synopsis</title> 174 <funcsynopsis><funcprototype> 175 <funcdef>void <function>__list_del_entry </function></funcdef> 176 <paramdef>struct list_head * <parameter>entry</parameter></paramdef> 177 </funcprototype></funcsynopsis> 178</refsynopsisdiv> 179<refsect1> 180 <title>Arguments</title> 181 <variablelist> 182 <varlistentry> 183 <term><parameter>entry</parameter></term> 184 <listitem> 185 <para> 186 the element to delete from the list. 187 </para> 188 </listitem> 189 </varlistentry> 190 </variablelist> 191</refsect1> 192<refsect1> 193<title>Note</title> 194<para> 195 <function>list_empty</function> on entry does not return true after this, the entry is 196 in an undefined state. 197</para> 198</refsect1> 199</refentry> 200 201<refentry id="API-list-replace"> 202<refentryinfo> 203 <title>LINUX</title> 204 <productname>Kernel Hackers Manual</productname> 205 <date>July 2017</date> 206</refentryinfo> 207<refmeta> 208 <refentrytitle><phrase>list_replace</phrase></refentrytitle> 209 <manvolnum>9</manvolnum> 210 <refmiscinfo class="version">4.1.27</refmiscinfo> 211</refmeta> 212<refnamediv> 213 <refname>list_replace</refname> 214 <refpurpose> 215 replace old entry by new one 216 </refpurpose> 217</refnamediv> 218<refsynopsisdiv> 219 <title>Synopsis</title> 220 <funcsynopsis><funcprototype> 221 <funcdef>void <function>list_replace </function></funcdef> 222 <paramdef>struct list_head * <parameter>old</parameter></paramdef> 223 <paramdef>struct list_head * <parameter>new</parameter></paramdef> 224 </funcprototype></funcsynopsis> 225</refsynopsisdiv> 226<refsect1> 227 <title>Arguments</title> 228 <variablelist> 229 <varlistentry> 230 <term><parameter>old</parameter></term> 231 <listitem> 232 <para> 233 the element to be replaced 234 </para> 235 </listitem> 236 </varlistentry> 237 <varlistentry> 238 <term><parameter>new</parameter></term> 239 <listitem> 240 <para> 241 the new element to insert 242 </para> 243 </listitem> 244 </varlistentry> 245 </variablelist> 246</refsect1> 247<refsect1> 248<title>Description</title> 249<para> 250 If <parameter>old</parameter> was empty, it will be overwritten. 251</para> 252</refsect1> 253</refentry> 254 255<refentry id="API-list-del-init"> 256<refentryinfo> 257 <title>LINUX</title> 258 <productname>Kernel Hackers Manual</productname> 259 <date>July 2017</date> 260</refentryinfo> 261<refmeta> 262 <refentrytitle><phrase>list_del_init</phrase></refentrytitle> 263 <manvolnum>9</manvolnum> 264 <refmiscinfo class="version">4.1.27</refmiscinfo> 265</refmeta> 266<refnamediv> 267 <refname>list_del_init</refname> 268 <refpurpose> 269 deletes entry from list and reinitialize it. 270 </refpurpose> 271</refnamediv> 272<refsynopsisdiv> 273 <title>Synopsis</title> 274 <funcsynopsis><funcprototype> 275 <funcdef>void <function>list_del_init </function></funcdef> 276 <paramdef>struct list_head * <parameter>entry</parameter></paramdef> 277 </funcprototype></funcsynopsis> 278</refsynopsisdiv> 279<refsect1> 280 <title>Arguments</title> 281 <variablelist> 282 <varlistentry> 283 <term><parameter>entry</parameter></term> 284 <listitem> 285 <para> 286 the element to delete from the list. 287 </para> 288 </listitem> 289 </varlistentry> 290 </variablelist> 291</refsect1> 292</refentry> 293 294<refentry id="API-list-move"> 295<refentryinfo> 296 <title>LINUX</title> 297 <productname>Kernel Hackers Manual</productname> 298 <date>July 2017</date> 299</refentryinfo> 300<refmeta> 301 <refentrytitle><phrase>list_move</phrase></refentrytitle> 302 <manvolnum>9</manvolnum> 303 <refmiscinfo class="version">4.1.27</refmiscinfo> 304</refmeta> 305<refnamediv> 306 <refname>list_move</refname> 307 <refpurpose> 308 delete from one list and add as another's head 309 </refpurpose> 310</refnamediv> 311<refsynopsisdiv> 312 <title>Synopsis</title> 313 <funcsynopsis><funcprototype> 314 <funcdef>void <function>list_move </function></funcdef> 315 <paramdef>struct list_head * <parameter>list</parameter></paramdef> 316 <paramdef>struct list_head * <parameter>head</parameter></paramdef> 317 </funcprototype></funcsynopsis> 318</refsynopsisdiv> 319<refsect1> 320 <title>Arguments</title> 321 <variablelist> 322 <varlistentry> 323 <term><parameter>list</parameter></term> 324 <listitem> 325 <para> 326 the entry to move 327 </para> 328 </listitem> 329 </varlistentry> 330 <varlistentry> 331 <term><parameter>head</parameter></term> 332 <listitem> 333 <para> 334 the head that will precede our entry 335 </para> 336 </listitem> 337 </varlistentry> 338 </variablelist> 339</refsect1> 340</refentry> 341 342<refentry id="API-list-move-tail"> 343<refentryinfo> 344 <title>LINUX</title> 345 <productname>Kernel Hackers Manual</productname> 346 <date>July 2017</date> 347</refentryinfo> 348<refmeta> 349 <refentrytitle><phrase>list_move_tail</phrase></refentrytitle> 350 <manvolnum>9</manvolnum> 351 <refmiscinfo class="version">4.1.27</refmiscinfo> 352</refmeta> 353<refnamediv> 354 <refname>list_move_tail</refname> 355 <refpurpose> 356 delete from one list and add as another's tail 357 </refpurpose> 358</refnamediv> 359<refsynopsisdiv> 360 <title>Synopsis</title> 361 <funcsynopsis><funcprototype> 362 <funcdef>void <function>list_move_tail </function></funcdef> 363 <paramdef>struct list_head * <parameter>list</parameter></paramdef> 364 <paramdef>struct list_head * <parameter>head</parameter></paramdef> 365 </funcprototype></funcsynopsis> 366</refsynopsisdiv> 367<refsect1> 368 <title>Arguments</title> 369 <variablelist> 370 <varlistentry> 371 <term><parameter>list</parameter></term> 372 <listitem> 373 <para> 374 the entry to move 375 </para> 376 </listitem> 377 </varlistentry> 378 <varlistentry> 379 <term><parameter>head</parameter></term> 380 <listitem> 381 <para> 382 the head that will follow our entry 383 </para> 384 </listitem> 385 </varlistentry> 386 </variablelist> 387</refsect1> 388</refentry> 389 390<refentry id="API-list-is-last"> 391<refentryinfo> 392 <title>LINUX</title> 393 <productname>Kernel Hackers Manual</productname> 394 <date>July 2017</date> 395</refentryinfo> 396<refmeta> 397 <refentrytitle><phrase>list_is_last</phrase></refentrytitle> 398 <manvolnum>9</manvolnum> 399 <refmiscinfo class="version">4.1.27</refmiscinfo> 400</refmeta> 401<refnamediv> 402 <refname>list_is_last</refname> 403 <refpurpose> 404 tests whether <parameter>list</parameter> is the last entry in list <parameter>head</parameter> 405 </refpurpose> 406</refnamediv> 407<refsynopsisdiv> 408 <title>Synopsis</title> 409 <funcsynopsis><funcprototype> 410 <funcdef>int <function>list_is_last </function></funcdef> 411 <paramdef>const struct list_head * <parameter>list</parameter></paramdef> 412 <paramdef>const struct list_head * <parameter>head</parameter></paramdef> 413 </funcprototype></funcsynopsis> 414</refsynopsisdiv> 415<refsect1> 416 <title>Arguments</title> 417 <variablelist> 418 <varlistentry> 419 <term><parameter>list</parameter></term> 420 <listitem> 421 <para> 422 the entry to test 423 </para> 424 </listitem> 425 </varlistentry> 426 <varlistentry> 427 <term><parameter>head</parameter></term> 428 <listitem> 429 <para> 430 the head of the list 431 </para> 432 </listitem> 433 </varlistentry> 434 </variablelist> 435</refsect1> 436</refentry> 437 438<refentry id="API-list-empty"> 439<refentryinfo> 440 <title>LINUX</title> 441 <productname>Kernel Hackers Manual</productname> 442 <date>July 2017</date> 443</refentryinfo> 444<refmeta> 445 <refentrytitle><phrase>list_empty</phrase></refentrytitle> 446 <manvolnum>9</manvolnum> 447 <refmiscinfo class="version">4.1.27</refmiscinfo> 448</refmeta> 449<refnamediv> 450 <refname>list_empty</refname> 451 <refpurpose> 452 tests whether a list is empty 453 </refpurpose> 454</refnamediv> 455<refsynopsisdiv> 456 <title>Synopsis</title> 457 <funcsynopsis><funcprototype> 458 <funcdef>int <function>list_empty </function></funcdef> 459 <paramdef>const struct list_head * <parameter>head</parameter></paramdef> 460 </funcprototype></funcsynopsis> 461</refsynopsisdiv> 462<refsect1> 463 <title>Arguments</title> 464 <variablelist> 465 <varlistentry> 466 <term><parameter>head</parameter></term> 467 <listitem> 468 <para> 469 the list to test. 470 </para> 471 </listitem> 472 </varlistentry> 473 </variablelist> 474</refsect1> 475</refentry> 476 477<refentry id="API-list-empty-careful"> 478<refentryinfo> 479 <title>LINUX</title> 480 <productname>Kernel Hackers Manual</productname> 481 <date>July 2017</date> 482</refentryinfo> 483<refmeta> 484 <refentrytitle><phrase>list_empty_careful</phrase></refentrytitle> 485 <manvolnum>9</manvolnum> 486 <refmiscinfo class="version">4.1.27</refmiscinfo> 487</refmeta> 488<refnamediv> 489 <refname>list_empty_careful</refname> 490 <refpurpose> 491 tests whether a list is empty and not being modified 492 </refpurpose> 493</refnamediv> 494<refsynopsisdiv> 495 <title>Synopsis</title> 496 <funcsynopsis><funcprototype> 497 <funcdef>int <function>list_empty_careful </function></funcdef> 498 <paramdef>const struct list_head * <parameter>head</parameter></paramdef> 499 </funcprototype></funcsynopsis> 500</refsynopsisdiv> 501<refsect1> 502 <title>Arguments</title> 503 <variablelist> 504 <varlistentry> 505 <term><parameter>head</parameter></term> 506 <listitem> 507 <para> 508 the list to test 509 </para> 510 </listitem> 511 </varlistentry> 512 </variablelist> 513</refsect1> 514<refsect1> 515<title>Description</title> 516<para> 517 tests whether a list is empty _and_ checks that no other CPU might be 518 in the process of modifying either member (next or prev) 519</para> 520</refsect1> 521<refsect1> 522<title>NOTE</title> 523<para> 524 using <function>list_empty_careful</function> without synchronization 525 can only be safe if the only activity that can happen 526 to the list entry is <function>list_del_init</function>. Eg. it cannot be used 527 if another CPU could re-<function>list_add</function> it. 528</para> 529</refsect1> 530</refentry> 531 532<refentry id="API-list-rotate-left"> 533<refentryinfo> 534 <title>LINUX</title> 535 <productname>Kernel Hackers Manual</productname> 536 <date>July 2017</date> 537</refentryinfo> 538<refmeta> 539 <refentrytitle><phrase>list_rotate_left</phrase></refentrytitle> 540 <manvolnum>9</manvolnum> 541 <refmiscinfo class="version">4.1.27</refmiscinfo> 542</refmeta> 543<refnamediv> 544 <refname>list_rotate_left</refname> 545 <refpurpose> 546 rotate the list to the left 547 </refpurpose> 548</refnamediv> 549<refsynopsisdiv> 550 <title>Synopsis</title> 551 <funcsynopsis><funcprototype> 552 <funcdef>void <function>list_rotate_left </function></funcdef> 553 <paramdef>struct list_head * <parameter>head</parameter></paramdef> 554 </funcprototype></funcsynopsis> 555</refsynopsisdiv> 556<refsect1> 557 <title>Arguments</title> 558 <variablelist> 559 <varlistentry> 560 <term><parameter>head</parameter></term> 561 <listitem> 562 <para> 563 the head of the list 564 </para> 565 </listitem> 566 </varlistentry> 567 </variablelist> 568</refsect1> 569</refentry> 570 571<refentry id="API-list-is-singular"> 572<refentryinfo> 573 <title>LINUX</title> 574 <productname>Kernel Hackers Manual</productname> 575 <date>July 2017</date> 576</refentryinfo> 577<refmeta> 578 <refentrytitle><phrase>list_is_singular</phrase></refentrytitle> 579 <manvolnum>9</manvolnum> 580 <refmiscinfo class="version">4.1.27</refmiscinfo> 581</refmeta> 582<refnamediv> 583 <refname>list_is_singular</refname> 584 <refpurpose> 585 tests whether a list has just one entry. 586 </refpurpose> 587</refnamediv> 588<refsynopsisdiv> 589 <title>Synopsis</title> 590 <funcsynopsis><funcprototype> 591 <funcdef>int <function>list_is_singular </function></funcdef> 592 <paramdef>const struct list_head * <parameter>head</parameter></paramdef> 593 </funcprototype></funcsynopsis> 594</refsynopsisdiv> 595<refsect1> 596 <title>Arguments</title> 597 <variablelist> 598 <varlistentry> 599 <term><parameter>head</parameter></term> 600 <listitem> 601 <para> 602 the list to test. 603 </para> 604 </listitem> 605 </varlistentry> 606 </variablelist> 607</refsect1> 608</refentry> 609 610<refentry id="API-list-cut-position"> 611<refentryinfo> 612 <title>LINUX</title> 613 <productname>Kernel Hackers Manual</productname> 614 <date>July 2017</date> 615</refentryinfo> 616<refmeta> 617 <refentrytitle><phrase>list_cut_position</phrase></refentrytitle> 618 <manvolnum>9</manvolnum> 619 <refmiscinfo class="version">4.1.27</refmiscinfo> 620</refmeta> 621<refnamediv> 622 <refname>list_cut_position</refname> 623 <refpurpose> 624 cut a list into two 625 </refpurpose> 626</refnamediv> 627<refsynopsisdiv> 628 <title>Synopsis</title> 629 <funcsynopsis><funcprototype> 630 <funcdef>void <function>list_cut_position </function></funcdef> 631 <paramdef>struct list_head * <parameter>list</parameter></paramdef> 632 <paramdef>struct list_head * <parameter>head</parameter></paramdef> 633 <paramdef>struct list_head * <parameter>entry</parameter></paramdef> 634 </funcprototype></funcsynopsis> 635</refsynopsisdiv> 636<refsect1> 637 <title>Arguments</title> 638 <variablelist> 639 <varlistentry> 640 <term><parameter>list</parameter></term> 641 <listitem> 642 <para> 643 a new list to add all removed entries 644 </para> 645 </listitem> 646 </varlistentry> 647 <varlistentry> 648 <term><parameter>head</parameter></term> 649 <listitem> 650 <para> 651 a list with entries 652 </para> 653 </listitem> 654 </varlistentry> 655 <varlistentry> 656 <term><parameter>entry</parameter></term> 657 <listitem> 658 <para> 659 an entry within head, could be the head itself 660 and if so we won't cut the list 661 </para> 662 </listitem> 663 </varlistentry> 664 </variablelist> 665</refsect1> 666<refsect1> 667<title>Description</title> 668<para> 669 This helper moves the initial part of <parameter>head</parameter>, up to and 670 including <parameter>entry</parameter>, from <parameter>head</parameter> to <parameter>list</parameter>. You should 671 pass on <parameter>entry</parameter> an element you know is on <parameter>head</parameter>. <parameter>list</parameter> 672 should be an empty list or a list you do not care about 673 losing its data. 674</para> 675</refsect1> 676</refentry> 677 678<refentry id="API-list-splice"> 679<refentryinfo> 680 <title>LINUX</title> 681 <productname>Kernel Hackers Manual</productname> 682 <date>July 2017</date> 683</refentryinfo> 684<refmeta> 685 <refentrytitle><phrase>list_splice</phrase></refentrytitle> 686 <manvolnum>9</manvolnum> 687 <refmiscinfo class="version">4.1.27</refmiscinfo> 688</refmeta> 689<refnamediv> 690 <refname>list_splice</refname> 691 <refpurpose> 692 join two lists, this is designed for stacks 693 </refpurpose> 694</refnamediv> 695<refsynopsisdiv> 696 <title>Synopsis</title> 697 <funcsynopsis><funcprototype> 698 <funcdef>void <function>list_splice </function></funcdef> 699 <paramdef>const struct list_head * <parameter>list</parameter></paramdef> 700 <paramdef>struct list_head * <parameter>head</parameter></paramdef> 701 </funcprototype></funcsynopsis> 702</refsynopsisdiv> 703<refsect1> 704 <title>Arguments</title> 705 <variablelist> 706 <varlistentry> 707 <term><parameter>list</parameter></term> 708 <listitem> 709 <para> 710 the new list to add. 711 </para> 712 </listitem> 713 </varlistentry> 714 <varlistentry> 715 <term><parameter>head</parameter></term> 716 <listitem> 717 <para> 718 the place to add it in the first list. 719 </para> 720 </listitem> 721 </varlistentry> 722 </variablelist> 723</refsect1> 724</refentry> 725 726<refentry id="API-list-splice-tail"> 727<refentryinfo> 728 <title>LINUX</title> 729 <productname>Kernel Hackers Manual</productname> 730 <date>July 2017</date> 731</refentryinfo> 732<refmeta> 733 <refentrytitle><phrase>list_splice_tail</phrase></refentrytitle> 734 <manvolnum>9</manvolnum> 735 <refmiscinfo class="version">4.1.27</refmiscinfo> 736</refmeta> 737<refnamediv> 738 <refname>list_splice_tail</refname> 739 <refpurpose> 740 join two lists, each list being a queue 741 </refpurpose> 742</refnamediv> 743<refsynopsisdiv> 744 <title>Synopsis</title> 745 <funcsynopsis><funcprototype> 746 <funcdef>void <function>list_splice_tail </function></funcdef> 747 <paramdef>struct list_head * <parameter>list</parameter></paramdef> 748 <paramdef>struct list_head * <parameter>head</parameter></paramdef> 749 </funcprototype></funcsynopsis> 750</refsynopsisdiv> 751<refsect1> 752 <title>Arguments</title> 753 <variablelist> 754 <varlistentry> 755 <term><parameter>list</parameter></term> 756 <listitem> 757 <para> 758 the new list to add. 759 </para> 760 </listitem> 761 </varlistentry> 762 <varlistentry> 763 <term><parameter>head</parameter></term> 764 <listitem> 765 <para> 766 the place to add it in the first list. 767 </para> 768 </listitem> 769 </varlistentry> 770 </variablelist> 771</refsect1> 772</refentry> 773 774<refentry id="API-list-splice-init"> 775<refentryinfo> 776 <title>LINUX</title> 777 <productname>Kernel Hackers Manual</productname> 778 <date>July 2017</date> 779</refentryinfo> 780<refmeta> 781 <refentrytitle><phrase>list_splice_init</phrase></refentrytitle> 782 <manvolnum>9</manvolnum> 783 <refmiscinfo class="version">4.1.27</refmiscinfo> 784</refmeta> 785<refnamediv> 786 <refname>list_splice_init</refname> 787 <refpurpose> 788 join two lists and reinitialise the emptied list. 789 </refpurpose> 790</refnamediv> 791<refsynopsisdiv> 792 <title>Synopsis</title> 793 <funcsynopsis><funcprototype> 794 <funcdef>void <function>list_splice_init </function></funcdef> 795 <paramdef>struct list_head * <parameter>list</parameter></paramdef> 796 <paramdef>struct list_head * <parameter>head</parameter></paramdef> 797 </funcprototype></funcsynopsis> 798</refsynopsisdiv> 799<refsect1> 800 <title>Arguments</title> 801 <variablelist> 802 <varlistentry> 803 <term><parameter>list</parameter></term> 804 <listitem> 805 <para> 806 the new list to add. 807 </para> 808 </listitem> 809 </varlistentry> 810 <varlistentry> 811 <term><parameter>head</parameter></term> 812 <listitem> 813 <para> 814 the place to add it in the first list. 815 </para> 816 </listitem> 817 </varlistentry> 818 </variablelist> 819</refsect1> 820<refsect1> 821<title>Description</title> 822<para> 823 The list at <parameter>list</parameter> is reinitialised 824</para> 825</refsect1> 826</refentry> 827 828<refentry id="API-list-splice-tail-init"> 829<refentryinfo> 830 <title>LINUX</title> 831 <productname>Kernel Hackers Manual</productname> 832 <date>July 2017</date> 833</refentryinfo> 834<refmeta> 835 <refentrytitle><phrase>list_splice_tail_init</phrase></refentrytitle> 836 <manvolnum>9</manvolnum> 837 <refmiscinfo class="version">4.1.27</refmiscinfo> 838</refmeta> 839<refnamediv> 840 <refname>list_splice_tail_init</refname> 841 <refpurpose> 842 join two lists and reinitialise the emptied list 843 </refpurpose> 844</refnamediv> 845<refsynopsisdiv> 846 <title>Synopsis</title> 847 <funcsynopsis><funcprototype> 848 <funcdef>void <function>list_splice_tail_init </function></funcdef> 849 <paramdef>struct list_head * <parameter>list</parameter></paramdef> 850 <paramdef>struct list_head * <parameter>head</parameter></paramdef> 851 </funcprototype></funcsynopsis> 852</refsynopsisdiv> 853<refsect1> 854 <title>Arguments</title> 855 <variablelist> 856 <varlistentry> 857 <term><parameter>list</parameter></term> 858 <listitem> 859 <para> 860 the new list to add. 861 </para> 862 </listitem> 863 </varlistentry> 864 <varlistentry> 865 <term><parameter>head</parameter></term> 866 <listitem> 867 <para> 868 the place to add it in the first list. 869 </para> 870 </listitem> 871 </varlistentry> 872 </variablelist> 873</refsect1> 874<refsect1> 875<title>Description</title> 876<para> 877 Each of the lists is a queue. 878 The list at <parameter>list</parameter> is reinitialised 879</para> 880</refsect1> 881</refentry> 882 883<refentry id="API-list-entry"> 884<refentryinfo> 885 <title>LINUX</title> 886 <productname>Kernel Hackers Manual</productname> 887 <date>July 2017</date> 888</refentryinfo> 889<refmeta> 890 <refentrytitle><phrase>list_entry</phrase></refentrytitle> 891 <manvolnum>9</manvolnum> 892 <refmiscinfo class="version">4.1.27</refmiscinfo> 893</refmeta> 894<refnamediv> 895 <refname>list_entry</refname> 896 <refpurpose> 897 get the struct for this entry 898 </refpurpose> 899</refnamediv> 900<refsynopsisdiv> 901 <title>Synopsis</title> 902 <funcsynopsis><funcprototype> 903 <funcdef> <function>list_entry </function></funcdef> 904 <paramdef> <parameter>ptr</parameter></paramdef> 905 <paramdef> <parameter>type</parameter></paramdef> 906 <paramdef> <parameter>member</parameter></paramdef> 907 </funcprototype></funcsynopsis> 908</refsynopsisdiv> 909<refsect1> 910 <title>Arguments</title> 911 <variablelist> 912 <varlistentry> 913 <term><parameter>ptr</parameter></term> 914 <listitem> 915 <para> 916 the <structname>struct list_head</structname> pointer. 917 </para> 918 </listitem> 919 </varlistentry> 920 <varlistentry> 921 <term><parameter>type</parameter></term> 922 <listitem> 923 <para> 924 the type of the struct this is embedded in. 925 </para> 926 </listitem> 927 </varlistentry> 928 <varlistentry> 929 <term><parameter>member</parameter></term> 930 <listitem> 931 <para> 932 the name of the list_head within the struct. 933 </para> 934 </listitem> 935 </varlistentry> 936 </variablelist> 937</refsect1> 938</refentry> 939 940<refentry id="API-list-first-entry"> 941<refentryinfo> 942 <title>LINUX</title> 943 <productname>Kernel Hackers Manual</productname> 944 <date>July 2017</date> 945</refentryinfo> 946<refmeta> 947 <refentrytitle><phrase>list_first_entry</phrase></refentrytitle> 948 <manvolnum>9</manvolnum> 949 <refmiscinfo class="version">4.1.27</refmiscinfo> 950</refmeta> 951<refnamediv> 952 <refname>list_first_entry</refname> 953 <refpurpose> 954 get the first element from a list 955 </refpurpose> 956</refnamediv> 957<refsynopsisdiv> 958 <title>Synopsis</title> 959 <funcsynopsis><funcprototype> 960 <funcdef> <function>list_first_entry </function></funcdef> 961 <paramdef> <parameter>ptr</parameter></paramdef> 962 <paramdef> <parameter>type</parameter></paramdef> 963 <paramdef> <parameter>member</parameter></paramdef> 964 </funcprototype></funcsynopsis> 965</refsynopsisdiv> 966<refsect1> 967 <title>Arguments</title> 968 <variablelist> 969 <varlistentry> 970 <term><parameter>ptr</parameter></term> 971 <listitem> 972 <para> 973 the list head to take the element from. 974 </para> 975 </listitem> 976 </varlistentry> 977 <varlistentry> 978 <term><parameter>type</parameter></term> 979 <listitem> 980 <para> 981 the type of the struct this is embedded in. 982 </para> 983 </listitem> 984 </varlistentry> 985 <varlistentry> 986 <term><parameter>member</parameter></term> 987 <listitem> 988 <para> 989 the name of the list_head within the struct. 990 </para> 991 </listitem> 992 </varlistentry> 993 </variablelist> 994</refsect1> 995<refsect1> 996<title>Description</title> 997<para> 998 Note, that list is expected to be not empty. 999</para> 1000</refsect1> 1001</refentry> 1002 1003<refentry id="API-list-last-entry"> 1004<refentryinfo> 1005 <title>LINUX</title> 1006 <productname>Kernel Hackers Manual</productname> 1007 <date>July 2017</date> 1008</refentryinfo> 1009<refmeta> 1010 <refentrytitle><phrase>list_last_entry</phrase></refentrytitle> 1011 <manvolnum>9</manvolnum> 1012 <refmiscinfo class="version">4.1.27</refmiscinfo> 1013</refmeta> 1014<refnamediv> 1015 <refname>list_last_entry</refname> 1016 <refpurpose> 1017 get the last element from a list 1018 </refpurpose> 1019</refnamediv> 1020<refsynopsisdiv> 1021 <title>Synopsis</title> 1022 <funcsynopsis><funcprototype> 1023 <funcdef> <function>list_last_entry </function></funcdef> 1024 <paramdef> <parameter>ptr</parameter></paramdef> 1025 <paramdef> <parameter>type</parameter></paramdef> 1026 <paramdef> <parameter>member</parameter></paramdef> 1027 </funcprototype></funcsynopsis> 1028</refsynopsisdiv> 1029<refsect1> 1030 <title>Arguments</title> 1031 <variablelist> 1032 <varlistentry> 1033 <term><parameter>ptr</parameter></term> 1034 <listitem> 1035 <para> 1036 the list head to take the element from. 1037 </para> 1038 </listitem> 1039 </varlistentry> 1040 <varlistentry> 1041 <term><parameter>type</parameter></term> 1042 <listitem> 1043 <para> 1044 the type of the struct this is embedded in. 1045 </para> 1046 </listitem> 1047 </varlistentry> 1048 <varlistentry> 1049 <term><parameter>member</parameter></term> 1050 <listitem> 1051 <para> 1052 the name of the list_head within the struct. 1053 </para> 1054 </listitem> 1055 </varlistentry> 1056 </variablelist> 1057</refsect1> 1058<refsect1> 1059<title>Description</title> 1060<para> 1061 Note, that list is expected to be not empty. 1062</para> 1063</refsect1> 1064</refentry> 1065 1066<refentry id="API-list-first-entry-or-null"> 1067<refentryinfo> 1068 <title>LINUX</title> 1069 <productname>Kernel Hackers Manual</productname> 1070 <date>July 2017</date> 1071</refentryinfo> 1072<refmeta> 1073 <refentrytitle><phrase>list_first_entry_or_null</phrase></refentrytitle> 1074 <manvolnum>9</manvolnum> 1075 <refmiscinfo class="version">4.1.27</refmiscinfo> 1076</refmeta> 1077<refnamediv> 1078 <refname>list_first_entry_or_null</refname> 1079 <refpurpose> 1080 get the first element from a list 1081 </refpurpose> 1082</refnamediv> 1083<refsynopsisdiv> 1084 <title>Synopsis</title> 1085 <funcsynopsis><funcprototype> 1086 <funcdef> <function>list_first_entry_or_null </function></funcdef> 1087 <paramdef> <parameter>ptr</parameter></paramdef> 1088 <paramdef> <parameter>type</parameter></paramdef> 1089 <paramdef> <parameter>member</parameter></paramdef> 1090 </funcprototype></funcsynopsis> 1091</refsynopsisdiv> 1092<refsect1> 1093 <title>Arguments</title> 1094 <variablelist> 1095 <varlistentry> 1096 <term><parameter>ptr</parameter></term> 1097 <listitem> 1098 <para> 1099 the list head to take the element from. 1100 </para> 1101 </listitem> 1102 </varlistentry> 1103 <varlistentry> 1104 <term><parameter>type</parameter></term> 1105 <listitem> 1106 <para> 1107 the type of the struct this is embedded in. 1108 </para> 1109 </listitem> 1110 </varlistentry> 1111 <varlistentry> 1112 <term><parameter>member</parameter></term> 1113 <listitem> 1114 <para> 1115 the name of the list_head within the struct. 1116 </para> 1117 </listitem> 1118 </varlistentry> 1119 </variablelist> 1120</refsect1> 1121<refsect1> 1122<title>Description</title> 1123<para> 1124 Note that if the list is empty, it returns NULL. 1125</para> 1126</refsect1> 1127</refentry> 1128 1129<refentry id="API-list-next-entry"> 1130<refentryinfo> 1131 <title>LINUX</title> 1132 <productname>Kernel Hackers Manual</productname> 1133 <date>July 2017</date> 1134</refentryinfo> 1135<refmeta> 1136 <refentrytitle><phrase>list_next_entry</phrase></refentrytitle> 1137 <manvolnum>9</manvolnum> 1138 <refmiscinfo class="version">4.1.27</refmiscinfo> 1139</refmeta> 1140<refnamediv> 1141 <refname>list_next_entry</refname> 1142 <refpurpose> 1143 get the next element in list 1144 </refpurpose> 1145</refnamediv> 1146<refsynopsisdiv> 1147 <title>Synopsis</title> 1148 <funcsynopsis><funcprototype> 1149 <funcdef> <function>list_next_entry </function></funcdef> 1150 <paramdef> <parameter>pos</parameter></paramdef> 1151 <paramdef> <parameter>member</parameter></paramdef> 1152 </funcprototype></funcsynopsis> 1153</refsynopsisdiv> 1154<refsect1> 1155 <title>Arguments</title> 1156 <variablelist> 1157 <varlistentry> 1158 <term><parameter>pos</parameter></term> 1159 <listitem> 1160 <para> 1161 the type * to cursor 1162 </para> 1163 </listitem> 1164 </varlistentry> 1165 <varlistentry> 1166 <term><parameter>member</parameter></term> 1167 <listitem> 1168 <para> 1169 the name of the list_head within the struct. 1170 </para> 1171 </listitem> 1172 </varlistentry> 1173 </variablelist> 1174</refsect1> 1175</refentry> 1176 1177<refentry id="API-list-prev-entry"> 1178<refentryinfo> 1179 <title>LINUX</title> 1180 <productname>Kernel Hackers Manual</productname> 1181 <date>July 2017</date> 1182</refentryinfo> 1183<refmeta> 1184 <refentrytitle><phrase>list_prev_entry</phrase></refentrytitle> 1185 <manvolnum>9</manvolnum> 1186 <refmiscinfo class="version">4.1.27</refmiscinfo> 1187</refmeta> 1188<refnamediv> 1189 <refname>list_prev_entry</refname> 1190 <refpurpose> 1191 get the prev element in list 1192 </refpurpose> 1193</refnamediv> 1194<refsynopsisdiv> 1195 <title>Synopsis</title> 1196 <funcsynopsis><funcprototype> 1197 <funcdef> <function>list_prev_entry </function></funcdef> 1198 <paramdef> <parameter>pos</parameter></paramdef> 1199 <paramdef> <parameter>member</parameter></paramdef> 1200 </funcprototype></funcsynopsis> 1201</refsynopsisdiv> 1202<refsect1> 1203 <title>Arguments</title> 1204 <variablelist> 1205 <varlistentry> 1206 <term><parameter>pos</parameter></term> 1207 <listitem> 1208 <para> 1209 the type * to cursor 1210 </para> 1211 </listitem> 1212 </varlistentry> 1213 <varlistentry> 1214 <term><parameter>member</parameter></term> 1215 <listitem> 1216 <para> 1217 the name of the list_head within the struct. 1218 </para> 1219 </listitem> 1220 </varlistentry> 1221 </variablelist> 1222</refsect1> 1223</refentry> 1224 1225<refentry id="API-list-for-each"> 1226<refentryinfo> 1227 <title>LINUX</title> 1228 <productname>Kernel Hackers Manual</productname> 1229 <date>July 2017</date> 1230</refentryinfo> 1231<refmeta> 1232 <refentrytitle><phrase>list_for_each</phrase></refentrytitle> 1233 <manvolnum>9</manvolnum> 1234 <refmiscinfo class="version">4.1.27</refmiscinfo> 1235</refmeta> 1236<refnamediv> 1237 <refname>list_for_each</refname> 1238 <refpurpose> 1239 iterate over a list 1240 </refpurpose> 1241</refnamediv> 1242<refsynopsisdiv> 1243 <title>Synopsis</title> 1244 <funcsynopsis><funcprototype> 1245 <funcdef> <function>list_for_each </function></funcdef> 1246 <paramdef> <parameter>pos</parameter></paramdef> 1247 <paramdef> <parameter>head</parameter></paramdef> 1248 </funcprototype></funcsynopsis> 1249</refsynopsisdiv> 1250<refsect1> 1251 <title>Arguments</title> 1252 <variablelist> 1253 <varlistentry> 1254 <term><parameter>pos</parameter></term> 1255 <listitem> 1256 <para> 1257 the <structname>struct list_head</structname> to use as a loop cursor. 1258 </para> 1259 </listitem> 1260 </varlistentry> 1261 <varlistentry> 1262 <term><parameter>head</parameter></term> 1263 <listitem> 1264 <para> 1265 the head for your list. 1266 </para> 1267 </listitem> 1268 </varlistentry> 1269 </variablelist> 1270</refsect1> 1271</refentry> 1272 1273<refentry id="API-list-for-each-prev"> 1274<refentryinfo> 1275 <title>LINUX</title> 1276 <productname>Kernel Hackers Manual</productname> 1277 <date>July 2017</date> 1278</refentryinfo> 1279<refmeta> 1280 <refentrytitle><phrase>list_for_each_prev</phrase></refentrytitle> 1281 <manvolnum>9</manvolnum> 1282 <refmiscinfo class="version">4.1.27</refmiscinfo> 1283</refmeta> 1284<refnamediv> 1285 <refname>list_for_each_prev</refname> 1286 <refpurpose> 1287 iterate over a list backwards 1288 </refpurpose> 1289</refnamediv> 1290<refsynopsisdiv> 1291 <title>Synopsis</title> 1292 <funcsynopsis><funcprototype> 1293 <funcdef> <function>list_for_each_prev </function></funcdef> 1294 <paramdef> <parameter>pos</parameter></paramdef> 1295 <paramdef> <parameter>head</parameter></paramdef> 1296 </funcprototype></funcsynopsis> 1297</refsynopsisdiv> 1298<refsect1> 1299 <title>Arguments</title> 1300 <variablelist> 1301 <varlistentry> 1302 <term><parameter>pos</parameter></term> 1303 <listitem> 1304 <para> 1305 the <structname>struct list_head</structname> to use as a loop cursor. 1306 </para> 1307 </listitem> 1308 </varlistentry> 1309 <varlistentry> 1310 <term><parameter>head</parameter></term> 1311 <listitem> 1312 <para> 1313 the head for your list. 1314 </para> 1315 </listitem> 1316 </varlistentry> 1317 </variablelist> 1318</refsect1> 1319</refentry> 1320 1321<refentry id="API-list-for-each-safe"> 1322<refentryinfo> 1323 <title>LINUX</title> 1324 <productname>Kernel Hackers Manual</productname> 1325 <date>July 2017</date> 1326</refentryinfo> 1327<refmeta> 1328 <refentrytitle><phrase>list_for_each_safe</phrase></refentrytitle> 1329 <manvolnum>9</manvolnum> 1330 <refmiscinfo class="version">4.1.27</refmiscinfo> 1331</refmeta> 1332<refnamediv> 1333 <refname>list_for_each_safe</refname> 1334 <refpurpose> 1335 iterate over a list safe against removal of list entry 1336 </refpurpose> 1337</refnamediv> 1338<refsynopsisdiv> 1339 <title>Synopsis</title> 1340 <funcsynopsis><funcprototype> 1341 <funcdef> <function>list_for_each_safe </function></funcdef> 1342 <paramdef> <parameter>pos</parameter></paramdef> 1343 <paramdef> <parameter>n</parameter></paramdef> 1344 <paramdef> <parameter>head</parameter></paramdef> 1345 </funcprototype></funcsynopsis> 1346</refsynopsisdiv> 1347<refsect1> 1348 <title>Arguments</title> 1349 <variablelist> 1350 <varlistentry> 1351 <term><parameter>pos</parameter></term> 1352 <listitem> 1353 <para> 1354 the <structname>struct list_head</structname> to use as a loop cursor. 1355 </para> 1356 </listitem> 1357 </varlistentry> 1358 <varlistentry> 1359 <term><parameter>n</parameter></term> 1360 <listitem> 1361 <para> 1362 another <structname>struct list_head</structname> to use as temporary storage 1363 </para> 1364 </listitem> 1365 </varlistentry> 1366 <varlistentry> 1367 <term><parameter>head</parameter></term> 1368 <listitem> 1369 <para> 1370 the head for your list. 1371 </para> 1372 </listitem> 1373 </varlistentry> 1374 </variablelist> 1375</refsect1> 1376</refentry> 1377 1378<refentry id="API-list-for-each-prev-safe"> 1379<refentryinfo> 1380 <title>LINUX</title> 1381 <productname>Kernel Hackers Manual</productname> 1382 <date>July 2017</date> 1383</refentryinfo> 1384<refmeta> 1385 <refentrytitle><phrase>list_for_each_prev_safe</phrase></refentrytitle> 1386 <manvolnum>9</manvolnum> 1387 <refmiscinfo class="version">4.1.27</refmiscinfo> 1388</refmeta> 1389<refnamediv> 1390 <refname>list_for_each_prev_safe</refname> 1391 <refpurpose> 1392 iterate over a list backwards safe against removal of list entry 1393 </refpurpose> 1394</refnamediv> 1395<refsynopsisdiv> 1396 <title>Synopsis</title> 1397 <funcsynopsis><funcprototype> 1398 <funcdef> <function>list_for_each_prev_safe </function></funcdef> 1399 <paramdef> <parameter>pos</parameter></paramdef> 1400 <paramdef> <parameter>n</parameter></paramdef> 1401 <paramdef> <parameter>head</parameter></paramdef> 1402 </funcprototype></funcsynopsis> 1403</refsynopsisdiv> 1404<refsect1> 1405 <title>Arguments</title> 1406 <variablelist> 1407 <varlistentry> 1408 <term><parameter>pos</parameter></term> 1409 <listitem> 1410 <para> 1411 the <structname>struct list_head</structname> to use as a loop cursor. 1412 </para> 1413 </listitem> 1414 </varlistentry> 1415 <varlistentry> 1416 <term><parameter>n</parameter></term> 1417 <listitem> 1418 <para> 1419 another <structname>struct list_head</structname> to use as temporary storage 1420 </para> 1421 </listitem> 1422 </varlistentry> 1423 <varlistentry> 1424 <term><parameter>head</parameter></term> 1425 <listitem> 1426 <para> 1427 the head for your list. 1428 </para> 1429 </listitem> 1430 </varlistentry> 1431 </variablelist> 1432</refsect1> 1433</refentry> 1434 1435<refentry id="API-list-for-each-entry"> 1436<refentryinfo> 1437 <title>LINUX</title> 1438 <productname>Kernel Hackers Manual</productname> 1439 <date>July 2017</date> 1440</refentryinfo> 1441<refmeta> 1442 <refentrytitle><phrase>list_for_each_entry</phrase></refentrytitle> 1443 <manvolnum>9</manvolnum> 1444 <refmiscinfo class="version">4.1.27</refmiscinfo> 1445</refmeta> 1446<refnamediv> 1447 <refname>list_for_each_entry</refname> 1448 <refpurpose> 1449 iterate over list of given type 1450 </refpurpose> 1451</refnamediv> 1452<refsynopsisdiv> 1453 <title>Synopsis</title> 1454 <funcsynopsis><funcprototype> 1455 <funcdef> <function>list_for_each_entry </function></funcdef> 1456 <paramdef> <parameter>pos</parameter></paramdef> 1457 <paramdef> <parameter>head</parameter></paramdef> 1458 <paramdef> <parameter>member</parameter></paramdef> 1459 </funcprototype></funcsynopsis> 1460</refsynopsisdiv> 1461<refsect1> 1462 <title>Arguments</title> 1463 <variablelist> 1464 <varlistentry> 1465 <term><parameter>pos</parameter></term> 1466 <listitem> 1467 <para> 1468 the type * to use as a loop cursor. 1469 </para> 1470 </listitem> 1471 </varlistentry> 1472 <varlistentry> 1473 <term><parameter>head</parameter></term> 1474 <listitem> 1475 <para> 1476 the head for your list. 1477 </para> 1478 </listitem> 1479 </varlistentry> 1480 <varlistentry> 1481 <term><parameter>member</parameter></term> 1482 <listitem> 1483 <para> 1484 the name of the list_head within the struct. 1485 </para> 1486 </listitem> 1487 </varlistentry> 1488 </variablelist> 1489</refsect1> 1490</refentry> 1491 1492<refentry id="API-list-for-each-entry-reverse"> 1493<refentryinfo> 1494 <title>LINUX</title> 1495 <productname>Kernel Hackers Manual</productname> 1496 <date>July 2017</date> 1497</refentryinfo> 1498<refmeta> 1499 <refentrytitle><phrase>list_for_each_entry_reverse</phrase></refentrytitle> 1500 <manvolnum>9</manvolnum> 1501 <refmiscinfo class="version">4.1.27</refmiscinfo> 1502</refmeta> 1503<refnamediv> 1504 <refname>list_for_each_entry_reverse</refname> 1505 <refpurpose> 1506 iterate backwards over list of given type. 1507 </refpurpose> 1508</refnamediv> 1509<refsynopsisdiv> 1510 <title>Synopsis</title> 1511 <funcsynopsis><funcprototype> 1512 <funcdef> <function>list_for_each_entry_reverse </function></funcdef> 1513 <paramdef> <parameter>pos</parameter></paramdef> 1514 <paramdef> <parameter>head</parameter></paramdef> 1515 <paramdef> <parameter>member</parameter></paramdef> 1516 </funcprototype></funcsynopsis> 1517</refsynopsisdiv> 1518<refsect1> 1519 <title>Arguments</title> 1520 <variablelist> 1521 <varlistentry> 1522 <term><parameter>pos</parameter></term> 1523 <listitem> 1524 <para> 1525 the type * to use as a loop cursor. 1526 </para> 1527 </listitem> 1528 </varlistentry> 1529 <varlistentry> 1530 <term><parameter>head</parameter></term> 1531 <listitem> 1532 <para> 1533 the head for your list. 1534 </para> 1535 </listitem> 1536 </varlistentry> 1537 <varlistentry> 1538 <term><parameter>member</parameter></term> 1539 <listitem> 1540 <para> 1541 the name of the list_head within the struct. 1542 </para> 1543 </listitem> 1544 </varlistentry> 1545 </variablelist> 1546</refsect1> 1547</refentry> 1548 1549<refentry id="API-list-prepare-entry"> 1550<refentryinfo> 1551 <title>LINUX</title> 1552 <productname>Kernel Hackers Manual</productname> 1553 <date>July 2017</date> 1554</refentryinfo> 1555<refmeta> 1556 <refentrytitle><phrase>list_prepare_entry</phrase></refentrytitle> 1557 <manvolnum>9</manvolnum> 1558 <refmiscinfo class="version">4.1.27</refmiscinfo> 1559</refmeta> 1560<refnamediv> 1561 <refname>list_prepare_entry</refname> 1562 <refpurpose> 1563 prepare a pos entry for use in <function>list_for_each_entry_continue</function> 1564 </refpurpose> 1565</refnamediv> 1566<refsynopsisdiv> 1567 <title>Synopsis</title> 1568 <funcsynopsis><funcprototype> 1569 <funcdef> <function>list_prepare_entry </function></funcdef> 1570 <paramdef> <parameter>pos</parameter></paramdef> 1571 <paramdef> <parameter>head</parameter></paramdef> 1572 <paramdef> <parameter>member</parameter></paramdef> 1573 </funcprototype></funcsynopsis> 1574</refsynopsisdiv> 1575<refsect1> 1576 <title>Arguments</title> 1577 <variablelist> 1578 <varlistentry> 1579 <term><parameter>pos</parameter></term> 1580 <listitem> 1581 <para> 1582 the type * to use as a start point 1583 </para> 1584 </listitem> 1585 </varlistentry> 1586 <varlistentry> 1587 <term><parameter>head</parameter></term> 1588 <listitem> 1589 <para> 1590 the head of the list 1591 </para> 1592 </listitem> 1593 </varlistentry> 1594 <varlistentry> 1595 <term><parameter>member</parameter></term> 1596 <listitem> 1597 <para> 1598 the name of the list_head within the struct. 1599 </para> 1600 </listitem> 1601 </varlistentry> 1602 </variablelist> 1603</refsect1> 1604<refsect1> 1605<title>Description</title> 1606<para> 1607 Prepares a pos entry for use as a start point in <function>list_for_each_entry_continue</function>. 1608</para> 1609</refsect1> 1610</refentry> 1611 1612<refentry id="API-list-for-each-entry-continue"> 1613<refentryinfo> 1614 <title>LINUX</title> 1615 <productname>Kernel Hackers Manual</productname> 1616 <date>July 2017</date> 1617</refentryinfo> 1618<refmeta> 1619 <refentrytitle><phrase>list_for_each_entry_continue</phrase></refentrytitle> 1620 <manvolnum>9</manvolnum> 1621 <refmiscinfo class="version">4.1.27</refmiscinfo> 1622</refmeta> 1623<refnamediv> 1624 <refname>list_for_each_entry_continue</refname> 1625 <refpurpose> 1626 continue iteration over list of given type 1627 </refpurpose> 1628</refnamediv> 1629<refsynopsisdiv> 1630 <title>Synopsis</title> 1631 <funcsynopsis><funcprototype> 1632 <funcdef> <function>list_for_each_entry_continue </function></funcdef> 1633 <paramdef> <parameter>pos</parameter></paramdef> 1634 <paramdef> <parameter>head</parameter></paramdef> 1635 <paramdef> <parameter>member</parameter></paramdef> 1636 </funcprototype></funcsynopsis> 1637</refsynopsisdiv> 1638<refsect1> 1639 <title>Arguments</title> 1640 <variablelist> 1641 <varlistentry> 1642 <term><parameter>pos</parameter></term> 1643 <listitem> 1644 <para> 1645 the type * to use as a loop cursor. 1646 </para> 1647 </listitem> 1648 </varlistentry> 1649 <varlistentry> 1650 <term><parameter>head</parameter></term> 1651 <listitem> 1652 <para> 1653 the head for your list. 1654 </para> 1655 </listitem> 1656 </varlistentry> 1657 <varlistentry> 1658 <term><parameter>member</parameter></term> 1659 <listitem> 1660 <para> 1661 the name of the list_head within the struct. 1662 </para> 1663 </listitem> 1664 </varlistentry> 1665 </variablelist> 1666</refsect1> 1667<refsect1> 1668<title>Description</title> 1669<para> 1670 Continue to iterate over list of given type, continuing after 1671 the current position. 1672</para> 1673</refsect1> 1674</refentry> 1675 1676<refentry id="API-list-for-each-entry-continue-reverse"> 1677<refentryinfo> 1678 <title>LINUX</title> 1679 <productname>Kernel Hackers Manual</productname> 1680 <date>July 2017</date> 1681</refentryinfo> 1682<refmeta> 1683 <refentrytitle><phrase>list_for_each_entry_continue_reverse</phrase></refentrytitle> 1684 <manvolnum>9</manvolnum> 1685 <refmiscinfo class="version">4.1.27</refmiscinfo> 1686</refmeta> 1687<refnamediv> 1688 <refname>list_for_each_entry_continue_reverse</refname> 1689 <refpurpose> 1690 iterate backwards from the given point 1691 </refpurpose> 1692</refnamediv> 1693<refsynopsisdiv> 1694 <title>Synopsis</title> 1695 <funcsynopsis><funcprototype> 1696 <funcdef> <function>list_for_each_entry_continue_reverse </function></funcdef> 1697 <paramdef> <parameter>pos</parameter></paramdef> 1698 <paramdef> <parameter>head</parameter></paramdef> 1699 <paramdef> <parameter>member</parameter></paramdef> 1700 </funcprototype></funcsynopsis> 1701</refsynopsisdiv> 1702<refsect1> 1703 <title>Arguments</title> 1704 <variablelist> 1705 <varlistentry> 1706 <term><parameter>pos</parameter></term> 1707 <listitem> 1708 <para> 1709 the type * to use as a loop cursor. 1710 </para> 1711 </listitem> 1712 </varlistentry> 1713 <varlistentry> 1714 <term><parameter>head</parameter></term> 1715 <listitem> 1716 <para> 1717 the head for your list. 1718 </para> 1719 </listitem> 1720 </varlistentry> 1721 <varlistentry> 1722 <term><parameter>member</parameter></term> 1723 <listitem> 1724 <para> 1725 the name of the list_head within the struct. 1726 </para> 1727 </listitem> 1728 </varlistentry> 1729 </variablelist> 1730</refsect1> 1731<refsect1> 1732<title>Description</title> 1733<para> 1734 Start to iterate over list of given type backwards, continuing after 1735 the current position. 1736</para> 1737</refsect1> 1738</refentry> 1739 1740<refentry id="API-list-for-each-entry-from"> 1741<refentryinfo> 1742 <title>LINUX</title> 1743 <productname>Kernel Hackers Manual</productname> 1744 <date>July 2017</date> 1745</refentryinfo> 1746<refmeta> 1747 <refentrytitle><phrase>list_for_each_entry_from</phrase></refentrytitle> 1748 <manvolnum>9</manvolnum> 1749 <refmiscinfo class="version">4.1.27</refmiscinfo> 1750</refmeta> 1751<refnamediv> 1752 <refname>list_for_each_entry_from</refname> 1753 <refpurpose> 1754 iterate over list of given type from the current point 1755 </refpurpose> 1756</refnamediv> 1757<refsynopsisdiv> 1758 <title>Synopsis</title> 1759 <funcsynopsis><funcprototype> 1760 <funcdef> <function>list_for_each_entry_from </function></funcdef> 1761 <paramdef> <parameter>pos</parameter></paramdef> 1762 <paramdef> <parameter>head</parameter></paramdef> 1763 <paramdef> <parameter>member</parameter></paramdef> 1764 </funcprototype></funcsynopsis> 1765</refsynopsisdiv> 1766<refsect1> 1767 <title>Arguments</title> 1768 <variablelist> 1769 <varlistentry> 1770 <term><parameter>pos</parameter></term> 1771 <listitem> 1772 <para> 1773 the type * to use as a loop cursor. 1774 </para> 1775 </listitem> 1776 </varlistentry> 1777 <varlistentry> 1778 <term><parameter>head</parameter></term> 1779 <listitem> 1780 <para> 1781 the head for your list. 1782 </para> 1783 </listitem> 1784 </varlistentry> 1785 <varlistentry> 1786 <term><parameter>member</parameter></term> 1787 <listitem> 1788 <para> 1789 the name of the list_head within the struct. 1790 </para> 1791 </listitem> 1792 </varlistentry> 1793 </variablelist> 1794</refsect1> 1795<refsect1> 1796<title>Description</title> 1797<para> 1798 Iterate over list of given type, continuing from current position. 1799</para> 1800</refsect1> 1801</refentry> 1802 1803<refentry id="API-list-for-each-entry-safe"> 1804<refentryinfo> 1805 <title>LINUX</title> 1806 <productname>Kernel Hackers Manual</productname> 1807 <date>July 2017</date> 1808</refentryinfo> 1809<refmeta> 1810 <refentrytitle><phrase>list_for_each_entry_safe</phrase></refentrytitle> 1811 <manvolnum>9</manvolnum> 1812 <refmiscinfo class="version">4.1.27</refmiscinfo> 1813</refmeta> 1814<refnamediv> 1815 <refname>list_for_each_entry_safe</refname> 1816 <refpurpose> 1817 iterate over list of given type safe against removal of list entry 1818 </refpurpose> 1819</refnamediv> 1820<refsynopsisdiv> 1821 <title>Synopsis</title> 1822 <funcsynopsis><funcprototype> 1823 <funcdef> <function>list_for_each_entry_safe </function></funcdef> 1824 <paramdef> <parameter>pos</parameter></paramdef> 1825 <paramdef> <parameter>n</parameter></paramdef> 1826 <paramdef> <parameter>head</parameter></paramdef> 1827 <paramdef> <parameter>member</parameter></paramdef> 1828 </funcprototype></funcsynopsis> 1829</refsynopsisdiv> 1830<refsect1> 1831 <title>Arguments</title> 1832 <variablelist> 1833 <varlistentry> 1834 <term><parameter>pos</parameter></term> 1835 <listitem> 1836 <para> 1837 the type * to use as a loop cursor. 1838 </para> 1839 </listitem> 1840 </varlistentry> 1841 <varlistentry> 1842 <term><parameter>n</parameter></term> 1843 <listitem> 1844 <para> 1845 another type * to use as temporary storage 1846 </para> 1847 </listitem> 1848 </varlistentry> 1849 <varlistentry> 1850 <term><parameter>head</parameter></term> 1851 <listitem> 1852 <para> 1853 the head for your list. 1854 </para> 1855 </listitem> 1856 </varlistentry> 1857 <varlistentry> 1858 <term><parameter>member</parameter></term> 1859 <listitem> 1860 <para> 1861 the name of the list_head within the struct. 1862 </para> 1863 </listitem> 1864 </varlistentry> 1865 </variablelist> 1866</refsect1> 1867</refentry> 1868 1869<refentry id="API-list-for-each-entry-safe-continue"> 1870<refentryinfo> 1871 <title>LINUX</title> 1872 <productname>Kernel Hackers Manual</productname> 1873 <date>July 2017</date> 1874</refentryinfo> 1875<refmeta> 1876 <refentrytitle><phrase>list_for_each_entry_safe_continue</phrase></refentrytitle> 1877 <manvolnum>9</manvolnum> 1878 <refmiscinfo class="version">4.1.27</refmiscinfo> 1879</refmeta> 1880<refnamediv> 1881 <refname>list_for_each_entry_safe_continue</refname> 1882 <refpurpose> 1883 continue list iteration safe against removal 1884 </refpurpose> 1885</refnamediv> 1886<refsynopsisdiv> 1887 <title>Synopsis</title> 1888 <funcsynopsis><funcprototype> 1889 <funcdef> <function>list_for_each_entry_safe_continue </function></funcdef> 1890 <paramdef> <parameter>pos</parameter></paramdef> 1891 <paramdef> <parameter>n</parameter></paramdef> 1892 <paramdef> <parameter>head</parameter></paramdef> 1893 <paramdef> <parameter>member</parameter></paramdef> 1894 </funcprototype></funcsynopsis> 1895</refsynopsisdiv> 1896<refsect1> 1897 <title>Arguments</title> 1898 <variablelist> 1899 <varlistentry> 1900 <term><parameter>pos</parameter></term> 1901 <listitem> 1902 <para> 1903 the type * to use as a loop cursor. 1904 </para> 1905 </listitem> 1906 </varlistentry> 1907 <varlistentry> 1908 <term><parameter>n</parameter></term> 1909 <listitem> 1910 <para> 1911 another type * to use as temporary storage 1912 </para> 1913 </listitem> 1914 </varlistentry> 1915 <varlistentry> 1916 <term><parameter>head</parameter></term> 1917 <listitem> 1918 <para> 1919 the head for your list. 1920 </para> 1921 </listitem> 1922 </varlistentry> 1923 <varlistentry> 1924 <term><parameter>member</parameter></term> 1925 <listitem> 1926 <para> 1927 the name of the list_head within the struct. 1928 </para> 1929 </listitem> 1930 </varlistentry> 1931 </variablelist> 1932</refsect1> 1933<refsect1> 1934<title>Description</title> 1935<para> 1936 Iterate over list of given type, continuing after current point, 1937 safe against removal of list entry. 1938</para> 1939</refsect1> 1940</refentry> 1941 1942<refentry id="API-list-for-each-entry-safe-from"> 1943<refentryinfo> 1944 <title>LINUX</title> 1945 <productname>Kernel Hackers Manual</productname> 1946 <date>July 2017</date> 1947</refentryinfo> 1948<refmeta> 1949 <refentrytitle><phrase>list_for_each_entry_safe_from</phrase></refentrytitle> 1950 <manvolnum>9</manvolnum> 1951 <refmiscinfo class="version">4.1.27</refmiscinfo> 1952</refmeta> 1953<refnamediv> 1954 <refname>list_for_each_entry_safe_from</refname> 1955 <refpurpose> 1956 iterate over list from current point safe against removal 1957 </refpurpose> 1958</refnamediv> 1959<refsynopsisdiv> 1960 <title>Synopsis</title> 1961 <funcsynopsis><funcprototype> 1962 <funcdef> <function>list_for_each_entry_safe_from </function></funcdef> 1963 <paramdef> <parameter>pos</parameter></paramdef> 1964 <paramdef> <parameter>n</parameter></paramdef> 1965 <paramdef> <parameter>head</parameter></paramdef> 1966 <paramdef> <parameter>member</parameter></paramdef> 1967 </funcprototype></funcsynopsis> 1968</refsynopsisdiv> 1969<refsect1> 1970 <title>Arguments</title> 1971 <variablelist> 1972 <varlistentry> 1973 <term><parameter>pos</parameter></term> 1974 <listitem> 1975 <para> 1976 the type * to use as a loop cursor. 1977 </para> 1978 </listitem> 1979 </varlistentry> 1980 <varlistentry> 1981 <term><parameter>n</parameter></term> 1982 <listitem> 1983 <para> 1984 another type * to use as temporary storage 1985 </para> 1986 </listitem> 1987 </varlistentry> 1988 <varlistentry> 1989 <term><parameter>head</parameter></term> 1990 <listitem> 1991 <para> 1992 the head for your list. 1993 </para> 1994 </listitem> 1995 </varlistentry> 1996 <varlistentry> 1997 <term><parameter>member</parameter></term> 1998 <listitem> 1999 <para> 2000 the name of the list_head within the struct. 2001 </para> 2002 </listitem> 2003 </varlistentry> 2004 </variablelist> 2005</refsect1> 2006<refsect1> 2007<title>Description</title> 2008<para> 2009 Iterate over list of given type from current point, safe against 2010 removal of list entry. 2011</para> 2012</refsect1> 2013</refentry> 2014 2015<refentry id="API-list-for-each-entry-safe-reverse"> 2016<refentryinfo> 2017 <title>LINUX</title> 2018 <productname>Kernel Hackers Manual</productname> 2019 <date>July 2017</date> 2020</refentryinfo> 2021<refmeta> 2022 <refentrytitle><phrase>list_for_each_entry_safe_reverse</phrase></refentrytitle> 2023 <manvolnum>9</manvolnum> 2024 <refmiscinfo class="version">4.1.27</refmiscinfo> 2025</refmeta> 2026<refnamediv> 2027 <refname>list_for_each_entry_safe_reverse</refname> 2028 <refpurpose> 2029 iterate backwards over list safe against removal 2030 </refpurpose> 2031</refnamediv> 2032<refsynopsisdiv> 2033 <title>Synopsis</title> 2034 <funcsynopsis><funcprototype> 2035 <funcdef> <function>list_for_each_entry_safe_reverse </function></funcdef> 2036 <paramdef> <parameter>pos</parameter></paramdef> 2037 <paramdef> <parameter>n</parameter></paramdef> 2038 <paramdef> <parameter>head</parameter></paramdef> 2039 <paramdef> <parameter>member</parameter></paramdef> 2040 </funcprototype></funcsynopsis> 2041</refsynopsisdiv> 2042<refsect1> 2043 <title>Arguments</title> 2044 <variablelist> 2045 <varlistentry> 2046 <term><parameter>pos</parameter></term> 2047 <listitem> 2048 <para> 2049 the type * to use as a loop cursor. 2050 </para> 2051 </listitem> 2052 </varlistentry> 2053 <varlistentry> 2054 <term><parameter>n</parameter></term> 2055 <listitem> 2056 <para> 2057 another type * to use as temporary storage 2058 </para> 2059 </listitem> 2060 </varlistentry> 2061 <varlistentry> 2062 <term><parameter>head</parameter></term> 2063 <listitem> 2064 <para> 2065 the head for your list. 2066 </para> 2067 </listitem> 2068 </varlistentry> 2069 <varlistentry> 2070 <term><parameter>member</parameter></term> 2071 <listitem> 2072 <para> 2073 the name of the list_head within the struct. 2074 </para> 2075 </listitem> 2076 </varlistentry> 2077 </variablelist> 2078</refsect1> 2079<refsect1> 2080<title>Description</title> 2081<para> 2082 Iterate backwards over list of given type, safe against removal 2083 of list entry. 2084</para> 2085</refsect1> 2086</refentry> 2087 2088<refentry id="API-list-safe-reset-next"> 2089<refentryinfo> 2090 <title>LINUX</title> 2091 <productname>Kernel Hackers Manual</productname> 2092 <date>July 2017</date> 2093</refentryinfo> 2094<refmeta> 2095 <refentrytitle><phrase>list_safe_reset_next</phrase></refentrytitle> 2096 <manvolnum>9</manvolnum> 2097 <refmiscinfo class="version">4.1.27</refmiscinfo> 2098</refmeta> 2099<refnamediv> 2100 <refname>list_safe_reset_next</refname> 2101 <refpurpose> 2102 reset a stale list_for_each_entry_safe loop 2103 </refpurpose> 2104</refnamediv> 2105<refsynopsisdiv> 2106 <title>Synopsis</title> 2107 <funcsynopsis><funcprototype> 2108 <funcdef> <function>list_safe_reset_next </function></funcdef> 2109 <paramdef> <parameter>pos</parameter></paramdef> 2110 <paramdef> <parameter>n</parameter></paramdef> 2111 <paramdef> <parameter>member</parameter></paramdef> 2112 </funcprototype></funcsynopsis> 2113</refsynopsisdiv> 2114<refsect1> 2115 <title>Arguments</title> 2116 <variablelist> 2117 <varlistentry> 2118 <term><parameter>pos</parameter></term> 2119 <listitem> 2120 <para> 2121 the loop cursor used in the list_for_each_entry_safe loop 2122 </para> 2123 </listitem> 2124 </varlistentry> 2125 <varlistentry> 2126 <term><parameter>n</parameter></term> 2127 <listitem> 2128 <para> 2129 temporary storage used in list_for_each_entry_safe 2130 </para> 2131 </listitem> 2132 </varlistentry> 2133 <varlistentry> 2134 <term><parameter>member</parameter></term> 2135 <listitem> 2136 <para> 2137 the name of the list_head within the struct. 2138 </para> 2139 </listitem> 2140 </varlistentry> 2141 </variablelist> 2142</refsect1> 2143<refsect1> 2144<title>Description</title> 2145<para> 2146 list_safe_reset_next is not safe to use in general if the list may be 2147 modified concurrently (eg. the lock is dropped in the loop body). An 2148 exception to this is if the cursor element (pos) is pinned in the list, 2149 and list_safe_reset_next is called after re-taking the lock and before 2150 completing the current iteration of the loop body. 2151</para> 2152</refsect1> 2153</refentry> 2154 2155<refentry id="API-hlist-for-each-entry"> 2156<refentryinfo> 2157 <title>LINUX</title> 2158 <productname>Kernel Hackers Manual</productname> 2159 <date>July 2017</date> 2160</refentryinfo> 2161<refmeta> 2162 <refentrytitle><phrase>hlist_for_each_entry</phrase></refentrytitle> 2163 <manvolnum>9</manvolnum> 2164 <refmiscinfo class="version">4.1.27</refmiscinfo> 2165</refmeta> 2166<refnamediv> 2167 <refname>hlist_for_each_entry</refname> 2168 <refpurpose> 2169 iterate over list of given type 2170 </refpurpose> 2171</refnamediv> 2172<refsynopsisdiv> 2173 <title>Synopsis</title> 2174 <funcsynopsis><funcprototype> 2175 <funcdef> <function>hlist_for_each_entry </function></funcdef> 2176 <paramdef> <parameter>pos</parameter></paramdef> 2177 <paramdef> <parameter>head</parameter></paramdef> 2178 <paramdef> <parameter>member</parameter></paramdef> 2179 </funcprototype></funcsynopsis> 2180</refsynopsisdiv> 2181<refsect1> 2182 <title>Arguments</title> 2183 <variablelist> 2184 <varlistentry> 2185 <term><parameter>pos</parameter></term> 2186 <listitem> 2187 <para> 2188 the type * to use as a loop cursor. 2189 </para> 2190 </listitem> 2191 </varlistentry> 2192 <varlistentry> 2193 <term><parameter>head</parameter></term> 2194 <listitem> 2195 <para> 2196 the head for your list. 2197 </para> 2198 </listitem> 2199 </varlistentry> 2200 <varlistentry> 2201 <term><parameter>member</parameter></term> 2202 <listitem> 2203 <para> 2204 the name of the hlist_node within the struct. 2205 </para> 2206 </listitem> 2207 </varlistentry> 2208 </variablelist> 2209</refsect1> 2210</refentry> 2211 2212<refentry id="API-hlist-for-each-entry-continue"> 2213<refentryinfo> 2214 <title>LINUX</title> 2215 <productname>Kernel Hackers Manual</productname> 2216 <date>July 2017</date> 2217</refentryinfo> 2218<refmeta> 2219 <refentrytitle><phrase>hlist_for_each_entry_continue</phrase></refentrytitle> 2220 <manvolnum>9</manvolnum> 2221 <refmiscinfo class="version">4.1.27</refmiscinfo> 2222</refmeta> 2223<refnamediv> 2224 <refname>hlist_for_each_entry_continue</refname> 2225 <refpurpose> 2226 iterate over a hlist continuing after current point 2227 </refpurpose> 2228</refnamediv> 2229<refsynopsisdiv> 2230 <title>Synopsis</title> 2231 <funcsynopsis><funcprototype> 2232 <funcdef> <function>hlist_for_each_entry_continue </function></funcdef> 2233 <paramdef> <parameter>pos</parameter></paramdef> 2234 <paramdef> <parameter>member</parameter></paramdef> 2235 </funcprototype></funcsynopsis> 2236</refsynopsisdiv> 2237<refsect1> 2238 <title>Arguments</title> 2239 <variablelist> 2240 <varlistentry> 2241 <term><parameter>pos</parameter></term> 2242 <listitem> 2243 <para> 2244 the type * to use as a loop cursor. 2245 </para> 2246 </listitem> 2247 </varlistentry> 2248 <varlistentry> 2249 <term><parameter>member</parameter></term> 2250 <listitem> 2251 <para> 2252 the name of the hlist_node within the struct. 2253 </para> 2254 </listitem> 2255 </varlistentry> 2256 </variablelist> 2257</refsect1> 2258</refentry> 2259 2260<refentry id="API-hlist-for-each-entry-from"> 2261<refentryinfo> 2262 <title>LINUX</title> 2263 <productname>Kernel Hackers Manual</productname> 2264 <date>July 2017</date> 2265</refentryinfo> 2266<refmeta> 2267 <refentrytitle><phrase>hlist_for_each_entry_from</phrase></refentrytitle> 2268 <manvolnum>9</manvolnum> 2269 <refmiscinfo class="version">4.1.27</refmiscinfo> 2270</refmeta> 2271<refnamediv> 2272 <refname>hlist_for_each_entry_from</refname> 2273 <refpurpose> 2274 iterate over a hlist continuing from current point 2275 </refpurpose> 2276</refnamediv> 2277<refsynopsisdiv> 2278 <title>Synopsis</title> 2279 <funcsynopsis><funcprototype> 2280 <funcdef> <function>hlist_for_each_entry_from </function></funcdef> 2281 <paramdef> <parameter>pos</parameter></paramdef> 2282 <paramdef> <parameter>member</parameter></paramdef> 2283 </funcprototype></funcsynopsis> 2284</refsynopsisdiv> 2285<refsect1> 2286 <title>Arguments</title> 2287 <variablelist> 2288 <varlistentry> 2289 <term><parameter>pos</parameter></term> 2290 <listitem> 2291 <para> 2292 the type * to use as a loop cursor. 2293 </para> 2294 </listitem> 2295 </varlistentry> 2296 <varlistentry> 2297 <term><parameter>member</parameter></term> 2298 <listitem> 2299 <para> 2300 the name of the hlist_node within the struct. 2301 </para> 2302 </listitem> 2303 </varlistentry> 2304 </variablelist> 2305</refsect1> 2306</refentry> 2307 2308<refentry id="API-hlist-for-each-entry-safe"> 2309<refentryinfo> 2310 <title>LINUX</title> 2311 <productname>Kernel Hackers Manual</productname> 2312 <date>July 2017</date> 2313</refentryinfo> 2314<refmeta> 2315 <refentrytitle><phrase>hlist_for_each_entry_safe</phrase></refentrytitle> 2316 <manvolnum>9</manvolnum> 2317 <refmiscinfo class="version">4.1.27</refmiscinfo> 2318</refmeta> 2319<refnamediv> 2320 <refname>hlist_for_each_entry_safe</refname> 2321 <refpurpose> 2322 iterate over list of given type safe against removal of list entry 2323 </refpurpose> 2324</refnamediv> 2325<refsynopsisdiv> 2326 <title>Synopsis</title> 2327 <funcsynopsis><funcprototype> 2328 <funcdef> <function>hlist_for_each_entry_safe </function></funcdef> 2329 <paramdef> <parameter>pos</parameter></paramdef> 2330 <paramdef> <parameter>n</parameter></paramdef> 2331 <paramdef> <parameter>head</parameter></paramdef> 2332 <paramdef> <parameter>member</parameter></paramdef> 2333 </funcprototype></funcsynopsis> 2334</refsynopsisdiv> 2335<refsect1> 2336 <title>Arguments</title> 2337 <variablelist> 2338 <varlistentry> 2339 <term><parameter>pos</parameter></term> 2340 <listitem> 2341 <para> 2342 the type * to use as a loop cursor. 2343 </para> 2344 </listitem> 2345 </varlistentry> 2346 <varlistentry> 2347 <term><parameter>n</parameter></term> 2348 <listitem> 2349 <para> 2350 another <structname>struct hlist_node</structname> to use as temporary storage 2351 </para> 2352 </listitem> 2353 </varlistentry> 2354 <varlistentry> 2355 <term><parameter>head</parameter></term> 2356 <listitem> 2357 <para> 2358 the head for your list. 2359 </para> 2360 </listitem> 2361 </varlistentry> 2362 <varlistentry> 2363 <term><parameter>member</parameter></term> 2364 <listitem> 2365 <para> 2366 the name of the hlist_node within the struct. 2367 </para> 2368 </listitem> 2369 </varlistentry> 2370 </variablelist> 2371</refsect1> 2372</refentry> 2373 2374 </sect1> 2375 </chapter> 2376 2377 <chapter id="libc"> 2378 <title>Basic C Library Functions</title> 2379 2380 <para> 2381 When writing drivers, you cannot in general use routines which are 2382 from the C Library. Some of the functions have been found generally 2383 useful and they are listed below. The behaviour of these functions 2384 may vary slightly from those defined by ANSI, and these deviations 2385 are noted in the text. 2386 </para> 2387 2388 <sect1><title>String Conversions</title> 2389<!-- lib/vsprintf.c --> 2390<refentry id="API-simple-strtoull"> 2391<refentryinfo> 2392 <title>LINUX</title> 2393 <productname>Kernel Hackers Manual</productname> 2394 <date>July 2017</date> 2395</refentryinfo> 2396<refmeta> 2397 <refentrytitle><phrase>simple_strtoull</phrase></refentrytitle> 2398 <manvolnum>9</manvolnum> 2399 <refmiscinfo class="version">4.1.27</refmiscinfo> 2400</refmeta> 2401<refnamediv> 2402 <refname>simple_strtoull</refname> 2403 <refpurpose> 2404 convert a string to an unsigned long long 2405 </refpurpose> 2406</refnamediv> 2407<refsynopsisdiv> 2408 <title>Synopsis</title> 2409 <funcsynopsis><funcprototype> 2410 <funcdef>unsigned long long <function>simple_strtoull </function></funcdef> 2411 <paramdef>const char * <parameter>cp</parameter></paramdef> 2412 <paramdef>char ** <parameter>endp</parameter></paramdef> 2413 <paramdef>unsigned int <parameter>base</parameter></paramdef> 2414 </funcprototype></funcsynopsis> 2415</refsynopsisdiv> 2416<refsect1> 2417 <title>Arguments</title> 2418 <variablelist> 2419 <varlistentry> 2420 <term><parameter>cp</parameter></term> 2421 <listitem> 2422 <para> 2423 The start of the string 2424 </para> 2425 </listitem> 2426 </varlistentry> 2427 <varlistentry> 2428 <term><parameter>endp</parameter></term> 2429 <listitem> 2430 <para> 2431 A pointer to the end of the parsed string will be placed here 2432 </para> 2433 </listitem> 2434 </varlistentry> 2435 <varlistentry> 2436 <term><parameter>base</parameter></term> 2437 <listitem> 2438 <para> 2439 The number base to use 2440 </para> 2441 </listitem> 2442 </varlistentry> 2443 </variablelist> 2444</refsect1> 2445<refsect1> 2446<title>Description</title> 2447<para> 2448 This function is obsolete. Please use kstrtoull instead. 2449</para> 2450</refsect1> 2451</refentry> 2452 2453<refentry id="API-simple-strtoul"> 2454<refentryinfo> 2455 <title>LINUX</title> 2456 <productname>Kernel Hackers Manual</productname> 2457 <date>July 2017</date> 2458</refentryinfo> 2459<refmeta> 2460 <refentrytitle><phrase>simple_strtoul</phrase></refentrytitle> 2461 <manvolnum>9</manvolnum> 2462 <refmiscinfo class="version">4.1.27</refmiscinfo> 2463</refmeta> 2464<refnamediv> 2465 <refname>simple_strtoul</refname> 2466 <refpurpose> 2467 convert a string to an unsigned long 2468 </refpurpose> 2469</refnamediv> 2470<refsynopsisdiv> 2471 <title>Synopsis</title> 2472 <funcsynopsis><funcprototype> 2473 <funcdef>unsigned long <function>simple_strtoul </function></funcdef> 2474 <paramdef>const char * <parameter>cp</parameter></paramdef> 2475 <paramdef>char ** <parameter>endp</parameter></paramdef> 2476 <paramdef>unsigned int <parameter>base</parameter></paramdef> 2477 </funcprototype></funcsynopsis> 2478</refsynopsisdiv> 2479<refsect1> 2480 <title>Arguments</title> 2481 <variablelist> 2482 <varlistentry> 2483 <term><parameter>cp</parameter></term> 2484 <listitem> 2485 <para> 2486 The start of the string 2487 </para> 2488 </listitem> 2489 </varlistentry> 2490 <varlistentry> 2491 <term><parameter>endp</parameter></term> 2492 <listitem> 2493 <para> 2494 A pointer to the end of the parsed string will be placed here 2495 </para> 2496 </listitem> 2497 </varlistentry> 2498 <varlistentry> 2499 <term><parameter>base</parameter></term> 2500 <listitem> 2501 <para> 2502 The number base to use 2503 </para> 2504 </listitem> 2505 </varlistentry> 2506 </variablelist> 2507</refsect1> 2508<refsect1> 2509<title>Description</title> 2510<para> 2511 This function is obsolete. Please use kstrtoul instead. 2512</para> 2513</refsect1> 2514</refentry> 2515 2516<refentry id="API-simple-strtol"> 2517<refentryinfo> 2518 <title>LINUX</title> 2519 <productname>Kernel Hackers Manual</productname> 2520 <date>July 2017</date> 2521</refentryinfo> 2522<refmeta> 2523 <refentrytitle><phrase>simple_strtol</phrase></refentrytitle> 2524 <manvolnum>9</manvolnum> 2525 <refmiscinfo class="version">4.1.27</refmiscinfo> 2526</refmeta> 2527<refnamediv> 2528 <refname>simple_strtol</refname> 2529 <refpurpose> 2530 convert a string to a signed long 2531 </refpurpose> 2532</refnamediv> 2533<refsynopsisdiv> 2534 <title>Synopsis</title> 2535 <funcsynopsis><funcprototype> 2536 <funcdef>long <function>simple_strtol </function></funcdef> 2537 <paramdef>const char * <parameter>cp</parameter></paramdef> 2538 <paramdef>char ** <parameter>endp</parameter></paramdef> 2539 <paramdef>unsigned int <parameter>base</parameter></paramdef> 2540 </funcprototype></funcsynopsis> 2541</refsynopsisdiv> 2542<refsect1> 2543 <title>Arguments</title> 2544 <variablelist> 2545 <varlistentry> 2546 <term><parameter>cp</parameter></term> 2547 <listitem> 2548 <para> 2549 The start of the string 2550 </para> 2551 </listitem> 2552 </varlistentry> 2553 <varlistentry> 2554 <term><parameter>endp</parameter></term> 2555 <listitem> 2556 <para> 2557 A pointer to the end of the parsed string will be placed here 2558 </para> 2559 </listitem> 2560 </varlistentry> 2561 <varlistentry> 2562 <term><parameter>base</parameter></term> 2563 <listitem> 2564 <para> 2565 The number base to use 2566 </para> 2567 </listitem> 2568 </varlistentry> 2569 </variablelist> 2570</refsect1> 2571<refsect1> 2572<title>Description</title> 2573<para> 2574 This function is obsolete. Please use kstrtol instead. 2575</para> 2576</refsect1> 2577</refentry> 2578 2579<refentry id="API-simple-strtoll"> 2580<refentryinfo> 2581 <title>LINUX</title> 2582 <productname>Kernel Hackers Manual</productname> 2583 <date>July 2017</date> 2584</refentryinfo> 2585<refmeta> 2586 <refentrytitle><phrase>simple_strtoll</phrase></refentrytitle> 2587 <manvolnum>9</manvolnum> 2588 <refmiscinfo class="version">4.1.27</refmiscinfo> 2589</refmeta> 2590<refnamediv> 2591 <refname>simple_strtoll</refname> 2592 <refpurpose> 2593 convert a string to a signed long long 2594 </refpurpose> 2595</refnamediv> 2596<refsynopsisdiv> 2597 <title>Synopsis</title> 2598 <funcsynopsis><funcprototype> 2599 <funcdef>long long <function>simple_strtoll </function></funcdef> 2600 <paramdef>const char * <parameter>cp</parameter></paramdef> 2601 <paramdef>char ** <parameter>endp</parameter></paramdef> 2602 <paramdef>unsigned int <parameter>base</parameter></paramdef> 2603 </funcprototype></funcsynopsis> 2604</refsynopsisdiv> 2605<refsect1> 2606 <title>Arguments</title> 2607 <variablelist> 2608 <varlistentry> 2609 <term><parameter>cp</parameter></term> 2610 <listitem> 2611 <para> 2612 The start of the string 2613 </para> 2614 </listitem> 2615 </varlistentry> 2616 <varlistentry> 2617 <term><parameter>endp</parameter></term> 2618 <listitem> 2619 <para> 2620 A pointer to the end of the parsed string will be placed here 2621 </para> 2622 </listitem> 2623 </varlistentry> 2624 <varlistentry> 2625 <term><parameter>base</parameter></term> 2626 <listitem> 2627 <para> 2628 The number base to use 2629 </para> 2630 </listitem> 2631 </varlistentry> 2632 </variablelist> 2633</refsect1> 2634<refsect1> 2635<title>Description</title> 2636<para> 2637 This function is obsolete. Please use kstrtoll instead. 2638</para> 2639</refsect1> 2640</refentry> 2641 2642<refentry id="API-vsnprintf"> 2643<refentryinfo> 2644 <title>LINUX</title> 2645 <productname>Kernel Hackers Manual</productname> 2646 <date>July 2017</date> 2647</refentryinfo> 2648<refmeta> 2649 <refentrytitle><phrase>vsnprintf</phrase></refentrytitle> 2650 <manvolnum>9</manvolnum> 2651 <refmiscinfo class="version">4.1.27</refmiscinfo> 2652</refmeta> 2653<refnamediv> 2654 <refname>vsnprintf</refname> 2655 <refpurpose> 2656 Format a string and place it in a buffer 2657 </refpurpose> 2658</refnamediv> 2659<refsynopsisdiv> 2660 <title>Synopsis</title> 2661 <funcsynopsis><funcprototype> 2662 <funcdef>int <function>vsnprintf </function></funcdef> 2663 <paramdef>char * <parameter>buf</parameter></paramdef> 2664 <paramdef>size_t <parameter>size</parameter></paramdef> 2665 <paramdef>const char * <parameter>fmt</parameter></paramdef> 2666 <paramdef>va_list <parameter>args</parameter></paramdef> 2667 </funcprototype></funcsynopsis> 2668</refsynopsisdiv> 2669<refsect1> 2670 <title>Arguments</title> 2671 <variablelist> 2672 <varlistentry> 2673 <term><parameter>buf</parameter></term> 2674 <listitem> 2675 <para> 2676 The buffer to place the result into 2677 </para> 2678 </listitem> 2679 </varlistentry> 2680 <varlistentry> 2681 <term><parameter>size</parameter></term> 2682 <listitem> 2683 <para> 2684 The size of the buffer, including the trailing null space 2685 </para> 2686 </listitem> 2687 </varlistentry> 2688 <varlistentry> 2689 <term><parameter>fmt</parameter></term> 2690 <listitem> 2691 <para> 2692 The format string to use 2693 </para> 2694 </listitem> 2695 </varlistentry> 2696 <varlistentry> 2697 <term><parameter>args</parameter></term> 2698 <listitem> 2699 <para> 2700 Arguments for the format string 2701 </para> 2702 </listitem> 2703 </varlistentry> 2704 </variablelist> 2705</refsect1> 2706<refsect1> 2707<title>Description</title> 2708<para> 2709 This function follows C99 vsnprintf, but has some extensions: 2710 <constant>pS</constant> output the name of a text symbol with offset 2711 <constant>ps</constant> output the name of a text symbol without offset 2712 <constant>pF</constant> output the name of a function pointer with its offset 2713 <constant>pf</constant> output the name of a function pointer without its offset 2714 <constant>pB</constant> output the name of a backtrace symbol with its offset 2715 <constant>pR</constant> output the address range in a struct resource with decoded flags 2716 <constant>pr</constant> output the address range in a struct resource with raw flags 2717 <constant>pb</constant> output the bitmap with field width as the number of bits 2718 <constant>pbl</constant> output the bitmap as range list with field width as the number of bits 2719 <constant>pM</constant> output a 6-byte MAC address with colons 2720 <constant>pMR</constant> output a 6-byte MAC address with colons in reversed order 2721 <constant>pMF</constant> output a 6-byte MAC address with dashes 2722 <constant>pm</constant> output a 6-byte MAC address without colons 2723 <constant>pmR</constant> output a 6-byte MAC address without colons in reversed order 2724 <constant>pI4</constant> print an IPv4 address without leading zeros 2725 <constant>pi4</constant> print an IPv4 address with leading zeros 2726 <constant>pI6</constant> print an IPv6 address with colons 2727 <constant>pi6</constant> print an IPv6 address without colons 2728 <constant>pI6c</constant> print an IPv6 address as specified by RFC 5952 2729 <constant>pIS</constant> depending on sa_family of 'struct sockaddr *' print IPv4/IPv6 address 2730 <constant>piS</constant> depending on sa_family of 'struct sockaddr *' print IPv4/IPv6 address 2731 <constant>pU</constant>[bBlL] print a UUID/GUID in big or little endian using lower or upper 2732 case. 2733 %*pE[achnops] print an escaped buffer 2734 %*ph[CDN] a variable-length hex string with a separator (supports up to 64 2735 bytes of the input) 2736 <constant>pC</constant> output the name (Common Clock Framework) or address (legacy clock 2737 framework) of a clock 2738 <constant>pCn</constant> output the name (Common Clock Framework) or address (legacy clock 2739 framework) of a clock 2740 <constant>pCr</constant> output the current rate of a clock 2741 <constant>n</constant> is ignored 2742 </para><para> 2743 2744 ** Please update Documentation/printk-formats.txt when making changes ** 2745 </para><para> 2746 2747 The return value is the number of characters which would 2748 be generated for the given input, excluding the trailing 2749 '\0', as per ISO C99. If you want to have the exact 2750 number of characters written into <parameter>buf</parameter> as return value 2751 (not including the trailing '\0'), use <function>vscnprintf</function>. If the 2752 return is greater than or equal to <parameter>size</parameter>, the resulting 2753 string is truncated. 2754 </para><para> 2755 2756 If you're not already dealing with a va_list consider using <function>snprintf</function>. 2757</para> 2758</refsect1> 2759</refentry> 2760 2761<refentry id="API-vscnprintf"> 2762<refentryinfo> 2763 <title>LINUX</title> 2764 <productname>Kernel Hackers Manual</productname> 2765 <date>July 2017</date> 2766</refentryinfo> 2767<refmeta> 2768 <refentrytitle><phrase>vscnprintf</phrase></refentrytitle> 2769 <manvolnum>9</manvolnum> 2770 <refmiscinfo class="version">4.1.27</refmiscinfo> 2771</refmeta> 2772<refnamediv> 2773 <refname>vscnprintf</refname> 2774 <refpurpose> 2775 Format a string and place it in a buffer 2776 </refpurpose> 2777</refnamediv> 2778<refsynopsisdiv> 2779 <title>Synopsis</title> 2780 <funcsynopsis><funcprototype> 2781 <funcdef>int <function>vscnprintf </function></funcdef> 2782 <paramdef>char * <parameter>buf</parameter></paramdef> 2783 <paramdef>size_t <parameter>size</parameter></paramdef> 2784 <paramdef>const char * <parameter>fmt</parameter></paramdef> 2785 <paramdef>va_list <parameter>args</parameter></paramdef> 2786 </funcprototype></funcsynopsis> 2787</refsynopsisdiv> 2788<refsect1> 2789 <title>Arguments</title> 2790 <variablelist> 2791 <varlistentry> 2792 <term><parameter>buf</parameter></term> 2793 <listitem> 2794 <para> 2795 The buffer to place the result into 2796 </para> 2797 </listitem> 2798 </varlistentry> 2799 <varlistentry> 2800 <term><parameter>size</parameter></term> 2801 <listitem> 2802 <para> 2803 The size of the buffer, including the trailing null space 2804 </para> 2805 </listitem> 2806 </varlistentry> 2807 <varlistentry> 2808 <term><parameter>fmt</parameter></term> 2809 <listitem> 2810 <para> 2811 The format string to use 2812 </para> 2813 </listitem> 2814 </varlistentry> 2815 <varlistentry> 2816 <term><parameter>args</parameter></term> 2817 <listitem> 2818 <para> 2819 Arguments for the format string 2820 </para> 2821 </listitem> 2822 </varlistentry> 2823 </variablelist> 2824</refsect1> 2825<refsect1> 2826<title>Description</title> 2827<para> 2828 The return value is the number of characters which have been written into 2829 the <parameter>buf</parameter> not including the trailing '\0'. If <parameter>size</parameter> is == 0 the function 2830 returns 0. 2831 </para><para> 2832 2833 If you're not already dealing with a va_list consider using <function>scnprintf</function>. 2834 </para><para> 2835 2836 See the <function>vsnprintf</function> documentation for format string extensions over C99. 2837</para> 2838</refsect1> 2839</refentry> 2840 2841<refentry id="API-snprintf"> 2842<refentryinfo> 2843 <title>LINUX</title> 2844 <productname>Kernel Hackers Manual</productname> 2845 <date>July 2017</date> 2846</refentryinfo> 2847<refmeta> 2848 <refentrytitle><phrase>snprintf</phrase></refentrytitle> 2849 <manvolnum>9</manvolnum> 2850 <refmiscinfo class="version">4.1.27</refmiscinfo> 2851</refmeta> 2852<refnamediv> 2853 <refname>snprintf</refname> 2854 <refpurpose> 2855 Format a string and place it in a buffer 2856 </refpurpose> 2857</refnamediv> 2858<refsynopsisdiv> 2859 <title>Synopsis</title> 2860 <funcsynopsis><funcprototype> 2861 <funcdef>int <function>snprintf </function></funcdef> 2862 <paramdef>char * <parameter>buf</parameter></paramdef> 2863 <paramdef>size_t <parameter>size</parameter></paramdef> 2864 <paramdef>const char * <parameter>fmt</parameter></paramdef> 2865 <paramdef> <parameter>...</parameter></paramdef> 2866 </funcprototype></funcsynopsis> 2867</refsynopsisdiv> 2868<refsect1> 2869 <title>Arguments</title> 2870 <variablelist> 2871 <varlistentry> 2872 <term><parameter>buf</parameter></term> 2873 <listitem> 2874 <para> 2875 The buffer to place the result into 2876 </para> 2877 </listitem> 2878 </varlistentry> 2879 <varlistentry> 2880 <term><parameter>size</parameter></term> 2881 <listitem> 2882 <para> 2883 The size of the buffer, including the trailing null space 2884 </para> 2885 </listitem> 2886 </varlistentry> 2887 <varlistentry> 2888 <term><parameter>fmt</parameter></term> 2889 <listitem> 2890 <para> 2891 The format string to use 2892 @...: Arguments for the format string 2893 </para> 2894 </listitem> 2895 </varlistentry> 2896 <varlistentry> 2897 <term><parameter>...</parameter></term> 2898 <listitem> 2899 <para> 2900 variable arguments 2901 </para> 2902 </listitem> 2903 </varlistentry> 2904 </variablelist> 2905</refsect1> 2906<refsect1> 2907<title>Description</title> 2908<para> 2909 The return value is the number of characters which would be 2910 generated for the given input, excluding the trailing null, 2911 as per ISO C99. If the return is greater than or equal to 2912 <parameter>size</parameter>, the resulting string is truncated. 2913 </para><para> 2914 2915 See the <function>vsnprintf</function> documentation for format string extensions over C99. 2916</para> 2917</refsect1> 2918</refentry> 2919 2920<refentry id="API-scnprintf"> 2921<refentryinfo> 2922 <title>LINUX</title> 2923 <productname>Kernel Hackers Manual</productname> 2924 <date>July 2017</date> 2925</refentryinfo> 2926<refmeta> 2927 <refentrytitle><phrase>scnprintf</phrase></refentrytitle> 2928 <manvolnum>9</manvolnum> 2929 <refmiscinfo class="version">4.1.27</refmiscinfo> 2930</refmeta> 2931<refnamediv> 2932 <refname>scnprintf</refname> 2933 <refpurpose> 2934 Format a string and place it in a buffer 2935 </refpurpose> 2936</refnamediv> 2937<refsynopsisdiv> 2938 <title>Synopsis</title> 2939 <funcsynopsis><funcprototype> 2940 <funcdef>int <function>scnprintf </function></funcdef> 2941 <paramdef>char * <parameter>buf</parameter></paramdef> 2942 <paramdef>size_t <parameter>size</parameter></paramdef> 2943 <paramdef>const char * <parameter>fmt</parameter></paramdef> 2944 <paramdef> <parameter>...</parameter></paramdef> 2945 </funcprototype></funcsynopsis> 2946</refsynopsisdiv> 2947<refsect1> 2948 <title>Arguments</title> 2949 <variablelist> 2950 <varlistentry> 2951 <term><parameter>buf</parameter></term> 2952 <listitem> 2953 <para> 2954 The buffer to place the result into 2955 </para> 2956 </listitem> 2957 </varlistentry> 2958 <varlistentry> 2959 <term><parameter>size</parameter></term> 2960 <listitem> 2961 <para> 2962 The size of the buffer, including the trailing null space 2963 </para> 2964 </listitem> 2965 </varlistentry> 2966 <varlistentry> 2967 <term><parameter>fmt</parameter></term> 2968 <listitem> 2969 <para> 2970 The format string to use 2971 @...: Arguments for the format string 2972 </para> 2973 </listitem> 2974 </varlistentry> 2975 <varlistentry> 2976 <term><parameter>...</parameter></term> 2977 <listitem> 2978 <para> 2979 variable arguments 2980 </para> 2981 </listitem> 2982 </varlistentry> 2983 </variablelist> 2984</refsect1> 2985<refsect1> 2986<title>Description</title> 2987<para> 2988 The return value is the number of characters written into <parameter>buf</parameter> not including 2989 the trailing '\0'. If <parameter>size</parameter> is == 0 the function returns 0. 2990</para> 2991</refsect1> 2992</refentry> 2993 2994<refentry id="API-vsprintf"> 2995<refentryinfo> 2996 <title>LINUX</title> 2997 <productname>Kernel Hackers Manual</productname> 2998 <date>July 2017</date> 2999</refentryinfo> 3000<refmeta> 3001 <refentrytitle><phrase>vsprintf</phrase></refentrytitle> 3002 <manvolnum>9</manvolnum> 3003 <refmiscinfo class="version">4.1.27</refmiscinfo> 3004</refmeta> 3005<refnamediv> 3006 <refname>vsprintf</refname> 3007 <refpurpose> 3008 Format a string and place it in a buffer 3009 </refpurpose> 3010</refnamediv> 3011<refsynopsisdiv> 3012 <title>Synopsis</title> 3013 <funcsynopsis><funcprototype> 3014 <funcdef>int <function>vsprintf </function></funcdef> 3015 <paramdef>char * <parameter>buf</parameter></paramdef> 3016 <paramdef>const char * <parameter>fmt</parameter></paramdef> 3017 <paramdef>va_list <parameter>args</parameter></paramdef> 3018 </funcprototype></funcsynopsis> 3019</refsynopsisdiv> 3020<refsect1> 3021 <title>Arguments</title> 3022 <variablelist> 3023 <varlistentry> 3024 <term><parameter>buf</parameter></term> 3025 <listitem> 3026 <para> 3027 The buffer to place the result into 3028 </para> 3029 </listitem> 3030 </varlistentry> 3031 <varlistentry> 3032 <term><parameter>fmt</parameter></term> 3033 <listitem> 3034 <para> 3035 The format string to use 3036 </para> 3037 </listitem> 3038 </varlistentry> 3039 <varlistentry> 3040 <term><parameter>args</parameter></term> 3041 <listitem> 3042 <para> 3043 Arguments for the format string 3044 </para> 3045 </listitem> 3046 </varlistentry> 3047 </variablelist> 3048</refsect1> 3049<refsect1> 3050<title>Description</title> 3051<para> 3052 The function returns the number of characters written 3053 into <parameter>buf</parameter>. Use <function>vsnprintf</function> or <function>vscnprintf</function> in order to avoid 3054 buffer overflows. 3055 </para><para> 3056 3057 If you're not already dealing with a va_list consider using <function>sprintf</function>. 3058 </para><para> 3059 3060 See the <function>vsnprintf</function> documentation for format string extensions over C99. 3061</para> 3062</refsect1> 3063</refentry> 3064 3065<refentry id="API-sprintf"> 3066<refentryinfo> 3067 <title>LINUX</title> 3068 <productname>Kernel Hackers Manual</productname> 3069 <date>July 2017</date> 3070</refentryinfo> 3071<refmeta> 3072 <refentrytitle><phrase>sprintf</phrase></refentrytitle> 3073 <manvolnum>9</manvolnum> 3074 <refmiscinfo class="version">4.1.27</refmiscinfo> 3075</refmeta> 3076<refnamediv> 3077 <refname>sprintf</refname> 3078 <refpurpose> 3079 Format a string and place it in a buffer 3080 </refpurpose> 3081</refnamediv> 3082<refsynopsisdiv> 3083 <title>Synopsis</title> 3084 <funcsynopsis><funcprototype> 3085 <funcdef>int <function>sprintf </function></funcdef> 3086 <paramdef>char * <parameter>buf</parameter></paramdef> 3087 <paramdef>const char * <parameter>fmt</parameter></paramdef> 3088 <paramdef> <parameter>...</parameter></paramdef> 3089 </funcprototype></funcsynopsis> 3090</refsynopsisdiv> 3091<refsect1> 3092 <title>Arguments</title> 3093 <variablelist> 3094 <varlistentry> 3095 <term><parameter>buf</parameter></term> 3096 <listitem> 3097 <para> 3098 The buffer to place the result into 3099 </para> 3100 </listitem> 3101 </varlistentry> 3102 <varlistentry> 3103 <term><parameter>fmt</parameter></term> 3104 <listitem> 3105 <para> 3106 The format string to use 3107 @...: Arguments for the format string 3108 </para> 3109 </listitem> 3110 </varlistentry> 3111 <varlistentry> 3112 <term><parameter>...</parameter></term> 3113 <listitem> 3114 <para> 3115 variable arguments 3116 </para> 3117 </listitem> 3118 </varlistentry> 3119 </variablelist> 3120</refsect1> 3121<refsect1> 3122<title>Description</title> 3123<para> 3124 The function returns the number of characters written 3125 into <parameter>buf</parameter>. Use <function>snprintf</function> or <function>scnprintf</function> in order to avoid 3126 buffer overflows. 3127 </para><para> 3128 3129 See the <function>vsnprintf</function> documentation for format string extensions over C99. 3130</para> 3131</refsect1> 3132</refentry> 3133 3134<refentry id="API-vbin-printf"> 3135<refentryinfo> 3136 <title>LINUX</title> 3137 <productname>Kernel Hackers Manual</productname> 3138 <date>July 2017</date> 3139</refentryinfo> 3140<refmeta> 3141 <refentrytitle><phrase>vbin_printf</phrase></refentrytitle> 3142 <manvolnum>9</manvolnum> 3143 <refmiscinfo class="version">4.1.27</refmiscinfo> 3144</refmeta> 3145<refnamediv> 3146 <refname>vbin_printf</refname> 3147 <refpurpose> 3148 Parse a format string and place args' binary value in a buffer 3149 </refpurpose> 3150</refnamediv> 3151<refsynopsisdiv> 3152 <title>Synopsis</title> 3153 <funcsynopsis><funcprototype> 3154 <funcdef>int <function>vbin_printf </function></funcdef> 3155 <paramdef>u32 * <parameter>bin_buf</parameter></paramdef> 3156 <paramdef>size_t <parameter>size</parameter></paramdef> 3157 <paramdef>const char * <parameter>fmt</parameter></paramdef> 3158 <paramdef>va_list <parameter>args</parameter></paramdef> 3159 </funcprototype></funcsynopsis> 3160</refsynopsisdiv> 3161<refsect1> 3162 <title>Arguments</title> 3163 <variablelist> 3164 <varlistentry> 3165 <term><parameter>bin_buf</parameter></term> 3166 <listitem> 3167 <para> 3168 The buffer to place args' binary value 3169 </para> 3170 </listitem> 3171 </varlistentry> 3172 <varlistentry> 3173 <term><parameter>size</parameter></term> 3174 <listitem> 3175 <para> 3176 The size of the buffer(by words(32bits), not characters) 3177 </para> 3178 </listitem> 3179 </varlistentry> 3180 <varlistentry> 3181 <term><parameter>fmt</parameter></term> 3182 <listitem> 3183 <para> 3184 The format string to use 3185 </para> 3186 </listitem> 3187 </varlistentry> 3188 <varlistentry> 3189 <term><parameter>args</parameter></term> 3190 <listitem> 3191 <para> 3192 Arguments for the format string 3193 </para> 3194 </listitem> 3195 </varlistentry> 3196 </variablelist> 3197</refsect1> 3198<refsect1> 3199<title>Description</title> 3200<para> 3201 The format follows C99 vsnprintf, except <constant>n</constant> is ignored, and its argument 3202 is skipped. 3203 </para><para> 3204 3205 The return value is the number of words(32bits) which would be generated for 3206 the given input. 3207</para> 3208</refsect1> 3209<refsect1> 3210<title>NOTE</title> 3211<para> 3212 If the return value is greater than <parameter>size</parameter>, the resulting bin_buf is NOT 3213 valid for <function>bstr_printf</function>. 3214</para> 3215</refsect1> 3216</refentry> 3217 3218<refentry id="API-bstr-printf"> 3219<refentryinfo> 3220 <title>LINUX</title> 3221 <productname>Kernel Hackers Manual</productname> 3222 <date>July 2017</date> 3223</refentryinfo> 3224<refmeta> 3225 <refentrytitle><phrase>bstr_printf</phrase></refentrytitle> 3226 <manvolnum>9</manvolnum> 3227 <refmiscinfo class="version">4.1.27</refmiscinfo> 3228</refmeta> 3229<refnamediv> 3230 <refname>bstr_printf</refname> 3231 <refpurpose> 3232 Format a string from binary arguments and place it in a buffer 3233 </refpurpose> 3234</refnamediv> 3235<refsynopsisdiv> 3236 <title>Synopsis</title> 3237 <funcsynopsis><funcprototype> 3238 <funcdef>int <function>bstr_printf </function></funcdef> 3239 <paramdef>char * <parameter>buf</parameter></paramdef> 3240 <paramdef>size_t <parameter>size</parameter></paramdef> 3241 <paramdef>const char * <parameter>fmt</parameter></paramdef> 3242 <paramdef>const u32 * <parameter>bin_buf</parameter></paramdef> 3243 </funcprototype></funcsynopsis> 3244</refsynopsisdiv> 3245<refsect1> 3246 <title>Arguments</title> 3247 <variablelist> 3248 <varlistentry> 3249 <term><parameter>buf</parameter></term> 3250 <listitem> 3251 <para> 3252 The buffer to place the result into 3253 </para> 3254 </listitem> 3255 </varlistentry> 3256 <varlistentry> 3257 <term><parameter>size</parameter></term> 3258 <listitem> 3259 <para> 3260 The size of the buffer, including the trailing null space 3261 </para> 3262 </listitem> 3263 </varlistentry> 3264 <varlistentry> 3265 <term><parameter>fmt</parameter></term> 3266 <listitem> 3267 <para> 3268 The format string to use 3269 </para> 3270 </listitem> 3271 </varlistentry> 3272 <varlistentry> 3273 <term><parameter>bin_buf</parameter></term> 3274 <listitem> 3275 <para> 3276 Binary arguments for the format string 3277 </para> 3278 </listitem> 3279 </varlistentry> 3280 </variablelist> 3281</refsect1> 3282<refsect1> 3283<title>Description</title> 3284<para> 3285 This function like C99 vsnprintf, but the difference is that vsnprintf gets 3286 arguments from stack, and bstr_printf gets arguments from <parameter>bin_buf</parameter> which is 3287 a binary buffer that generated by vbin_printf. 3288 </para><para> 3289 3290 The format follows C99 vsnprintf, but has some extensions: 3291 see vsnprintf comment for details. 3292 </para><para> 3293 3294 The return value is the number of characters which would 3295 be generated for the given input, excluding the trailing 3296 '\0', as per ISO C99. If you want to have the exact 3297 number of characters written into <parameter>buf</parameter> as return value 3298 (not including the trailing '\0'), use <function>vscnprintf</function>. If the 3299 return is greater than or equal to <parameter>size</parameter>, the resulting 3300 string is truncated. 3301</para> 3302</refsect1> 3303</refentry> 3304 3305<refentry id="API-bprintf"> 3306<refentryinfo> 3307 <title>LINUX</title> 3308 <productname>Kernel Hackers Manual</productname> 3309 <date>July 2017</date> 3310</refentryinfo> 3311<refmeta> 3312 <refentrytitle><phrase>bprintf</phrase></refentrytitle> 3313 <manvolnum>9</manvolnum> 3314 <refmiscinfo class="version">4.1.27</refmiscinfo> 3315</refmeta> 3316<refnamediv> 3317 <refname>bprintf</refname> 3318 <refpurpose> 3319 Parse a format string and place args' binary value in a buffer 3320 </refpurpose> 3321</refnamediv> 3322<refsynopsisdiv> 3323 <title>Synopsis</title> 3324 <funcsynopsis><funcprototype> 3325 <funcdef>int <function>bprintf </function></funcdef> 3326 <paramdef>u32 * <parameter>bin_buf</parameter></paramdef> 3327 <paramdef>size_t <parameter>size</parameter></paramdef> 3328 <paramdef>const char * <parameter>fmt</parameter></paramdef> 3329 <paramdef> <parameter>...</parameter></paramdef> 3330 </funcprototype></funcsynopsis> 3331</refsynopsisdiv> 3332<refsect1> 3333 <title>Arguments</title> 3334 <variablelist> 3335 <varlistentry> 3336 <term><parameter>bin_buf</parameter></term> 3337 <listitem> 3338 <para> 3339 The buffer to place args' binary value 3340 </para> 3341 </listitem> 3342 </varlistentry> 3343 <varlistentry> 3344 <term><parameter>size</parameter></term> 3345 <listitem> 3346 <para> 3347 The size of the buffer(by words(32bits), not characters) 3348 </para> 3349 </listitem> 3350 </varlistentry> 3351 <varlistentry> 3352 <term><parameter>fmt</parameter></term> 3353 <listitem> 3354 <para> 3355 The format string to use 3356 @...: Arguments for the format string 3357 </para> 3358 </listitem> 3359 </varlistentry> 3360 <varlistentry> 3361 <term><parameter>...</parameter></term> 3362 <listitem> 3363 <para> 3364 variable arguments 3365 </para> 3366 </listitem> 3367 </varlistentry> 3368 </variablelist> 3369</refsect1> 3370<refsect1> 3371<title>Description</title> 3372<para> 3373 The function returns the number of words(u32) written 3374 into <parameter>bin_buf</parameter>. 3375</para> 3376</refsect1> 3377</refentry> 3378 3379<refentry id="API-vsscanf"> 3380<refentryinfo> 3381 <title>LINUX</title> 3382 <productname>Kernel Hackers Manual</productname> 3383 <date>July 2017</date> 3384</refentryinfo> 3385<refmeta> 3386 <refentrytitle><phrase>vsscanf</phrase></refentrytitle> 3387 <manvolnum>9</manvolnum> 3388 <refmiscinfo class="version">4.1.27</refmiscinfo> 3389</refmeta> 3390<refnamediv> 3391 <refname>vsscanf</refname> 3392 <refpurpose> 3393 Unformat a buffer into a list of arguments 3394 </refpurpose> 3395</refnamediv> 3396<refsynopsisdiv> 3397 <title>Synopsis</title> 3398 <funcsynopsis><funcprototype> 3399 <funcdef>int <function>vsscanf </function></funcdef> 3400 <paramdef>const char * <parameter>buf</parameter></paramdef> 3401 <paramdef>const char * <parameter>fmt</parameter></paramdef> 3402 <paramdef>va_list <parameter>args</parameter></paramdef> 3403 </funcprototype></funcsynopsis> 3404</refsynopsisdiv> 3405<refsect1> 3406 <title>Arguments</title> 3407 <variablelist> 3408 <varlistentry> 3409 <term><parameter>buf</parameter></term> 3410 <listitem> 3411 <para> 3412 input buffer 3413 </para> 3414 </listitem> 3415 </varlistentry> 3416 <varlistentry> 3417 <term><parameter>fmt</parameter></term> 3418 <listitem> 3419 <para> 3420 format of buffer 3421 </para> 3422 </listitem> 3423 </varlistentry> 3424 <varlistentry> 3425 <term><parameter>args</parameter></term> 3426 <listitem> 3427 <para> 3428 arguments 3429 </para> 3430 </listitem> 3431 </varlistentry> 3432 </variablelist> 3433</refsect1> 3434</refentry> 3435 3436<refentry id="API-sscanf"> 3437<refentryinfo> 3438 <title>LINUX</title> 3439 <productname>Kernel Hackers Manual</productname> 3440 <date>July 2017</date> 3441</refentryinfo> 3442<refmeta> 3443 <refentrytitle><phrase>sscanf</phrase></refentrytitle> 3444 <manvolnum>9</manvolnum> 3445 <refmiscinfo class="version">4.1.27</refmiscinfo> 3446</refmeta> 3447<refnamediv> 3448 <refname>sscanf</refname> 3449 <refpurpose> 3450 Unformat a buffer into a list of arguments 3451 </refpurpose> 3452</refnamediv> 3453<refsynopsisdiv> 3454 <title>Synopsis</title> 3455 <funcsynopsis><funcprototype> 3456 <funcdef>int <function>sscanf </function></funcdef> 3457 <paramdef>const char * <parameter>buf</parameter></paramdef> 3458 <paramdef>const char * <parameter>fmt</parameter></paramdef> 3459 <paramdef> <parameter>...</parameter></paramdef> 3460 </funcprototype></funcsynopsis> 3461</refsynopsisdiv> 3462<refsect1> 3463 <title>Arguments</title> 3464 <variablelist> 3465 <varlistentry> 3466 <term><parameter>buf</parameter></term> 3467 <listitem> 3468 <para> 3469 input buffer 3470 </para> 3471 </listitem> 3472 </varlistentry> 3473 <varlistentry> 3474 <term><parameter>fmt</parameter></term> 3475 <listitem> 3476 <para> 3477 formatting of buffer 3478 @...: resulting arguments 3479 </para> 3480 </listitem> 3481 </varlistentry> 3482 <varlistentry> 3483 <term><parameter>...</parameter></term> 3484 <listitem> 3485 <para> 3486 variable arguments 3487 </para> 3488 </listitem> 3489 </varlistentry> 3490 </variablelist> 3491</refsect1> 3492</refentry> 3493 3494<refentry id="API-kstrtol"> 3495<refentryinfo> 3496 <title>LINUX</title> 3497 <productname>Kernel Hackers Manual</productname> 3498 <date>July 2017</date> 3499</refentryinfo> 3500<refmeta> 3501 <refentrytitle><phrase>kstrtol</phrase></refentrytitle> 3502 <manvolnum>9</manvolnum> 3503 <refmiscinfo class="version">4.1.27</refmiscinfo> 3504</refmeta> 3505<refnamediv> 3506 <refname>kstrtol</refname> 3507 <refpurpose> 3508 convert a string to a long 3509 </refpurpose> 3510</refnamediv> 3511<refsynopsisdiv> 3512 <title>Synopsis</title> 3513 <funcsynopsis><funcprototype> 3514 <funcdef>int <function>kstrtol </function></funcdef> 3515 <paramdef>const char * <parameter>s</parameter></paramdef> 3516 <paramdef>unsigned int <parameter>base</parameter></paramdef> 3517 <paramdef>long * <parameter>res</parameter></paramdef> 3518 </funcprototype></funcsynopsis> 3519</refsynopsisdiv> 3520<refsect1> 3521 <title>Arguments</title> 3522 <variablelist> 3523 <varlistentry> 3524 <term><parameter>s</parameter></term> 3525 <listitem> 3526 <para> 3527 The start of the string. The string must be null-terminated, and may also 3528 include a single newline before its terminating null. The first character 3529 may also be a plus sign or a minus sign. 3530 </para> 3531 </listitem> 3532 </varlistentry> 3533 <varlistentry> 3534 <term><parameter>base</parameter></term> 3535 <listitem> 3536 <para> 3537 The number base to use. The maximum supported base is 16. If base is 3538 given as 0, then the base of the string is automatically detected with the 3539 conventional semantics - If it begins with 0x the number will be parsed as a 3540 hexadecimal (case insensitive), if it otherwise begins with 0, it will be 3541 parsed as an octal number. Otherwise it will be parsed as a decimal. 3542 </para> 3543 </listitem> 3544 </varlistentry> 3545 <varlistentry> 3546 <term><parameter>res</parameter></term> 3547 <listitem> 3548 <para> 3549 Where to write the result of the conversion on success. 3550 </para> 3551 </listitem> 3552 </varlistentry> 3553 </variablelist> 3554</refsect1> 3555<refsect1> 3556<title>Description</title> 3557<para> 3558 Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. 3559 Used as a replacement for the obsolete simple_strtoull. Return code must 3560 be checked. 3561</para> 3562</refsect1> 3563</refentry> 3564 3565<refentry id="API-kstrtoul"> 3566<refentryinfo> 3567 <title>LINUX</title> 3568 <productname>Kernel Hackers Manual</productname> 3569 <date>July 2017</date> 3570</refentryinfo> 3571<refmeta> 3572 <refentrytitle><phrase>kstrtoul</phrase></refentrytitle> 3573 <manvolnum>9</manvolnum> 3574 <refmiscinfo class="version">4.1.27</refmiscinfo> 3575</refmeta> 3576<refnamediv> 3577 <refname>kstrtoul</refname> 3578 <refpurpose> 3579 convert a string to an unsigned long 3580 </refpurpose> 3581</refnamediv> 3582<refsynopsisdiv> 3583 <title>Synopsis</title> 3584 <funcsynopsis><funcprototype> 3585 <funcdef>int <function>kstrtoul </function></funcdef> 3586 <paramdef>const char * <parameter>s</parameter></paramdef> 3587 <paramdef>unsigned int <parameter>base</parameter></paramdef> 3588 <paramdef>unsigned long * <parameter>res</parameter></paramdef> 3589 </funcprototype></funcsynopsis> 3590</refsynopsisdiv> 3591<refsect1> 3592 <title>Arguments</title> 3593 <variablelist> 3594 <varlistentry> 3595 <term><parameter>s</parameter></term> 3596 <listitem> 3597 <para> 3598 The start of the string. The string must be null-terminated, and may also 3599 include a single newline before its terminating null. The first character 3600 may also be a plus sign, but not a minus sign. 3601 </para> 3602 </listitem> 3603 </varlistentry> 3604 <varlistentry> 3605 <term><parameter>base</parameter></term> 3606 <listitem> 3607 <para> 3608 The number base to use. The maximum supported base is 16. If base is 3609 given as 0, then the base of the string is automatically detected with the 3610 conventional semantics - If it begins with 0x the number will be parsed as a 3611 hexadecimal (case insensitive), if it otherwise begins with 0, it will be 3612 parsed as an octal number. Otherwise it will be parsed as a decimal. 3613 </para> 3614 </listitem> 3615 </varlistentry> 3616 <varlistentry> 3617 <term><parameter>res</parameter></term> 3618 <listitem> 3619 <para> 3620 Where to write the result of the conversion on success. 3621 </para> 3622 </listitem> 3623 </varlistentry> 3624 </variablelist> 3625</refsect1> 3626<refsect1> 3627<title>Description</title> 3628<para> 3629 Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. 3630 Used as a replacement for the obsolete simple_strtoull. Return code must 3631 be checked. 3632</para> 3633</refsect1> 3634</refentry> 3635 3636<!-- lib/kstrtox.c --> 3637<refentry id="API-kstrtoull"> 3638<refentryinfo> 3639 <title>LINUX</title> 3640 <productname>Kernel Hackers Manual</productname> 3641 <date>July 2017</date> 3642</refentryinfo> 3643<refmeta> 3644 <refentrytitle><phrase>kstrtoull</phrase></refentrytitle> 3645 <manvolnum>9</manvolnum> 3646 <refmiscinfo class="version">4.1.27</refmiscinfo> 3647</refmeta> 3648<refnamediv> 3649 <refname>kstrtoull</refname> 3650 <refpurpose> 3651 convert a string to an unsigned long long 3652 </refpurpose> 3653</refnamediv> 3654<refsynopsisdiv> 3655 <title>Synopsis</title> 3656 <funcsynopsis><funcprototype> 3657 <funcdef>int <function>kstrtoull </function></funcdef> 3658 <paramdef>const char * <parameter>s</parameter></paramdef> 3659 <paramdef>unsigned int <parameter>base</parameter></paramdef> 3660 <paramdef>unsigned long long * <parameter>res</parameter></paramdef> 3661 </funcprototype></funcsynopsis> 3662</refsynopsisdiv> 3663<refsect1> 3664 <title>Arguments</title> 3665 <variablelist> 3666 <varlistentry> 3667 <term><parameter>s</parameter></term> 3668 <listitem> 3669 <para> 3670 The start of the string. The string must be null-terminated, and may also 3671 include a single newline before its terminating null. The first character 3672 may also be a plus sign, but not a minus sign. 3673 </para> 3674 </listitem> 3675 </varlistentry> 3676 <varlistentry> 3677 <term><parameter>base</parameter></term> 3678 <listitem> 3679 <para> 3680 The number base to use. The maximum supported base is 16. If base is 3681 given as 0, then the base of the string is automatically detected with the 3682 conventional semantics - If it begins with 0x the number will be parsed as a 3683 hexadecimal (case insensitive), if it otherwise begins with 0, it will be 3684 parsed as an octal number. Otherwise it will be parsed as a decimal. 3685 </para> 3686 </listitem> 3687 </varlistentry> 3688 <varlistentry> 3689 <term><parameter>res</parameter></term> 3690 <listitem> 3691 <para> 3692 Where to write the result of the conversion on success. 3693 </para> 3694 </listitem> 3695 </varlistentry> 3696 </variablelist> 3697</refsect1> 3698<refsect1> 3699<title>Description</title> 3700<para> 3701 Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. 3702 Used as a replacement for the obsolete simple_strtoull. Return code must 3703 be checked. 3704</para> 3705</refsect1> 3706</refentry> 3707 3708<refentry id="API-kstrtoll"> 3709<refentryinfo> 3710 <title>LINUX</title> 3711 <productname>Kernel Hackers Manual</productname> 3712 <date>July 2017</date> 3713</refentryinfo> 3714<refmeta> 3715 <refentrytitle><phrase>kstrtoll</phrase></refentrytitle> 3716 <manvolnum>9</manvolnum> 3717 <refmiscinfo class="version">4.1.27</refmiscinfo> 3718</refmeta> 3719<refnamediv> 3720 <refname>kstrtoll</refname> 3721 <refpurpose> 3722 convert a string to a long long 3723 </refpurpose> 3724</refnamediv> 3725<refsynopsisdiv> 3726 <title>Synopsis</title> 3727 <funcsynopsis><funcprototype> 3728 <funcdef>int <function>kstrtoll </function></funcdef> 3729 <paramdef>const char * <parameter>s</parameter></paramdef> 3730 <paramdef>unsigned int <parameter>base</parameter></paramdef> 3731 <paramdef>long long * <parameter>res</parameter></paramdef> 3732 </funcprototype></funcsynopsis> 3733</refsynopsisdiv> 3734<refsect1> 3735 <title>Arguments</title> 3736 <variablelist> 3737 <varlistentry> 3738 <term><parameter>s</parameter></term> 3739 <listitem> 3740 <para> 3741 The start of the string. The string must be null-terminated, and may also 3742 include a single newline before its terminating null. The first character 3743 may also be a plus sign or a minus sign. 3744 </para> 3745 </listitem> 3746 </varlistentry> 3747 <varlistentry> 3748 <term><parameter>base</parameter></term> 3749 <listitem> 3750 <para> 3751 The number base to use. The maximum supported base is 16. If base is 3752 given as 0, then the base of the string is automatically detected with the 3753 conventional semantics - If it begins with 0x the number will be parsed as a 3754 hexadecimal (case insensitive), if it otherwise begins with 0, it will be 3755 parsed as an octal number. Otherwise it will be parsed as a decimal. 3756 </para> 3757 </listitem> 3758 </varlistentry> 3759 <varlistentry> 3760 <term><parameter>res</parameter></term> 3761 <listitem> 3762 <para> 3763 Where to write the result of the conversion on success. 3764 </para> 3765 </listitem> 3766 </varlistentry> 3767 </variablelist> 3768</refsect1> 3769<refsect1> 3770<title>Description</title> 3771<para> 3772 Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. 3773 Used as a replacement for the obsolete simple_strtoull. Return code must 3774 be checked. 3775</para> 3776</refsect1> 3777</refentry> 3778 3779<refentry id="API-kstrtouint"> 3780<refentryinfo> 3781 <title>LINUX</title> 3782 <productname>Kernel Hackers Manual</productname> 3783 <date>July 2017</date> 3784</refentryinfo> 3785<refmeta> 3786 <refentrytitle><phrase>kstrtouint</phrase></refentrytitle> 3787 <manvolnum>9</manvolnum> 3788 <refmiscinfo class="version">4.1.27</refmiscinfo> 3789</refmeta> 3790<refnamediv> 3791 <refname>kstrtouint</refname> 3792 <refpurpose> 3793 convert a string to an unsigned int 3794 </refpurpose> 3795</refnamediv> 3796<refsynopsisdiv> 3797 <title>Synopsis</title> 3798 <funcsynopsis><funcprototype> 3799 <funcdef>int <function>kstrtouint </function></funcdef> 3800 <paramdef>const char * <parameter>s</parameter></paramdef> 3801 <paramdef>unsigned int <parameter>base</parameter></paramdef> 3802 <paramdef>unsigned int * <parameter>res</parameter></paramdef> 3803 </funcprototype></funcsynopsis> 3804</refsynopsisdiv> 3805<refsect1> 3806 <title>Arguments</title> 3807 <variablelist> 3808 <varlistentry> 3809 <term><parameter>s</parameter></term> 3810 <listitem> 3811 <para> 3812 The start of the string. The string must be null-terminated, and may also 3813 include a single newline before its terminating null. The first character 3814 may also be a plus sign, but not a minus sign. 3815 </para> 3816 </listitem> 3817 </varlistentry> 3818 <varlistentry> 3819 <term><parameter>base</parameter></term> 3820 <listitem> 3821 <para> 3822 The number base to use. The maximum supported base is 16. If base is 3823 given as 0, then the base of the string is automatically detected with the 3824 conventional semantics - If it begins with 0x the number will be parsed as a 3825 hexadecimal (case insensitive), if it otherwise begins with 0, it will be 3826 parsed as an octal number. Otherwise it will be parsed as a decimal. 3827 </para> 3828 </listitem> 3829 </varlistentry> 3830 <varlistentry> 3831 <term><parameter>res</parameter></term> 3832 <listitem> 3833 <para> 3834 Where to write the result of the conversion on success. 3835 </para> 3836 </listitem> 3837 </varlistentry> 3838 </variablelist> 3839</refsect1> 3840<refsect1> 3841<title>Description</title> 3842<para> 3843 Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. 3844 Used as a replacement for the obsolete simple_strtoull. Return code must 3845 be checked. 3846</para> 3847</refsect1> 3848</refentry> 3849 3850<refentry id="API-kstrtoint"> 3851<refentryinfo> 3852 <title>LINUX</title> 3853 <productname>Kernel Hackers Manual</productname> 3854 <date>July 2017</date> 3855</refentryinfo> 3856<refmeta> 3857 <refentrytitle><phrase>kstrtoint</phrase></refentrytitle> 3858 <manvolnum>9</manvolnum> 3859 <refmiscinfo class="version">4.1.27</refmiscinfo> 3860</refmeta> 3861<refnamediv> 3862 <refname>kstrtoint</refname> 3863 <refpurpose> 3864 convert a string to an int 3865 </refpurpose> 3866</refnamediv> 3867<refsynopsisdiv> 3868 <title>Synopsis</title> 3869 <funcsynopsis><funcprototype> 3870 <funcdef>int <function>kstrtoint </function></funcdef> 3871 <paramdef>const char * <parameter>s</parameter></paramdef> 3872 <paramdef>unsigned int <parameter>base</parameter></paramdef> 3873 <paramdef>int * <parameter>res</parameter></paramdef> 3874 </funcprototype></funcsynopsis> 3875</refsynopsisdiv> 3876<refsect1> 3877 <title>Arguments</title> 3878 <variablelist> 3879 <varlistentry> 3880 <term><parameter>s</parameter></term> 3881 <listitem> 3882 <para> 3883 The start of the string. The string must be null-terminated, and may also 3884 include a single newline before its terminating null. The first character 3885 may also be a plus sign or a minus sign. 3886 </para> 3887 </listitem> 3888 </varlistentry> 3889 <varlistentry> 3890 <term><parameter>base</parameter></term> 3891 <listitem> 3892 <para> 3893 The number base to use. The maximum supported base is 16. If base is 3894 given as 0, then the base of the string is automatically detected with the 3895 conventional semantics - If it begins with 0x the number will be parsed as a 3896 hexadecimal (case insensitive), if it otherwise begins with 0, it will be 3897 parsed as an octal number. Otherwise it will be parsed as a decimal. 3898 </para> 3899 </listitem> 3900 </varlistentry> 3901 <varlistentry> 3902 <term><parameter>res</parameter></term> 3903 <listitem> 3904 <para> 3905 Where to write the result of the conversion on success. 3906 </para> 3907 </listitem> 3908 </varlistentry> 3909 </variablelist> 3910</refsect1> 3911<refsect1> 3912<title>Description</title> 3913<para> 3914 Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. 3915 Used as a replacement for the obsolete simple_strtoull. Return code must 3916 be checked. 3917</para> 3918</refsect1> 3919</refentry> 3920 3921 </sect1> 3922 <sect1><title>String Manipulation</title> 3923<!-- All functions are exported at now 3924X!Ilib/string.c 3925 --> 3926<!-- lib/string.c --> 3927<refentry id="API-strncasecmp"> 3928<refentryinfo> 3929 <title>LINUX</title> 3930 <productname>Kernel Hackers Manual</productname> 3931 <date>July 2017</date> 3932</refentryinfo> 3933<refmeta> 3934 <refentrytitle><phrase>strncasecmp</phrase></refentrytitle> 3935 <manvolnum>9</manvolnum> 3936 <refmiscinfo class="version">4.1.27</refmiscinfo> 3937</refmeta> 3938<refnamediv> 3939 <refname>strncasecmp</refname> 3940 <refpurpose> 3941 Case insensitive, length-limited string comparison 3942 </refpurpose> 3943</refnamediv> 3944<refsynopsisdiv> 3945 <title>Synopsis</title> 3946 <funcsynopsis><funcprototype> 3947 <funcdef>int <function>strncasecmp </function></funcdef> 3948 <paramdef>const char * <parameter>s1</parameter></paramdef> 3949 <paramdef>const char * <parameter>s2</parameter></paramdef> 3950 <paramdef>size_t <parameter>len</parameter></paramdef> 3951 </funcprototype></funcsynopsis> 3952</refsynopsisdiv> 3953<refsect1> 3954 <title>Arguments</title> 3955 <variablelist> 3956 <varlistentry> 3957 <term><parameter>s1</parameter></term> 3958 <listitem> 3959 <para> 3960 One string 3961 </para> 3962 </listitem> 3963 </varlistentry> 3964 <varlistentry> 3965 <term><parameter>s2</parameter></term> 3966 <listitem> 3967 <para> 3968 The other string 3969 </para> 3970 </listitem> 3971 </varlistentry> 3972 <varlistentry> 3973 <term><parameter>len</parameter></term> 3974 <listitem> 3975 <para> 3976 the maximum number of characters to compare 3977 </para> 3978 </listitem> 3979 </varlistentry> 3980 </variablelist> 3981</refsect1> 3982</refentry> 3983 3984<refentry id="API-strcpy"> 3985<refentryinfo> 3986 <title>LINUX</title> 3987 <productname>Kernel Hackers Manual</productname> 3988 <date>July 2017</date> 3989</refentryinfo> 3990<refmeta> 3991 <refentrytitle><phrase>strcpy</phrase></refentrytitle> 3992 <manvolnum>9</manvolnum> 3993 <refmiscinfo class="version">4.1.27</refmiscinfo> 3994</refmeta> 3995<refnamediv> 3996 <refname>strcpy</refname> 3997 <refpurpose> 3998 Copy a <constant>NUL</constant> terminated string 3999 </refpurpose> 4000</refnamediv> 4001<refsynopsisdiv> 4002 <title>Synopsis</title> 4003 <funcsynopsis><funcprototype> 4004 <funcdef>char * <function>strcpy </function></funcdef> 4005 <paramdef>char * <parameter>dest</parameter></paramdef> 4006 <paramdef>const char * <parameter>src</parameter></paramdef> 4007 </funcprototype></funcsynopsis> 4008</refsynopsisdiv> 4009<refsect1> 4010 <title>Arguments</title> 4011 <variablelist> 4012 <varlistentry> 4013 <term><parameter>dest</parameter></term> 4014 <listitem> 4015 <para> 4016 Where to copy the string to 4017 </para> 4018 </listitem> 4019 </varlistentry> 4020 <varlistentry> 4021 <term><parameter>src</parameter></term> 4022 <listitem> 4023 <para> 4024 Where to copy the string from 4025 </para> 4026 </listitem> 4027 </varlistentry> 4028 </variablelist> 4029</refsect1> 4030</refentry> 4031 4032<refentry id="API-strncpy"> 4033<refentryinfo> 4034 <title>LINUX</title> 4035 <productname>Kernel Hackers Manual</productname> 4036 <date>July 2017</date> 4037</refentryinfo> 4038<refmeta> 4039 <refentrytitle><phrase>strncpy</phrase></refentrytitle> 4040 <manvolnum>9</manvolnum> 4041 <refmiscinfo class="version">4.1.27</refmiscinfo> 4042</refmeta> 4043<refnamediv> 4044 <refname>strncpy</refname> 4045 <refpurpose> 4046 Copy a length-limited, C-string 4047 </refpurpose> 4048</refnamediv> 4049<refsynopsisdiv> 4050 <title>Synopsis</title> 4051 <funcsynopsis><funcprototype> 4052 <funcdef>char * <function>strncpy </function></funcdef> 4053 <paramdef>char * <parameter>dest</parameter></paramdef> 4054 <paramdef>const char * <parameter>src</parameter></paramdef> 4055 <paramdef>size_t <parameter>count</parameter></paramdef> 4056 </funcprototype></funcsynopsis> 4057</refsynopsisdiv> 4058<refsect1> 4059 <title>Arguments</title> 4060 <variablelist> 4061 <varlistentry> 4062 <term><parameter>dest</parameter></term> 4063 <listitem> 4064 <para> 4065 Where to copy the string to 4066 </para> 4067 </listitem> 4068 </varlistentry> 4069 <varlistentry> 4070 <term><parameter>src</parameter></term> 4071 <listitem> 4072 <para> 4073 Where to copy the string from 4074 </para> 4075 </listitem> 4076 </varlistentry> 4077 <varlistentry> 4078 <term><parameter>count</parameter></term> 4079 <listitem> 4080 <para> 4081 The maximum number of bytes to copy 4082 </para> 4083 </listitem> 4084 </varlistentry> 4085 </variablelist> 4086</refsect1> 4087<refsect1> 4088<title>Description</title> 4089<para> 4090 The result is not <constant>NUL-terminated</constant> if the source exceeds 4091 <parameter>count</parameter> bytes. 4092 </para><para> 4093 4094 In the case where the length of <parameter>src</parameter> is less than that of 4095 count, the remainder of <parameter>dest</parameter> will be padded with <constant>NUL</constant>. 4096</para> 4097</refsect1> 4098</refentry> 4099 4100<refentry id="API-strlcpy"> 4101<refentryinfo> 4102 <title>LINUX</title> 4103 <productname>Kernel Hackers Manual</productname> 4104 <date>July 2017</date> 4105</refentryinfo> 4106<refmeta> 4107 <refentrytitle><phrase>strlcpy</phrase></refentrytitle> 4108 <manvolnum>9</manvolnum> 4109 <refmiscinfo class="version">4.1.27</refmiscinfo> 4110</refmeta> 4111<refnamediv> 4112 <refname>strlcpy</refname> 4113 <refpurpose> 4114 Copy a C-string into a sized buffer 4115 </refpurpose> 4116</refnamediv> 4117<refsynopsisdiv> 4118 <title>Synopsis</title> 4119 <funcsynopsis><funcprototype> 4120 <funcdef>size_t <function>strlcpy </function></funcdef> 4121 <paramdef>char * <parameter>dest</parameter></paramdef> 4122 <paramdef>const char * <parameter>src</parameter></paramdef> 4123 <paramdef>size_t <parameter>size</parameter></paramdef> 4124 </funcprototype></funcsynopsis> 4125</refsynopsisdiv> 4126<refsect1> 4127 <title>Arguments</title> 4128 <variablelist> 4129 <varlistentry> 4130 <term><parameter>dest</parameter></term> 4131 <listitem> 4132 <para> 4133 Where to copy the string to 4134 </para> 4135 </listitem> 4136 </varlistentry> 4137 <varlistentry> 4138 <term><parameter>src</parameter></term> 4139 <listitem> 4140 <para> 4141 Where to copy the string from 4142 </para> 4143 </listitem> 4144 </varlistentry> 4145 <varlistentry> 4146 <term><parameter>size</parameter></term> 4147 <listitem> 4148 <para> 4149 size of destination buffer 4150 </para> 4151 </listitem> 4152 </varlistentry> 4153 </variablelist> 4154</refsect1> 4155<refsect1> 4156<title>BSD</title> 4157<para> 4158 the result is always a valid 4159 NUL-terminated string that fits in the buffer (unless, 4160 of course, the buffer size is zero). It does not pad 4161 out the result like <function>strncpy</function> does. 4162</para> 4163</refsect1> 4164</refentry> 4165 4166<refentry id="API-strcat"> 4167<refentryinfo> 4168 <title>LINUX</title> 4169 <productname>Kernel Hackers Manual</productname> 4170 <date>July 2017</date> 4171</refentryinfo> 4172<refmeta> 4173 <refentrytitle><phrase>strcat</phrase></refentrytitle> 4174 <manvolnum>9</manvolnum> 4175 <refmiscinfo class="version">4.1.27</refmiscinfo> 4176</refmeta> 4177<refnamediv> 4178 <refname>strcat</refname> 4179 <refpurpose> 4180 Append one <constant>NUL-terminated</constant> string to another 4181 </refpurpose> 4182</refnamediv> 4183<refsynopsisdiv> 4184 <title>Synopsis</title> 4185 <funcsynopsis><funcprototype> 4186 <funcdef>char * <function>strcat </function></funcdef> 4187 <paramdef>char * <parameter>dest</parameter></paramdef> 4188 <paramdef>const char * <parameter>src</parameter></paramdef> 4189 </funcprototype></funcsynopsis> 4190</refsynopsisdiv> 4191<refsect1> 4192 <title>Arguments</title> 4193 <variablelist> 4194 <varlistentry> 4195 <term><parameter>dest</parameter></term> 4196 <listitem> 4197 <para> 4198 The string to be appended to 4199 </para> 4200 </listitem> 4201 </varlistentry> 4202 <varlistentry> 4203 <term><parameter>src</parameter></term> 4204 <listitem> 4205 <para> 4206 The string to append to it 4207 </para> 4208 </listitem> 4209 </varlistentry> 4210 </variablelist> 4211</refsect1> 4212</refentry> 4213 4214<refentry id="API-strncat"> 4215<refentryinfo> 4216 <title>LINUX</title> 4217 <productname>Kernel Hackers Manual</productname> 4218 <date>July 2017</date> 4219</refentryinfo> 4220<refmeta> 4221 <refentrytitle><phrase>strncat</phrase></refentrytitle> 4222 <manvolnum>9</manvolnum> 4223 <refmiscinfo class="version">4.1.27</refmiscinfo> 4224</refmeta> 4225<refnamediv> 4226 <refname>strncat</refname> 4227 <refpurpose> 4228 Append a length-limited, C-string to another 4229 </refpurpose> 4230</refnamediv> 4231<refsynopsisdiv> 4232 <title>Synopsis</title> 4233 <funcsynopsis><funcprototype> 4234 <funcdef>char * <function>strncat </function></funcdef> 4235 <paramdef>char * <parameter>dest</parameter></paramdef> 4236 <paramdef>const char * <parameter>src</parameter></paramdef> 4237 <paramdef>size_t <parameter>count</parameter></paramdef> 4238 </funcprototype></funcsynopsis> 4239</refsynopsisdiv> 4240<refsect1> 4241 <title>Arguments</title> 4242 <variablelist> 4243 <varlistentry> 4244 <term><parameter>dest</parameter></term> 4245 <listitem> 4246 <para> 4247 The string to be appended to 4248 </para> 4249 </listitem> 4250 </varlistentry> 4251 <varlistentry> 4252 <term><parameter>src</parameter></term> 4253 <listitem> 4254 <para> 4255 The string to append to it 4256 </para> 4257 </listitem> 4258 </varlistentry> 4259 <varlistentry> 4260 <term><parameter>count</parameter></term> 4261 <listitem> 4262 <para> 4263 The maximum numbers of bytes to copy 4264 </para> 4265 </listitem> 4266 </varlistentry> 4267 </variablelist> 4268</refsect1> 4269<refsect1> 4270<title>Description</title> 4271<para> 4272 Note that in contrast to <function>strncpy</function>, <function>strncat</function> ensures the result is 4273 terminated. 4274</para> 4275</refsect1> 4276</refentry> 4277 4278<refentry id="API-strlcat"> 4279<refentryinfo> 4280 <title>LINUX</title> 4281 <productname>Kernel Hackers Manual</productname> 4282 <date>July 2017</date> 4283</refentryinfo> 4284<refmeta> 4285 <refentrytitle><phrase>strlcat</phrase></refentrytitle> 4286 <manvolnum>9</manvolnum> 4287 <refmiscinfo class="version">4.1.27</refmiscinfo> 4288</refmeta> 4289<refnamediv> 4290 <refname>strlcat</refname> 4291 <refpurpose> 4292 Append a length-limited, C-string to another 4293 </refpurpose> 4294</refnamediv> 4295<refsynopsisdiv> 4296 <title>Synopsis</title> 4297 <funcsynopsis><funcprototype> 4298 <funcdef>size_t <function>strlcat </function></funcdef> 4299 <paramdef>char * <parameter>dest</parameter></paramdef> 4300 <paramdef>const char * <parameter>src</parameter></paramdef> 4301 <paramdef>size_t <parameter>count</parameter></paramdef> 4302 </funcprototype></funcsynopsis> 4303</refsynopsisdiv> 4304<refsect1> 4305 <title>Arguments</title> 4306 <variablelist> 4307 <varlistentry> 4308 <term><parameter>dest</parameter></term> 4309 <listitem> 4310 <para> 4311 The string to be appended to 4312 </para> 4313 </listitem> 4314 </varlistentry> 4315 <varlistentry> 4316 <term><parameter>src</parameter></term> 4317 <listitem> 4318 <para> 4319 The string to append to it 4320 </para> 4321 </listitem> 4322 </varlistentry> 4323 <varlistentry> 4324 <term><parameter>count</parameter></term> 4325 <listitem> 4326 <para> 4327 The size of the destination buffer. 4328 </para> 4329 </listitem> 4330 </varlistentry> 4331 </variablelist> 4332</refsect1> 4333</refentry> 4334 4335<refentry id="API-strcmp"> 4336<refentryinfo> 4337 <title>LINUX</title> 4338 <productname>Kernel Hackers Manual</productname> 4339 <date>July 2017</date> 4340</refentryinfo> 4341<refmeta> 4342 <refentrytitle><phrase>strcmp</phrase></refentrytitle> 4343 <manvolnum>9</manvolnum> 4344 <refmiscinfo class="version">4.1.27</refmiscinfo> 4345</refmeta> 4346<refnamediv> 4347 <refname>strcmp</refname> 4348 <refpurpose> 4349 Compare two strings 4350 </refpurpose> 4351</refnamediv> 4352<refsynopsisdiv> 4353 <title>Synopsis</title> 4354 <funcsynopsis><funcprototype> 4355 <funcdef>int <function>strcmp </function></funcdef> 4356 <paramdef>const char * <parameter>cs</parameter></paramdef> 4357 <paramdef>const char * <parameter>ct</parameter></paramdef> 4358 </funcprototype></funcsynopsis> 4359</refsynopsisdiv> 4360<refsect1> 4361 <title>Arguments</title> 4362 <variablelist> 4363 <varlistentry> 4364 <term><parameter>cs</parameter></term> 4365 <listitem> 4366 <para> 4367 One string 4368 </para> 4369 </listitem> 4370 </varlistentry> 4371 <varlistentry> 4372 <term><parameter>ct</parameter></term> 4373 <listitem> 4374 <para> 4375 Another string 4376 </para> 4377 </listitem> 4378 </varlistentry> 4379 </variablelist> 4380</refsect1> 4381</refentry> 4382 4383<refentry id="API-strncmp"> 4384<refentryinfo> 4385 <title>LINUX</title> 4386 <productname>Kernel Hackers Manual</productname> 4387 <date>July 2017</date> 4388</refentryinfo> 4389<refmeta> 4390 <refentrytitle><phrase>strncmp</phrase></refentrytitle> 4391 <manvolnum>9</manvolnum> 4392 <refmiscinfo class="version">4.1.27</refmiscinfo> 4393</refmeta> 4394<refnamediv> 4395 <refname>strncmp</refname> 4396 <refpurpose> 4397 Compare two length-limited strings 4398 </refpurpose> 4399</refnamediv> 4400<refsynopsisdiv> 4401 <title>Synopsis</title> 4402 <funcsynopsis><funcprototype> 4403 <funcdef>int <function>strncmp </function></funcdef> 4404 <paramdef>const char * <parameter>cs</parameter></paramdef> 4405 <paramdef>const char * <parameter>ct</parameter></paramdef> 4406 <paramdef>size_t <parameter>count</parameter></paramdef> 4407 </funcprototype></funcsynopsis> 4408</refsynopsisdiv> 4409<refsect1> 4410 <title>Arguments</title> 4411 <variablelist> 4412 <varlistentry> 4413 <term><parameter>cs</parameter></term> 4414 <listitem> 4415 <para> 4416 One string 4417 </para> 4418 </listitem> 4419 </varlistentry> 4420 <varlistentry> 4421 <term><parameter>ct</parameter></term> 4422 <listitem> 4423 <para> 4424 Another string 4425 </para> 4426 </listitem> 4427 </varlistentry> 4428 <varlistentry> 4429 <term><parameter>count</parameter></term> 4430 <listitem> 4431 <para> 4432 The maximum number of bytes to compare 4433 </para> 4434 </listitem> 4435 </varlistentry> 4436 </variablelist> 4437</refsect1> 4438</refentry> 4439 4440<refentry id="API-strchr"> 4441<refentryinfo> 4442 <title>LINUX</title> 4443 <productname>Kernel Hackers Manual</productname> 4444 <date>July 2017</date> 4445</refentryinfo> 4446<refmeta> 4447 <refentrytitle><phrase>strchr</phrase></refentrytitle> 4448 <manvolnum>9</manvolnum> 4449 <refmiscinfo class="version">4.1.27</refmiscinfo> 4450</refmeta> 4451<refnamediv> 4452 <refname>strchr</refname> 4453 <refpurpose> 4454 Find the first occurrence of a character in a string 4455 </refpurpose> 4456</refnamediv> 4457<refsynopsisdiv> 4458 <title>Synopsis</title> 4459 <funcsynopsis><funcprototype> 4460 <funcdef>char * <function>strchr </function></funcdef> 4461 <paramdef>const char * <parameter>s</parameter></paramdef> 4462 <paramdef>int <parameter>c</parameter></paramdef> 4463 </funcprototype></funcsynopsis> 4464</refsynopsisdiv> 4465<refsect1> 4466 <title>Arguments</title> 4467 <variablelist> 4468 <varlistentry> 4469 <term><parameter>s</parameter></term> 4470 <listitem> 4471 <para> 4472 The string to be searched 4473 </para> 4474 </listitem> 4475 </varlistentry> 4476 <varlistentry> 4477 <term><parameter>c</parameter></term> 4478 <listitem> 4479 <para> 4480 The character to search for 4481 </para> 4482 </listitem> 4483 </varlistentry> 4484 </variablelist> 4485</refsect1> 4486</refentry> 4487 4488<refentry id="API-strchrnul"> 4489<refentryinfo> 4490 <title>LINUX</title> 4491 <productname>Kernel Hackers Manual</productname> 4492 <date>July 2017</date> 4493</refentryinfo> 4494<refmeta> 4495 <refentrytitle><phrase>strchrnul</phrase></refentrytitle> 4496 <manvolnum>9</manvolnum> 4497 <refmiscinfo class="version">4.1.27</refmiscinfo> 4498</refmeta> 4499<refnamediv> 4500 <refname>strchrnul</refname> 4501 <refpurpose> 4502 Find and return a character in a string, or end of string 4503 </refpurpose> 4504</refnamediv> 4505<refsynopsisdiv> 4506 <title>Synopsis</title> 4507 <funcsynopsis><funcprototype> 4508 <funcdef>char * <function>strchrnul </function></funcdef> 4509 <paramdef>const char * <parameter>s</parameter></paramdef> 4510 <paramdef>int <parameter>c</parameter></paramdef> 4511 </funcprototype></funcsynopsis> 4512</refsynopsisdiv> 4513<refsect1> 4514 <title>Arguments</title> 4515 <variablelist> 4516 <varlistentry> 4517 <term><parameter>s</parameter></term> 4518 <listitem> 4519 <para> 4520 The string to be searched 4521 </para> 4522 </listitem> 4523 </varlistentry> 4524 <varlistentry> 4525 <term><parameter>c</parameter></term> 4526 <listitem> 4527 <para> 4528 The character to search for 4529 </para> 4530 </listitem> 4531 </varlistentry> 4532 </variablelist> 4533</refsect1> 4534<refsect1> 4535<title>Description</title> 4536<para> 4537 Returns pointer to first occurrence of 'c' in s. If c is not found, then 4538 return a pointer to the null byte at the end of s. 4539</para> 4540</refsect1> 4541</refentry> 4542 4543<refentry id="API-strrchr"> 4544<refentryinfo> 4545 <title>LINUX</title> 4546 <productname>Kernel Hackers Manual</productname> 4547 <date>July 2017</date> 4548</refentryinfo> 4549<refmeta> 4550 <refentrytitle><phrase>strrchr</phrase></refentrytitle> 4551 <manvolnum>9</manvolnum> 4552 <refmiscinfo class="version">4.1.27</refmiscinfo> 4553</refmeta> 4554<refnamediv> 4555 <refname>strrchr</refname> 4556 <refpurpose> 4557 Find the last occurrence of a character in a string 4558 </refpurpose> 4559</refnamediv> 4560<refsynopsisdiv> 4561 <title>Synopsis</title> 4562 <funcsynopsis><funcprototype> 4563 <funcdef>char * <function>strrchr </function></funcdef> 4564 <paramdef>const char * <parameter>s</parameter></paramdef> 4565 <paramdef>int <parameter>c</parameter></paramdef> 4566 </funcprototype></funcsynopsis> 4567</refsynopsisdiv> 4568<refsect1> 4569 <title>Arguments</title> 4570 <variablelist> 4571 <varlistentry> 4572 <term><parameter>s</parameter></term> 4573 <listitem> 4574 <para> 4575 The string to be searched 4576 </para> 4577 </listitem> 4578 </varlistentry> 4579 <varlistentry> 4580 <term><parameter>c</parameter></term> 4581 <listitem> 4582 <para> 4583 The character to search for 4584 </para> 4585 </listitem> 4586 </varlistentry> 4587 </variablelist> 4588</refsect1> 4589</refentry> 4590 4591<refentry id="API-strnchr"> 4592<refentryinfo> 4593 <title>LINUX</title> 4594 <productname>Kernel Hackers Manual</productname> 4595 <date>July 2017</date> 4596</refentryinfo> 4597<refmeta> 4598 <refentrytitle><phrase>strnchr</phrase></refentrytitle> 4599 <manvolnum>9</manvolnum> 4600 <refmiscinfo class="version">4.1.27</refmiscinfo> 4601</refmeta> 4602<refnamediv> 4603 <refname>strnchr</refname> 4604 <refpurpose> 4605 Find a character in a length limited string 4606 </refpurpose> 4607</refnamediv> 4608<refsynopsisdiv> 4609 <title>Synopsis</title> 4610 <funcsynopsis><funcprototype> 4611 <funcdef>char * <function>strnchr </function></funcdef> 4612 <paramdef>const char * <parameter>s</parameter></paramdef> 4613 <paramdef>size_t <parameter>count</parameter></paramdef> 4614 <paramdef>int <parameter>c</parameter></paramdef> 4615 </funcprototype></funcsynopsis> 4616</refsynopsisdiv> 4617<refsect1> 4618 <title>Arguments</title> 4619 <variablelist> 4620 <varlistentry> 4621 <term><parameter>s</parameter></term> 4622 <listitem> 4623 <para> 4624 The string to be searched 4625 </para> 4626 </listitem> 4627 </varlistentry> 4628 <varlistentry> 4629 <term><parameter>count</parameter></term> 4630 <listitem> 4631 <para> 4632 The number of characters to be searched 4633 </para> 4634 </listitem> 4635 </varlistentry> 4636 <varlistentry> 4637 <term><parameter>c</parameter></term> 4638 <listitem> 4639 <para> 4640 The character to search for 4641 </para> 4642 </listitem> 4643 </varlistentry> 4644 </variablelist> 4645</refsect1> 4646</refentry> 4647 4648<refentry id="API-skip-spaces"> 4649<refentryinfo> 4650 <title>LINUX</title> 4651 <productname>Kernel Hackers Manual</productname> 4652 <date>July 2017</date> 4653</refentryinfo> 4654<refmeta> 4655 <refentrytitle><phrase>skip_spaces</phrase></refentrytitle> 4656 <manvolnum>9</manvolnum> 4657 <refmiscinfo class="version">4.1.27</refmiscinfo> 4658</refmeta> 4659<refnamediv> 4660 <refname>skip_spaces</refname> 4661 <refpurpose> 4662 Removes leading whitespace from <parameter>str</parameter>. 4663 </refpurpose> 4664</refnamediv> 4665<refsynopsisdiv> 4666 <title>Synopsis</title> 4667 <funcsynopsis><funcprototype> 4668 <funcdef>char * <function>skip_spaces </function></funcdef> 4669 <paramdef>const char * <parameter>str</parameter></paramdef> 4670 </funcprototype></funcsynopsis> 4671</refsynopsisdiv> 4672<refsect1> 4673 <title>Arguments</title> 4674 <variablelist> 4675 <varlistentry> 4676 <term><parameter>str</parameter></term> 4677 <listitem> 4678 <para> 4679 The string to be stripped. 4680 </para> 4681 </listitem> 4682 </varlistentry> 4683 </variablelist> 4684</refsect1> 4685<refsect1> 4686<title>Description</title> 4687<para> 4688 Returns a pointer to the first non-whitespace character in <parameter>str</parameter>. 4689</para> 4690</refsect1> 4691</refentry> 4692 4693<refentry id="API-strim"> 4694<refentryinfo> 4695 <title>LINUX</title> 4696 <productname>Kernel Hackers Manual</productname> 4697 <date>July 2017</date> 4698</refentryinfo> 4699<refmeta> 4700 <refentrytitle><phrase>strim</phrase></refentrytitle> 4701 <manvolnum>9</manvolnum> 4702 <refmiscinfo class="version">4.1.27</refmiscinfo> 4703</refmeta> 4704<refnamediv> 4705 <refname>strim</refname> 4706 <refpurpose> 4707 Removes leading and trailing whitespace from <parameter>s</parameter>. 4708 </refpurpose> 4709</refnamediv> 4710<refsynopsisdiv> 4711 <title>Synopsis</title> 4712 <funcsynopsis><funcprototype> 4713 <funcdef>char * <function>strim </function></funcdef> 4714 <paramdef>char * <parameter>s</parameter></paramdef> 4715 </funcprototype></funcsynopsis> 4716</refsynopsisdiv> 4717<refsect1> 4718 <title>Arguments</title> 4719 <variablelist> 4720 <varlistentry> 4721 <term><parameter>s</parameter></term> 4722 <listitem> 4723 <para> 4724 The string to be stripped. 4725 </para> 4726 </listitem> 4727 </varlistentry> 4728 </variablelist> 4729</refsect1> 4730<refsect1> 4731<title>Description</title> 4732<para> 4733 Note that the first trailing whitespace is replaced with a <constant>NUL-terminator</constant> 4734 in the given string <parameter>s</parameter>. Returns a pointer to the first non-whitespace 4735 character in <parameter>s</parameter>. 4736</para> 4737</refsect1> 4738</refentry> 4739 4740<refentry id="API-strlen"> 4741<refentryinfo> 4742 <title>LINUX</title> 4743 <productname>Kernel Hackers Manual</productname> 4744 <date>July 2017</date> 4745</refentryinfo> 4746<refmeta> 4747 <refentrytitle><phrase>strlen</phrase></refentrytitle> 4748 <manvolnum>9</manvolnum> 4749 <refmiscinfo class="version">4.1.27</refmiscinfo> 4750</refmeta> 4751<refnamediv> 4752 <refname>strlen</refname> 4753 <refpurpose> 4754 Find the length of a string 4755 </refpurpose> 4756</refnamediv> 4757<refsynopsisdiv> 4758 <title>Synopsis</title> 4759 <funcsynopsis><funcprototype> 4760 <funcdef>size_t <function>strlen </function></funcdef> 4761 <paramdef>const char * <parameter>s</parameter></paramdef> 4762 </funcprototype></funcsynopsis> 4763</refsynopsisdiv> 4764<refsect1> 4765 <title>Arguments</title> 4766 <variablelist> 4767 <varlistentry> 4768 <term><parameter>s</parameter></term> 4769 <listitem> 4770 <para> 4771 The string to be sized 4772 </para> 4773 </listitem> 4774 </varlistentry> 4775 </variablelist> 4776</refsect1> 4777</refentry> 4778 4779<refentry id="API-strnlen"> 4780<refentryinfo> 4781 <title>LINUX</title> 4782 <productname>Kernel Hackers Manual</productname> 4783 <date>July 2017</date> 4784</refentryinfo> 4785<refmeta> 4786 <refentrytitle><phrase>strnlen</phrase></refentrytitle> 4787 <manvolnum>9</manvolnum> 4788 <refmiscinfo class="version">4.1.27</refmiscinfo> 4789</refmeta> 4790<refnamediv> 4791 <refname>strnlen</refname> 4792 <refpurpose> 4793 Find the length of a length-limited string 4794 </refpurpose> 4795</refnamediv> 4796<refsynopsisdiv> 4797 <title>Synopsis</title> 4798 <funcsynopsis><funcprototype> 4799 <funcdef>size_t <function>strnlen </function></funcdef> 4800 <paramdef>const char * <parameter>s</parameter></paramdef> 4801 <paramdef>size_t <parameter>count</parameter></paramdef> 4802 </funcprototype></funcsynopsis> 4803</refsynopsisdiv> 4804<refsect1> 4805 <title>Arguments</title> 4806 <variablelist> 4807 <varlistentry> 4808 <term><parameter>s</parameter></term> 4809 <listitem> 4810 <para> 4811 The string to be sized 4812 </para> 4813 </listitem> 4814 </varlistentry> 4815 <varlistentry> 4816 <term><parameter>count</parameter></term> 4817 <listitem> 4818 <para> 4819 The maximum number of bytes to search 4820 </para> 4821 </listitem> 4822 </varlistentry> 4823 </variablelist> 4824</refsect1> 4825</refentry> 4826 4827<refentry id="API-strspn"> 4828<refentryinfo> 4829 <title>LINUX</title> 4830 <productname>Kernel Hackers Manual</productname> 4831 <date>July 2017</date> 4832</refentryinfo> 4833<refmeta> 4834 <refentrytitle><phrase>strspn</phrase></refentrytitle> 4835 <manvolnum>9</manvolnum> 4836 <refmiscinfo class="version">4.1.27</refmiscinfo> 4837</refmeta> 4838<refnamediv> 4839 <refname>strspn</refname> 4840 <refpurpose> 4841 Calculate the length of the initial substring of <parameter>s</parameter> which only contain letters in <parameter>accept</parameter> 4842 </refpurpose> 4843</refnamediv> 4844<refsynopsisdiv> 4845 <title>Synopsis</title> 4846 <funcsynopsis><funcprototype> 4847 <funcdef>size_t <function>strspn </function></funcdef> 4848 <paramdef>const char * <parameter>s</parameter></paramdef> 4849 <paramdef>const char * <parameter>accept</parameter></paramdef> 4850 </funcprototype></funcsynopsis> 4851</refsynopsisdiv> 4852<refsect1> 4853 <title>Arguments</title> 4854 <variablelist> 4855 <varlistentry> 4856 <term><parameter>s</parameter></term> 4857 <listitem> 4858 <para> 4859 The string to be searched 4860 </para> 4861 </listitem> 4862 </varlistentry> 4863 <varlistentry> 4864 <term><parameter>accept</parameter></term> 4865 <listitem> 4866 <para> 4867 The string to search for 4868 </para> 4869 </listitem> 4870 </varlistentry> 4871 </variablelist> 4872</refsect1> 4873</refentry> 4874 4875<refentry id="API-strcspn"> 4876<refentryinfo> 4877 <title>LINUX</title> 4878 <productname>Kernel Hackers Manual</productname> 4879 <date>July 2017</date> 4880</refentryinfo> 4881<refmeta> 4882 <refentrytitle><phrase>strcspn</phrase></refentrytitle> 4883 <manvolnum>9</manvolnum> 4884 <refmiscinfo class="version">4.1.27</refmiscinfo> 4885</refmeta> 4886<refnamediv> 4887 <refname>strcspn</refname> 4888 <refpurpose> 4889 Calculate the length of the initial substring of <parameter>s</parameter> which does not contain letters in <parameter>reject</parameter> 4890 </refpurpose> 4891</refnamediv> 4892<refsynopsisdiv> 4893 <title>Synopsis</title> 4894 <funcsynopsis><funcprototype> 4895 <funcdef>size_t <function>strcspn </function></funcdef> 4896 <paramdef>const char * <parameter>s</parameter></paramdef> 4897 <paramdef>const char * <parameter>reject</parameter></paramdef> 4898 </funcprototype></funcsynopsis> 4899</refsynopsisdiv> 4900<refsect1> 4901 <title>Arguments</title> 4902 <variablelist> 4903 <varlistentry> 4904 <term><parameter>s</parameter></term> 4905 <listitem> 4906 <para> 4907 The string to be searched 4908 </para> 4909 </listitem> 4910 </varlistentry> 4911 <varlistentry> 4912 <term><parameter>reject</parameter></term> 4913 <listitem> 4914 <para> 4915 The string to avoid 4916 </para> 4917 </listitem> 4918 </varlistentry> 4919 </variablelist> 4920</refsect1> 4921</refentry> 4922 4923<refentry id="API-strpbrk"> 4924<refentryinfo> 4925 <title>LINUX</title> 4926 <productname>Kernel Hackers Manual</productname> 4927 <date>July 2017</date> 4928</refentryinfo> 4929<refmeta> 4930 <refentrytitle><phrase>strpbrk</phrase></refentrytitle> 4931 <manvolnum>9</manvolnum> 4932 <refmiscinfo class="version">4.1.27</refmiscinfo> 4933</refmeta> 4934<refnamediv> 4935 <refname>strpbrk</refname> 4936 <refpurpose> 4937 Find the first occurrence of a set of characters 4938 </refpurpose> 4939</refnamediv> 4940<refsynopsisdiv> 4941 <title>Synopsis</title> 4942 <funcsynopsis><funcprototype> 4943 <funcdef>char * <function>strpbrk </function></funcdef> 4944 <paramdef>const char * <parameter>cs</parameter></paramdef> 4945 <paramdef>const char * <parameter>ct</parameter></paramdef> 4946 </funcprototype></funcsynopsis> 4947</refsynopsisdiv> 4948<refsect1> 4949 <title>Arguments</title> 4950 <variablelist> 4951 <varlistentry> 4952 <term><parameter>cs</parameter></term> 4953 <listitem> 4954 <para> 4955 The string to be searched 4956 </para> 4957 </listitem> 4958 </varlistentry> 4959 <varlistentry> 4960 <term><parameter>ct</parameter></term> 4961 <listitem> 4962 <para> 4963 The characters to search for 4964 </para> 4965 </listitem> 4966 </varlistentry> 4967 </variablelist> 4968</refsect1> 4969</refentry> 4970 4971<refentry id="API-strsep"> 4972<refentryinfo> 4973 <title>LINUX</title> 4974 <productname>Kernel Hackers Manual</productname> 4975 <date>July 2017</date> 4976</refentryinfo> 4977<refmeta> 4978 <refentrytitle><phrase>strsep</phrase></refentrytitle> 4979 <manvolnum>9</manvolnum> 4980 <refmiscinfo class="version">4.1.27</refmiscinfo> 4981</refmeta> 4982<refnamediv> 4983 <refname>strsep</refname> 4984 <refpurpose> 4985 Split a string into tokens 4986 </refpurpose> 4987</refnamediv> 4988<refsynopsisdiv> 4989 <title>Synopsis</title> 4990 <funcsynopsis><funcprototype> 4991 <funcdef>char * <function>strsep </function></funcdef> 4992 <paramdef>char ** <parameter>s</parameter></paramdef> 4993 <paramdef>const char * <parameter>ct</parameter></paramdef> 4994 </funcprototype></funcsynopsis> 4995</refsynopsisdiv> 4996<refsect1> 4997 <title>Arguments</title> 4998 <variablelist> 4999 <varlistentry> 5000 <term><parameter>s</parameter></term> 5001 <listitem> 5002 <para> 5003 The string to be searched 5004 </para> 5005 </listitem> 5006 </varlistentry> 5007 <varlistentry> 5008 <term><parameter>ct</parameter></term> 5009 <listitem> 5010 <para> 5011 The characters to search for 5012 </para> 5013 </listitem> 5014 </varlistentry> 5015 </variablelist> 5016</refsect1> 5017<refsect1> 5018<title>Description</title> 5019<para> 5020 <function>strsep</function> updates <parameter>s</parameter> to point after the token, ready for the next call. 5021 </para><para> 5022 5023 It returns empty tokens, too, behaving exactly like the libc function 5024 of that name. In fact, it was stolen from glibc2 and de-fancy-fied. 5025 Same semantics, slimmer shape. ;) 5026</para> 5027</refsect1> 5028</refentry> 5029 5030<refentry id="API-sysfs-streq"> 5031<refentryinfo> 5032 <title>LINUX</title> 5033 <productname>Kernel Hackers Manual</productname> 5034 <date>July 2017</date> 5035</refentryinfo> 5036<refmeta> 5037 <refentrytitle><phrase>sysfs_streq</phrase></refentrytitle> 5038 <manvolnum>9</manvolnum> 5039 <refmiscinfo class="version">4.1.27</refmiscinfo> 5040</refmeta> 5041<refnamediv> 5042 <refname>sysfs_streq</refname> 5043 <refpurpose> 5044 return true if strings are equal, modulo trailing newline 5045 </refpurpose> 5046</refnamediv> 5047<refsynopsisdiv> 5048 <title>Synopsis</title> 5049 <funcsynopsis><funcprototype> 5050 <funcdef>bool <function>sysfs_streq </function></funcdef> 5051 <paramdef>const char * <parameter>s1</parameter></paramdef> 5052 <paramdef>const char * <parameter>s2</parameter></paramdef> 5053 </funcprototype></funcsynopsis> 5054</refsynopsisdiv> 5055<refsect1> 5056 <title>Arguments</title> 5057 <variablelist> 5058 <varlistentry> 5059 <term><parameter>s1</parameter></term> 5060 <listitem> 5061 <para> 5062 one string 5063 </para> 5064 </listitem> 5065 </varlistentry> 5066 <varlistentry> 5067 <term><parameter>s2</parameter></term> 5068 <listitem> 5069 <para> 5070 another string 5071 </para> 5072 </listitem> 5073 </varlistentry> 5074 </variablelist> 5075</refsect1> 5076<refsect1> 5077<title>Description</title> 5078<para> 5079 This routine returns true iff two strings are equal, treating both 5080 NUL and newline-then-NUL as equivalent string terminations. It's 5081 geared for use with sysfs input strings, which generally terminate 5082 with newlines but are compared against values without newlines. 5083</para> 5084</refsect1> 5085</refentry> 5086 5087<refentry id="API-strtobool"> 5088<refentryinfo> 5089 <title>LINUX</title> 5090 <productname>Kernel Hackers Manual</productname> 5091 <date>July 2017</date> 5092</refentryinfo> 5093<refmeta> 5094 <refentrytitle><phrase>strtobool</phrase></refentrytitle> 5095 <manvolnum>9</manvolnum> 5096 <refmiscinfo class="version">4.1.27</refmiscinfo> 5097</refmeta> 5098<refnamediv> 5099 <refname>strtobool</refname> 5100 <refpurpose> 5101 convert common user inputs into boolean values 5102 </refpurpose> 5103</refnamediv> 5104<refsynopsisdiv> 5105 <title>Synopsis</title> 5106 <funcsynopsis><funcprototype> 5107 <funcdef>int <function>strtobool </function></funcdef> 5108 <paramdef>const char * <parameter>s</parameter></paramdef> 5109 <paramdef>bool * <parameter>res</parameter></paramdef> 5110 </funcprototype></funcsynopsis> 5111</refsynopsisdiv> 5112<refsect1> 5113 <title>Arguments</title> 5114 <variablelist> 5115 <varlistentry> 5116 <term><parameter>s</parameter></term> 5117 <listitem> 5118 <para> 5119 input string 5120 </para> 5121 </listitem> 5122 </varlistentry> 5123 <varlistentry> 5124 <term><parameter>res</parameter></term> 5125 <listitem> 5126 <para> 5127 result 5128 </para> 5129 </listitem> 5130 </varlistentry> 5131 </variablelist> 5132</refsect1> 5133<refsect1> 5134<title>Description</title> 5135<para> 5136 This routine returns 0 iff the first character is one of 'Yy1Nn0'. 5137 Otherwise it will return -EINVAL. Value pointed to by res is 5138 updated upon finding a match. 5139</para> 5140</refsect1> 5141</refentry> 5142 5143<refentry id="API-memset"> 5144<refentryinfo> 5145 <title>LINUX</title> 5146 <productname>Kernel Hackers Manual</productname> 5147 <date>July 2017</date> 5148</refentryinfo> 5149<refmeta> 5150 <refentrytitle><phrase>memset</phrase></refentrytitle> 5151 <manvolnum>9</manvolnum> 5152 <refmiscinfo class="version">4.1.27</refmiscinfo> 5153</refmeta> 5154<refnamediv> 5155 <refname>memset</refname> 5156 <refpurpose> 5157 Fill a region of memory with the given value 5158 </refpurpose> 5159</refnamediv> 5160<refsynopsisdiv> 5161 <title>Synopsis</title> 5162 <funcsynopsis><funcprototype> 5163 <funcdef>void * <function>memset </function></funcdef> 5164 <paramdef>void * <parameter>s</parameter></paramdef> 5165 <paramdef>int <parameter>c</parameter></paramdef> 5166 <paramdef>size_t <parameter>count</parameter></paramdef> 5167 </funcprototype></funcsynopsis> 5168</refsynopsisdiv> 5169<refsect1> 5170 <title>Arguments</title> 5171 <variablelist> 5172 <varlistentry> 5173 <term><parameter>s</parameter></term> 5174 <listitem> 5175 <para> 5176 Pointer to the start of the area. 5177 </para> 5178 </listitem> 5179 </varlistentry> 5180 <varlistentry> 5181 <term><parameter>c</parameter></term> 5182 <listitem> 5183 <para> 5184 The byte to fill the area with 5185 </para> 5186 </listitem> 5187 </varlistentry> 5188 <varlistentry> 5189 <term><parameter>count</parameter></term> 5190 <listitem> 5191 <para> 5192 The size of the area. 5193 </para> 5194 </listitem> 5195 </varlistentry> 5196 </variablelist> 5197</refsect1> 5198<refsect1> 5199<title>Description</title> 5200<para> 5201 Do not use <function>memset</function> to access IO space, use <function>memset_io</function> instead. 5202</para> 5203</refsect1> 5204</refentry> 5205 5206<refentry id="API-memzero-explicit"> 5207<refentryinfo> 5208 <title>LINUX</title> 5209 <productname>Kernel Hackers Manual</productname> 5210 <date>July 2017</date> 5211</refentryinfo> 5212<refmeta> 5213 <refentrytitle><phrase>memzero_explicit</phrase></refentrytitle> 5214 <manvolnum>9</manvolnum> 5215 <refmiscinfo class="version">4.1.27</refmiscinfo> 5216</refmeta> 5217<refnamediv> 5218 <refname>memzero_explicit</refname> 5219 <refpurpose> 5220 Fill a region of memory (e.g. sensitive keying data) with 0s. 5221 </refpurpose> 5222</refnamediv> 5223<refsynopsisdiv> 5224 <title>Synopsis</title> 5225 <funcsynopsis><funcprototype> 5226 <funcdef>void <function>memzero_explicit </function></funcdef> 5227 <paramdef>void * <parameter>s</parameter></paramdef> 5228 <paramdef>size_t <parameter>count</parameter></paramdef> 5229 </funcprototype></funcsynopsis> 5230</refsynopsisdiv> 5231<refsect1> 5232 <title>Arguments</title> 5233 <variablelist> 5234 <varlistentry> 5235 <term><parameter>s</parameter></term> 5236 <listitem> 5237 <para> 5238 Pointer to the start of the area. 5239 </para> 5240 </listitem> 5241 </varlistentry> 5242 <varlistentry> 5243 <term><parameter>count</parameter></term> 5244 <listitem> 5245 <para> 5246 The size of the area. 5247 </para> 5248 </listitem> 5249 </varlistentry> 5250 </variablelist> 5251</refsect1> 5252<refsect1> 5253<title>Note</title> 5254<para> 5255 usually using <function>memset</function> is just fine (!), but in cases 5256 where clearing out _local_ data at the end of a scope is 5257 necessary, <function>memzero_explicit</function> should be used instead in 5258 order to prevent the compiler from optimising away zeroing. 5259 </para><para> 5260 5261 <function>memzero_explicit</function> doesn't need an arch-specific version as 5262 it just invokes the one of <function>memset</function> implicitly. 5263</para> 5264</refsect1> 5265</refentry> 5266 5267<refentry id="API-memcpy"> 5268<refentryinfo> 5269 <title>LINUX</title> 5270 <productname>Kernel Hackers Manual</productname> 5271 <date>July 2017</date> 5272</refentryinfo> 5273<refmeta> 5274 <refentrytitle><phrase>memcpy</phrase></refentrytitle> 5275 <manvolnum>9</manvolnum> 5276 <refmiscinfo class="version">4.1.27</refmiscinfo> 5277</refmeta> 5278<refnamediv> 5279 <refname>memcpy</refname> 5280 <refpurpose> 5281 Copy one area of memory to another 5282 </refpurpose> 5283</refnamediv> 5284<refsynopsisdiv> 5285 <title>Synopsis</title> 5286 <funcsynopsis><funcprototype> 5287 <funcdef>void * <function>memcpy </function></funcdef> 5288 <paramdef>void * <parameter>dest</parameter></paramdef> 5289 <paramdef>const void * <parameter>src</parameter></paramdef> 5290 <paramdef>size_t <parameter>count</parameter></paramdef> 5291 </funcprototype></funcsynopsis> 5292</refsynopsisdiv> 5293<refsect1> 5294 <title>Arguments</title> 5295 <variablelist> 5296 <varlistentry> 5297 <term><parameter>dest</parameter></term> 5298 <listitem> 5299 <para> 5300 Where to copy to 5301 </para> 5302 </listitem> 5303 </varlistentry> 5304 <varlistentry> 5305 <term><parameter>src</parameter></term> 5306 <listitem> 5307 <para> 5308 Where to copy from 5309 </para> 5310 </listitem> 5311 </varlistentry> 5312 <varlistentry> 5313 <term><parameter>count</parameter></term> 5314 <listitem> 5315 <para> 5316 The size of the area. 5317 </para> 5318 </listitem> 5319 </varlistentry> 5320 </variablelist> 5321</refsect1> 5322<refsect1> 5323<title>Description</title> 5324<para> 5325 You should not use this function to access IO space, use <function>memcpy_toio</function> 5326 or <function>memcpy_fromio</function> instead. 5327</para> 5328</refsect1> 5329</refentry> 5330 5331<refentry id="API-memmove"> 5332<refentryinfo> 5333 <title>LINUX</title> 5334 <productname>Kernel Hackers Manual</productname> 5335 <date>July 2017</date> 5336</refentryinfo> 5337<refmeta> 5338 <refentrytitle><phrase>memmove</phrase></refentrytitle> 5339 <manvolnum>9</manvolnum> 5340 <refmiscinfo class="version">4.1.27</refmiscinfo> 5341</refmeta> 5342<refnamediv> 5343 <refname>memmove</refname> 5344 <refpurpose> 5345 Copy one area of memory to another 5346 </refpurpose> 5347</refnamediv> 5348<refsynopsisdiv> 5349 <title>Synopsis</title> 5350 <funcsynopsis><funcprototype> 5351 <funcdef>void * <function>memmove </function></funcdef> 5352 <paramdef>void * <parameter>dest</parameter></paramdef> 5353 <paramdef>const void * <parameter>src</parameter></paramdef> 5354 <paramdef>size_t <parameter>count</parameter></paramdef> 5355 </funcprototype></funcsynopsis> 5356</refsynopsisdiv> 5357<refsect1> 5358 <title>Arguments</title> 5359 <variablelist> 5360 <varlistentry> 5361 <term><parameter>dest</parameter></term> 5362 <listitem> 5363 <para> 5364 Where to copy to 5365 </para> 5366 </listitem> 5367 </varlistentry> 5368 <varlistentry> 5369 <term><parameter>src</parameter></term> 5370 <listitem> 5371 <para> 5372 Where to copy from 5373 </para> 5374 </listitem> 5375 </varlistentry> 5376 <varlistentry> 5377 <term><parameter>count</parameter></term> 5378 <listitem> 5379 <para> 5380 The size of the area. 5381 </para> 5382 </listitem> 5383 </varlistentry> 5384 </variablelist> 5385</refsect1> 5386<refsect1> 5387<title>Description</title> 5388<para> 5389 Unlike <function>memcpy</function>, <function>memmove</function> copes with overlapping areas. 5390</para> 5391</refsect1> 5392</refentry> 5393 5394<refentry id="API-memcmp"> 5395<refentryinfo> 5396 <title>LINUX</title> 5397 <productname>Kernel Hackers Manual</productname> 5398 <date>July 2017</date> 5399</refentryinfo> 5400<refmeta> 5401 <refentrytitle><phrase>memcmp</phrase></refentrytitle> 5402 <manvolnum>9</manvolnum> 5403 <refmiscinfo class="version">4.1.27</refmiscinfo> 5404</refmeta> 5405<refnamediv> 5406 <refname>memcmp</refname> 5407 <refpurpose> 5408 Compare two areas of memory 5409 </refpurpose> 5410</refnamediv> 5411<refsynopsisdiv> 5412 <title>Synopsis</title> 5413 <funcsynopsis><funcprototype> 5414 <funcdef>__visible int <function>memcmp </function></funcdef> 5415 <paramdef>const void * <parameter>cs</parameter></paramdef> 5416 <paramdef>const void * <parameter>ct</parameter></paramdef> 5417 <paramdef>size_t <parameter>count</parameter></paramdef> 5418 </funcprototype></funcsynopsis> 5419</refsynopsisdiv> 5420<refsect1> 5421 <title>Arguments</title> 5422 <variablelist> 5423 <varlistentry> 5424 <term><parameter>cs</parameter></term> 5425 <listitem> 5426 <para> 5427 One area of memory 5428 </para> 5429 </listitem> 5430 </varlistentry> 5431 <varlistentry> 5432 <term><parameter>ct</parameter></term> 5433 <listitem> 5434 <para> 5435 Another area of memory 5436 </para> 5437 </listitem> 5438 </varlistentry> 5439 <varlistentry> 5440 <term><parameter>count</parameter></term> 5441 <listitem> 5442 <para> 5443 The size of the area. 5444 </para> 5445 </listitem> 5446 </varlistentry> 5447 </variablelist> 5448</refsect1> 5449</refentry> 5450 5451<refentry id="API-memscan"> 5452<refentryinfo> 5453 <title>LINUX</title> 5454 <productname>Kernel Hackers Manual</productname> 5455 <date>July 2017</date> 5456</refentryinfo> 5457<refmeta> 5458 <refentrytitle><phrase>memscan</phrase></refentrytitle> 5459 <manvolnum>9</manvolnum> 5460 <refmiscinfo class="version">4.1.27</refmiscinfo> 5461</refmeta> 5462<refnamediv> 5463 <refname>memscan</refname> 5464 <refpurpose> 5465 Find a character in an area of memory. 5466 </refpurpose> 5467</refnamediv> 5468<refsynopsisdiv> 5469 <title>Synopsis</title> 5470 <funcsynopsis><funcprototype> 5471 <funcdef>void * <function>memscan </function></funcdef> 5472 <paramdef>void * <parameter>addr</parameter></paramdef> 5473 <paramdef>int <parameter>c</parameter></paramdef> 5474 <paramdef>size_t <parameter>size</parameter></paramdef> 5475 </funcprototype></funcsynopsis> 5476</refsynopsisdiv> 5477<refsect1> 5478 <title>Arguments</title> 5479 <variablelist> 5480 <varlistentry> 5481 <term><parameter>addr</parameter></term> 5482 <listitem> 5483 <para> 5484 The memory area 5485 </para> 5486 </listitem> 5487 </varlistentry> 5488 <varlistentry> 5489 <term><parameter>c</parameter></term> 5490 <listitem> 5491 <para> 5492 The byte to search for 5493 </para> 5494 </listitem> 5495 </varlistentry> 5496 <varlistentry> 5497 <term><parameter>size</parameter></term> 5498 <listitem> 5499 <para> 5500 The size of the area. 5501 </para> 5502 </listitem> 5503 </varlistentry> 5504 </variablelist> 5505</refsect1> 5506<refsect1> 5507<title>Description</title> 5508<para> 5509 returns the address of the first occurrence of <parameter>c</parameter>, or 1 byte past 5510 the area if <parameter>c</parameter> is not found 5511</para> 5512</refsect1> 5513</refentry> 5514 5515<refentry id="API-strstr"> 5516<refentryinfo> 5517 <title>LINUX</title> 5518 <productname>Kernel Hackers Manual</productname> 5519 <date>July 2017</date> 5520</refentryinfo> 5521<refmeta> 5522 <refentrytitle><phrase>strstr</phrase></refentrytitle> 5523 <manvolnum>9</manvolnum> 5524 <refmiscinfo class="version">4.1.27</refmiscinfo> 5525</refmeta> 5526<refnamediv> 5527 <refname>strstr</refname> 5528 <refpurpose> 5529 Find the first substring in a <constant>NUL</constant> terminated string 5530 </refpurpose> 5531</refnamediv> 5532<refsynopsisdiv> 5533 <title>Synopsis</title> 5534 <funcsynopsis><funcprototype> 5535 <funcdef>char * <function>strstr </function></funcdef> 5536 <paramdef>const char * <parameter>s1</parameter></paramdef> 5537 <paramdef>const char * <parameter>s2</parameter></paramdef> 5538 </funcprototype></funcsynopsis> 5539</refsynopsisdiv> 5540<refsect1> 5541 <title>Arguments</title> 5542 <variablelist> 5543 <varlistentry> 5544 <term><parameter>s1</parameter></term> 5545 <listitem> 5546 <para> 5547 The string to be searched 5548 </para> 5549 </listitem> 5550 </varlistentry> 5551 <varlistentry> 5552 <term><parameter>s2</parameter></term> 5553 <listitem> 5554 <para> 5555 The string to search for 5556 </para> 5557 </listitem> 5558 </varlistentry> 5559 </variablelist> 5560</refsect1> 5561</refentry> 5562 5563<refentry id="API-strnstr"> 5564<refentryinfo> 5565 <title>LINUX</title> 5566 <productname>Kernel Hackers Manual</productname> 5567 <date>July 2017</date> 5568</refentryinfo> 5569<refmeta> 5570 <refentrytitle><phrase>strnstr</phrase></refentrytitle> 5571 <manvolnum>9</manvolnum> 5572 <refmiscinfo class="version">4.1.27</refmiscinfo> 5573</refmeta> 5574<refnamediv> 5575 <refname>strnstr</refname> 5576 <refpurpose> 5577 Find the first substring in a length-limited string 5578 </refpurpose> 5579</refnamediv> 5580<refsynopsisdiv> 5581 <title>Synopsis</title> 5582 <funcsynopsis><funcprototype> 5583 <funcdef>char * <function>strnstr </function></funcdef> 5584 <paramdef>const char * <parameter>s1</parameter></paramdef> 5585 <paramdef>const char * <parameter>s2</parameter></paramdef> 5586 <paramdef>size_t <parameter>len</parameter></paramdef> 5587 </funcprototype></funcsynopsis> 5588</refsynopsisdiv> 5589<refsect1> 5590 <title>Arguments</title> 5591 <variablelist> 5592 <varlistentry> 5593 <term><parameter>s1</parameter></term> 5594 <listitem> 5595 <para> 5596 The string to be searched 5597 </para> 5598 </listitem> 5599 </varlistentry> 5600 <varlistentry> 5601 <term><parameter>s2</parameter></term> 5602 <listitem> 5603 <para> 5604 The string to search for 5605 </para> 5606 </listitem> 5607 </varlistentry> 5608 <varlistentry> 5609 <term><parameter>len</parameter></term> 5610 <listitem> 5611 <para> 5612 the maximum number of characters to search 5613 </para> 5614 </listitem> 5615 </varlistentry> 5616 </variablelist> 5617</refsect1> 5618</refentry> 5619 5620<refentry id="API-memchr"> 5621<refentryinfo> 5622 <title>LINUX</title> 5623 <productname>Kernel Hackers Manual</productname> 5624 <date>July 2017</date> 5625</refentryinfo> 5626<refmeta> 5627 <refentrytitle><phrase>memchr</phrase></refentrytitle> 5628 <manvolnum>9</manvolnum> 5629 <refmiscinfo class="version">4.1.27</refmiscinfo> 5630</refmeta> 5631<refnamediv> 5632 <refname>memchr</refname> 5633 <refpurpose> 5634 Find a character in an area of memory. 5635 </refpurpose> 5636</refnamediv> 5637<refsynopsisdiv> 5638 <title>Synopsis</title> 5639 <funcsynopsis><funcprototype> 5640 <funcdef>void * <function>memchr </function></funcdef> 5641 <paramdef>const void * <parameter>s</parameter></paramdef> 5642 <paramdef>int <parameter>c</parameter></paramdef> 5643 <paramdef>size_t <parameter>n</parameter></paramdef> 5644 </funcprototype></funcsynopsis> 5645</refsynopsisdiv> 5646<refsect1> 5647 <title>Arguments</title> 5648 <variablelist> 5649 <varlistentry> 5650 <term><parameter>s</parameter></term> 5651 <listitem> 5652 <para> 5653 The memory area 5654 </para> 5655 </listitem> 5656 </varlistentry> 5657 <varlistentry> 5658 <term><parameter>c</parameter></term> 5659 <listitem> 5660 <para> 5661 The byte to search for 5662 </para> 5663 </listitem> 5664 </varlistentry> 5665 <varlistentry> 5666 <term><parameter>n</parameter></term> 5667 <listitem> 5668 <para> 5669 The size of the area. 5670 </para> 5671 </listitem> 5672 </varlistentry> 5673 </variablelist> 5674</refsect1> 5675<refsect1> 5676<title>Description</title> 5677<para> 5678 returns the address of the first occurrence of <parameter>c</parameter>, or <constant>NULL</constant> 5679 if <parameter>c</parameter> is not found 5680</para> 5681</refsect1> 5682</refentry> 5683 5684<refentry id="API-memchr-inv"> 5685<refentryinfo> 5686 <title>LINUX</title> 5687 <productname>Kernel Hackers Manual</productname> 5688 <date>July 2017</date> 5689</refentryinfo> 5690<refmeta> 5691 <refentrytitle><phrase>memchr_inv</phrase></refentrytitle> 5692 <manvolnum>9</manvolnum> 5693 <refmiscinfo class="version">4.1.27</refmiscinfo> 5694</refmeta> 5695<refnamediv> 5696 <refname>memchr_inv</refname> 5697 <refpurpose> 5698 Find an unmatching character in an area of memory. 5699 </refpurpose> 5700</refnamediv> 5701<refsynopsisdiv> 5702 <title>Synopsis</title> 5703 <funcsynopsis><funcprototype> 5704 <funcdef>void * <function>memchr_inv </function></funcdef> 5705 <paramdef>const void * <parameter>start</parameter></paramdef> 5706 <paramdef>int <parameter>c</parameter></paramdef> 5707 <paramdef>size_t <parameter>bytes</parameter></paramdef> 5708 </funcprototype></funcsynopsis> 5709</refsynopsisdiv> 5710<refsect1> 5711 <title>Arguments</title> 5712 <variablelist> 5713 <varlistentry> 5714 <term><parameter>start</parameter></term> 5715 <listitem> 5716 <para> 5717 The memory area 5718 </para> 5719 </listitem> 5720 </varlistentry> 5721 <varlistentry> 5722 <term><parameter>c</parameter></term> 5723 <listitem> 5724 <para> 5725 Find a character other than c 5726 </para> 5727 </listitem> 5728 </varlistentry> 5729 <varlistentry> 5730 <term><parameter>bytes</parameter></term> 5731 <listitem> 5732 <para> 5733 The size of the area. 5734 </para> 5735 </listitem> 5736 </varlistentry> 5737 </variablelist> 5738</refsect1> 5739<refsect1> 5740<title>Description</title> 5741<para> 5742 returns the address of the first character other than <parameter>c</parameter>, or <constant>NULL</constant> 5743 if the whole buffer contains just <parameter>c</parameter>. 5744</para> 5745</refsect1> 5746</refentry> 5747 5748 </sect1> 5749 <sect1><title>Bit Operations</title> 5750<!-- arch/x86/include/asm/bitops.h --> 5751<refentry id="API-set-bit"> 5752<refentryinfo> 5753 <title>LINUX</title> 5754 <productname>Kernel Hackers Manual</productname> 5755 <date>July 2017</date> 5756</refentryinfo> 5757<refmeta> 5758 <refentrytitle><phrase>set_bit</phrase></refentrytitle> 5759 <manvolnum>9</manvolnum> 5760 <refmiscinfo class="version">4.1.27</refmiscinfo> 5761</refmeta> 5762<refnamediv> 5763 <refname>set_bit</refname> 5764 <refpurpose> 5765 Atomically set a bit in memory 5766 </refpurpose> 5767</refnamediv> 5768<refsynopsisdiv> 5769 <title>Synopsis</title> 5770 <funcsynopsis><funcprototype> 5771 <funcdef>void <function>set_bit </function></funcdef> 5772 <paramdef>long <parameter>nr</parameter></paramdef> 5773 <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef> 5774 </funcprototype></funcsynopsis> 5775</refsynopsisdiv> 5776<refsect1> 5777 <title>Arguments</title> 5778 <variablelist> 5779 <varlistentry> 5780 <term><parameter>nr</parameter></term> 5781 <listitem> 5782 <para> 5783 the bit to set 5784 </para> 5785 </listitem> 5786 </varlistentry> 5787 <varlistentry> 5788 <term><parameter>addr</parameter></term> 5789 <listitem> 5790 <para> 5791 the address to start counting from 5792 </para> 5793 </listitem> 5794 </varlistentry> 5795 </variablelist> 5796</refsect1> 5797<refsect1> 5798<title>Description</title> 5799<para> 5800 This function is atomic and may not be reordered. See <function>__set_bit</function> 5801 if you do not require the atomic guarantees. 5802</para> 5803</refsect1> 5804<refsect1> 5805<title>Note</title> 5806<para> 5807 there are no guarantees that this function will not be reordered 5808 on non x86 architectures, so if you are writing portable code, 5809 make sure not to rely on its reordering guarantees. 5810 </para><para> 5811 5812 Note that <parameter>nr</parameter> may be almost arbitrarily large; this function is not 5813 restricted to acting on a single-word quantity. 5814</para> 5815</refsect1> 5816</refentry> 5817 5818<refentry id="API---set-bit"> 5819<refentryinfo> 5820 <title>LINUX</title> 5821 <productname>Kernel Hackers Manual</productname> 5822 <date>July 2017</date> 5823</refentryinfo> 5824<refmeta> 5825 <refentrytitle><phrase>__set_bit</phrase></refentrytitle> 5826 <manvolnum>9</manvolnum> 5827 <refmiscinfo class="version">4.1.27</refmiscinfo> 5828</refmeta> 5829<refnamediv> 5830 <refname>__set_bit</refname> 5831 <refpurpose> 5832 Set a bit in memory 5833 </refpurpose> 5834</refnamediv> 5835<refsynopsisdiv> 5836 <title>Synopsis</title> 5837 <funcsynopsis><funcprototype> 5838 <funcdef>void <function>__set_bit </function></funcdef> 5839 <paramdef>long <parameter>nr</parameter></paramdef> 5840 <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef> 5841 </funcprototype></funcsynopsis> 5842</refsynopsisdiv> 5843<refsect1> 5844 <title>Arguments</title> 5845 <variablelist> 5846 <varlistentry> 5847 <term><parameter>nr</parameter></term> 5848 <listitem> 5849 <para> 5850 the bit to set 5851 </para> 5852 </listitem> 5853 </varlistentry> 5854 <varlistentry> 5855 <term><parameter>addr</parameter></term> 5856 <listitem> 5857 <para> 5858 the address to start counting from 5859 </para> 5860 </listitem> 5861 </varlistentry> 5862 </variablelist> 5863</refsect1> 5864<refsect1> 5865<title>Description</title> 5866<para> 5867 Unlike <function>set_bit</function>, this function is non-atomic and may be reordered. 5868 If it's called on the same region of memory simultaneously, the effect 5869 may be that only one operation succeeds. 5870</para> 5871</refsect1> 5872</refentry> 5873 5874<refentry id="API-clear-bit"> 5875<refentryinfo> 5876 <title>LINUX</title> 5877 <productname>Kernel Hackers Manual</productname> 5878 <date>July 2017</date> 5879</refentryinfo> 5880<refmeta> 5881 <refentrytitle><phrase>clear_bit</phrase></refentrytitle> 5882 <manvolnum>9</manvolnum> 5883 <refmiscinfo class="version">4.1.27</refmiscinfo> 5884</refmeta> 5885<refnamediv> 5886 <refname>clear_bit</refname> 5887 <refpurpose> 5888 Clears a bit in memory 5889 </refpurpose> 5890</refnamediv> 5891<refsynopsisdiv> 5892 <title>Synopsis</title> 5893 <funcsynopsis><funcprototype> 5894 <funcdef>void <function>clear_bit </function></funcdef> 5895 <paramdef>long <parameter>nr</parameter></paramdef> 5896 <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef> 5897 </funcprototype></funcsynopsis> 5898</refsynopsisdiv> 5899<refsect1> 5900 <title>Arguments</title> 5901 <variablelist> 5902 <varlistentry> 5903 <term><parameter>nr</parameter></term> 5904 <listitem> 5905 <para> 5906 Bit to clear 5907 </para> 5908 </listitem> 5909 </varlistentry> 5910 <varlistentry> 5911 <term><parameter>addr</parameter></term> 5912 <listitem> 5913 <para> 5914 Address to start counting from 5915 </para> 5916 </listitem> 5917 </varlistentry> 5918 </variablelist> 5919</refsect1> 5920<refsect1> 5921<title>Description</title> 5922<para> 5923 <function>clear_bit</function> is atomic and may not be reordered. However, it does 5924 not contain a memory barrier, so if it is used for locking purposes, 5925 you should call <function>smp_mb__before_atomic</function> and/or <function>smp_mb__after_atomic</function> 5926 in order to ensure changes are visible on other processors. 5927</para> 5928</refsect1> 5929</refentry> 5930 5931<refentry id="API---change-bit"> 5932<refentryinfo> 5933 <title>LINUX</title> 5934 <productname>Kernel Hackers Manual</productname> 5935 <date>July 2017</date> 5936</refentryinfo> 5937<refmeta> 5938 <refentrytitle><phrase>__change_bit</phrase></refentrytitle> 5939 <manvolnum>9</manvolnum> 5940 <refmiscinfo class="version">4.1.27</refmiscinfo> 5941</refmeta> 5942<refnamediv> 5943 <refname>__change_bit</refname> 5944 <refpurpose> 5945 Toggle a bit in memory 5946 </refpurpose> 5947</refnamediv> 5948<refsynopsisdiv> 5949 <title>Synopsis</title> 5950 <funcsynopsis><funcprototype> 5951 <funcdef>void <function>__change_bit </function></funcdef> 5952 <paramdef>long <parameter>nr</parameter></paramdef> 5953 <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef> 5954 </funcprototype></funcsynopsis> 5955</refsynopsisdiv> 5956<refsect1> 5957 <title>Arguments</title> 5958 <variablelist> 5959 <varlistentry> 5960 <term><parameter>nr</parameter></term> 5961 <listitem> 5962 <para> 5963 the bit to change 5964 </para> 5965 </listitem> 5966 </varlistentry> 5967 <varlistentry> 5968 <term><parameter>addr</parameter></term> 5969 <listitem> 5970 <para> 5971 the address to start counting from 5972 </para> 5973 </listitem> 5974 </varlistentry> 5975 </variablelist> 5976</refsect1> 5977<refsect1> 5978<title>Description</title> 5979<para> 5980 Unlike <function>change_bit</function>, this function is non-atomic and may be reordered. 5981 If it's called on the same region of memory simultaneously, the effect 5982 may be that only one operation succeeds. 5983</para> 5984</refsect1> 5985</refentry> 5986 5987<refentry id="API-change-bit"> 5988<refentryinfo> 5989 <title>LINUX</title> 5990 <productname>Kernel Hackers Manual</productname> 5991 <date>July 2017</date> 5992</refentryinfo> 5993<refmeta> 5994 <refentrytitle><phrase>change_bit</phrase></refentrytitle> 5995 <manvolnum>9</manvolnum> 5996 <refmiscinfo class="version">4.1.27</refmiscinfo> 5997</refmeta> 5998<refnamediv> 5999 <refname>change_bit</refname> 6000 <refpurpose> 6001 Toggle a bit in memory 6002 </refpurpose> 6003</refnamediv> 6004<refsynopsisdiv> 6005 <title>Synopsis</title> 6006 <funcsynopsis><funcprototype> 6007 <funcdef>void <function>change_bit </function></funcdef> 6008 <paramdef>long <parameter>nr</parameter></paramdef> 6009 <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef> 6010 </funcprototype></funcsynopsis> 6011</refsynopsisdiv> 6012<refsect1> 6013 <title>Arguments</title> 6014 <variablelist> 6015 <varlistentry> 6016 <term><parameter>nr</parameter></term> 6017 <listitem> 6018 <para> 6019 Bit to change 6020 </para> 6021 </listitem> 6022 </varlistentry> 6023 <varlistentry> 6024 <term><parameter>addr</parameter></term> 6025 <listitem> 6026 <para> 6027 Address to start counting from 6028 </para> 6029 </listitem> 6030 </varlistentry> 6031 </variablelist> 6032</refsect1> 6033<refsect1> 6034<title>Description</title> 6035<para> 6036 <function>change_bit</function> is atomic and may not be reordered. 6037 Note that <parameter>nr</parameter> may be almost arbitrarily large; this function is not 6038 restricted to acting on a single-word quantity. 6039</para> 6040</refsect1> 6041</refentry> 6042 6043<refentry id="API-test-and-set-bit"> 6044<refentryinfo> 6045 <title>LINUX</title> 6046 <productname>Kernel Hackers Manual</productname> 6047 <date>July 2017</date> 6048</refentryinfo> 6049<refmeta> 6050 <refentrytitle><phrase>test_and_set_bit</phrase></refentrytitle> 6051 <manvolnum>9</manvolnum> 6052 <refmiscinfo class="version">4.1.27</refmiscinfo> 6053</refmeta> 6054<refnamediv> 6055 <refname>test_and_set_bit</refname> 6056 <refpurpose> 6057 Set a bit and return its old value 6058 </refpurpose> 6059</refnamediv> 6060<refsynopsisdiv> 6061 <title>Synopsis</title> 6062 <funcsynopsis><funcprototype> 6063 <funcdef>int <function>test_and_set_bit </function></funcdef> 6064 <paramdef>long <parameter>nr</parameter></paramdef> 6065 <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef> 6066 </funcprototype></funcsynopsis> 6067</refsynopsisdiv> 6068<refsect1> 6069 <title>Arguments</title> 6070 <variablelist> 6071 <varlistentry> 6072 <term><parameter>nr</parameter></term> 6073 <listitem> 6074 <para> 6075 Bit to set 6076 </para> 6077 </listitem> 6078 </varlistentry> 6079 <varlistentry> 6080 <term><parameter>addr</parameter></term> 6081 <listitem> 6082 <para> 6083 Address to count from 6084 </para> 6085 </listitem> 6086 </varlistentry> 6087 </variablelist> 6088</refsect1> 6089<refsect1> 6090<title>Description</title> 6091<para> 6092 This operation is atomic and cannot be reordered. 6093 It also implies a memory barrier. 6094</para> 6095</refsect1> 6096</refentry> 6097 6098<refentry id="API-test-and-set-bit-lock"> 6099<refentryinfo> 6100 <title>LINUX</title> 6101 <productname>Kernel Hackers Manual</productname> 6102 <date>July 2017</date> 6103</refentryinfo> 6104<refmeta> 6105 <refentrytitle><phrase>test_and_set_bit_lock</phrase></refentrytitle> 6106 <manvolnum>9</manvolnum> 6107 <refmiscinfo class="version">4.1.27</refmiscinfo> 6108</refmeta> 6109<refnamediv> 6110 <refname>test_and_set_bit_lock</refname> 6111 <refpurpose> 6112 Set a bit and return its old value for lock 6113 </refpurpose> 6114</refnamediv> 6115<refsynopsisdiv> 6116 <title>Synopsis</title> 6117 <funcsynopsis><funcprototype> 6118 <funcdef>int <function>test_and_set_bit_lock </function></funcdef> 6119 <paramdef>long <parameter>nr</parameter></paramdef> 6120 <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef> 6121 </funcprototype></funcsynopsis> 6122</refsynopsisdiv> 6123<refsect1> 6124 <title>Arguments</title> 6125 <variablelist> 6126 <varlistentry> 6127 <term><parameter>nr</parameter></term> 6128 <listitem> 6129 <para> 6130 Bit to set 6131 </para> 6132 </listitem> 6133 </varlistentry> 6134 <varlistentry> 6135 <term><parameter>addr</parameter></term> 6136 <listitem> 6137 <para> 6138 Address to count from 6139 </para> 6140 </listitem> 6141 </varlistentry> 6142 </variablelist> 6143</refsect1> 6144<refsect1> 6145<title>Description</title> 6146<para> 6147 This is the same as test_and_set_bit on x86. 6148</para> 6149</refsect1> 6150</refentry> 6151 6152<refentry id="API---test-and-set-bit"> 6153<refentryinfo> 6154 <title>LINUX</title> 6155 <productname>Kernel Hackers Manual</productname> 6156 <date>July 2017</date> 6157</refentryinfo> 6158<refmeta> 6159 <refentrytitle><phrase>__test_and_set_bit</phrase></refentrytitle> 6160 <manvolnum>9</manvolnum> 6161 <refmiscinfo class="version">4.1.27</refmiscinfo> 6162</refmeta> 6163<refnamediv> 6164 <refname>__test_and_set_bit</refname> 6165 <refpurpose> 6166 Set a bit and return its old value 6167 </refpurpose> 6168</refnamediv> 6169<refsynopsisdiv> 6170 <title>Synopsis</title> 6171 <funcsynopsis><funcprototype> 6172 <funcdef>int <function>__test_and_set_bit </function></funcdef> 6173 <paramdef>long <parameter>nr</parameter></paramdef> 6174 <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef> 6175 </funcprototype></funcsynopsis> 6176</refsynopsisdiv> 6177<refsect1> 6178 <title>Arguments</title> 6179 <variablelist> 6180 <varlistentry> 6181 <term><parameter>nr</parameter></term> 6182 <listitem> 6183 <para> 6184 Bit to set 6185 </para> 6186 </listitem> 6187 </varlistentry> 6188 <varlistentry> 6189 <term><parameter>addr</parameter></term> 6190 <listitem> 6191 <para> 6192 Address to count from 6193 </para> 6194 </listitem> 6195 </varlistentry> 6196 </variablelist> 6197</refsect1> 6198<refsect1> 6199<title>Description</title> 6200<para> 6201 This operation is non-atomic and can be reordered. 6202 If two examples of this operation race, one can appear to succeed 6203 but actually fail. You must protect multiple accesses with a lock. 6204</para> 6205</refsect1> 6206</refentry> 6207 6208<refentry id="API-test-and-clear-bit"> 6209<refentryinfo> 6210 <title>LINUX</title> 6211 <productname>Kernel Hackers Manual</productname> 6212 <date>July 2017</date> 6213</refentryinfo> 6214<refmeta> 6215 <refentrytitle><phrase>test_and_clear_bit</phrase></refentrytitle> 6216 <manvolnum>9</manvolnum> 6217 <refmiscinfo class="version">4.1.27</refmiscinfo> 6218</refmeta> 6219<refnamediv> 6220 <refname>test_and_clear_bit</refname> 6221 <refpurpose> 6222 Clear a bit and return its old value 6223 </refpurpose> 6224</refnamediv> 6225<refsynopsisdiv> 6226 <title>Synopsis</title> 6227 <funcsynopsis><funcprototype> 6228 <funcdef>int <function>test_and_clear_bit </function></funcdef> 6229 <paramdef>long <parameter>nr</parameter></paramdef> 6230 <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef> 6231 </funcprototype></funcsynopsis> 6232</refsynopsisdiv> 6233<refsect1> 6234 <title>Arguments</title> 6235 <variablelist> 6236 <varlistentry> 6237 <term><parameter>nr</parameter></term> 6238 <listitem> 6239 <para> 6240 Bit to clear 6241 </para> 6242 </listitem> 6243 </varlistentry> 6244 <varlistentry> 6245 <term><parameter>addr</parameter></term> 6246 <listitem> 6247 <para> 6248 Address to count from 6249 </para> 6250 </listitem> 6251 </varlistentry> 6252 </variablelist> 6253</refsect1> 6254<refsect1> 6255<title>Description</title> 6256<para> 6257 This operation is atomic and cannot be reordered. 6258 It also implies a memory barrier. 6259</para> 6260</refsect1> 6261</refentry> 6262 6263<refentry id="API---test-and-clear-bit"> 6264<refentryinfo> 6265 <title>LINUX</title> 6266 <productname>Kernel Hackers Manual</productname> 6267 <date>July 2017</date> 6268</refentryinfo> 6269<refmeta> 6270 <refentrytitle><phrase>__test_and_clear_bit</phrase></refentrytitle> 6271 <manvolnum>9</manvolnum> 6272 <refmiscinfo class="version">4.1.27</refmiscinfo> 6273</refmeta> 6274<refnamediv> 6275 <refname>__test_and_clear_bit</refname> 6276 <refpurpose> 6277 Clear a bit and return its old value 6278 </refpurpose> 6279</refnamediv> 6280<refsynopsisdiv> 6281 <title>Synopsis</title> 6282 <funcsynopsis><funcprototype> 6283 <funcdef>int <function>__test_and_clear_bit </function></funcdef> 6284 <paramdef>long <parameter>nr</parameter></paramdef> 6285 <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef> 6286 </funcprototype></funcsynopsis> 6287</refsynopsisdiv> 6288<refsect1> 6289 <title>Arguments</title> 6290 <variablelist> 6291 <varlistentry> 6292 <term><parameter>nr</parameter></term> 6293 <listitem> 6294 <para> 6295 Bit to clear 6296 </para> 6297 </listitem> 6298 </varlistentry> 6299 <varlistentry> 6300 <term><parameter>addr</parameter></term> 6301 <listitem> 6302 <para> 6303 Address to count from 6304 </para> 6305 </listitem> 6306 </varlistentry> 6307 </variablelist> 6308</refsect1> 6309<refsect1> 6310<title>Description</title> 6311<para> 6312 This operation is non-atomic and can be reordered. 6313 If two examples of this operation race, one can appear to succeed 6314 but actually fail. You must protect multiple accesses with a lock. 6315</para> 6316</refsect1> 6317<refsect1> 6318<title>Note</title> 6319<para> 6320 the operation is performed atomically with respect to 6321 the local CPU, but not other CPUs. Portable code should not 6322 rely on this behaviour. 6323 KVM relies on this behaviour on x86 for modifying memory that is also 6324</para> 6325</refsect1> 6326<refsect1> 6327<title>accessed from a hypervisor on the same CPU if running in a VM</title> 6328<para> 6329 don't change 6330 this without also updating arch/x86/kernel/kvm.c 6331</para> 6332</refsect1> 6333</refentry> 6334 6335<refentry id="API-test-and-change-bit"> 6336<refentryinfo> 6337 <title>LINUX</title> 6338 <productname>Kernel Hackers Manual</productname> 6339 <date>July 2017</date> 6340</refentryinfo> 6341<refmeta> 6342 <refentrytitle><phrase>test_and_change_bit</phrase></refentrytitle> 6343 <manvolnum>9</manvolnum> 6344 <refmiscinfo class="version">4.1.27</refmiscinfo> 6345</refmeta> 6346<refnamediv> 6347 <refname>test_and_change_bit</refname> 6348 <refpurpose> 6349 Change a bit and return its old value 6350 </refpurpose> 6351</refnamediv> 6352<refsynopsisdiv> 6353 <title>Synopsis</title> 6354 <funcsynopsis><funcprototype> 6355 <funcdef>int <function>test_and_change_bit </function></funcdef> 6356 <paramdef>long <parameter>nr</parameter></paramdef> 6357 <paramdef>volatile unsigned long * <parameter>addr</parameter></paramdef> 6358 </funcprototype></funcsynopsis> 6359</refsynopsisdiv> 6360<refsect1> 6361 <title>Arguments</title> 6362 <variablelist> 6363 <varlistentry> 6364 <term><parameter>nr</parameter></term> 6365 <listitem> 6366 <para> 6367 Bit to change 6368 </para> 6369 </listitem> 6370 </varlistentry> 6371 <varlistentry> 6372 <term><parameter>addr</parameter></term> 6373 <listitem> 6374 <para> 6375 Address to count from 6376 </para> 6377 </listitem> 6378 </varlistentry> 6379 </variablelist> 6380</refsect1> 6381<refsect1> 6382<title>Description</title> 6383<para> 6384 This operation is atomic and cannot be reordered. 6385 It also implies a memory barrier. 6386</para> 6387</refsect1> 6388</refentry> 6389 6390<refentry id="API-test-bit"> 6391<refentryinfo> 6392 <title>LINUX</title> 6393 <productname>Kernel Hackers Manual</productname> 6394 <date>July 2017</date> 6395</refentryinfo> 6396<refmeta> 6397 <refentrytitle><phrase>test_bit</phrase></refentrytitle> 6398 <manvolnum>9</manvolnum> 6399 <refmiscinfo class="version">4.1.27</refmiscinfo> 6400</refmeta> 6401<refnamediv> 6402 <refname>test_bit</refname> 6403 <refpurpose> 6404 Determine whether a bit is set 6405 </refpurpose> 6406</refnamediv> 6407<refsynopsisdiv> 6408 <title>Synopsis</title> 6409 <funcsynopsis><funcprototype> 6410 <funcdef>int <function>test_bit </function></funcdef> 6411 <paramdef>int <parameter>nr</parameter></paramdef> 6412 <paramdef>const volatile unsigned long * <parameter>addr</parameter></paramdef> 6413 </funcprototype></funcsynopsis> 6414</refsynopsisdiv> 6415<refsect1> 6416 <title>Arguments</title> 6417 <variablelist> 6418 <varlistentry> 6419 <term><parameter>nr</parameter></term> 6420 <listitem> 6421 <para> 6422 bit number to test 6423 </para> 6424 </listitem> 6425 </varlistentry> 6426 <varlistentry> 6427 <term><parameter>addr</parameter></term> 6428 <listitem> 6429 <para> 6430 Address to start counting from 6431 </para> 6432 </listitem> 6433 </varlistentry> 6434 </variablelist> 6435</refsect1> 6436</refentry> 6437 6438<refentry id="API---ffs"> 6439<refentryinfo> 6440 <title>LINUX</title> 6441 <productname>Kernel Hackers Manual</productname> 6442 <date>July 2017</date> 6443</refentryinfo> 6444<refmeta> 6445 <refentrytitle><phrase>__ffs</phrase></refentrytitle> 6446 <manvolnum>9</manvolnum> 6447 <refmiscinfo class="version">4.1.27</refmiscinfo> 6448</refmeta> 6449<refnamediv> 6450 <refname>__ffs</refname> 6451 <refpurpose> 6452 find first set bit in word 6453 </refpurpose> 6454</refnamediv> 6455<refsynopsisdiv> 6456 <title>Synopsis</title> 6457 <funcsynopsis><funcprototype> 6458 <funcdef>unsigned long <function>__ffs </function></funcdef> 6459 <paramdef>unsigned long <parameter>word</parameter></paramdef> 6460 </funcprototype></funcsynopsis> 6461</refsynopsisdiv> 6462<refsect1> 6463 <title>Arguments</title> 6464 <variablelist> 6465 <varlistentry> 6466 <term><parameter>word</parameter></term> 6467 <listitem> 6468 <para> 6469 The word to search 6470 </para> 6471 </listitem> 6472 </varlistentry> 6473 </variablelist> 6474</refsect1> 6475<refsect1> 6476<title>Description</title> 6477<para> 6478 Undefined if no bit exists, so code should check against 0 first. 6479</para> 6480</refsect1> 6481</refentry> 6482 6483<refentry id="API-ffz"> 6484<refentryinfo> 6485 <title>LINUX</title> 6486 <productname>Kernel Hackers Manual</productname> 6487 <date>July 2017</date> 6488</refentryinfo> 6489<refmeta> 6490 <refentrytitle><phrase>ffz</phrase></refentrytitle> 6491 <manvolnum>9</manvolnum> 6492 <refmiscinfo class="version">4.1.27</refmiscinfo> 6493</refmeta> 6494<refnamediv> 6495 <refname>ffz</refname> 6496 <refpurpose> 6497 find first zero bit in word 6498 </refpurpose> 6499</refnamediv> 6500<refsynopsisdiv> 6501 <title>Synopsis</title> 6502 <funcsynopsis><funcprototype> 6503 <funcdef>unsigned long <function>ffz </function></funcdef> 6504 <paramdef>unsigned long <parameter>word</parameter></paramdef> 6505 </funcprototype></funcsynopsis> 6506</refsynopsisdiv> 6507<refsect1> 6508 <title>Arguments</title> 6509 <variablelist> 6510 <varlistentry> 6511 <term><parameter>word</parameter></term> 6512 <listitem> 6513 <para> 6514 The word to search 6515 </para> 6516 </listitem> 6517 </varlistentry> 6518 </variablelist> 6519</refsect1> 6520<refsect1> 6521<title>Description</title> 6522<para> 6523 Undefined if no zero exists, so code should check against ~0UL first. 6524</para> 6525</refsect1> 6526</refentry> 6527 6528<refentry id="API-ffs"> 6529<refentryinfo> 6530 <title>LINUX</title> 6531 <productname>Kernel Hackers Manual</productname> 6532 <date>July 2017</date> 6533</refentryinfo> 6534<refmeta> 6535 <refentrytitle><phrase>ffs</phrase></refentrytitle> 6536 <manvolnum>9</manvolnum> 6537 <refmiscinfo class="version">4.1.27</refmiscinfo> 6538</refmeta> 6539<refnamediv> 6540 <refname>ffs</refname> 6541 <refpurpose> 6542 find first set bit in word 6543 </refpurpose> 6544</refnamediv> 6545<refsynopsisdiv> 6546 <title>Synopsis</title> 6547 <funcsynopsis><funcprototype> 6548 <funcdef>int <function>ffs </function></funcdef> 6549 <paramdef>int <parameter>x</parameter></paramdef> 6550 </funcprototype></funcsynopsis> 6551</refsynopsisdiv> 6552<refsect1> 6553 <title>Arguments</title> 6554 <variablelist> 6555 <varlistentry> 6556 <term><parameter>x</parameter></term> 6557 <listitem> 6558 <para> 6559 the word to search 6560 </para> 6561 </listitem> 6562 </varlistentry> 6563 </variablelist> 6564</refsect1> 6565<refsect1> 6566<title>Description</title> 6567<para> 6568 This is defined the same way as the libc and compiler builtin ffs 6569 routines, therefore differs in spirit from the other bitops. 6570 </para><para> 6571 6572 ffs(value) returns 0 if value is 0 or the position of the first 6573 set bit if value is nonzero. The first (least significant) bit 6574 is at position 1. 6575</para> 6576</refsect1> 6577</refentry> 6578 6579<refentry id="API-fls"> 6580<refentryinfo> 6581 <title>LINUX</title> 6582 <productname>Kernel Hackers Manual</productname> 6583 <date>July 2017</date> 6584</refentryinfo> 6585<refmeta> 6586 <refentrytitle><phrase>fls</phrase></refentrytitle> 6587 <manvolnum>9</manvolnum> 6588 <refmiscinfo class="version">4.1.27</refmiscinfo> 6589</refmeta> 6590<refnamediv> 6591 <refname>fls</refname> 6592 <refpurpose> 6593 find last set bit in word 6594 </refpurpose> 6595</refnamediv> 6596<refsynopsisdiv> 6597 <title>Synopsis</title> 6598 <funcsynopsis><funcprototype> 6599 <funcdef>int <function>fls </function></funcdef> 6600 <paramdef>int <parameter>x</parameter></paramdef> 6601 </funcprototype></funcsynopsis> 6602</refsynopsisdiv> 6603<refsect1> 6604 <title>Arguments</title> 6605 <variablelist> 6606 <varlistentry> 6607 <term><parameter>x</parameter></term> 6608 <listitem> 6609 <para> 6610 the word to search 6611 </para> 6612 </listitem> 6613 </varlistentry> 6614 </variablelist> 6615</refsect1> 6616<refsect1> 6617<title>Description</title> 6618<para> 6619 This is defined in a similar way as the libc and compiler builtin 6620 ffs, but returns the position of the most significant set bit. 6621 </para><para> 6622 6623 fls(value) returns 0 if value is 0 or the position of the last 6624 set bit if value is nonzero. The last (most significant) bit is 6625 at position 32. 6626</para> 6627</refsect1> 6628</refentry> 6629 6630<refentry id="API-fls64"> 6631<refentryinfo> 6632 <title>LINUX</title> 6633 <productname>Kernel Hackers Manual</productname> 6634 <date>July 2017</date> 6635</refentryinfo> 6636<refmeta> 6637 <refentrytitle><phrase>fls64</phrase></refentrytitle> 6638 <manvolnum>9</manvolnum> 6639 <refmiscinfo class="version">4.1.27</refmiscinfo> 6640</refmeta> 6641<refnamediv> 6642 <refname>fls64</refname> 6643 <refpurpose> 6644 find last set bit in a 64-bit word 6645 </refpurpose> 6646</refnamediv> 6647<refsynopsisdiv> 6648 <title>Synopsis</title> 6649 <funcsynopsis><funcprototype> 6650 <funcdef>int <function>fls64 </function></funcdef> 6651 <paramdef>__u64 <parameter>x</parameter></paramdef> 6652 </funcprototype></funcsynopsis> 6653</refsynopsisdiv> 6654<refsect1> 6655 <title>Arguments</title> 6656 <variablelist> 6657 <varlistentry> 6658 <term><parameter>x</parameter></term> 6659 <listitem> 6660 <para> 6661 the word to search 6662 </para> 6663 </listitem> 6664 </varlistentry> 6665 </variablelist> 6666</refsect1> 6667<refsect1> 6668<title>Description</title> 6669<para> 6670 This is defined in a similar way as the libc and compiler builtin 6671 ffsll, but returns the position of the most significant set bit. 6672 </para><para> 6673 6674 fls64(value) returns 0 if value is 0 or the position of the last 6675 set bit if value is nonzero. The last (most significant) bit is 6676 at position 64. 6677</para> 6678</refsect1> 6679</refentry> 6680 6681 </sect1> 6682 </chapter> 6683 6684 <chapter id="kernel-lib"> 6685 <title>Basic Kernel Library Functions</title> 6686 6687 <para> 6688 The Linux kernel provides more basic utility functions. 6689 </para> 6690 6691 <sect1><title>Bitmap Operations</title> 6692<!-- lib/bitmap.c --> 6693<refentry id="API---bitmap-shift-right"> 6694<refentryinfo> 6695 <title>LINUX</title> 6696 <productname>Kernel Hackers Manual</productname> 6697 <date>July 2017</date> 6698</refentryinfo> 6699<refmeta> 6700 <refentrytitle><phrase>__bitmap_shift_right</phrase></refentrytitle> 6701 <manvolnum>9</manvolnum> 6702 <refmiscinfo class="version">4.1.27</refmiscinfo> 6703</refmeta> 6704<refnamediv> 6705 <refname>__bitmap_shift_right</refname> 6706 <refpurpose> 6707 logical right shift of the bits in a bitmap 6708 </refpurpose> 6709</refnamediv> 6710<refsynopsisdiv> 6711 <title>Synopsis</title> 6712 <funcsynopsis><funcprototype> 6713 <funcdef>void <function>__bitmap_shift_right </function></funcdef> 6714 <paramdef>unsigned long * <parameter>dst</parameter></paramdef> 6715 <paramdef>const unsigned long * <parameter>src</parameter></paramdef> 6716 <paramdef>unsigned <parameter>shift</parameter></paramdef> 6717 <paramdef>unsigned <parameter>nbits</parameter></paramdef> 6718 </funcprototype></funcsynopsis> 6719</refsynopsisdiv> 6720<refsect1> 6721 <title>Arguments</title> 6722 <variablelist> 6723 <varlistentry> 6724 <term><parameter>dst</parameter></term> 6725 <listitem> 6726 <para> 6727 destination bitmap 6728 </para> 6729 </listitem> 6730 </varlistentry> 6731 <varlistentry> 6732 <term><parameter>src</parameter></term> 6733 <listitem> 6734 <para> 6735 source bitmap 6736 </para> 6737 </listitem> 6738 </varlistentry> 6739 <varlistentry> 6740 <term><parameter>shift</parameter></term> 6741 <listitem> 6742 <para> 6743 shift by this many bits 6744 </para> 6745 </listitem> 6746 </varlistentry> 6747 <varlistentry> 6748 <term><parameter>nbits</parameter></term> 6749 <listitem> 6750 <para> 6751 bitmap size, in bits 6752 </para> 6753 </listitem> 6754 </varlistentry> 6755 </variablelist> 6756</refsect1> 6757<refsect1> 6758<title>Description</title> 6759<para> 6760 Shifting right (dividing) means moving bits in the MS -> LS bit 6761 direction. Zeros are fed into the vacated MS positions and the 6762 LS bits shifted off the bottom are lost. 6763</para> 6764</refsect1> 6765</refentry> 6766 6767<refentry id="API---bitmap-shift-left"> 6768<refentryinfo> 6769 <title>LINUX</title> 6770 <productname>Kernel Hackers Manual</productname> 6771 <date>July 2017</date> 6772</refentryinfo> 6773<refmeta> 6774 <refentrytitle><phrase>__bitmap_shift_left</phrase></refentrytitle> 6775 <manvolnum>9</manvolnum> 6776 <refmiscinfo class="version">4.1.27</refmiscinfo> 6777</refmeta> 6778<refnamediv> 6779 <refname>__bitmap_shift_left</refname> 6780 <refpurpose> 6781 logical left shift of the bits in a bitmap 6782 </refpurpose> 6783</refnamediv> 6784<refsynopsisdiv> 6785 <title>Synopsis</title> 6786 <funcsynopsis><funcprototype> 6787 <funcdef>void <function>__bitmap_shift_left </function></funcdef> 6788 <paramdef>unsigned long * <parameter>dst</parameter></paramdef> 6789 <paramdef>const unsigned long * <parameter>src</parameter></paramdef> 6790 <paramdef>unsigned int <parameter>shift</parameter></paramdef> 6791 <paramdef>unsigned int <parameter>nbits</parameter></paramdef> 6792 </funcprototype></funcsynopsis> 6793</refsynopsisdiv> 6794<refsect1> 6795 <title>Arguments</title> 6796 <variablelist> 6797 <varlistentry> 6798 <term><parameter>dst</parameter></term> 6799 <listitem> 6800 <para> 6801 destination bitmap 6802 </para> 6803 </listitem> 6804 </varlistentry> 6805 <varlistentry> 6806 <term><parameter>src</parameter></term> 6807 <listitem> 6808 <para> 6809 source bitmap 6810 </para> 6811 </listitem> 6812 </varlistentry> 6813 <varlistentry> 6814 <term><parameter>shift</parameter></term> 6815 <listitem> 6816 <para> 6817 shift by this many bits 6818 </para> 6819 </listitem> 6820 </varlistentry> 6821 <varlistentry> 6822 <term><parameter>nbits</parameter></term> 6823 <listitem> 6824 <para> 6825 bitmap size, in bits 6826 </para> 6827 </listitem> 6828 </varlistentry> 6829 </variablelist> 6830</refsect1> 6831<refsect1> 6832<title>Description</title> 6833<para> 6834 Shifting left (multiplying) means moving bits in the LS -> MS 6835 direction. Zeros are fed into the vacated LS bit positions 6836 and those MS bits shifted off the top are lost. 6837</para> 6838</refsect1> 6839</refentry> 6840 6841<refentry id="API-bitmap-find-next-zero-area-off"> 6842<refentryinfo> 6843 <title>LINUX</title> 6844 <productname>Kernel Hackers Manual</productname> 6845 <date>July 2017</date> 6846</refentryinfo> 6847<refmeta> 6848 <refentrytitle><phrase>bitmap_find_next_zero_area_off</phrase></refentrytitle> 6849 <manvolnum>9</manvolnum> 6850 <refmiscinfo class="version">4.1.27</refmiscinfo> 6851</refmeta> 6852<refnamediv> 6853 <refname>bitmap_find_next_zero_area_off</refname> 6854 <refpurpose> 6855 find a contiguous aligned zero area 6856 </refpurpose> 6857</refnamediv> 6858<refsynopsisdiv> 6859 <title>Synopsis</title> 6860 <funcsynopsis><funcprototype> 6861 <funcdef>unsigned long <function>bitmap_find_next_zero_area_off </function></funcdef> 6862 <paramdef>unsigned long * <parameter>map</parameter></paramdef> 6863 <paramdef>unsigned long <parameter>size</parameter></paramdef> 6864 <paramdef>unsigned long <parameter>start</parameter></paramdef> 6865 <paramdef>unsigned int <parameter>nr</parameter></paramdef> 6866 <paramdef>unsigned long <parameter>align_mask</parameter></paramdef> 6867 <paramdef>unsigned long <parameter>align_offset</parameter></paramdef> 6868 </funcprototype></funcsynopsis> 6869</refsynopsisdiv> 6870<refsect1> 6871 <title>Arguments</title> 6872 <variablelist> 6873 <varlistentry> 6874 <term><parameter>map</parameter></term> 6875 <listitem> 6876 <para> 6877 The address to base the search on 6878 </para> 6879 </listitem> 6880 </varlistentry> 6881 <varlistentry> 6882 <term><parameter>size</parameter></term> 6883 <listitem> 6884 <para> 6885 The bitmap size in bits 6886 </para> 6887 </listitem> 6888 </varlistentry> 6889 <varlistentry> 6890 <term><parameter>start</parameter></term> 6891 <listitem> 6892 <para> 6893 The bitnumber to start searching at 6894 </para> 6895 </listitem> 6896 </varlistentry> 6897 <varlistentry> 6898 <term><parameter>nr</parameter></term> 6899 <listitem> 6900 <para> 6901 The number of zeroed bits we're looking for 6902 </para> 6903 </listitem> 6904 </varlistentry> 6905 <varlistentry> 6906 <term><parameter>align_mask</parameter></term> 6907 <listitem> 6908 <para> 6909 Alignment mask for zero area 6910 </para> 6911 </listitem> 6912 </varlistentry> 6913 <varlistentry> 6914 <term><parameter>align_offset</parameter></term> 6915 <listitem> 6916 <para> 6917 Alignment offset for zero area. 6918 </para> 6919 </listitem> 6920 </varlistentry> 6921 </variablelist> 6922</refsect1> 6923<refsect1> 6924<title>Description</title> 6925<para> 6926 The <parameter>align_mask</parameter> should be one less than a power of 2; the effect is that 6927 the bit offset of all zero areas this function finds plus <parameter>align_offset</parameter> 6928 is multiple of that power of 2. 6929</para> 6930</refsect1> 6931</refentry> 6932 6933<refentry id="API---bitmap-parse"> 6934<refentryinfo> 6935 <title>LINUX</title> 6936 <productname>Kernel Hackers Manual</productname> 6937 <date>July 2017</date> 6938</refentryinfo> 6939<refmeta> 6940 <refentrytitle><phrase>__bitmap_parse</phrase></refentrytitle> 6941 <manvolnum>9</manvolnum> 6942 <refmiscinfo class="version">4.1.27</refmiscinfo> 6943</refmeta> 6944<refnamediv> 6945 <refname>__bitmap_parse</refname> 6946 <refpurpose> 6947 convert an ASCII hex string into a bitmap. 6948 </refpurpose> 6949</refnamediv> 6950<refsynopsisdiv> 6951 <title>Synopsis</title> 6952 <funcsynopsis><funcprototype> 6953 <funcdef>int <function>__bitmap_parse </function></funcdef> 6954 <paramdef>const char * <parameter>buf</parameter></paramdef> 6955 <paramdef>unsigned int <parameter>buflen</parameter></paramdef> 6956 <paramdef>int <parameter>is_user</parameter></paramdef> 6957 <paramdef>unsigned long * <parameter>maskp</parameter></paramdef> 6958 <paramdef>int <parameter>nmaskbits</parameter></paramdef> 6959 </funcprototype></funcsynopsis> 6960</refsynopsisdiv> 6961<refsect1> 6962 <title>Arguments</title> 6963 <variablelist> 6964 <varlistentry> 6965 <term><parameter>buf</parameter></term> 6966 <listitem> 6967 <para> 6968 pointer to buffer containing string. 6969 </para> 6970 </listitem> 6971 </varlistentry> 6972 <varlistentry> 6973 <term><parameter>buflen</parameter></term> 6974 <listitem> 6975 <para> 6976 buffer size in bytes. If string is smaller than this 6977 then it must be terminated with a \0. 6978 </para> 6979 </listitem> 6980 </varlistentry> 6981 <varlistentry> 6982 <term><parameter>is_user</parameter></term> 6983 <listitem> 6984 <para> 6985 location of buffer, 0 indicates kernel space 6986 </para> 6987 </listitem> 6988 </varlistentry> 6989 <varlistentry> 6990 <term><parameter>maskp</parameter></term> 6991 <listitem> 6992 <para> 6993 pointer to bitmap array that will contain result. 6994 </para> 6995 </listitem> 6996 </varlistentry> 6997 <varlistentry> 6998 <term><parameter>nmaskbits</parameter></term> 6999 <listitem> 7000 <para> 7001 size of bitmap, in bits. 7002 </para> 7003 </listitem> 7004 </varlistentry> 7005 </variablelist> 7006</refsect1> 7007<refsect1> 7008<title>Description</title> 7009<para> 7010 Commas group hex digits into chunks. Each chunk defines exactly 32 7011 bits of the resultant bitmask. No chunk may specify a value larger 7012 than 32 bits (<constant>-EOVERFLOW</constant>), and if a chunk specifies a smaller value 7013 then leading 0-bits are prepended. <constant>-EINVAL</constant> is returned for illegal 7014 characters and for grouping errors such as <quote>1,,5</quote>, <quote>,44</quote>, <quote>,</quote> and "". 7015 Leading and trailing whitespace accepted, but not embedded whitespace. 7016</para> 7017</refsect1> 7018</refentry> 7019 7020<refentry id="API-bitmap-parse-user"> 7021<refentryinfo> 7022 <title>LINUX</title> 7023 <productname>Kernel Hackers Manual</productname> 7024 <date>July 2017</date> 7025</refentryinfo> 7026<refmeta> 7027 <refentrytitle><phrase>bitmap_parse_user</phrase></refentrytitle> 7028 <manvolnum>9</manvolnum> 7029 <refmiscinfo class="version">4.1.27</refmiscinfo> 7030</refmeta> 7031<refnamediv> 7032 <refname>bitmap_parse_user</refname> 7033 <refpurpose> 7034 convert an ASCII hex string in a user buffer into a bitmap 7035 </refpurpose> 7036</refnamediv> 7037<refsynopsisdiv> 7038 <title>Synopsis</title> 7039 <funcsynopsis><funcprototype> 7040 <funcdef>int <function>bitmap_parse_user </function></funcdef> 7041 <paramdef>const char __user * <parameter>ubuf</parameter></paramdef> 7042 <paramdef>unsigned int <parameter>ulen</parameter></paramdef> 7043 <paramdef>unsigned long * <parameter>maskp</parameter></paramdef> 7044 <paramdef>int <parameter>nmaskbits</parameter></paramdef> 7045 </funcprototype></funcsynopsis> 7046</refsynopsisdiv> 7047<refsect1> 7048 <title>Arguments</title> 7049 <variablelist> 7050 <varlistentry> 7051 <term><parameter>ubuf</parameter></term> 7052 <listitem> 7053 <para> 7054 pointer to user buffer containing string. 7055 </para> 7056 </listitem> 7057 </varlistentry> 7058 <varlistentry> 7059 <term><parameter>ulen</parameter></term> 7060 <listitem> 7061 <para> 7062 buffer size in bytes. If string is smaller than this 7063 then it must be terminated with a \0. 7064 </para> 7065 </listitem> 7066 </varlistentry> 7067 <varlistentry> 7068 <term><parameter>maskp</parameter></term> 7069 <listitem> 7070 <para> 7071 pointer to bitmap array that will contain result. 7072 </para> 7073 </listitem> 7074 </varlistentry> 7075 <varlistentry> 7076 <term><parameter>nmaskbits</parameter></term> 7077 <listitem> 7078 <para> 7079 size of bitmap, in bits. 7080 </para> 7081 </listitem> 7082 </varlistentry> 7083 </variablelist> 7084</refsect1> 7085<refsect1> 7086<title>Description</title> 7087<para> 7088 Wrapper for <function>__bitmap_parse</function>, providing it with user buffer. 7089 </para><para> 7090 7091 We cannot have this as an inline function in bitmap.h because it needs 7092 linux/uaccess.h to get the <function>access_ok</function> declaration and this causes 7093 cyclic dependencies. 7094</para> 7095</refsect1> 7096</refentry> 7097 7098<refentry id="API-bitmap-print-to-pagebuf"> 7099<refentryinfo> 7100 <title>LINUX</title> 7101 <productname>Kernel Hackers Manual</productname> 7102 <date>July 2017</date> 7103</refentryinfo> 7104<refmeta> 7105 <refentrytitle><phrase>bitmap_print_to_pagebuf</phrase></refentrytitle> 7106 <manvolnum>9</manvolnum> 7107 <refmiscinfo class="version">4.1.27</refmiscinfo> 7108</refmeta> 7109<refnamediv> 7110 <refname>bitmap_print_to_pagebuf</refname> 7111 <refpurpose> 7112 convert bitmap to list or hex format ASCII string 7113 </refpurpose> 7114</refnamediv> 7115<refsynopsisdiv> 7116 <title>Synopsis</title> 7117 <funcsynopsis><funcprototype> 7118 <funcdef>int <function>bitmap_print_to_pagebuf </function></funcdef> 7119 <paramdef>bool <parameter>list</parameter></paramdef> 7120 <paramdef>char * <parameter>buf</parameter></paramdef> 7121 <paramdef>const unsigned long * <parameter>maskp</parameter></paramdef> 7122 <paramdef>int <parameter>nmaskbits</parameter></paramdef> 7123 </funcprototype></funcsynopsis> 7124</refsynopsisdiv> 7125<refsect1> 7126 <title>Arguments</title> 7127 <variablelist> 7128 <varlistentry> 7129 <term><parameter>list</parameter></term> 7130 <listitem> 7131 <para> 7132 indicates whether the bitmap must be list 7133 </para> 7134 </listitem> 7135 </varlistentry> 7136 <varlistentry> 7137 <term><parameter>buf</parameter></term> 7138 <listitem> 7139 <para> 7140 page aligned buffer into which string is placed 7141 </para> 7142 </listitem> 7143 </varlistentry> 7144 <varlistentry> 7145 <term><parameter>maskp</parameter></term> 7146 <listitem> 7147 <para> 7148 pointer to bitmap to convert 7149 </para> 7150 </listitem> 7151 </varlistentry> 7152 <varlistentry> 7153 <term><parameter>nmaskbits</parameter></term> 7154 <listitem> 7155 <para> 7156 size of bitmap, in bits 7157 </para> 7158 </listitem> 7159 </varlistentry> 7160 </variablelist> 7161</refsect1> 7162<refsect1> 7163<title>Description</title> 7164<para> 7165 Output format is a comma-separated list of decimal numbers and 7166 ranges if list is specified or hex digits grouped into comma-separated 7167 sets of 8 digits/set. Returns the number of characters written to buf. 7168</para> 7169</refsect1> 7170</refentry> 7171 7172<refentry id="API-bitmap-parselist-user"> 7173<refentryinfo> 7174 <title>LINUX</title> 7175 <productname>Kernel Hackers Manual</productname> 7176 <date>July 2017</date> 7177</refentryinfo> 7178<refmeta> 7179 <refentrytitle><phrase>bitmap_parselist_user</phrase></refentrytitle> 7180 <manvolnum>9</manvolnum> 7181 <refmiscinfo class="version">4.1.27</refmiscinfo> 7182</refmeta> 7183<refnamediv> 7184 <refname>bitmap_parselist_user</refname> 7185 <refpurpose> 7186 </refpurpose> 7187</refnamediv> 7188<refsynopsisdiv> 7189 <title>Synopsis</title> 7190 <funcsynopsis><funcprototype> 7191 <funcdef>int <function>bitmap_parselist_user </function></funcdef> 7192 <paramdef>const char __user * <parameter>ubuf</parameter></paramdef> 7193 <paramdef>unsigned int <parameter>ulen</parameter></paramdef> 7194 <paramdef>unsigned long * <parameter>maskp</parameter></paramdef> 7195 <paramdef>int <parameter>nmaskbits</parameter></paramdef> 7196 </funcprototype></funcsynopsis> 7197</refsynopsisdiv> 7198<refsect1> 7199 <title>Arguments</title> 7200 <variablelist> 7201 <varlistentry> 7202 <term><parameter>ubuf</parameter></term> 7203 <listitem> 7204 <para> 7205 pointer to user buffer containing string. 7206 </para> 7207 </listitem> 7208 </varlistentry> 7209 <varlistentry> 7210 <term><parameter>ulen</parameter></term> 7211 <listitem> 7212 <para> 7213 buffer size in bytes. If string is smaller than this 7214 then it must be terminated with a \0. 7215 </para> 7216 </listitem> 7217 </varlistentry> 7218 <varlistentry> 7219 <term><parameter>maskp</parameter></term> 7220 <listitem> 7221 <para> 7222 pointer to bitmap array that will contain result. 7223 </para> 7224 </listitem> 7225 </varlistentry> 7226 <varlistentry> 7227 <term><parameter>nmaskbits</parameter></term> 7228 <listitem> 7229 <para> 7230 size of bitmap, in bits. 7231 </para> 7232 </listitem> 7233 </varlistentry> 7234 </variablelist> 7235</refsect1> 7236<refsect1> 7237<title>Description</title> 7238<para> 7239 Wrapper for <function>bitmap_parselist</function>, providing it with user buffer. 7240 </para><para> 7241 7242 We cannot have this as an inline function in bitmap.h because it needs 7243 linux/uaccess.h to get the <function>access_ok</function> declaration and this causes 7244 cyclic dependencies. 7245</para> 7246</refsect1> 7247</refentry> 7248 7249<refentry id="API-bitmap-remap"> 7250<refentryinfo> 7251 <title>LINUX</title> 7252 <productname>Kernel Hackers Manual</productname> 7253 <date>July 2017</date> 7254</refentryinfo> 7255<refmeta> 7256 <refentrytitle><phrase>bitmap_remap</phrase></refentrytitle> 7257 <manvolnum>9</manvolnum> 7258 <refmiscinfo class="version">4.1.27</refmiscinfo> 7259</refmeta> 7260<refnamediv> 7261 <refname>bitmap_remap</refname> 7262 <refpurpose> 7263 Apply map defined by a pair of bitmaps to another bitmap 7264 </refpurpose> 7265</refnamediv> 7266<refsynopsisdiv> 7267 <title>Synopsis</title> 7268 <funcsynopsis><funcprototype> 7269 <funcdef>void <function>bitmap_remap </function></funcdef> 7270 <paramdef>unsigned long * <parameter>dst</parameter></paramdef> 7271 <paramdef>const unsigned long * <parameter>src</parameter></paramdef> 7272 <paramdef>const unsigned long * <parameter>old</parameter></paramdef> 7273 <paramdef>const unsigned long * <parameter>new</parameter></paramdef> 7274 <paramdef>unsigned int <parameter>nbits</parameter></paramdef> 7275 </funcprototype></funcsynopsis> 7276</refsynopsisdiv> 7277<refsect1> 7278 <title>Arguments</title> 7279 <variablelist> 7280 <varlistentry> 7281 <term><parameter>dst</parameter></term> 7282 <listitem> 7283 <para> 7284 remapped result 7285 </para> 7286 </listitem> 7287 </varlistentry> 7288 <varlistentry> 7289 <term><parameter>src</parameter></term> 7290 <listitem> 7291 <para> 7292 subset to be remapped 7293 </para> 7294 </listitem> 7295 </varlistentry> 7296 <varlistentry> 7297 <term><parameter>old</parameter></term> 7298 <listitem> 7299 <para> 7300 defines domain of map 7301 </para> 7302 </listitem> 7303 </varlistentry> 7304 <varlistentry> 7305 <term><parameter>new</parameter></term> 7306 <listitem> 7307 <para> 7308 defines range of map 7309 </para> 7310 </listitem> 7311 </varlistentry> 7312 <varlistentry> 7313 <term><parameter>nbits</parameter></term> 7314 <listitem> 7315 <para> 7316 number of bits in each of these bitmaps 7317 </para> 7318 </listitem> 7319 </varlistentry> 7320 </variablelist> 7321</refsect1> 7322<refsect1> 7323<title>Description</title> 7324<para> 7325 Let <parameter>old</parameter> and <parameter>new</parameter> define a mapping of bit positions, such that 7326 whatever position is held by the n-th set bit in <parameter>old</parameter> is mapped 7327 to the n-th set bit in <parameter>new</parameter>. In the more general case, allowing 7328 for the possibility that the weight 'w' of <parameter>new</parameter> is less than the 7329 weight of <parameter>old</parameter>, map the position of the n-th set bit in <parameter>old</parameter> to 7330 the position of the m-th set bit in <parameter>new</parameter>, where m == n % w. 7331 </para><para> 7332 7333 If either of the <parameter>old</parameter> and <parameter>new</parameter> bitmaps are empty, or if <parameter>src</parameter> and 7334 <parameter>dst</parameter> point to the same location, then this routine copies <parameter>src</parameter> 7335 to <parameter>dst</parameter>. 7336 </para><para> 7337 7338 The positions of unset bits in <parameter>old</parameter> are mapped to themselves 7339 (the identify map). 7340 </para><para> 7341 7342 Apply the above specified mapping to <parameter>src</parameter>, placing the result in 7343 <parameter>dst</parameter>, clearing any bits previously set in <parameter>dst</parameter>. 7344 </para><para> 7345 7346 For example, lets say that <parameter>old</parameter> has bits 4 through 7 set, and 7347 <parameter>new</parameter> has bits 12 through 15 set. This defines the mapping of bit 7348 position 4 to 12, 5 to 13, 6 to 14 and 7 to 15, and of all other 7349 bit positions unchanged. So if say <parameter>src</parameter> comes into this routine 7350 with bits 1, 5 and 7 set, then <parameter>dst</parameter> should leave with bits 1, 7351 13 and 15 set. 7352</para> 7353</refsect1> 7354</refentry> 7355 7356<refentry id="API-bitmap-bitremap"> 7357<refentryinfo> 7358 <title>LINUX</title> 7359 <productname>Kernel Hackers Manual</productname> 7360 <date>July 2017</date> 7361</refentryinfo> 7362<refmeta> 7363 <refentrytitle><phrase>bitmap_bitremap</phrase></refentrytitle> 7364 <manvolnum>9</manvolnum> 7365 <refmiscinfo class="version">4.1.27</refmiscinfo> 7366</refmeta> 7367<refnamediv> 7368 <refname>bitmap_bitremap</refname> 7369 <refpurpose> 7370 Apply map defined by a pair of bitmaps to a single bit 7371 </refpurpose> 7372</refnamediv> 7373<refsynopsisdiv> 7374 <title>Synopsis</title> 7375 <funcsynopsis><funcprototype> 7376 <funcdef>int <function>bitmap_bitremap </function></funcdef> 7377 <paramdef>int <parameter>oldbit</parameter></paramdef> 7378 <paramdef>const unsigned long * <parameter>old</parameter></paramdef> 7379 <paramdef>const unsigned long * <parameter>new</parameter></paramdef> 7380 <paramdef>int <parameter>bits</parameter></paramdef> 7381 </funcprototype></funcsynopsis> 7382</refsynopsisdiv> 7383<refsect1> 7384 <title>Arguments</title> 7385 <variablelist> 7386 <varlistentry> 7387 <term><parameter>oldbit</parameter></term> 7388 <listitem> 7389 <para> 7390 bit position to be mapped 7391 </para> 7392 </listitem> 7393 </varlistentry> 7394 <varlistentry> 7395 <term><parameter>old</parameter></term> 7396 <listitem> 7397 <para> 7398 defines domain of map 7399 </para> 7400 </listitem> 7401 </varlistentry> 7402 <varlistentry> 7403 <term><parameter>new</parameter></term> 7404 <listitem> 7405 <para> 7406 defines range of map 7407 </para> 7408 </listitem> 7409 </varlistentry> 7410 <varlistentry> 7411 <term><parameter>bits</parameter></term> 7412 <listitem> 7413 <para> 7414 number of bits in each of these bitmaps 7415 </para> 7416 </listitem> 7417 </varlistentry> 7418 </variablelist> 7419</refsect1> 7420<refsect1> 7421<title>Description</title> 7422<para> 7423 Let <parameter>old</parameter> and <parameter>new</parameter> define a mapping of bit positions, such that 7424 whatever position is held by the n-th set bit in <parameter>old</parameter> is mapped 7425 to the n-th set bit in <parameter>new</parameter>. In the more general case, allowing 7426 for the possibility that the weight 'w' of <parameter>new</parameter> is less than the 7427 weight of <parameter>old</parameter>, map the position of the n-th set bit in <parameter>old</parameter> to 7428 the position of the m-th set bit in <parameter>new</parameter>, where m == n % w. 7429 </para><para> 7430 7431 The positions of unset bits in <parameter>old</parameter> are mapped to themselves 7432 (the identify map). 7433 </para><para> 7434 7435 Apply the above specified mapping to bit position <parameter>oldbit</parameter>, returning 7436 the new bit position. 7437 </para><para> 7438 7439 For example, lets say that <parameter>old</parameter> has bits 4 through 7 set, and 7440 <parameter>new</parameter> has bits 12 through 15 set. This defines the mapping of bit 7441 position 4 to 12, 5 to 13, 6 to 14 and 7 to 15, and of all other 7442 bit positions unchanged. So if say <parameter>oldbit</parameter> is 5, then this routine 7443 returns 13. 7444</para> 7445</refsect1> 7446</refentry> 7447 7448<refentry id="API-bitmap-onto"> 7449<refentryinfo> 7450 <title>LINUX</title> 7451 <productname>Kernel Hackers Manual</productname> 7452 <date>July 2017</date> 7453</refentryinfo> 7454<refmeta> 7455 <refentrytitle><phrase>bitmap_onto</phrase></refentrytitle> 7456 <manvolnum>9</manvolnum> 7457 <refmiscinfo class="version">4.1.27</refmiscinfo> 7458</refmeta> 7459<refnamediv> 7460 <refname>bitmap_onto</refname> 7461 <refpurpose> 7462 translate one bitmap relative to another 7463 </refpurpose> 7464</refnamediv> 7465<refsynopsisdiv> 7466 <title>Synopsis</title> 7467 <funcsynopsis><funcprototype> 7468 <funcdef>void <function>bitmap_onto </function></funcdef> 7469 <paramdef>unsigned long * <parameter>dst</parameter></paramdef> 7470 <paramdef>const unsigned long * <parameter>orig</parameter></paramdef> 7471 <paramdef>const unsigned long * <parameter>relmap</parameter></paramdef> 7472 <paramdef>unsigned int <parameter>bits</parameter></paramdef> 7473 </funcprototype></funcsynopsis> 7474</refsynopsisdiv> 7475<refsect1> 7476 <title>Arguments</title> 7477 <variablelist> 7478 <varlistentry> 7479 <term><parameter>dst</parameter></term> 7480 <listitem> 7481 <para> 7482 resulting translated bitmap 7483 </para> 7484 </listitem> 7485 </varlistentry> 7486 <varlistentry> 7487 <term><parameter>orig</parameter></term> 7488 <listitem> 7489 <para> 7490 original untranslated bitmap 7491 </para> 7492 </listitem> 7493 </varlistentry> 7494 <varlistentry> 7495 <term><parameter>relmap</parameter></term> 7496 <listitem> 7497 <para> 7498 bitmap relative to which translated 7499 </para> 7500 </listitem> 7501 </varlistentry> 7502 <varlistentry> 7503 <term><parameter>bits</parameter></term> 7504 <listitem> 7505 <para> 7506 number of bits in each of these bitmaps 7507 </para> 7508 </listitem> 7509 </varlistentry> 7510 </variablelist> 7511</refsect1> 7512<refsect1> 7513<title>Description</title> 7514<para> 7515 Set the n-th bit of <parameter>dst</parameter> iff there exists some m such that the 7516 n-th bit of <parameter>relmap</parameter> is set, the m-th bit of <parameter>orig</parameter> is set, and 7517 the n-th bit of <parameter>relmap</parameter> is also the m-th _set_ bit of <parameter>relmap</parameter>. 7518 (If you understood the previous sentence the first time your 7519 read it, you're overqualified for your current job.) 7520 </para><para> 7521 7522 In other words, <parameter>orig</parameter> is mapped onto (surjectively) <parameter>dst</parameter>, 7523 using the map { <n, m> | the n-th bit of <parameter>relmap</parameter> is the 7524 m-th set bit of <parameter>relmap</parameter> }. 7525 </para><para> 7526 7527 Any set bits in <parameter>orig</parameter> above bit number W, where W is the 7528 weight of (number of set bits in) <parameter>relmap</parameter> are mapped nowhere. 7529 In particular, if for all bits m set in <parameter>orig</parameter>, m >= W, then 7530 <parameter>dst</parameter> will end up empty. In situations where the possibility 7531 of such an empty result is not desired, one way to avoid it is 7532 to use the <function>bitmap_fold</function> operator, below, to first fold the 7533 <parameter>orig</parameter> bitmap over itself so that all its set bits x are in the 7534 range 0 <= x < W. The <function>bitmap_fold</function> operator does this by 7535 setting the bit (m % W) in <parameter>dst</parameter>, for each bit (m) set in <parameter>orig</parameter>. 7536 </para><para> 7537 7538 Example [1] for <function>bitmap_onto</function>: 7539 Let's say <parameter>relmap</parameter> has bits 30-39 set, and <parameter>orig</parameter> has bits 7540 1, 3, 5, 7, 9 and 11 set. Then on return from this routine, 7541 <parameter>dst</parameter> will have bits 31, 33, 35, 37 and 39 set. 7542 </para><para> 7543 7544 When bit 0 is set in <parameter>orig</parameter>, it means turn on the bit in 7545 <parameter>dst</parameter> corresponding to whatever is the first bit (if any) 7546 that is turned on in <parameter>relmap</parameter>. Since bit 0 was off in the 7547 above example, we leave off that bit (bit 30) in <parameter>dst</parameter>. 7548 </para><para> 7549 7550 When bit 1 is set in <parameter>orig</parameter> (as in the above example), it 7551 means turn on the bit in <parameter>dst</parameter> corresponding to whatever 7552 is the second bit that is turned on in <parameter>relmap</parameter>. The second 7553 bit in <parameter>relmap</parameter> that was turned on in the above example was 7554 bit 31, so we turned on bit 31 in <parameter>dst</parameter>. 7555 </para><para> 7556 7557 Similarly, we turned on bits 33, 35, 37 and 39 in <parameter>dst</parameter>, 7558 because they were the 4th, 6th, 8th and 10th set bits 7559 set in <parameter>relmap</parameter>, and the 4th, 6th, 8th and 10th bits of 7560 <parameter>orig</parameter> (i.e. bits 3, 5, 7 and 9) were also set. 7561 </para><para> 7562 7563 When bit 11 is set in <parameter>orig</parameter>, it means turn on the bit in 7564 <parameter>dst</parameter> corresponding to whatever is the twelfth bit that is 7565 turned on in <parameter>relmap</parameter>. In the above example, there were 7566 only ten bits turned on in <parameter>relmap</parameter> (30..39), so that bit 7567 11 was set in <parameter>orig</parameter> had no affect on <parameter>dst</parameter>. 7568 </para><para> 7569 7570 Example [2] for <function>bitmap_fold</function> + <function>bitmap_onto</function>: 7571 Let's say <parameter>relmap</parameter> has these ten bits set: 7572 40 41 42 43 45 48 53 61 74 95 7573 (for the curious, that's 40 plus the first ten terms of the 7574 Fibonacci sequence.) 7575 </para><para> 7576 7577 Further lets say we use the following code, invoking 7578 <function>bitmap_fold</function> then bitmap_onto, as suggested above to 7579 avoid the possibility of an empty <parameter>dst</parameter> result: 7580 </para><para> 7581 7582 unsigned long *tmp; // a temporary bitmap's bits 7583 </para><para> 7584 7585 bitmap_fold(tmp, orig, bitmap_weight(relmap, bits), bits); 7586 bitmap_onto(dst, tmp, relmap, bits); 7587 </para><para> 7588 7589 Then this table shows what various values of <parameter>dst</parameter> would be, for 7590 various <parameter>orig</parameter>'s. I list the zero-based positions of each set bit. 7591 The tmp column shows the intermediate result, as computed by 7592 using <function>bitmap_fold</function> to fold the <parameter>orig</parameter> bitmap modulo ten 7593 (the weight of <parameter>relmap</parameter>). 7594 </para><para> 7595 7596 <parameter>orig</parameter> tmp <parameter>dst</parameter> 7597 0 0 40 7598 1 1 41 7599 9 9 95 7600 10 0 40 (*) 7601 1 3 5 7 1 3 5 7 41 43 48 61 7602 0 1 2 3 4 0 1 2 3 4 40 41 42 43 45 7603 0 9 18 27 0 9 8 7 40 61 74 95 7604 0 10 20 30 0 40 7605 0 11 22 33 0 1 2 3 40 41 42 43 7606 0 12 24 36 0 2 4 6 40 42 45 53 7607 78 102 211 1 2 8 41 42 74 (*) 7608 </para><para> 7609 7610 (*) For these marked lines, if we hadn't first done <function>bitmap_fold</function> 7611 into tmp, then the <parameter>dst</parameter> result would have been empty. 7612 </para><para> 7613 7614 If either of <parameter>orig</parameter> or <parameter>relmap</parameter> is empty (no set bits), then <parameter>dst</parameter> 7615 will be returned empty. 7616 </para><para> 7617 7618 If (as explained above) the only set bits in <parameter>orig</parameter> are in positions 7619 m where m >= W, (where W is the weight of <parameter>relmap</parameter>) then <parameter>dst</parameter> will 7620 once again be returned empty. 7621 </para><para> 7622 7623 All bits in <parameter>dst</parameter> not set by the above rule are cleared. 7624</para> 7625</refsect1> 7626</refentry> 7627 7628<refentry id="API-bitmap-fold"> 7629<refentryinfo> 7630 <title>LINUX</title> 7631 <productname>Kernel Hackers Manual</productname> 7632 <date>July 2017</date> 7633</refentryinfo> 7634<refmeta> 7635 <refentrytitle><phrase>bitmap_fold</phrase></refentrytitle> 7636 <manvolnum>9</manvolnum> 7637 <refmiscinfo class="version">4.1.27</refmiscinfo> 7638</refmeta> 7639<refnamediv> 7640 <refname>bitmap_fold</refname> 7641 <refpurpose> 7642 fold larger bitmap into smaller, modulo specified size 7643 </refpurpose> 7644</refnamediv> 7645<refsynopsisdiv> 7646 <title>Synopsis</title> 7647 <funcsynopsis><funcprototype> 7648 <funcdef>void <function>bitmap_fold </function></funcdef> 7649 <paramdef>unsigned long * <parameter>dst</parameter></paramdef> 7650 <paramdef>const unsigned long * <parameter>orig</parameter></paramdef> 7651 <paramdef>unsigned int <parameter>sz</parameter></paramdef> 7652 <paramdef>unsigned int <parameter>nbits</parameter></paramdef> 7653 </funcprototype></funcsynopsis> 7654</refsynopsisdiv> 7655<refsect1> 7656 <title>Arguments</title> 7657 <variablelist> 7658 <varlistentry> 7659 <term><parameter>dst</parameter></term> 7660 <listitem> 7661 <para> 7662 resulting smaller bitmap 7663 </para> 7664 </listitem> 7665 </varlistentry> 7666 <varlistentry> 7667 <term><parameter>orig</parameter></term> 7668 <listitem> 7669 <para> 7670 original larger bitmap 7671 </para> 7672 </listitem> 7673 </varlistentry> 7674 <varlistentry> 7675 <term><parameter>sz</parameter></term> 7676 <listitem> 7677 <para> 7678 specified size 7679 </para> 7680 </listitem> 7681 </varlistentry> 7682 <varlistentry> 7683 <term><parameter>nbits</parameter></term> 7684 <listitem> 7685 <para> 7686 number of bits in each of these bitmaps 7687 </para> 7688 </listitem> 7689 </varlistentry> 7690 </variablelist> 7691</refsect1> 7692<refsect1> 7693<title>Description</title> 7694<para> 7695 For each bit oldbit in <parameter>orig</parameter>, set bit oldbit mod <parameter>sz</parameter> in <parameter>dst</parameter>. 7696 Clear all other bits in <parameter>dst</parameter>. See further the comment and 7697 Example [2] for <function>bitmap_onto</function> for why and how to use this. 7698</para> 7699</refsect1> 7700</refentry> 7701 7702<refentry id="API-bitmap-find-free-region"> 7703<refentryinfo> 7704 <title>LINUX</title> 7705 <productname>Kernel Hackers Manual</productname> 7706 <date>July 2017</date> 7707</refentryinfo> 7708<refmeta> 7709 <refentrytitle><phrase>bitmap_find_free_region</phrase></refentrytitle> 7710 <manvolnum>9</manvolnum> 7711 <refmiscinfo class="version">4.1.27</refmiscinfo> 7712</refmeta> 7713<refnamediv> 7714 <refname>bitmap_find_free_region</refname> 7715 <refpurpose> 7716 find a contiguous aligned mem region 7717 </refpurpose> 7718</refnamediv> 7719<refsynopsisdiv> 7720 <title>Synopsis</title> 7721 <funcsynopsis><funcprototype> 7722 <funcdef>int <function>bitmap_find_free_region </function></funcdef> 7723 <paramdef>unsigned long * <parameter>bitmap</parameter></paramdef> 7724 <paramdef>unsigned int <parameter>bits</parameter></paramdef> 7725 <paramdef>int <parameter>order</parameter></paramdef> 7726 </funcprototype></funcsynopsis> 7727</refsynopsisdiv> 7728<refsect1> 7729 <title>Arguments</title> 7730 <variablelist> 7731 <varlistentry> 7732 <term><parameter>bitmap</parameter></term> 7733 <listitem> 7734 <para> 7735 array of unsigned longs corresponding to the bitmap 7736 </para> 7737 </listitem> 7738 </varlistentry> 7739 <varlistentry> 7740 <term><parameter>bits</parameter></term> 7741 <listitem> 7742 <para> 7743 number of bits in the bitmap 7744 </para> 7745 </listitem> 7746 </varlistentry> 7747 <varlistentry> 7748 <term><parameter>order</parameter></term> 7749 <listitem> 7750 <para> 7751 region size (log base 2 of number of bits) to find 7752 </para> 7753 </listitem> 7754 </varlistentry> 7755 </variablelist> 7756</refsect1> 7757<refsect1> 7758<title>Description</title> 7759<para> 7760 Find a region of free (zero) bits in a <parameter>bitmap</parameter> of <parameter>bits</parameter> bits and 7761 allocate them (set them to one). Only consider regions of length 7762 a power (<parameter>order</parameter>) of two, aligned to that power of two, which 7763 makes the search algorithm much faster. 7764 </para><para> 7765 7766 Return the bit offset in bitmap of the allocated region, 7767 or -errno on failure. 7768</para> 7769</refsect1> 7770</refentry> 7771 7772<refentry id="API-bitmap-release-region"> 7773<refentryinfo> 7774 <title>LINUX</title> 7775 <productname>Kernel Hackers Manual</productname> 7776 <date>July 2017</date> 7777</refentryinfo> 7778<refmeta> 7779 <refentrytitle><phrase>bitmap_release_region</phrase></refentrytitle> 7780 <manvolnum>9</manvolnum> 7781 <refmiscinfo class="version">4.1.27</refmiscinfo> 7782</refmeta> 7783<refnamediv> 7784 <refname>bitmap_release_region</refname> 7785 <refpurpose> 7786 release allocated bitmap region 7787 </refpurpose> 7788</refnamediv> 7789<refsynopsisdiv> 7790 <title>Synopsis</title> 7791 <funcsynopsis><funcprototype> 7792 <funcdef>void <function>bitmap_release_region </function></funcdef> 7793 <paramdef>unsigned long * <parameter>bitmap</parameter></paramdef> 7794 <paramdef>unsigned int <parameter>pos</parameter></paramdef> 7795 <paramdef>int <parameter>order</parameter></paramdef> 7796 </funcprototype></funcsynopsis> 7797</refsynopsisdiv> 7798<refsect1> 7799 <title>Arguments</title> 7800 <variablelist> 7801 <varlistentry> 7802 <term><parameter>bitmap</parameter></term> 7803 <listitem> 7804 <para> 7805 array of unsigned longs corresponding to the bitmap 7806 </para> 7807 </listitem> 7808 </varlistentry> 7809 <varlistentry> 7810 <term><parameter>pos</parameter></term> 7811 <listitem> 7812 <para> 7813 beginning of bit region to release 7814 </para> 7815 </listitem> 7816 </varlistentry> 7817 <varlistentry> 7818 <term><parameter>order</parameter></term> 7819 <listitem> 7820 <para> 7821 region size (log base 2 of number of bits) to release 7822 </para> 7823 </listitem> 7824 </varlistentry> 7825 </variablelist> 7826</refsect1> 7827<refsect1> 7828<title>Description</title> 7829<para> 7830 This is the complement to <function>__bitmap_find_free_region</function> and releases 7831 the found region (by clearing it in the bitmap). 7832 </para><para> 7833 7834 No return value. 7835</para> 7836</refsect1> 7837</refentry> 7838 7839<refentry id="API-bitmap-allocate-region"> 7840<refentryinfo> 7841 <title>LINUX</title> 7842 <productname>Kernel Hackers Manual</productname> 7843 <date>July 2017</date> 7844</refentryinfo> 7845<refmeta> 7846 <refentrytitle><phrase>bitmap_allocate_region</phrase></refentrytitle> 7847 <manvolnum>9</manvolnum> 7848 <refmiscinfo class="version">4.1.27</refmiscinfo> 7849</refmeta> 7850<refnamediv> 7851 <refname>bitmap_allocate_region</refname> 7852 <refpurpose> 7853 allocate bitmap region 7854 </refpurpose> 7855</refnamediv> 7856<refsynopsisdiv> 7857 <title>Synopsis</title> 7858 <funcsynopsis><funcprototype> 7859 <funcdef>int <function>bitmap_allocate_region </function></funcdef> 7860 <paramdef>unsigned long * <parameter>bitmap</parameter></paramdef> 7861 <paramdef>unsigned int <parameter>pos</parameter></paramdef> 7862 <paramdef>int <parameter>order</parameter></paramdef> 7863 </funcprototype></funcsynopsis> 7864</refsynopsisdiv> 7865<refsect1> 7866 <title>Arguments</title> 7867 <variablelist> 7868 <varlistentry> 7869 <term><parameter>bitmap</parameter></term> 7870 <listitem> 7871 <para> 7872 array of unsigned longs corresponding to the bitmap 7873 </para> 7874 </listitem> 7875 </varlistentry> 7876 <varlistentry> 7877 <term><parameter>pos</parameter></term> 7878 <listitem> 7879 <para> 7880 beginning of bit region to allocate 7881 </para> 7882 </listitem> 7883 </varlistentry> 7884 <varlistentry> 7885 <term><parameter>order</parameter></term> 7886 <listitem> 7887 <para> 7888 region size (log base 2 of number of bits) to allocate 7889 </para> 7890 </listitem> 7891 </varlistentry> 7892 </variablelist> 7893</refsect1> 7894<refsect1> 7895<title>Description</title> 7896<para> 7897 Allocate (set bits in) a specified region of a bitmap. 7898 </para><para> 7899 7900 Return 0 on success, or <constant>-EBUSY</constant> if specified region wasn't 7901 free (not all bits were zero). 7902</para> 7903</refsect1> 7904</refentry> 7905 7906<refentry id="API-bitmap-copy-le"> 7907<refentryinfo> 7908 <title>LINUX</title> 7909 <productname>Kernel Hackers Manual</productname> 7910 <date>July 2017</date> 7911</refentryinfo> 7912<refmeta> 7913 <refentrytitle><phrase>bitmap_copy_le</phrase></refentrytitle> 7914 <manvolnum>9</manvolnum> 7915 <refmiscinfo class="version">4.1.27</refmiscinfo> 7916</refmeta> 7917<refnamediv> 7918 <refname>bitmap_copy_le</refname> 7919 <refpurpose> 7920 copy a bitmap, putting the bits into little-endian order. 7921 </refpurpose> 7922</refnamediv> 7923<refsynopsisdiv> 7924 <title>Synopsis</title> 7925 <funcsynopsis><funcprototype> 7926 <funcdef>void <function>bitmap_copy_le </function></funcdef> 7927 <paramdef>unsigned long * <parameter>dst</parameter></paramdef> 7928 <paramdef>const unsigned long * <parameter>src</parameter></paramdef> 7929 <paramdef>unsigned int <parameter>nbits</parameter></paramdef> 7930 </funcprototype></funcsynopsis> 7931</refsynopsisdiv> 7932<refsect1> 7933 <title>Arguments</title> 7934 <variablelist> 7935 <varlistentry> 7936 <term><parameter>dst</parameter></term> 7937 <listitem> 7938 <para> 7939 destination buffer 7940 </para> 7941 </listitem> 7942 </varlistentry> 7943 <varlistentry> 7944 <term><parameter>src</parameter></term> 7945 <listitem> 7946 <para> 7947 bitmap to copy 7948 </para> 7949 </listitem> 7950 </varlistentry> 7951 <varlistentry> 7952 <term><parameter>nbits</parameter></term> 7953 <listitem> 7954 <para> 7955 number of bits in the bitmap 7956 </para> 7957 </listitem> 7958 </varlistentry> 7959 </variablelist> 7960</refsect1> 7961<refsect1> 7962<title>Description</title> 7963<para> 7964 Require nbits % BITS_PER_LONG == 0. 7965</para> 7966</refsect1> 7967</refentry> 7968 7969<!-- lib/bitmap.c --> 7970<refentry id="API---bitmap-parselist"> 7971<refentryinfo> 7972 <title>LINUX</title> 7973 <productname>Kernel Hackers Manual</productname> 7974 <date>July 2017</date> 7975</refentryinfo> 7976<refmeta> 7977 <refentrytitle><phrase>__bitmap_parselist</phrase></refentrytitle> 7978 <manvolnum>9</manvolnum> 7979 <refmiscinfo class="version">4.1.27</refmiscinfo> 7980</refmeta> 7981<refnamediv> 7982 <refname>__bitmap_parselist</refname> 7983 <refpurpose> 7984 convert list format ASCII string to bitmap 7985 </refpurpose> 7986</refnamediv> 7987<refsynopsisdiv> 7988 <title>Synopsis</title> 7989 <funcsynopsis><funcprototype> 7990 <funcdef>int <function>__bitmap_parselist </function></funcdef> 7991 <paramdef>const char * <parameter>buf</parameter></paramdef> 7992 <paramdef>unsigned int <parameter>buflen</parameter></paramdef> 7993 <paramdef>int <parameter>is_user</parameter></paramdef> 7994 <paramdef>unsigned long * <parameter>maskp</parameter></paramdef> 7995 <paramdef>int <parameter>nmaskbits</parameter></paramdef> 7996 </funcprototype></funcsynopsis> 7997</refsynopsisdiv> 7998<refsect1> 7999 <title>Arguments</title> 8000 <variablelist> 8001 <varlistentry> 8002 <term><parameter>buf</parameter></term> 8003 <listitem> 8004 <para> 8005 read nul-terminated user string from this buffer 8006 </para> 8007 </listitem> 8008 </varlistentry> 8009 <varlistentry> 8010 <term><parameter>buflen</parameter></term> 8011 <listitem> 8012 <para> 8013 buffer size in bytes. If string is smaller than this 8014 then it must be terminated with a \0. 8015 </para> 8016 </listitem> 8017 </varlistentry> 8018 <varlistentry> 8019 <term><parameter>is_user</parameter></term> 8020 <listitem> 8021 <para> 8022 location of buffer, 0 indicates kernel space 8023 </para> 8024 </listitem> 8025 </varlistentry> 8026 <varlistentry> 8027 <term><parameter>maskp</parameter></term> 8028 <listitem> 8029 <para> 8030 write resulting mask here 8031 </para> 8032 </listitem> 8033 </varlistentry> 8034 <varlistentry> 8035 <term><parameter>nmaskbits</parameter></term> 8036 <listitem> 8037 <para> 8038 number of bits in mask to be written 8039 </para> 8040 </listitem> 8041 </varlistentry> 8042 </variablelist> 8043</refsect1> 8044<refsect1> 8045<title>Description</title> 8046<para> 8047 Input format is a comma-separated list of decimal numbers and 8048 ranges. Consecutively set bits are shown as two hyphen-separated 8049 decimal numbers, the smallest and largest bit numbers set in 8050 the range. 8051 </para><para> 8052 8053 Returns 0 on success, -errno on invalid input strings. 8054</para> 8055</refsect1> 8056<refsect1> 8057<title>Error values</title> 8058<para> 8059 <constant>-EINVAL</constant>: second number in range smaller than first 8060 <constant>-EINVAL</constant>: invalid character in string 8061 <constant>-ERANGE</constant>: bit number specified too large for mask 8062</para> 8063</refsect1> 8064</refentry> 8065 8066<refentry id="API-bitmap-pos-to-ord"> 8067<refentryinfo> 8068 <title>LINUX</title> 8069 <productname>Kernel Hackers Manual</productname> 8070 <date>July 2017</date> 8071</refentryinfo> 8072<refmeta> 8073 <refentrytitle><phrase>bitmap_pos_to_ord</phrase></refentrytitle> 8074 <manvolnum>9</manvolnum> 8075 <refmiscinfo class="version">4.1.27</refmiscinfo> 8076</refmeta> 8077<refnamediv> 8078 <refname>bitmap_pos_to_ord</refname> 8079 <refpurpose> 8080 find ordinal of set bit at given position in bitmap 8081 </refpurpose> 8082</refnamediv> 8083<refsynopsisdiv> 8084 <title>Synopsis</title> 8085 <funcsynopsis><funcprototype> 8086 <funcdef>int <function>bitmap_pos_to_ord </function></funcdef> 8087 <paramdef>const unsigned long * <parameter>buf</parameter></paramdef> 8088 <paramdef>unsigned int <parameter>pos</parameter></paramdef> 8089 <paramdef>unsigned int <parameter>nbits</parameter></paramdef> 8090 </funcprototype></funcsynopsis> 8091</refsynopsisdiv> 8092<refsect1> 8093 <title>Arguments</title> 8094 <variablelist> 8095 <varlistentry> 8096 <term><parameter>buf</parameter></term> 8097 <listitem> 8098 <para> 8099 pointer to a bitmap 8100 </para> 8101 </listitem> 8102 </varlistentry> 8103 <varlistentry> 8104 <term><parameter>pos</parameter></term> 8105 <listitem> 8106 <para> 8107 a bit position in <parameter>buf</parameter> (0 <= <parameter>pos</parameter> < <parameter>nbits</parameter>) 8108 </para> 8109 </listitem> 8110 </varlistentry> 8111 <varlistentry> 8112 <term><parameter>nbits</parameter></term> 8113 <listitem> 8114 <para> 8115 number of valid bit positions in <parameter>buf</parameter> 8116 </para> 8117 </listitem> 8118 </varlistentry> 8119 </variablelist> 8120</refsect1> 8121<refsect1> 8122<title>Description</title> 8123<para> 8124 Map the bit at position <parameter>pos</parameter> in <parameter>buf</parameter> (of length <parameter>nbits</parameter>) to the 8125 ordinal of which set bit it is. If it is not set or if <parameter>pos</parameter> 8126 is not a valid bit position, map to -1. 8127 </para><para> 8128 8129 If for example, just bits 4 through 7 are set in <parameter>buf</parameter>, then <parameter>pos</parameter> 8130 values 4 through 7 will get mapped to 0 through 3, respectively, 8131 and other <parameter>pos</parameter> values will get mapped to -1. When <parameter>pos</parameter> value 7 8132 gets mapped to (returns) <parameter>ord</parameter> value 3 in this example, that means 8133 that bit 7 is the 3rd (starting with 0th) set bit in <parameter>buf</parameter>. 8134 </para><para> 8135 8136 The bit positions 0 through <parameter>bits</parameter> are valid positions in <parameter>buf</parameter>. 8137</para> 8138</refsect1> 8139</refentry> 8140 8141<refentry id="API-bitmap-ord-to-pos"> 8142<refentryinfo> 8143 <title>LINUX</title> 8144 <productname>Kernel Hackers Manual</productname> 8145 <date>July 2017</date> 8146</refentryinfo> 8147<refmeta> 8148 <refentrytitle><phrase>bitmap_ord_to_pos</phrase></refentrytitle> 8149 <manvolnum>9</manvolnum> 8150 <refmiscinfo class="version">4.1.27</refmiscinfo> 8151</refmeta> 8152<refnamediv> 8153 <refname>bitmap_ord_to_pos</refname> 8154 <refpurpose> 8155 find position of n-th set bit in bitmap 8156 </refpurpose> 8157</refnamediv> 8158<refsynopsisdiv> 8159 <title>Synopsis</title> 8160 <funcsynopsis><funcprototype> 8161 <funcdef>unsigned int <function>bitmap_ord_to_pos </function></funcdef> 8162 <paramdef>const unsigned long * <parameter>buf</parameter></paramdef> 8163 <paramdef>unsigned int <parameter>ord</parameter></paramdef> 8164 <paramdef>unsigned int <parameter>nbits</parameter></paramdef> 8165 </funcprototype></funcsynopsis> 8166</refsynopsisdiv> 8167<refsect1> 8168 <title>Arguments</title> 8169 <variablelist> 8170 <varlistentry> 8171 <term><parameter>buf</parameter></term> 8172 <listitem> 8173 <para> 8174 pointer to bitmap 8175 </para> 8176 </listitem> 8177 </varlistentry> 8178 <varlistentry> 8179 <term><parameter>ord</parameter></term> 8180 <listitem> 8181 <para> 8182 ordinal bit position (n-th set bit, n >= 0) 8183 </para> 8184 </listitem> 8185 </varlistentry> 8186 <varlistentry> 8187 <term><parameter>nbits</parameter></term> 8188 <listitem> 8189 <para> 8190 number of valid bit positions in <parameter>buf</parameter> 8191 </para> 8192 </listitem> 8193 </varlistentry> 8194 </variablelist> 8195</refsect1> 8196<refsect1> 8197<title>Description</title> 8198<para> 8199 Map the ordinal offset of bit <parameter>ord</parameter> in <parameter>buf</parameter> to its position in <parameter>buf</parameter>. 8200 Value of <parameter>ord</parameter> should be in range 0 <= <parameter>ord</parameter> < weight(buf). If <parameter>ord</parameter> 8201 >= weight(buf), returns <parameter>nbits</parameter>. 8202 </para><para> 8203 8204 If for example, just bits 4 through 7 are set in <parameter>buf</parameter>, then <parameter>ord</parameter> 8205 values 0 through 3 will get mapped to 4 through 7, respectively, 8206 and all other <parameter>ord</parameter> values returns <parameter>nbits</parameter>. When <parameter>ord</parameter> value 3 8207 gets mapped to (returns) <parameter>pos</parameter> value 7 in this example, that means 8208 that the 3rd set bit (starting with 0th) is at position 7 in <parameter>buf</parameter>. 8209 </para><para> 8210 8211 The bit positions 0 through <parameter>nbits</parameter>-1 are valid positions in <parameter>buf</parameter>. 8212</para> 8213</refsect1> 8214</refentry> 8215 8216 </sect1> 8217 8218 <sect1><title>Command-line Parsing</title> 8219<!-- lib/cmdline.c --> 8220<refentry id="API-get-option"> 8221<refentryinfo> 8222 <title>LINUX</title> 8223 <productname>Kernel Hackers Manual</productname> 8224 <date>July 2017</date> 8225</refentryinfo> 8226<refmeta> 8227 <refentrytitle><phrase>get_option</phrase></refentrytitle> 8228 <manvolnum>9</manvolnum> 8229 <refmiscinfo class="version">4.1.27</refmiscinfo> 8230</refmeta> 8231<refnamediv> 8232 <refname>get_option</refname> 8233 <refpurpose> 8234 Parse integer from an option string 8235 </refpurpose> 8236</refnamediv> 8237<refsynopsisdiv> 8238 <title>Synopsis</title> 8239 <funcsynopsis><funcprototype> 8240 <funcdef>int <function>get_option </function></funcdef> 8241 <paramdef>char ** <parameter>str</parameter></paramdef> 8242 <paramdef>int * <parameter>pint</parameter></paramdef> 8243 </funcprototype></funcsynopsis> 8244</refsynopsisdiv> 8245<refsect1> 8246 <title>Arguments</title> 8247 <variablelist> 8248 <varlistentry> 8249 <term><parameter>str</parameter></term> 8250 <listitem> 8251 <para> 8252 option string 8253 </para> 8254 </listitem> 8255 </varlistentry> 8256 <varlistentry> 8257 <term><parameter>pint</parameter></term> 8258 <listitem> 8259 <para> 8260 (output) integer value parsed from <parameter>str</parameter> 8261 </para> 8262 </listitem> 8263 </varlistentry> 8264 </variablelist> 8265</refsect1> 8266<refsect1> 8267<title>Description</title> 8268<para> 8269 Read an int from an option string; if available accept a subsequent 8270 comma as well. 8271</para> 8272</refsect1> 8273<refsect1> 8274<title>Return values</title> 8275<para> 8276 0 - no int in string 8277 1 - int found, no subsequent comma 8278 2 - int found including a subsequent comma 8279 3 - hyphen found to denote a range 8280</para> 8281</refsect1> 8282</refentry> 8283 8284<refentry id="API-get-options"> 8285<refentryinfo> 8286 <title>LINUX</title> 8287 <productname>Kernel Hackers Manual</productname> 8288 <date>July 2017</date> 8289</refentryinfo> 8290<refmeta> 8291 <refentrytitle><phrase>get_options</phrase></refentrytitle> 8292 <manvolnum>9</manvolnum> 8293 <refmiscinfo class="version">4.1.27</refmiscinfo> 8294</refmeta> 8295<refnamediv> 8296 <refname>get_options</refname> 8297 <refpurpose> 8298 Parse a string into a list of integers 8299 </refpurpose> 8300</refnamediv> 8301<refsynopsisdiv> 8302 <title>Synopsis</title> 8303 <funcsynopsis><funcprototype> 8304 <funcdef>char * <function>get_options </function></funcdef> 8305 <paramdef>const char * <parameter>str</parameter></paramdef> 8306 <paramdef>int <parameter>nints</parameter></paramdef> 8307 <paramdef>int * <parameter>ints</parameter></paramdef> 8308 </funcprototype></funcsynopsis> 8309</refsynopsisdiv> 8310<refsect1> 8311 <title>Arguments</title> 8312 <variablelist> 8313 <varlistentry> 8314 <term><parameter>str</parameter></term> 8315 <listitem> 8316 <para> 8317 String to be parsed 8318 </para> 8319 </listitem> 8320 </varlistentry> 8321 <varlistentry> 8322 <term><parameter>nints</parameter></term> 8323 <listitem> 8324 <para> 8325 size of integer array 8326 </para> 8327 </listitem> 8328 </varlistentry> 8329 <varlistentry> 8330 <term><parameter>ints</parameter></term> 8331 <listitem> 8332 <para> 8333 integer array 8334 </para> 8335 </listitem> 8336 </varlistentry> 8337 </variablelist> 8338</refsect1> 8339<refsect1> 8340<title>Description</title> 8341<para> 8342 This function parses a string containing a comma-separated 8343 list of integers, a hyphen-separated range of _positive_ integers, 8344 or a combination of both. The parse halts when the array is 8345 full, or when no more numbers can be retrieved from the 8346 string. 8347 </para><para> 8348 8349 Return value is the character in the string which caused 8350 the parse to end (typically a null terminator, if <parameter>str</parameter> is 8351 completely parseable). 8352</para> 8353</refsect1> 8354</refentry> 8355 8356<refentry id="API-memparse"> 8357<refentryinfo> 8358 <title>LINUX</title> 8359 <productname>Kernel Hackers Manual</productname> 8360 <date>July 2017</date> 8361</refentryinfo> 8362<refmeta> 8363 <refentrytitle><phrase>memparse</phrase></refentrytitle> 8364 <manvolnum>9</manvolnum> 8365 <refmiscinfo class="version">4.1.27</refmiscinfo> 8366</refmeta> 8367<refnamediv> 8368 <refname>memparse</refname> 8369 <refpurpose> 8370 parse a string with mem suffixes into a number 8371 </refpurpose> 8372</refnamediv> 8373<refsynopsisdiv> 8374 <title>Synopsis</title> 8375 <funcsynopsis><funcprototype> 8376 <funcdef>unsigned long long <function>memparse </function></funcdef> 8377 <paramdef>const char * <parameter>ptr</parameter></paramdef> 8378 <paramdef>char ** <parameter>retptr</parameter></paramdef> 8379 </funcprototype></funcsynopsis> 8380</refsynopsisdiv> 8381<refsect1> 8382 <title>Arguments</title> 8383 <variablelist> 8384 <varlistentry> 8385 <term><parameter>ptr</parameter></term> 8386 <listitem> 8387 <para> 8388 Where parse begins 8389 </para> 8390 </listitem> 8391 </varlistentry> 8392 <varlistentry> 8393 <term><parameter>retptr</parameter></term> 8394 <listitem> 8395 <para> 8396 (output) Optional pointer to next char after parse completes 8397 </para> 8398 </listitem> 8399 </varlistentry> 8400 </variablelist> 8401</refsect1> 8402<refsect1> 8403<title>Description</title> 8404<para> 8405 Parses a string into a number. The number stored at <parameter>ptr</parameter> is 8406 potentially suffixed with K, M, G, T, P, E. 8407</para> 8408</refsect1> 8409</refentry> 8410 8411 </sect1> 8412 8413 <sect1 id="crc"><title>CRC Functions</title> 8414<!-- lib/crc7.c --> 8415<refentry id="API-crc7-be"> 8416<refentryinfo> 8417 <title>LINUX</title> 8418 <productname>Kernel Hackers Manual</productname> 8419 <date>July 2017</date> 8420</refentryinfo> 8421<refmeta> 8422 <refentrytitle><phrase>crc7_be</phrase></refentrytitle> 8423 <manvolnum>9</manvolnum> 8424 <refmiscinfo class="version">4.1.27</refmiscinfo> 8425</refmeta> 8426<refnamediv> 8427 <refname>crc7_be</refname> 8428 <refpurpose> 8429 update the CRC7 for the data buffer 8430 </refpurpose> 8431</refnamediv> 8432<refsynopsisdiv> 8433 <title>Synopsis</title> 8434 <funcsynopsis><funcprototype> 8435 <funcdef>u8 <function>crc7_be </function></funcdef> 8436 <paramdef>u8 <parameter>crc</parameter></paramdef> 8437 <paramdef>const u8 * <parameter>buffer</parameter></paramdef> 8438 <paramdef>size_t <parameter>len</parameter></paramdef> 8439 </funcprototype></funcsynopsis> 8440</refsynopsisdiv> 8441<refsect1> 8442 <title>Arguments</title> 8443 <variablelist> 8444 <varlistentry> 8445 <term><parameter>crc</parameter></term> 8446 <listitem> 8447 <para> 8448 previous CRC7 value 8449 </para> 8450 </listitem> 8451 </varlistentry> 8452 <varlistentry> 8453 <term><parameter>buffer</parameter></term> 8454 <listitem> 8455 <para> 8456 data pointer 8457 </para> 8458 </listitem> 8459 </varlistentry> 8460 <varlistentry> 8461 <term><parameter>len</parameter></term> 8462 <listitem> 8463 <para> 8464 number of bytes in the buffer 8465 </para> 8466 </listitem> 8467 </varlistentry> 8468 </variablelist> 8469</refsect1> 8470<refsect1> 8471<title>Context</title> 8472<para> 8473 any 8474</para> 8475</refsect1> 8476<refsect1> 8477<title>Description</title> 8478<para> 8479 Returns the updated CRC7 value. 8480 The CRC7 is left-aligned in the byte (the lsbit is always 0), as that 8481 makes the computation easier, and all callers want it in that form. 8482</para> 8483</refsect1> 8484</refentry> 8485 8486<!-- lib/crc16.c --> 8487<refentry id="API-crc16"> 8488<refentryinfo> 8489 <title>LINUX</title> 8490 <productname>Kernel Hackers Manual</productname> 8491 <date>July 2017</date> 8492</refentryinfo> 8493<refmeta> 8494 <refentrytitle><phrase>crc16</phrase></refentrytitle> 8495 <manvolnum>9</manvolnum> 8496 <refmiscinfo class="version">4.1.27</refmiscinfo> 8497</refmeta> 8498<refnamediv> 8499 <refname>crc16</refname> 8500 <refpurpose> 8501 compute the CRC-16 for the data buffer 8502 </refpurpose> 8503</refnamediv> 8504<refsynopsisdiv> 8505 <title>Synopsis</title> 8506 <funcsynopsis><funcprototype> 8507 <funcdef>u16 <function>crc16 </function></funcdef> 8508 <paramdef>u16 <parameter>crc</parameter></paramdef> 8509 <paramdef>u8 const * <parameter>buffer</parameter></paramdef> 8510 <paramdef>size_t <parameter>len</parameter></paramdef> 8511 </funcprototype></funcsynopsis> 8512</refsynopsisdiv> 8513<refsect1> 8514 <title>Arguments</title> 8515 <variablelist> 8516 <varlistentry> 8517 <term><parameter>crc</parameter></term> 8518 <listitem> 8519 <para> 8520 previous CRC value 8521 </para> 8522 </listitem> 8523 </varlistentry> 8524 <varlistentry> 8525 <term><parameter>buffer</parameter></term> 8526 <listitem> 8527 <para> 8528 data pointer 8529 </para> 8530 </listitem> 8531 </varlistentry> 8532 <varlistentry> 8533 <term><parameter>len</parameter></term> 8534 <listitem> 8535 <para> 8536 number of bytes in the buffer 8537 </para> 8538 </listitem> 8539 </varlistentry> 8540 </variablelist> 8541</refsect1> 8542<refsect1> 8543<title>Description</title> 8544<para> 8545 Returns the updated CRC value. 8546</para> 8547</refsect1> 8548</refentry> 8549 8550<!-- lib/crc-itu-t.c --> 8551<refentry id="API-crc-itu-t"> 8552<refentryinfo> 8553 <title>LINUX</title> 8554 <productname>Kernel Hackers Manual</productname> 8555 <date>July 2017</date> 8556</refentryinfo> 8557<refmeta> 8558 <refentrytitle><phrase>crc_itu_t</phrase></refentrytitle> 8559 <manvolnum>9</manvolnum> 8560 <refmiscinfo class="version">4.1.27</refmiscinfo> 8561</refmeta> 8562<refnamediv> 8563 <refname>crc_itu_t</refname> 8564 <refpurpose> 8565 Compute the CRC-ITU-T for the data buffer 8566 </refpurpose> 8567</refnamediv> 8568<refsynopsisdiv> 8569 <title>Synopsis</title> 8570 <funcsynopsis><funcprototype> 8571 <funcdef>u16 <function>crc_itu_t </function></funcdef> 8572 <paramdef>u16 <parameter>crc</parameter></paramdef> 8573 <paramdef>const u8 * <parameter>buffer</parameter></paramdef> 8574 <paramdef>size_t <parameter>len</parameter></paramdef> 8575 </funcprototype></funcsynopsis> 8576</refsynopsisdiv> 8577<refsect1> 8578 <title>Arguments</title> 8579 <variablelist> 8580 <varlistentry> 8581 <term><parameter>crc</parameter></term> 8582 <listitem> 8583 <para> 8584 previous CRC value 8585 </para> 8586 </listitem> 8587 </varlistentry> 8588 <varlistentry> 8589 <term><parameter>buffer</parameter></term> 8590 <listitem> 8591 <para> 8592 data pointer 8593 </para> 8594 </listitem> 8595 </varlistentry> 8596 <varlistentry> 8597 <term><parameter>len</parameter></term> 8598 <listitem> 8599 <para> 8600 number of bytes in the buffer 8601 </para> 8602 </listitem> 8603 </varlistentry> 8604 </variablelist> 8605</refsect1> 8606<refsect1> 8607<title>Description</title> 8608<para> 8609 Returns the updated CRC value 8610</para> 8611</refsect1> 8612</refentry> 8613 8614<!-- lib/crc32.c --> 8615<refentry> 8616 <refnamediv> 8617 <refname> 8618 .//lib/crc32.c 8619 </refname> 8620 <refpurpose> 8621 Document generation inconsistency 8622 </refpurpose> 8623 </refnamediv> 8624 <refsect1> 8625 <title> 8626 Oops 8627 </title> 8628 <warning> 8629 <para> 8630 The template for this document tried to insert 8631 the structured comment from the file 8632 <filename>.//lib/crc32.c</filename> at this point, 8633 but none was found. 8634 This dummy section is inserted to allow 8635 generation to continue. 8636 </para> 8637 </warning> 8638 </refsect1> 8639</refentry> 8640<!-- lib/crc-ccitt.c --> 8641<refentry id="API-crc-ccitt"> 8642<refentryinfo> 8643 <title>LINUX</title> 8644 <productname>Kernel Hackers Manual</productname> 8645 <date>July 2017</date> 8646</refentryinfo> 8647<refmeta> 8648 <refentrytitle><phrase>crc_ccitt</phrase></refentrytitle> 8649 <manvolnum>9</manvolnum> 8650 <refmiscinfo class="version">4.1.27</refmiscinfo> 8651</refmeta> 8652<refnamediv> 8653 <refname>crc_ccitt</refname> 8654 <refpurpose> 8655 recompute the CRC for the data buffer 8656 </refpurpose> 8657</refnamediv> 8658<refsynopsisdiv> 8659 <title>Synopsis</title> 8660 <funcsynopsis><funcprototype> 8661 <funcdef>u16 <function>crc_ccitt </function></funcdef> 8662 <paramdef>u16 <parameter>crc</parameter></paramdef> 8663 <paramdef>u8 const * <parameter>buffer</parameter></paramdef> 8664 <paramdef>size_t <parameter>len</parameter></paramdef> 8665 </funcprototype></funcsynopsis> 8666</refsynopsisdiv> 8667<refsect1> 8668 <title>Arguments</title> 8669 <variablelist> 8670 <varlistentry> 8671 <term><parameter>crc</parameter></term> 8672 <listitem> 8673 <para> 8674 previous CRC value 8675 </para> 8676 </listitem> 8677 </varlistentry> 8678 <varlistentry> 8679 <term><parameter>buffer</parameter></term> 8680 <listitem> 8681 <para> 8682 data pointer 8683 </para> 8684 </listitem> 8685 </varlistentry> 8686 <varlistentry> 8687 <term><parameter>len</parameter></term> 8688 <listitem> 8689 <para> 8690 number of bytes in the buffer 8691 </para> 8692 </listitem> 8693 </varlistentry> 8694 </variablelist> 8695</refsect1> 8696</refentry> 8697 8698 </sect1> 8699 8700 <sect1 id="idr"><title>idr/ida Functions</title> 8701<para> 8702 idr synchronization (stolen from radix-tree.h) 8703 </para><para> 8704 <function>idr_find</function> is able to be called locklessly, using RCU. The caller must 8705 ensure calls to this function are made within <function>rcu_read_lock</function> regions. 8706 Other readers (lock-free or otherwise) and modifications may be running 8707 concurrently. 8708 </para><para> 8709 It is still required that the caller manage the synchronization and 8710 lifetimes of the items. So if RCU lock-free lookups are used, typically 8711 this would mean that the items have their own locks, or are amenable to 8712 lock-free access; and that the items are freed by RCU (or only freed after 8713 having been deleted from the idr tree *and* a <function>synchronize_rcu</function> grace 8714 period). 8715</para> 8716 8717<para> 8718 IDA - IDR based ID allocator 8719 </para><para> 8720 This is id allocator without id -> pointer translation. Memory 8721 usage is much lower than full blown idr because each id only 8722 occupies a bit. ida uses a custom leaf node which contains 8723 IDA_BITMAP_BITS slots. 8724 </para><para> 8725 2007-04-25 written by Tejun Heo <htejun<parameter>gmail</parameter>.com> 8726</para> 8727 8728<!-- lib/idr.c --> 8729<refentry id="API-idr-preload"> 8730<refentryinfo> 8731 <title>LINUX</title> 8732 <productname>Kernel Hackers Manual</productname> 8733 <date>July 2017</date> 8734</refentryinfo> 8735<refmeta> 8736 <refentrytitle><phrase>idr_preload</phrase></refentrytitle> 8737 <manvolnum>9</manvolnum> 8738 <refmiscinfo class="version">4.1.27</refmiscinfo> 8739</refmeta> 8740<refnamediv> 8741 <refname>idr_preload</refname> 8742 <refpurpose> 8743 preload for <function>idr_alloc</function> 8744 </refpurpose> 8745</refnamediv> 8746<refsynopsisdiv> 8747 <title>Synopsis</title> 8748 <funcsynopsis><funcprototype> 8749 <funcdef>void <function>idr_preload </function></funcdef> 8750 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 8751 </funcprototype></funcsynopsis> 8752</refsynopsisdiv> 8753<refsect1> 8754 <title>Arguments</title> 8755 <variablelist> 8756 <varlistentry> 8757 <term><parameter>gfp_mask</parameter></term> 8758 <listitem> 8759 <para> 8760 allocation mask to use for preloading 8761 </para> 8762 </listitem> 8763 </varlistentry> 8764 </variablelist> 8765</refsect1> 8766<refsect1> 8767<title>Description</title> 8768<para> 8769 Preload per-cpu layer buffer for <function>idr_alloc</function>. Can only be used from 8770 process context and each <function>idr_preload</function> invocation should be matched with 8771 <function>idr_preload_end</function>. Note that preemption is disabled while preloaded. 8772 </para><para> 8773 8774 The first <function>idr_alloc</function> in the preloaded section can be treated as if it 8775 were invoked with <parameter>gfp_mask</parameter> used for preloading. This allows using more 8776 permissive allocation masks for idrs protected by spinlocks. 8777 </para><para> 8778 8779 For example, if <function>idr_alloc</function> below fails, the failure can be treated as 8780 if <function>idr_alloc</function> were called with GFP_KERNEL rather than GFP_NOWAIT. 8781 </para><para> 8782 8783 idr_preload(GFP_KERNEL); 8784 spin_lock(lock); 8785 </para><para> 8786 8787 id = idr_alloc(idr, ptr, start, end, GFP_NOWAIT); 8788 </para><para> 8789 8790 spin_unlock(lock); 8791 <function>idr_preload_end</function>; 8792 if (id < 0) 8793 error; 8794</para> 8795</refsect1> 8796</refentry> 8797 8798<refentry id="API-idr-alloc"> 8799<refentryinfo> 8800 <title>LINUX</title> 8801 <productname>Kernel Hackers Manual</productname> 8802 <date>July 2017</date> 8803</refentryinfo> 8804<refmeta> 8805 <refentrytitle><phrase>idr_alloc</phrase></refentrytitle> 8806 <manvolnum>9</manvolnum> 8807 <refmiscinfo class="version">4.1.27</refmiscinfo> 8808</refmeta> 8809<refnamediv> 8810 <refname>idr_alloc</refname> 8811 <refpurpose> 8812 allocate new idr entry 8813 </refpurpose> 8814</refnamediv> 8815<refsynopsisdiv> 8816 <title>Synopsis</title> 8817 <funcsynopsis><funcprototype> 8818 <funcdef>int <function>idr_alloc </function></funcdef> 8819 <paramdef>struct idr * <parameter>idr</parameter></paramdef> 8820 <paramdef>void * <parameter>ptr</parameter></paramdef> 8821 <paramdef>int <parameter>start</parameter></paramdef> 8822 <paramdef>int <parameter>end</parameter></paramdef> 8823 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 8824 </funcprototype></funcsynopsis> 8825</refsynopsisdiv> 8826<refsect1> 8827 <title>Arguments</title> 8828 <variablelist> 8829 <varlistentry> 8830 <term><parameter>idr</parameter></term> 8831 <listitem> 8832 <para> 8833 the (initialized) idr 8834 </para> 8835 </listitem> 8836 </varlistentry> 8837 <varlistentry> 8838 <term><parameter>ptr</parameter></term> 8839 <listitem> 8840 <para> 8841 pointer to be associated with the new id 8842 </para> 8843 </listitem> 8844 </varlistentry> 8845 <varlistentry> 8846 <term><parameter>start</parameter></term> 8847 <listitem> 8848 <para> 8849 the minimum id (inclusive) 8850 </para> 8851 </listitem> 8852 </varlistentry> 8853 <varlistentry> 8854 <term><parameter>end</parameter></term> 8855 <listitem> 8856 <para> 8857 the maximum id (exclusive, <= 0 for max) 8858 </para> 8859 </listitem> 8860 </varlistentry> 8861 <varlistentry> 8862 <term><parameter>gfp_mask</parameter></term> 8863 <listitem> 8864 <para> 8865 memory allocation flags 8866 </para> 8867 </listitem> 8868 </varlistentry> 8869 </variablelist> 8870</refsect1> 8871<refsect1> 8872<title>Description</title> 8873<para> 8874 Allocate an id in [start, end) and associate it with <parameter>ptr</parameter>. If no ID is 8875 available in the specified range, returns -ENOSPC. On memory allocation 8876 failure, returns -ENOMEM. 8877 </para><para> 8878 8879 Note that <parameter>end</parameter> is treated as max when <= 0. This is to always allow 8880 using <parameter>start</parameter> + N as <parameter>end</parameter> as long as N is inside integer range. 8881 </para><para> 8882 8883 The user is responsible for exclusively synchronizing all operations 8884 which may modify <parameter>idr</parameter>. However, read-only accesses such as <function>idr_find</function> 8885 or iteration can be performed under RCU read lock provided the user 8886 destroys <parameter>ptr</parameter> in RCU-safe way after removal from idr. 8887</para> 8888</refsect1> 8889</refentry> 8890 8891<refentry id="API-idr-alloc-cyclic"> 8892<refentryinfo> 8893 <title>LINUX</title> 8894 <productname>Kernel Hackers Manual</productname> 8895 <date>July 2017</date> 8896</refentryinfo> 8897<refmeta> 8898 <refentrytitle><phrase>idr_alloc_cyclic</phrase></refentrytitle> 8899 <manvolnum>9</manvolnum> 8900 <refmiscinfo class="version">4.1.27</refmiscinfo> 8901</refmeta> 8902<refnamediv> 8903 <refname>idr_alloc_cyclic</refname> 8904 <refpurpose> 8905 allocate new idr entry in a cyclical fashion 8906 </refpurpose> 8907</refnamediv> 8908<refsynopsisdiv> 8909 <title>Synopsis</title> 8910 <funcsynopsis><funcprototype> 8911 <funcdef>int <function>idr_alloc_cyclic </function></funcdef> 8912 <paramdef>struct idr * <parameter>idr</parameter></paramdef> 8913 <paramdef>void * <parameter>ptr</parameter></paramdef> 8914 <paramdef>int <parameter>start</parameter></paramdef> 8915 <paramdef>int <parameter>end</parameter></paramdef> 8916 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 8917 </funcprototype></funcsynopsis> 8918</refsynopsisdiv> 8919<refsect1> 8920 <title>Arguments</title> 8921 <variablelist> 8922 <varlistentry> 8923 <term><parameter>idr</parameter></term> 8924 <listitem> 8925 <para> 8926 the (initialized) idr 8927 </para> 8928 </listitem> 8929 </varlistentry> 8930 <varlistentry> 8931 <term><parameter>ptr</parameter></term> 8932 <listitem> 8933 <para> 8934 pointer to be associated with the new id 8935 </para> 8936 </listitem> 8937 </varlistentry> 8938 <varlistentry> 8939 <term><parameter>start</parameter></term> 8940 <listitem> 8941 <para> 8942 the minimum id (inclusive) 8943 </para> 8944 </listitem> 8945 </varlistentry> 8946 <varlistentry> 8947 <term><parameter>end</parameter></term> 8948 <listitem> 8949 <para> 8950 the maximum id (exclusive, <= 0 for max) 8951 </para> 8952 </listitem> 8953 </varlistentry> 8954 <varlistentry> 8955 <term><parameter>gfp_mask</parameter></term> 8956 <listitem> 8957 <para> 8958 memory allocation flags 8959 </para> 8960 </listitem> 8961 </varlistentry> 8962 </variablelist> 8963</refsect1> 8964<refsect1> 8965<title>Description</title> 8966<para> 8967 Essentially the same as idr_alloc, but prefers to allocate progressively 8968 higher ids if it can. If the <quote>cur</quote> counter wraps, then it will start again 8969 at the <quote>start</quote> end of the range and allocate one that has already been used. 8970</para> 8971</refsect1> 8972</refentry> 8973 8974<refentry id="API-idr-remove"> 8975<refentryinfo> 8976 <title>LINUX</title> 8977 <productname>Kernel Hackers Manual</productname> 8978 <date>July 2017</date> 8979</refentryinfo> 8980<refmeta> 8981 <refentrytitle><phrase>idr_remove</phrase></refentrytitle> 8982 <manvolnum>9</manvolnum> 8983 <refmiscinfo class="version">4.1.27</refmiscinfo> 8984</refmeta> 8985<refnamediv> 8986 <refname>idr_remove</refname> 8987 <refpurpose> 8988 remove the given id and free its slot 8989 </refpurpose> 8990</refnamediv> 8991<refsynopsisdiv> 8992 <title>Synopsis</title> 8993 <funcsynopsis><funcprototype> 8994 <funcdef>void <function>idr_remove </function></funcdef> 8995 <paramdef>struct idr * <parameter>idp</parameter></paramdef> 8996 <paramdef>int <parameter>id</parameter></paramdef> 8997 </funcprototype></funcsynopsis> 8998</refsynopsisdiv> 8999<refsect1> 9000 <title>Arguments</title> 9001 <variablelist> 9002 <varlistentry> 9003 <term><parameter>idp</parameter></term> 9004 <listitem> 9005 <para> 9006 idr handle 9007 </para> 9008 </listitem> 9009 </varlistentry> 9010 <varlistentry> 9011 <term><parameter>id</parameter></term> 9012 <listitem> 9013 <para> 9014 unique key 9015 </para> 9016 </listitem> 9017 </varlistentry> 9018 </variablelist> 9019</refsect1> 9020</refentry> 9021 9022<refentry id="API-idr-destroy"> 9023<refentryinfo> 9024 <title>LINUX</title> 9025 <productname>Kernel Hackers Manual</productname> 9026 <date>July 2017</date> 9027</refentryinfo> 9028<refmeta> 9029 <refentrytitle><phrase>idr_destroy</phrase></refentrytitle> 9030 <manvolnum>9</manvolnum> 9031 <refmiscinfo class="version">4.1.27</refmiscinfo> 9032</refmeta> 9033<refnamediv> 9034 <refname>idr_destroy</refname> 9035 <refpurpose> 9036 release all cached layers within an idr tree 9037 </refpurpose> 9038</refnamediv> 9039<refsynopsisdiv> 9040 <title>Synopsis</title> 9041 <funcsynopsis><funcprototype> 9042 <funcdef>void <function>idr_destroy </function></funcdef> 9043 <paramdef>struct idr * <parameter>idp</parameter></paramdef> 9044 </funcprototype></funcsynopsis> 9045</refsynopsisdiv> 9046<refsect1> 9047 <title>Arguments</title> 9048 <variablelist> 9049 <varlistentry> 9050 <term><parameter>idp</parameter></term> 9051 <listitem> 9052 <para> 9053 idr handle 9054 </para> 9055 </listitem> 9056 </varlistentry> 9057 </variablelist> 9058</refsect1> 9059<refsect1> 9060<title>Description</title> 9061<para> 9062 Free all id mappings and all idp_layers. After this function, <parameter>idp</parameter> is 9063 completely unused and can be freed / recycled. The caller is 9064 responsible for ensuring that no one else accesses <parameter>idp</parameter> during or after 9065 <function>idr_destroy</function>. 9066 </para><para> 9067 9068 A typical clean-up sequence for objects stored in an idr tree will use 9069 <function>idr_for_each</function> to free all objects, if necessary, then <function>idr_destroy</function> to 9070 free up the id mappings and cached idr_layers. 9071</para> 9072</refsect1> 9073</refentry> 9074 9075<refentry id="API-idr-for-each"> 9076<refentryinfo> 9077 <title>LINUX</title> 9078 <productname>Kernel Hackers Manual</productname> 9079 <date>July 2017</date> 9080</refentryinfo> 9081<refmeta> 9082 <refentrytitle><phrase>idr_for_each</phrase></refentrytitle> 9083 <manvolnum>9</manvolnum> 9084 <refmiscinfo class="version">4.1.27</refmiscinfo> 9085</refmeta> 9086<refnamediv> 9087 <refname>idr_for_each</refname> 9088 <refpurpose> 9089 iterate through all stored pointers 9090 </refpurpose> 9091</refnamediv> 9092<refsynopsisdiv> 9093 <title>Synopsis</title> 9094 <funcsynopsis><funcprototype> 9095 <funcdef>int <function>idr_for_each </function></funcdef> 9096 <paramdef>struct idr * <parameter>idp</parameter></paramdef> 9097 <paramdef>int (*<parameter>fn</parameter>) 9098 <funcparams>int id, void *p, void *data</funcparams></paramdef> 9099 <paramdef>void * <parameter>data</parameter></paramdef> 9100 </funcprototype></funcsynopsis> 9101</refsynopsisdiv> 9102<refsect1> 9103 <title>Arguments</title> 9104 <variablelist> 9105 <varlistentry> 9106 <term><parameter>idp</parameter></term> 9107 <listitem> 9108 <para> 9109 idr handle 9110 </para> 9111 </listitem> 9112 </varlistentry> 9113 <varlistentry> 9114 <term><parameter>fn</parameter></term> 9115 <listitem> 9116 <para> 9117 function to be called for each pointer 9118 </para> 9119 </listitem> 9120 </varlistentry> 9121 <varlistentry> 9122 <term><parameter>data</parameter></term> 9123 <listitem> 9124 <para> 9125 data passed back to callback function 9126 </para> 9127 </listitem> 9128 </varlistentry> 9129 </variablelist> 9130</refsect1> 9131<refsect1> 9132<title>Description</title> 9133<para> 9134 Iterate over the pointers registered with the given idr. The 9135 callback function will be called for each pointer currently 9136 registered, passing the id, the pointer and the data pointer passed 9137 to this function. It is not safe to modify the idr tree while in 9138 the callback, so functions such as idr_get_new and idr_remove are 9139 not allowed. 9140 </para><para> 9141 9142 We check the return of <parameter>fn</parameter> each time. If it returns anything other 9143 than <constant>0</constant>, we break out and return that value. 9144 </para><para> 9145 9146 The caller must serialize <function>idr_for_each</function> vs <function>idr_get_new</function> and <function>idr_remove</function>. 9147</para> 9148</refsect1> 9149</refentry> 9150 9151<refentry id="API-idr-get-next"> 9152<refentryinfo> 9153 <title>LINUX</title> 9154 <productname>Kernel Hackers Manual</productname> 9155 <date>July 2017</date> 9156</refentryinfo> 9157<refmeta> 9158 <refentrytitle><phrase>idr_get_next</phrase></refentrytitle> 9159 <manvolnum>9</manvolnum> 9160 <refmiscinfo class="version">4.1.27</refmiscinfo> 9161</refmeta> 9162<refnamediv> 9163 <refname>idr_get_next</refname> 9164 <refpurpose> 9165 lookup next object of id to given id. 9166 </refpurpose> 9167</refnamediv> 9168<refsynopsisdiv> 9169 <title>Synopsis</title> 9170 <funcsynopsis><funcprototype> 9171 <funcdef>void * <function>idr_get_next </function></funcdef> 9172 <paramdef>struct idr * <parameter>idp</parameter></paramdef> 9173 <paramdef>int * <parameter>nextidp</parameter></paramdef> 9174 </funcprototype></funcsynopsis> 9175</refsynopsisdiv> 9176<refsect1> 9177 <title>Arguments</title> 9178 <variablelist> 9179 <varlistentry> 9180 <term><parameter>idp</parameter></term> 9181 <listitem> 9182 <para> 9183 idr handle 9184 </para> 9185 </listitem> 9186 </varlistentry> 9187 <varlistentry> 9188 <term><parameter>nextidp</parameter></term> 9189 <listitem> 9190 <para> 9191 pointer to lookup key 9192 </para> 9193 </listitem> 9194 </varlistentry> 9195 </variablelist> 9196</refsect1> 9197<refsect1> 9198<title>Description</title> 9199<para> 9200 Returns pointer to registered object with id, which is next number to 9201 given id. After being looked up, *<parameter>nextidp</parameter> will be updated for the next 9202 iteration. 9203 </para><para> 9204 9205 This function can be called under <function>rcu_read_lock</function>, given that the leaf 9206 pointers lifetimes are correctly managed. 9207</para> 9208</refsect1> 9209</refentry> 9210 9211<refentry id="API-idr-replace"> 9212<refentryinfo> 9213 <title>LINUX</title> 9214 <productname>Kernel Hackers Manual</productname> 9215 <date>July 2017</date> 9216</refentryinfo> 9217<refmeta> 9218 <refentrytitle><phrase>idr_replace</phrase></refentrytitle> 9219 <manvolnum>9</manvolnum> 9220 <refmiscinfo class="version">4.1.27</refmiscinfo> 9221</refmeta> 9222<refnamediv> 9223 <refname>idr_replace</refname> 9224 <refpurpose> 9225 replace pointer for given id 9226 </refpurpose> 9227</refnamediv> 9228<refsynopsisdiv> 9229 <title>Synopsis</title> 9230 <funcsynopsis><funcprototype> 9231 <funcdef>void * <function>idr_replace </function></funcdef> 9232 <paramdef>struct idr * <parameter>idp</parameter></paramdef> 9233 <paramdef>void * <parameter>ptr</parameter></paramdef> 9234 <paramdef>int <parameter>id</parameter></paramdef> 9235 </funcprototype></funcsynopsis> 9236</refsynopsisdiv> 9237<refsect1> 9238 <title>Arguments</title> 9239 <variablelist> 9240 <varlistentry> 9241 <term><parameter>idp</parameter></term> 9242 <listitem> 9243 <para> 9244 idr handle 9245 </para> 9246 </listitem> 9247 </varlistentry> 9248 <varlistentry> 9249 <term><parameter>ptr</parameter></term> 9250 <listitem> 9251 <para> 9252 pointer you want associated with the id 9253 </para> 9254 </listitem> 9255 </varlistentry> 9256 <varlistentry> 9257 <term><parameter>id</parameter></term> 9258 <listitem> 9259 <para> 9260 lookup key 9261 </para> 9262 </listitem> 9263 </varlistentry> 9264 </variablelist> 9265</refsect1> 9266<refsect1> 9267<title>Description</title> 9268<para> 9269 Replace the pointer registered with an id and return the old value. 9270 A <constant>-ENOENT</constant> return indicates that <parameter>id</parameter> was not found. 9271 A <constant>-EINVAL</constant> return indicates that <parameter>id</parameter> was not within valid constraints. 9272 </para><para> 9273 9274 The caller must serialize with writers. 9275</para> 9276</refsect1> 9277</refentry> 9278 9279<refentry id="API-idr-init"> 9280<refentryinfo> 9281 <title>LINUX</title> 9282 <productname>Kernel Hackers Manual</productname> 9283 <date>July 2017</date> 9284</refentryinfo> 9285<refmeta> 9286 <refentrytitle><phrase>idr_init</phrase></refentrytitle> 9287 <manvolnum>9</manvolnum> 9288 <refmiscinfo class="version">4.1.27</refmiscinfo> 9289</refmeta> 9290<refnamediv> 9291 <refname>idr_init</refname> 9292 <refpurpose> 9293 initialize idr handle 9294 </refpurpose> 9295</refnamediv> 9296<refsynopsisdiv> 9297 <title>Synopsis</title> 9298 <funcsynopsis><funcprototype> 9299 <funcdef>void <function>idr_init </function></funcdef> 9300 <paramdef>struct idr * <parameter>idp</parameter></paramdef> 9301 </funcprototype></funcsynopsis> 9302</refsynopsisdiv> 9303<refsect1> 9304 <title>Arguments</title> 9305 <variablelist> 9306 <varlistentry> 9307 <term><parameter>idp</parameter></term> 9308 <listitem> 9309 <para> 9310 idr handle 9311 </para> 9312 </listitem> 9313 </varlistentry> 9314 </variablelist> 9315</refsect1> 9316<refsect1> 9317<title>Description</title> 9318<para> 9319 This function is use to set up the handle (<parameter>idp</parameter>) that you will pass 9320 to the rest of the functions. 9321</para> 9322</refsect1> 9323</refentry> 9324 9325<refentry id="API-ida-pre-get"> 9326<refentryinfo> 9327 <title>LINUX</title> 9328 <productname>Kernel Hackers Manual</productname> 9329 <date>July 2017</date> 9330</refentryinfo> 9331<refmeta> 9332 <refentrytitle><phrase>ida_pre_get</phrase></refentrytitle> 9333 <manvolnum>9</manvolnum> 9334 <refmiscinfo class="version">4.1.27</refmiscinfo> 9335</refmeta> 9336<refnamediv> 9337 <refname>ida_pre_get</refname> 9338 <refpurpose> 9339 reserve resources for ida allocation 9340 </refpurpose> 9341</refnamediv> 9342<refsynopsisdiv> 9343 <title>Synopsis</title> 9344 <funcsynopsis><funcprototype> 9345 <funcdef>int <function>ida_pre_get </function></funcdef> 9346 <paramdef>struct ida * <parameter>ida</parameter></paramdef> 9347 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 9348 </funcprototype></funcsynopsis> 9349</refsynopsisdiv> 9350<refsect1> 9351 <title>Arguments</title> 9352 <variablelist> 9353 <varlistentry> 9354 <term><parameter>ida</parameter></term> 9355 <listitem> 9356 <para> 9357 ida handle 9358 </para> 9359 </listitem> 9360 </varlistentry> 9361 <varlistentry> 9362 <term><parameter>gfp_mask</parameter></term> 9363 <listitem> 9364 <para> 9365 memory allocation flag 9366 </para> 9367 </listitem> 9368 </varlistentry> 9369 </variablelist> 9370</refsect1> 9371<refsect1> 9372<title>Description</title> 9373<para> 9374 This function should be called prior to locking and calling the 9375 following function. It preallocates enough memory to satisfy the 9376 worst possible allocation. 9377 </para><para> 9378 9379 If the system is REALLY out of memory this function returns <constant>0</constant>, 9380 otherwise <constant>1</constant>. 9381</para> 9382</refsect1> 9383</refentry> 9384 9385<refentry id="API-ida-get-new-above"> 9386<refentryinfo> 9387 <title>LINUX</title> 9388 <productname>Kernel Hackers Manual</productname> 9389 <date>July 2017</date> 9390</refentryinfo> 9391<refmeta> 9392 <refentrytitle><phrase>ida_get_new_above</phrase></refentrytitle> 9393 <manvolnum>9</manvolnum> 9394 <refmiscinfo class="version">4.1.27</refmiscinfo> 9395</refmeta> 9396<refnamediv> 9397 <refname>ida_get_new_above</refname> 9398 <refpurpose> 9399 allocate new ID above or equal to a start id 9400 </refpurpose> 9401</refnamediv> 9402<refsynopsisdiv> 9403 <title>Synopsis</title> 9404 <funcsynopsis><funcprototype> 9405 <funcdef>int <function>ida_get_new_above </function></funcdef> 9406 <paramdef>struct ida * <parameter>ida</parameter></paramdef> 9407 <paramdef>int <parameter>starting_id</parameter></paramdef> 9408 <paramdef>int * <parameter>p_id</parameter></paramdef> 9409 </funcprototype></funcsynopsis> 9410</refsynopsisdiv> 9411<refsect1> 9412 <title>Arguments</title> 9413 <variablelist> 9414 <varlistentry> 9415 <term><parameter>ida</parameter></term> 9416 <listitem> 9417 <para> 9418 ida handle 9419 </para> 9420 </listitem> 9421 </varlistentry> 9422 <varlistentry> 9423 <term><parameter>starting_id</parameter></term> 9424 <listitem> 9425 <para> 9426 id to start search at 9427 </para> 9428 </listitem> 9429 </varlistentry> 9430 <varlistentry> 9431 <term><parameter>p_id</parameter></term> 9432 <listitem> 9433 <para> 9434 pointer to the allocated handle 9435 </para> 9436 </listitem> 9437 </varlistentry> 9438 </variablelist> 9439</refsect1> 9440<refsect1> 9441<title>Description</title> 9442<para> 9443 Allocate new ID above or equal to <parameter>starting_id</parameter>. It should be called 9444 with any required locks. 9445 </para><para> 9446 9447 If memory is required, it will return <constant>-EAGAIN</constant>, you should unlock 9448 and go back to the <function>ida_pre_get</function> call. If the ida is full, it will 9449 return <constant>-ENOSPC</constant>. 9450 </para><para> 9451 9452 <parameter>p_id</parameter> returns a value in the range <parameter>starting_id</parameter> ... <constant>0x7fffffff</constant>. 9453</para> 9454</refsect1> 9455</refentry> 9456 9457<refentry id="API-ida-remove"> 9458<refentryinfo> 9459 <title>LINUX</title> 9460 <productname>Kernel Hackers Manual</productname> 9461 <date>July 2017</date> 9462</refentryinfo> 9463<refmeta> 9464 <refentrytitle><phrase>ida_remove</phrase></refentrytitle> 9465 <manvolnum>9</manvolnum> 9466 <refmiscinfo class="version">4.1.27</refmiscinfo> 9467</refmeta> 9468<refnamediv> 9469 <refname>ida_remove</refname> 9470 <refpurpose> 9471 remove the given ID 9472 </refpurpose> 9473</refnamediv> 9474<refsynopsisdiv> 9475 <title>Synopsis</title> 9476 <funcsynopsis><funcprototype> 9477 <funcdef>void <function>ida_remove </function></funcdef> 9478 <paramdef>struct ida * <parameter>ida</parameter></paramdef> 9479 <paramdef>int <parameter>id</parameter></paramdef> 9480 </funcprototype></funcsynopsis> 9481</refsynopsisdiv> 9482<refsect1> 9483 <title>Arguments</title> 9484 <variablelist> 9485 <varlistentry> 9486 <term><parameter>ida</parameter></term> 9487 <listitem> 9488 <para> 9489 ida handle 9490 </para> 9491 </listitem> 9492 </varlistentry> 9493 <varlistentry> 9494 <term><parameter>id</parameter></term> 9495 <listitem> 9496 <para> 9497 ID to free 9498 </para> 9499 </listitem> 9500 </varlistentry> 9501 </variablelist> 9502</refsect1> 9503</refentry> 9504 9505<refentry id="API-ida-destroy"> 9506<refentryinfo> 9507 <title>LINUX</title> 9508 <productname>Kernel Hackers Manual</productname> 9509 <date>July 2017</date> 9510</refentryinfo> 9511<refmeta> 9512 <refentrytitle><phrase>ida_destroy</phrase></refentrytitle> 9513 <manvolnum>9</manvolnum> 9514 <refmiscinfo class="version">4.1.27</refmiscinfo> 9515</refmeta> 9516<refnamediv> 9517 <refname>ida_destroy</refname> 9518 <refpurpose> 9519 release all cached layers within an ida tree 9520 </refpurpose> 9521</refnamediv> 9522<refsynopsisdiv> 9523 <title>Synopsis</title> 9524 <funcsynopsis><funcprototype> 9525 <funcdef>void <function>ida_destroy </function></funcdef> 9526 <paramdef>struct ida * <parameter>ida</parameter></paramdef> 9527 </funcprototype></funcsynopsis> 9528</refsynopsisdiv> 9529<refsect1> 9530 <title>Arguments</title> 9531 <variablelist> 9532 <varlistentry> 9533 <term><parameter>ida</parameter></term> 9534 <listitem> 9535 <para> 9536 ida handle 9537 </para> 9538 </listitem> 9539 </varlistentry> 9540 </variablelist> 9541</refsect1> 9542</refentry> 9543 9544<refentry id="API-ida-simple-get"> 9545<refentryinfo> 9546 <title>LINUX</title> 9547 <productname>Kernel Hackers Manual</productname> 9548 <date>July 2017</date> 9549</refentryinfo> 9550<refmeta> 9551 <refentrytitle><phrase>ida_simple_get</phrase></refentrytitle> 9552 <manvolnum>9</manvolnum> 9553 <refmiscinfo class="version">4.1.27</refmiscinfo> 9554</refmeta> 9555<refnamediv> 9556 <refname>ida_simple_get</refname> 9557 <refpurpose> 9558 get a new id. 9559 </refpurpose> 9560</refnamediv> 9561<refsynopsisdiv> 9562 <title>Synopsis</title> 9563 <funcsynopsis><funcprototype> 9564 <funcdef>int <function>ida_simple_get </function></funcdef> 9565 <paramdef>struct ida * <parameter>ida</parameter></paramdef> 9566 <paramdef>unsigned int <parameter>start</parameter></paramdef> 9567 <paramdef>unsigned int <parameter>end</parameter></paramdef> 9568 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 9569 </funcprototype></funcsynopsis> 9570</refsynopsisdiv> 9571<refsect1> 9572 <title>Arguments</title> 9573 <variablelist> 9574 <varlistentry> 9575 <term><parameter>ida</parameter></term> 9576 <listitem> 9577 <para> 9578 the (initialized) ida. 9579 </para> 9580 </listitem> 9581 </varlistentry> 9582 <varlistentry> 9583 <term><parameter>start</parameter></term> 9584 <listitem> 9585 <para> 9586 the minimum id (inclusive, < 0x8000000) 9587 </para> 9588 </listitem> 9589 </varlistentry> 9590 <varlistentry> 9591 <term><parameter>end</parameter></term> 9592 <listitem> 9593 <para> 9594 the maximum id (exclusive, < 0x8000000 or 0) 9595 </para> 9596 </listitem> 9597 </varlistentry> 9598 <varlistentry> 9599 <term><parameter>gfp_mask</parameter></term> 9600 <listitem> 9601 <para> 9602 memory allocation flags 9603 </para> 9604 </listitem> 9605 </varlistentry> 9606 </variablelist> 9607</refsect1> 9608<refsect1> 9609<title>Description</title> 9610<para> 9611 Allocates an id in the range start <= id < end, or returns -ENOSPC. 9612 On memory allocation failure, returns -ENOMEM. 9613 </para><para> 9614 9615 Use <function>ida_simple_remove</function> to get rid of an id. 9616</para> 9617</refsect1> 9618</refentry> 9619 9620<refentry id="API-ida-simple-remove"> 9621<refentryinfo> 9622 <title>LINUX</title> 9623 <productname>Kernel Hackers Manual</productname> 9624 <date>July 2017</date> 9625</refentryinfo> 9626<refmeta> 9627 <refentrytitle><phrase>ida_simple_remove</phrase></refentrytitle> 9628 <manvolnum>9</manvolnum> 9629 <refmiscinfo class="version">4.1.27</refmiscinfo> 9630</refmeta> 9631<refnamediv> 9632 <refname>ida_simple_remove</refname> 9633 <refpurpose> 9634 remove an allocated id. 9635 </refpurpose> 9636</refnamediv> 9637<refsynopsisdiv> 9638 <title>Synopsis</title> 9639 <funcsynopsis><funcprototype> 9640 <funcdef>void <function>ida_simple_remove </function></funcdef> 9641 <paramdef>struct ida * <parameter>ida</parameter></paramdef> 9642 <paramdef>unsigned int <parameter>id</parameter></paramdef> 9643 </funcprototype></funcsynopsis> 9644</refsynopsisdiv> 9645<refsect1> 9646 <title>Arguments</title> 9647 <variablelist> 9648 <varlistentry> 9649 <term><parameter>ida</parameter></term> 9650 <listitem> 9651 <para> 9652 the (initialized) ida. 9653 </para> 9654 </listitem> 9655 </varlistentry> 9656 <varlistentry> 9657 <term><parameter>id</parameter></term> 9658 <listitem> 9659 <para> 9660 the id returned by ida_simple_get. 9661 </para> 9662 </listitem> 9663 </varlistentry> 9664 </variablelist> 9665</refsect1> 9666</refentry> 9667 9668<refentry id="API-ida-init"> 9669<refentryinfo> 9670 <title>LINUX</title> 9671 <productname>Kernel Hackers Manual</productname> 9672 <date>July 2017</date> 9673</refentryinfo> 9674<refmeta> 9675 <refentrytitle><phrase>ida_init</phrase></refentrytitle> 9676 <manvolnum>9</manvolnum> 9677 <refmiscinfo class="version">4.1.27</refmiscinfo> 9678</refmeta> 9679<refnamediv> 9680 <refname>ida_init</refname> 9681 <refpurpose> 9682 initialize ida handle 9683 </refpurpose> 9684</refnamediv> 9685<refsynopsisdiv> 9686 <title>Synopsis</title> 9687 <funcsynopsis><funcprototype> 9688 <funcdef>void <function>ida_init </function></funcdef> 9689 <paramdef>struct ida * <parameter>ida</parameter></paramdef> 9690 </funcprototype></funcsynopsis> 9691</refsynopsisdiv> 9692<refsect1> 9693 <title>Arguments</title> 9694 <variablelist> 9695 <varlistentry> 9696 <term><parameter>ida</parameter></term> 9697 <listitem> 9698 <para> 9699 ida handle 9700 </para> 9701 </listitem> 9702 </varlistentry> 9703 </variablelist> 9704</refsect1> 9705<refsect1> 9706<title>Description</title> 9707<para> 9708 This function is use to set up the handle (<parameter>ida</parameter>) that you will pass 9709 to the rest of the functions. 9710</para> 9711</refsect1> 9712</refentry> 9713 9714 </sect1> 9715 </chapter> 9716 9717 <chapter id="mm"> 9718 <title>Memory Management in Linux</title> 9719 <sect1><title>The Slab Cache</title> 9720<!-- include/linux/slab.h --> 9721<refentry id="API-kmalloc"> 9722<refentryinfo> 9723 <title>LINUX</title> 9724 <productname>Kernel Hackers Manual</productname> 9725 <date>July 2017</date> 9726</refentryinfo> 9727<refmeta> 9728 <refentrytitle><phrase>kmalloc</phrase></refentrytitle> 9729 <manvolnum>9</manvolnum> 9730 <refmiscinfo class="version">4.1.27</refmiscinfo> 9731</refmeta> 9732<refnamediv> 9733 <refname>kmalloc</refname> 9734 <refpurpose> 9735 allocate memory 9736 </refpurpose> 9737</refnamediv> 9738<refsynopsisdiv> 9739 <title>Synopsis</title> 9740 <funcsynopsis><funcprototype> 9741 <funcdef>void * <function>kmalloc </function></funcdef> 9742 <paramdef>size_t <parameter>size</parameter></paramdef> 9743 <paramdef>gfp_t <parameter>flags</parameter></paramdef> 9744 </funcprototype></funcsynopsis> 9745</refsynopsisdiv> 9746<refsect1> 9747 <title>Arguments</title> 9748 <variablelist> 9749 <varlistentry> 9750 <term><parameter>size</parameter></term> 9751 <listitem> 9752 <para> 9753 how many bytes of memory are required. 9754 </para> 9755 </listitem> 9756 </varlistentry> 9757 <varlistentry> 9758 <term><parameter>flags</parameter></term> 9759 <listitem> 9760 <para> 9761 the type of memory to allocate. 9762 </para> 9763 </listitem> 9764 </varlistentry> 9765 </variablelist> 9766</refsect1> 9767<refsect1> 9768<title>Description</title> 9769<para> 9770 kmalloc is the normal method of allocating memory 9771 for objects smaller than page size in the kernel. 9772 </para><para> 9773 9774 The <parameter>flags</parameter> argument may be one of: 9775 </para><para> 9776 9777 <constant>GFP_USER</constant> - Allocate memory on behalf of user. May sleep. 9778 </para><para> 9779 9780 <constant>GFP_KERNEL</constant> - Allocate normal kernel ram. May sleep. 9781 </para><para> 9782 9783 <constant>GFP_ATOMIC</constant> - Allocation will not sleep. May use emergency pools. 9784 For example, use this inside interrupt handlers. 9785 </para><para> 9786 9787 <constant>GFP_HIGHUSER</constant> - Allocate pages from high memory. 9788 </para><para> 9789 9790 <constant>GFP_NOIO</constant> - Do not do any I/O at all while trying to get memory. 9791 </para><para> 9792 9793 <constant>GFP_NOFS</constant> - Do not make any fs calls while trying to get memory. 9794 </para><para> 9795 9796 <constant>GFP_NOWAIT</constant> - Allocation will not sleep. 9797 </para><para> 9798 9799 <constant>__GFP_THISNODE</constant> - Allocate node-local memory only. 9800 </para><para> 9801 9802 <constant>GFP_DMA</constant> - Allocation suitable for DMA. 9803 Should only be used for <function>kmalloc</function> caches. Otherwise, use a 9804 slab created with SLAB_DMA. 9805 </para><para> 9806 9807 Also it is possible to set different flags by OR'ing 9808 in one or more of the following additional <parameter>flags</parameter>: 9809 </para><para> 9810 9811 <constant>__GFP_COLD</constant> - Request cache-cold pages instead of 9812 trying to return cache-warm pages. 9813 </para><para> 9814 9815 <constant>__GFP_HIGH</constant> - This allocation has high priority and may use emergency pools. 9816 </para><para> 9817 9818 <constant>__GFP_NOFAIL</constant> - Indicate that this allocation is in no way allowed to fail 9819 (think twice before using). 9820 </para><para> 9821 9822 <constant>__GFP_NORETRY</constant> - If memory is not immediately available, 9823 then give up at once. 9824 </para><para> 9825 9826 <constant>__GFP_NOWARN</constant> - If allocation fails, don't issue any warnings. 9827 </para><para> 9828 9829 <constant>__GFP_REPEAT</constant> - If allocation fails initially, try once more before failing. 9830 </para><para> 9831 9832 There are other flags available as well, but these are not intended 9833 for general use, and so are not documented here. For a full list of 9834 potential flags, always refer to linux/gfp.h. 9835</para> 9836</refsect1> 9837</refentry> 9838 9839<refentry id="API-kmalloc-array"> 9840<refentryinfo> 9841 <title>LINUX</title> 9842 <productname>Kernel Hackers Manual</productname> 9843 <date>July 2017</date> 9844</refentryinfo> 9845<refmeta> 9846 <refentrytitle><phrase>kmalloc_array</phrase></refentrytitle> 9847 <manvolnum>9</manvolnum> 9848 <refmiscinfo class="version">4.1.27</refmiscinfo> 9849</refmeta> 9850<refnamediv> 9851 <refname>kmalloc_array</refname> 9852 <refpurpose> 9853 allocate memory for an array. 9854 </refpurpose> 9855</refnamediv> 9856<refsynopsisdiv> 9857 <title>Synopsis</title> 9858 <funcsynopsis><funcprototype> 9859 <funcdef>void * <function>kmalloc_array </function></funcdef> 9860 <paramdef>size_t <parameter>n</parameter></paramdef> 9861 <paramdef>size_t <parameter>size</parameter></paramdef> 9862 <paramdef>gfp_t <parameter>flags</parameter></paramdef> 9863 </funcprototype></funcsynopsis> 9864</refsynopsisdiv> 9865<refsect1> 9866 <title>Arguments</title> 9867 <variablelist> 9868 <varlistentry> 9869 <term><parameter>n</parameter></term> 9870 <listitem> 9871 <para> 9872 number of elements. 9873 </para> 9874 </listitem> 9875 </varlistentry> 9876 <varlistentry> 9877 <term><parameter>size</parameter></term> 9878 <listitem> 9879 <para> 9880 element size. 9881 </para> 9882 </listitem> 9883 </varlistentry> 9884 <varlistentry> 9885 <term><parameter>flags</parameter></term> 9886 <listitem> 9887 <para> 9888 the type of memory to allocate (see kmalloc). 9889 </para> 9890 </listitem> 9891 </varlistentry> 9892 </variablelist> 9893</refsect1> 9894</refentry> 9895 9896<refentry id="API-kcalloc"> 9897<refentryinfo> 9898 <title>LINUX</title> 9899 <productname>Kernel Hackers Manual</productname> 9900 <date>July 2017</date> 9901</refentryinfo> 9902<refmeta> 9903 <refentrytitle><phrase>kcalloc</phrase></refentrytitle> 9904 <manvolnum>9</manvolnum> 9905 <refmiscinfo class="version">4.1.27</refmiscinfo> 9906</refmeta> 9907<refnamediv> 9908 <refname>kcalloc</refname> 9909 <refpurpose> 9910 allocate memory for an array. The memory is set to zero. 9911 </refpurpose> 9912</refnamediv> 9913<refsynopsisdiv> 9914 <title>Synopsis</title> 9915 <funcsynopsis><funcprototype> 9916 <funcdef>void * <function>kcalloc </function></funcdef> 9917 <paramdef>size_t <parameter>n</parameter></paramdef> 9918 <paramdef>size_t <parameter>size</parameter></paramdef> 9919 <paramdef>gfp_t <parameter>flags</parameter></paramdef> 9920 </funcprototype></funcsynopsis> 9921</refsynopsisdiv> 9922<refsect1> 9923 <title>Arguments</title> 9924 <variablelist> 9925 <varlistentry> 9926 <term><parameter>n</parameter></term> 9927 <listitem> 9928 <para> 9929 number of elements. 9930 </para> 9931 </listitem> 9932 </varlistentry> 9933 <varlistentry> 9934 <term><parameter>size</parameter></term> 9935 <listitem> 9936 <para> 9937 element size. 9938 </para> 9939 </listitem> 9940 </varlistentry> 9941 <varlistentry> 9942 <term><parameter>flags</parameter></term> 9943 <listitem> 9944 <para> 9945 the type of memory to allocate (see kmalloc). 9946 </para> 9947 </listitem> 9948 </varlistentry> 9949 </variablelist> 9950</refsect1> 9951</refentry> 9952 9953<refentry id="API-kzalloc"> 9954<refentryinfo> 9955 <title>LINUX</title> 9956 <productname>Kernel Hackers Manual</productname> 9957 <date>July 2017</date> 9958</refentryinfo> 9959<refmeta> 9960 <refentrytitle><phrase>kzalloc</phrase></refentrytitle> 9961 <manvolnum>9</manvolnum> 9962 <refmiscinfo class="version">4.1.27</refmiscinfo> 9963</refmeta> 9964<refnamediv> 9965 <refname>kzalloc</refname> 9966 <refpurpose> 9967 allocate memory. The memory is set to zero. 9968 </refpurpose> 9969</refnamediv> 9970<refsynopsisdiv> 9971 <title>Synopsis</title> 9972 <funcsynopsis><funcprototype> 9973 <funcdef>void * <function>kzalloc </function></funcdef> 9974 <paramdef>size_t <parameter>size</parameter></paramdef> 9975 <paramdef>gfp_t <parameter>flags</parameter></paramdef> 9976 </funcprototype></funcsynopsis> 9977</refsynopsisdiv> 9978<refsect1> 9979 <title>Arguments</title> 9980 <variablelist> 9981 <varlistentry> 9982 <term><parameter>size</parameter></term> 9983 <listitem> 9984 <para> 9985 how many bytes of memory are required. 9986 </para> 9987 </listitem> 9988 </varlistentry> 9989 <varlistentry> 9990 <term><parameter>flags</parameter></term> 9991 <listitem> 9992 <para> 9993 the type of memory to allocate (see kmalloc). 9994 </para> 9995 </listitem> 9996 </varlistentry> 9997 </variablelist> 9998</refsect1> 9999</refentry> 10000 10001<refentry id="API-kzalloc-node"> 10002<refentryinfo> 10003 <title>LINUX</title> 10004 <productname>Kernel Hackers Manual</productname> 10005 <date>July 2017</date> 10006</refentryinfo> 10007<refmeta> 10008 <refentrytitle><phrase>kzalloc_node</phrase></refentrytitle> 10009 <manvolnum>9</manvolnum> 10010 <refmiscinfo class="version">4.1.27</refmiscinfo> 10011</refmeta> 10012<refnamediv> 10013 <refname>kzalloc_node</refname> 10014 <refpurpose> 10015 allocate zeroed memory from a particular memory node. 10016 </refpurpose> 10017</refnamediv> 10018<refsynopsisdiv> 10019 <title>Synopsis</title> 10020 <funcsynopsis><funcprototype> 10021 <funcdef>void * <function>kzalloc_node </function></funcdef> 10022 <paramdef>size_t <parameter>size</parameter></paramdef> 10023 <paramdef>gfp_t <parameter>flags</parameter></paramdef> 10024 <paramdef>int <parameter>node</parameter></paramdef> 10025 </funcprototype></funcsynopsis> 10026</refsynopsisdiv> 10027<refsect1> 10028 <title>Arguments</title> 10029 <variablelist> 10030 <varlistentry> 10031 <term><parameter>size</parameter></term> 10032 <listitem> 10033 <para> 10034 how many bytes of memory are required. 10035 </para> 10036 </listitem> 10037 </varlistentry> 10038 <varlistentry> 10039 <term><parameter>flags</parameter></term> 10040 <listitem> 10041 <para> 10042 the type of memory to allocate (see kmalloc). 10043 </para> 10044 </listitem> 10045 </varlistentry> 10046 <varlistentry> 10047 <term><parameter>node</parameter></term> 10048 <listitem> 10049 <para> 10050 memory node from which to allocate 10051 </para> 10052 </listitem> 10053 </varlistentry> 10054 </variablelist> 10055</refsect1> 10056</refentry> 10057 10058<!-- mm/slab.c --> 10059<refentry id="API-kmem-cache-alloc"> 10060<refentryinfo> 10061 <title>LINUX</title> 10062 <productname>Kernel Hackers Manual</productname> 10063 <date>July 2017</date> 10064</refentryinfo> 10065<refmeta> 10066 <refentrytitle><phrase>kmem_cache_alloc</phrase></refentrytitle> 10067 <manvolnum>9</manvolnum> 10068 <refmiscinfo class="version">4.1.27</refmiscinfo> 10069</refmeta> 10070<refnamediv> 10071 <refname>kmem_cache_alloc</refname> 10072 <refpurpose> 10073 Allocate an object 10074 </refpurpose> 10075</refnamediv> 10076<refsynopsisdiv> 10077 <title>Synopsis</title> 10078 <funcsynopsis><funcprototype> 10079 <funcdef>void * <function>kmem_cache_alloc </function></funcdef> 10080 <paramdef>struct kmem_cache * <parameter>cachep</parameter></paramdef> 10081 <paramdef>gfp_t <parameter>flags</parameter></paramdef> 10082 </funcprototype></funcsynopsis> 10083</refsynopsisdiv> 10084<refsect1> 10085 <title>Arguments</title> 10086 <variablelist> 10087 <varlistentry> 10088 <term><parameter>cachep</parameter></term> 10089 <listitem> 10090 <para> 10091 The cache to allocate from. 10092 </para> 10093 </listitem> 10094 </varlistentry> 10095 <varlistentry> 10096 <term><parameter>flags</parameter></term> 10097 <listitem> 10098 <para> 10099 See <function>kmalloc</function>. 10100 </para> 10101 </listitem> 10102 </varlistentry> 10103 </variablelist> 10104</refsect1> 10105<refsect1> 10106<title>Description</title> 10107<para> 10108 Allocate an object from this cache. The flags are only relevant 10109 if the cache has no available objects. 10110</para> 10111</refsect1> 10112</refentry> 10113 10114<refentry id="API-kmem-cache-alloc-node"> 10115<refentryinfo> 10116 <title>LINUX</title> 10117 <productname>Kernel Hackers Manual</productname> 10118 <date>July 2017</date> 10119</refentryinfo> 10120<refmeta> 10121 <refentrytitle><phrase>kmem_cache_alloc_node</phrase></refentrytitle> 10122 <manvolnum>9</manvolnum> 10123 <refmiscinfo class="version">4.1.27</refmiscinfo> 10124</refmeta> 10125<refnamediv> 10126 <refname>kmem_cache_alloc_node</refname> 10127 <refpurpose> 10128 Allocate an object on the specified node 10129 </refpurpose> 10130</refnamediv> 10131<refsynopsisdiv> 10132 <title>Synopsis</title> 10133 <funcsynopsis><funcprototype> 10134 <funcdef>void * <function>kmem_cache_alloc_node </function></funcdef> 10135 <paramdef>struct kmem_cache * <parameter>cachep</parameter></paramdef> 10136 <paramdef>gfp_t <parameter>flags</parameter></paramdef> 10137 <paramdef>int <parameter>nodeid</parameter></paramdef> 10138 </funcprototype></funcsynopsis> 10139</refsynopsisdiv> 10140<refsect1> 10141 <title>Arguments</title> 10142 <variablelist> 10143 <varlistentry> 10144 <term><parameter>cachep</parameter></term> 10145 <listitem> 10146 <para> 10147 The cache to allocate from. 10148 </para> 10149 </listitem> 10150 </varlistentry> 10151 <varlistentry> 10152 <term><parameter>flags</parameter></term> 10153 <listitem> 10154 <para> 10155 See <function>kmalloc</function>. 10156 </para> 10157 </listitem> 10158 </varlistentry> 10159 <varlistentry> 10160 <term><parameter>nodeid</parameter></term> 10161 <listitem> 10162 <para> 10163 node number of the target node. 10164 </para> 10165 </listitem> 10166 </varlistentry> 10167 </variablelist> 10168</refsect1> 10169<refsect1> 10170<title>Description</title> 10171<para> 10172 Identical to kmem_cache_alloc but it will allocate memory on the given 10173 node, which can improve the performance for cpu bound structures. 10174 </para><para> 10175 10176 Fallback to other node is possible if __GFP_THISNODE is not set. 10177</para> 10178</refsect1> 10179</refentry> 10180 10181<refentry id="API-kmem-cache-free"> 10182<refentryinfo> 10183 <title>LINUX</title> 10184 <productname>Kernel Hackers Manual</productname> 10185 <date>July 2017</date> 10186</refentryinfo> 10187<refmeta> 10188 <refentrytitle><phrase>kmem_cache_free</phrase></refentrytitle> 10189 <manvolnum>9</manvolnum> 10190 <refmiscinfo class="version">4.1.27</refmiscinfo> 10191</refmeta> 10192<refnamediv> 10193 <refname>kmem_cache_free</refname> 10194 <refpurpose> 10195 Deallocate an object 10196 </refpurpose> 10197</refnamediv> 10198<refsynopsisdiv> 10199 <title>Synopsis</title> 10200 <funcsynopsis><funcprototype> 10201 <funcdef>void <function>kmem_cache_free </function></funcdef> 10202 <paramdef>struct kmem_cache * <parameter>cachep</parameter></paramdef> 10203 <paramdef>void * <parameter>objp</parameter></paramdef> 10204 </funcprototype></funcsynopsis> 10205</refsynopsisdiv> 10206<refsect1> 10207 <title>Arguments</title> 10208 <variablelist> 10209 <varlistentry> 10210 <term><parameter>cachep</parameter></term> 10211 <listitem> 10212 <para> 10213 The cache the allocation was from. 10214 </para> 10215 </listitem> 10216 </varlistentry> 10217 <varlistentry> 10218 <term><parameter>objp</parameter></term> 10219 <listitem> 10220 <para> 10221 The previously allocated object. 10222 </para> 10223 </listitem> 10224 </varlistentry> 10225 </variablelist> 10226</refsect1> 10227<refsect1> 10228<title>Description</title> 10229<para> 10230 Free an object which was previously allocated from this 10231 cache. 10232</para> 10233</refsect1> 10234</refentry> 10235 10236<refentry id="API-kfree"> 10237<refentryinfo> 10238 <title>LINUX</title> 10239 <productname>Kernel Hackers Manual</productname> 10240 <date>July 2017</date> 10241</refentryinfo> 10242<refmeta> 10243 <refentrytitle><phrase>kfree</phrase></refentrytitle> 10244 <manvolnum>9</manvolnum> 10245 <refmiscinfo class="version">4.1.27</refmiscinfo> 10246</refmeta> 10247<refnamediv> 10248 <refname>kfree</refname> 10249 <refpurpose> 10250 free previously allocated memory 10251 </refpurpose> 10252</refnamediv> 10253<refsynopsisdiv> 10254 <title>Synopsis</title> 10255 <funcsynopsis><funcprototype> 10256 <funcdef>void <function>kfree </function></funcdef> 10257 <paramdef>const void * <parameter>objp</parameter></paramdef> 10258 </funcprototype></funcsynopsis> 10259</refsynopsisdiv> 10260<refsect1> 10261 <title>Arguments</title> 10262 <variablelist> 10263 <varlistentry> 10264 <term><parameter>objp</parameter></term> 10265 <listitem> 10266 <para> 10267 pointer returned by kmalloc. 10268 </para> 10269 </listitem> 10270 </varlistentry> 10271 </variablelist> 10272</refsect1> 10273<refsect1> 10274<title>Description</title> 10275<para> 10276 If <parameter>objp</parameter> is NULL, no operation is performed. 10277 </para><para> 10278 10279 Don't free memory not originally allocated by <function>kmalloc</function> 10280 or you will run into trouble. 10281</para> 10282</refsect1> 10283</refentry> 10284 10285<refentry id="API-ksize"> 10286<refentryinfo> 10287 <title>LINUX</title> 10288 <productname>Kernel Hackers Manual</productname> 10289 <date>July 2017</date> 10290</refentryinfo> 10291<refmeta> 10292 <refentrytitle><phrase>ksize</phrase></refentrytitle> 10293 <manvolnum>9</manvolnum> 10294 <refmiscinfo class="version">4.1.27</refmiscinfo> 10295</refmeta> 10296<refnamediv> 10297 <refname>ksize</refname> 10298 <refpurpose> 10299 get the actual amount of memory allocated for a given object 10300 </refpurpose> 10301</refnamediv> 10302<refsynopsisdiv> 10303 <title>Synopsis</title> 10304 <funcsynopsis><funcprototype> 10305 <funcdef>size_t <function>ksize </function></funcdef> 10306 <paramdef>const void * <parameter>objp</parameter></paramdef> 10307 </funcprototype></funcsynopsis> 10308</refsynopsisdiv> 10309<refsect1> 10310 <title>Arguments</title> 10311 <variablelist> 10312 <varlistentry> 10313 <term><parameter>objp</parameter></term> 10314 <listitem> 10315 <para> 10316 Pointer to the object 10317 </para> 10318 </listitem> 10319 </varlistentry> 10320 </variablelist> 10321</refsect1> 10322<refsect1> 10323<title>Description</title> 10324<para> 10325 kmalloc may internally round up allocations and return more memory 10326 than requested. <function>ksize</function> can be used to determine the actual amount of 10327 memory allocated. The caller may use this additional memory, even though 10328 a smaller amount of memory was initially specified with the kmalloc call. 10329 The caller must guarantee that objp points to a valid object previously 10330 allocated with either <function>kmalloc</function> or <function>kmem_cache_alloc</function>. The object 10331 must not be freed during the duration of the call. 10332</para> 10333</refsect1> 10334</refentry> 10335 10336<!-- mm/util.c --> 10337<refentry id="API-kfree-const"> 10338<refentryinfo> 10339 <title>LINUX</title> 10340 <productname>Kernel Hackers Manual</productname> 10341 <date>July 2017</date> 10342</refentryinfo> 10343<refmeta> 10344 <refentrytitle><phrase>kfree_const</phrase></refentrytitle> 10345 <manvolnum>9</manvolnum> 10346 <refmiscinfo class="version">4.1.27</refmiscinfo> 10347</refmeta> 10348<refnamediv> 10349 <refname>kfree_const</refname> 10350 <refpurpose> 10351 conditionally free memory 10352 </refpurpose> 10353</refnamediv> 10354<refsynopsisdiv> 10355 <title>Synopsis</title> 10356 <funcsynopsis><funcprototype> 10357 <funcdef>void <function>kfree_const </function></funcdef> 10358 <paramdef>const void * <parameter>x</parameter></paramdef> 10359 </funcprototype></funcsynopsis> 10360</refsynopsisdiv> 10361<refsect1> 10362 <title>Arguments</title> 10363 <variablelist> 10364 <varlistentry> 10365 <term><parameter>x</parameter></term> 10366 <listitem> 10367 <para> 10368 pointer to the memory 10369 </para> 10370 </listitem> 10371 </varlistentry> 10372 </variablelist> 10373</refsect1> 10374<refsect1> 10375<title>Description</title> 10376<para> 10377 Function calls kfree only if <parameter>x</parameter> is not in .rodata section. 10378</para> 10379</refsect1> 10380</refentry> 10381 10382<refentry id="API-kstrdup"> 10383<refentryinfo> 10384 <title>LINUX</title> 10385 <productname>Kernel Hackers Manual</productname> 10386 <date>July 2017</date> 10387</refentryinfo> 10388<refmeta> 10389 <refentrytitle><phrase>kstrdup</phrase></refentrytitle> 10390 <manvolnum>9</manvolnum> 10391 <refmiscinfo class="version">4.1.27</refmiscinfo> 10392</refmeta> 10393<refnamediv> 10394 <refname>kstrdup</refname> 10395 <refpurpose> 10396 allocate space for and copy an existing string 10397 </refpurpose> 10398</refnamediv> 10399<refsynopsisdiv> 10400 <title>Synopsis</title> 10401 <funcsynopsis><funcprototype> 10402 <funcdef>char * <function>kstrdup </function></funcdef> 10403 <paramdef>const char * <parameter>s</parameter></paramdef> 10404 <paramdef>gfp_t <parameter>gfp</parameter></paramdef> 10405 </funcprototype></funcsynopsis> 10406</refsynopsisdiv> 10407<refsect1> 10408 <title>Arguments</title> 10409 <variablelist> 10410 <varlistentry> 10411 <term><parameter>s</parameter></term> 10412 <listitem> 10413 <para> 10414 the string to duplicate 10415 </para> 10416 </listitem> 10417 </varlistentry> 10418 <varlistentry> 10419 <term><parameter>gfp</parameter></term> 10420 <listitem> 10421 <para> 10422 the GFP mask used in the <function>kmalloc</function> call when allocating memory 10423 </para> 10424 </listitem> 10425 </varlistentry> 10426 </variablelist> 10427</refsect1> 10428</refentry> 10429 10430<refentry id="API-kstrdup-const"> 10431<refentryinfo> 10432 <title>LINUX</title> 10433 <productname>Kernel Hackers Manual</productname> 10434 <date>July 2017</date> 10435</refentryinfo> 10436<refmeta> 10437 <refentrytitle><phrase>kstrdup_const</phrase></refentrytitle> 10438 <manvolnum>9</manvolnum> 10439 <refmiscinfo class="version">4.1.27</refmiscinfo> 10440</refmeta> 10441<refnamediv> 10442 <refname>kstrdup_const</refname> 10443 <refpurpose> 10444 conditionally duplicate an existing const string 10445 </refpurpose> 10446</refnamediv> 10447<refsynopsisdiv> 10448 <title>Synopsis</title> 10449 <funcsynopsis><funcprototype> 10450 <funcdef>const char * <function>kstrdup_const </function></funcdef> 10451 <paramdef>const char * <parameter>s</parameter></paramdef> 10452 <paramdef>gfp_t <parameter>gfp</parameter></paramdef> 10453 </funcprototype></funcsynopsis> 10454</refsynopsisdiv> 10455<refsect1> 10456 <title>Arguments</title> 10457 <variablelist> 10458 <varlistentry> 10459 <term><parameter>s</parameter></term> 10460 <listitem> 10461 <para> 10462 the string to duplicate 10463 </para> 10464 </listitem> 10465 </varlistentry> 10466 <varlistentry> 10467 <term><parameter>gfp</parameter></term> 10468 <listitem> 10469 <para> 10470 the GFP mask used in the <function>kmalloc</function> call when allocating memory 10471 </para> 10472 </listitem> 10473 </varlistentry> 10474 </variablelist> 10475</refsect1> 10476<refsect1> 10477<title>Description</title> 10478<para> 10479 Function returns source string if it is in .rodata section otherwise it 10480 fallbacks to kstrdup. 10481 Strings allocated by kstrdup_const should be freed by kfree_const. 10482</para> 10483</refsect1> 10484</refentry> 10485 10486<refentry id="API-kstrndup"> 10487<refentryinfo> 10488 <title>LINUX</title> 10489 <productname>Kernel Hackers Manual</productname> 10490 <date>July 2017</date> 10491</refentryinfo> 10492<refmeta> 10493 <refentrytitle><phrase>kstrndup</phrase></refentrytitle> 10494 <manvolnum>9</manvolnum> 10495 <refmiscinfo class="version">4.1.27</refmiscinfo> 10496</refmeta> 10497<refnamediv> 10498 <refname>kstrndup</refname> 10499 <refpurpose> 10500 allocate space for and copy an existing string 10501 </refpurpose> 10502</refnamediv> 10503<refsynopsisdiv> 10504 <title>Synopsis</title> 10505 <funcsynopsis><funcprototype> 10506 <funcdef>char * <function>kstrndup </function></funcdef> 10507 <paramdef>const char * <parameter>s</parameter></paramdef> 10508 <paramdef>size_t <parameter>max</parameter></paramdef> 10509 <paramdef>gfp_t <parameter>gfp</parameter></paramdef> 10510 </funcprototype></funcsynopsis> 10511</refsynopsisdiv> 10512<refsect1> 10513 <title>Arguments</title> 10514 <variablelist> 10515 <varlistentry> 10516 <term><parameter>s</parameter></term> 10517 <listitem> 10518 <para> 10519 the string to duplicate 10520 </para> 10521 </listitem> 10522 </varlistentry> 10523 <varlistentry> 10524 <term><parameter>max</parameter></term> 10525 <listitem> 10526 <para> 10527 read at most <parameter>max</parameter> chars from <parameter>s</parameter> 10528 </para> 10529 </listitem> 10530 </varlistentry> 10531 <varlistentry> 10532 <term><parameter>gfp</parameter></term> 10533 <listitem> 10534 <para> 10535 the GFP mask used in the <function>kmalloc</function> call when allocating memory 10536 </para> 10537 </listitem> 10538 </varlistentry> 10539 </variablelist> 10540</refsect1> 10541</refentry> 10542 10543<refentry id="API-kmemdup"> 10544<refentryinfo> 10545 <title>LINUX</title> 10546 <productname>Kernel Hackers Manual</productname> 10547 <date>July 2017</date> 10548</refentryinfo> 10549<refmeta> 10550 <refentrytitle><phrase>kmemdup</phrase></refentrytitle> 10551 <manvolnum>9</manvolnum> 10552 <refmiscinfo class="version">4.1.27</refmiscinfo> 10553</refmeta> 10554<refnamediv> 10555 <refname>kmemdup</refname> 10556 <refpurpose> 10557 duplicate region of memory 10558 </refpurpose> 10559</refnamediv> 10560<refsynopsisdiv> 10561 <title>Synopsis</title> 10562 <funcsynopsis><funcprototype> 10563 <funcdef>void * <function>kmemdup </function></funcdef> 10564 <paramdef>const void * <parameter>src</parameter></paramdef> 10565 <paramdef>size_t <parameter>len</parameter></paramdef> 10566 <paramdef>gfp_t <parameter>gfp</parameter></paramdef> 10567 </funcprototype></funcsynopsis> 10568</refsynopsisdiv> 10569<refsect1> 10570 <title>Arguments</title> 10571 <variablelist> 10572 <varlistentry> 10573 <term><parameter>src</parameter></term> 10574 <listitem> 10575 <para> 10576 memory region to duplicate 10577 </para> 10578 </listitem> 10579 </varlistentry> 10580 <varlistentry> 10581 <term><parameter>len</parameter></term> 10582 <listitem> 10583 <para> 10584 memory region length 10585 </para> 10586 </listitem> 10587 </varlistentry> 10588 <varlistentry> 10589 <term><parameter>gfp</parameter></term> 10590 <listitem> 10591 <para> 10592 GFP mask to use 10593 </para> 10594 </listitem> 10595 </varlistentry> 10596 </variablelist> 10597</refsect1> 10598</refentry> 10599 10600<refentry id="API-memdup-user"> 10601<refentryinfo> 10602 <title>LINUX</title> 10603 <productname>Kernel Hackers Manual</productname> 10604 <date>July 2017</date> 10605</refentryinfo> 10606<refmeta> 10607 <refentrytitle><phrase>memdup_user</phrase></refentrytitle> 10608 <manvolnum>9</manvolnum> 10609 <refmiscinfo class="version">4.1.27</refmiscinfo> 10610</refmeta> 10611<refnamediv> 10612 <refname>memdup_user</refname> 10613 <refpurpose> 10614 duplicate memory region from user space 10615 </refpurpose> 10616</refnamediv> 10617<refsynopsisdiv> 10618 <title>Synopsis</title> 10619 <funcsynopsis><funcprototype> 10620 <funcdef>void * <function>memdup_user </function></funcdef> 10621 <paramdef>const void __user * <parameter>src</parameter></paramdef> 10622 <paramdef>size_t <parameter>len</parameter></paramdef> 10623 </funcprototype></funcsynopsis> 10624</refsynopsisdiv> 10625<refsect1> 10626 <title>Arguments</title> 10627 <variablelist> 10628 <varlistentry> 10629 <term><parameter>src</parameter></term> 10630 <listitem> 10631 <para> 10632 source address in user space 10633 </para> 10634 </listitem> 10635 </varlistentry> 10636 <varlistentry> 10637 <term><parameter>len</parameter></term> 10638 <listitem> 10639 <para> 10640 number of bytes to copy 10641 </para> 10642 </listitem> 10643 </varlistentry> 10644 </variablelist> 10645</refsect1> 10646<refsect1> 10647<title>Description</title> 10648<para> 10649 Returns an <function>ERR_PTR</function> on failure. 10650</para> 10651</refsect1> 10652</refentry> 10653 10654<refentry id="API-get-user-pages-fast"> 10655<refentryinfo> 10656 <title>LINUX</title> 10657 <productname>Kernel Hackers Manual</productname> 10658 <date>July 2017</date> 10659</refentryinfo> 10660<refmeta> 10661 <refentrytitle><phrase>get_user_pages_fast</phrase></refentrytitle> 10662 <manvolnum>9</manvolnum> 10663 <refmiscinfo class="version">4.1.27</refmiscinfo> 10664</refmeta> 10665<refnamediv> 10666 <refname>get_user_pages_fast</refname> 10667 <refpurpose> 10668 pin user pages in memory 10669 </refpurpose> 10670</refnamediv> 10671<refsynopsisdiv> 10672 <title>Synopsis</title> 10673 <funcsynopsis><funcprototype> 10674 <funcdef>int <function>get_user_pages_fast </function></funcdef> 10675 <paramdef>unsigned long <parameter>start</parameter></paramdef> 10676 <paramdef>int <parameter>nr_pages</parameter></paramdef> 10677 <paramdef>int <parameter>write</parameter></paramdef> 10678 <paramdef>struct page ** <parameter>pages</parameter></paramdef> 10679 </funcprototype></funcsynopsis> 10680</refsynopsisdiv> 10681<refsect1> 10682 <title>Arguments</title> 10683 <variablelist> 10684 <varlistentry> 10685 <term><parameter>start</parameter></term> 10686 <listitem> 10687 <para> 10688 starting user address 10689 </para> 10690 </listitem> 10691 </varlistentry> 10692 <varlistentry> 10693 <term><parameter>nr_pages</parameter></term> 10694 <listitem> 10695 <para> 10696 number of pages from start to pin 10697 </para> 10698 </listitem> 10699 </varlistentry> 10700 <varlistentry> 10701 <term><parameter>write</parameter></term> 10702 <listitem> 10703 <para> 10704 whether pages will be written to 10705 </para> 10706 </listitem> 10707 </varlistentry> 10708 <varlistentry> 10709 <term><parameter>pages</parameter></term> 10710 <listitem> 10711 <para> 10712 array that receives pointers to the pages pinned. 10713 Should be at least nr_pages long. 10714 </para> 10715 </listitem> 10716 </varlistentry> 10717 </variablelist> 10718</refsect1> 10719<refsect1> 10720<title>Description</title> 10721<para> 10722 Returns number of pages pinned. This may be fewer than the number 10723 requested. If nr_pages is 0 or negative, returns 0. If no pages 10724 were pinned, returns -errno. 10725 </para><para> 10726 10727 get_user_pages_fast provides equivalent functionality to get_user_pages, 10728 operating on current and current->mm, with force=0 and vma=NULL. However 10729 unlike get_user_pages, it must be called without mmap_sem held. 10730 </para><para> 10731 10732 get_user_pages_fast may take mmap_sem and page table locks, so no 10733 assumptions can be made about lack of locking. get_user_pages_fast is to be 10734 implemented in a way that is advantageous (vs <function>get_user_pages</function>) when the 10735 user memory area is already faulted in and present in ptes. However if the 10736 pages have to be faulted in, it may turn out to be slightly slower so 10737 callers need to carefully consider what to use. On many architectures, 10738 get_user_pages_fast simply falls back to get_user_pages. 10739</para> 10740</refsect1> 10741</refentry> 10742 10743 </sect1> 10744 <sect1><title>User Space Memory Access</title> 10745<!-- arch/x86/include/asm/uaccess_32.h --> 10746<refentry id="API---copy-to-user-inatomic"> 10747<refentryinfo> 10748 <title>LINUX</title> 10749 <productname>Kernel Hackers Manual</productname> 10750 <date>July 2017</date> 10751</refentryinfo> 10752<refmeta> 10753 <refentrytitle><phrase>__copy_to_user_inatomic</phrase></refentrytitle> 10754 <manvolnum>9</manvolnum> 10755 <refmiscinfo class="version">4.1.27</refmiscinfo> 10756</refmeta> 10757<refnamediv> 10758 <refname>__copy_to_user_inatomic</refname> 10759 <refpurpose> 10760 Copy a block of data into user space, with less checking. 10761 </refpurpose> 10762</refnamediv> 10763<refsynopsisdiv> 10764 <title>Synopsis</title> 10765 <funcsynopsis><funcprototype> 10766 <funcdef>unsigned long <function>__copy_to_user_inatomic </function></funcdef> 10767 <paramdef>void __user * <parameter>to</parameter></paramdef> 10768 <paramdef>const void * <parameter>from</parameter></paramdef> 10769 <paramdef>unsigned long <parameter>n</parameter></paramdef> 10770 </funcprototype></funcsynopsis> 10771</refsynopsisdiv> 10772<refsect1> 10773 <title>Arguments</title> 10774 <variablelist> 10775 <varlistentry> 10776 <term><parameter>to</parameter></term> 10777 <listitem> 10778 <para> 10779 Destination address, in user space. 10780 </para> 10781 </listitem> 10782 </varlistentry> 10783 <varlistentry> 10784 <term><parameter>from</parameter></term> 10785 <listitem> 10786 <para> 10787 Source address, in kernel space. 10788 </para> 10789 </listitem> 10790 </varlistentry> 10791 <varlistentry> 10792 <term><parameter>n</parameter></term> 10793 <listitem> 10794 <para> 10795 Number of bytes to copy. 10796 </para> 10797 </listitem> 10798 </varlistentry> 10799 </variablelist> 10800</refsect1> 10801<refsect1> 10802<title>Context</title> 10803<para> 10804 User context only. 10805</para> 10806</refsect1> 10807<refsect1> 10808<title>Description</title> 10809<para> 10810 Copy data from kernel space to user space. Caller must check 10811 the specified block with <function>access_ok</function> before calling this function. 10812 The caller should also make sure he pins the user space address 10813 so that we don't result in page fault and sleep. 10814 </para><para> 10815 10816 Here we special-case 1, 2 and 4-byte copy_*_user invocations. On a fault 10817 we return the initial request size (1, 2 or 4), as copy_*_user should do. 10818 If a store crosses a page boundary and gets a fault, the x86 will not write 10819 anything, so this is accurate. 10820</para> 10821</refsect1> 10822</refentry> 10823 10824<refentry id="API---copy-to-user"> 10825<refentryinfo> 10826 <title>LINUX</title> 10827 <productname>Kernel Hackers Manual</productname> 10828 <date>July 2017</date> 10829</refentryinfo> 10830<refmeta> 10831 <refentrytitle><phrase>__copy_to_user</phrase></refentrytitle> 10832 <manvolnum>9</manvolnum> 10833 <refmiscinfo class="version">4.1.27</refmiscinfo> 10834</refmeta> 10835<refnamediv> 10836 <refname>__copy_to_user</refname> 10837 <refpurpose> 10838 Copy a block of data into user space, with less checking. 10839 </refpurpose> 10840</refnamediv> 10841<refsynopsisdiv> 10842 <title>Synopsis</title> 10843 <funcsynopsis><funcprototype> 10844 <funcdef>unsigned long <function>__copy_to_user </function></funcdef> 10845 <paramdef>void __user * <parameter>to</parameter></paramdef> 10846 <paramdef>const void * <parameter>from</parameter></paramdef> 10847 <paramdef>unsigned long <parameter>n</parameter></paramdef> 10848 </funcprototype></funcsynopsis> 10849</refsynopsisdiv> 10850<refsect1> 10851 <title>Arguments</title> 10852 <variablelist> 10853 <varlistentry> 10854 <term><parameter>to</parameter></term> 10855 <listitem> 10856 <para> 10857 Destination address, in user space. 10858 </para> 10859 </listitem> 10860 </varlistentry> 10861 <varlistentry> 10862 <term><parameter>from</parameter></term> 10863 <listitem> 10864 <para> 10865 Source address, in kernel space. 10866 </para> 10867 </listitem> 10868 </varlistentry> 10869 <varlistentry> 10870 <term><parameter>n</parameter></term> 10871 <listitem> 10872 <para> 10873 Number of bytes to copy. 10874 </para> 10875 </listitem> 10876 </varlistentry> 10877 </variablelist> 10878</refsect1> 10879<refsect1> 10880<title>Context</title> 10881<para> 10882 User context only. This function may sleep. 10883</para> 10884</refsect1> 10885<refsect1> 10886<title>Description</title> 10887<para> 10888 Copy data from kernel space to user space. Caller must check 10889 the specified block with <function>access_ok</function> before calling this function. 10890 </para><para> 10891 10892 Returns number of bytes that could not be copied. 10893 On success, this will be zero. 10894</para> 10895</refsect1> 10896</refentry> 10897 10898<refentry id="API---copy-from-user"> 10899<refentryinfo> 10900 <title>LINUX</title> 10901 <productname>Kernel Hackers Manual</productname> 10902 <date>July 2017</date> 10903</refentryinfo> 10904<refmeta> 10905 <refentrytitle><phrase>__copy_from_user</phrase></refentrytitle> 10906 <manvolnum>9</manvolnum> 10907 <refmiscinfo class="version">4.1.27</refmiscinfo> 10908</refmeta> 10909<refnamediv> 10910 <refname>__copy_from_user</refname> 10911 <refpurpose> 10912 Copy a block of data from user space, with less checking. 10913 </refpurpose> 10914</refnamediv> 10915<refsynopsisdiv> 10916 <title>Synopsis</title> 10917 <funcsynopsis><funcprototype> 10918 <funcdef>unsigned long <function>__copy_from_user </function></funcdef> 10919 <paramdef>void * <parameter>to</parameter></paramdef> 10920 <paramdef>const void __user * <parameter>from</parameter></paramdef> 10921 <paramdef>unsigned long <parameter>n</parameter></paramdef> 10922 </funcprototype></funcsynopsis> 10923</refsynopsisdiv> 10924<refsect1> 10925 <title>Arguments</title> 10926 <variablelist> 10927 <varlistentry> 10928 <term><parameter>to</parameter></term> 10929 <listitem> 10930 <para> 10931 Destination address, in kernel space. 10932 </para> 10933 </listitem> 10934 </varlistentry> 10935 <varlistentry> 10936 <term><parameter>from</parameter></term> 10937 <listitem> 10938 <para> 10939 Source address, in user space. 10940 </para> 10941 </listitem> 10942 </varlistentry> 10943 <varlistentry> 10944 <term><parameter>n</parameter></term> 10945 <listitem> 10946 <para> 10947 Number of bytes to copy. 10948 </para> 10949 </listitem> 10950 </varlistentry> 10951 </variablelist> 10952</refsect1> 10953<refsect1> 10954<title>Context</title> 10955<para> 10956 User context only. This function may sleep. 10957</para> 10958</refsect1> 10959<refsect1> 10960<title>Description</title> 10961<para> 10962 Copy data from user space to kernel space. Caller must check 10963 the specified block with <function>access_ok</function> before calling this function. 10964 </para><para> 10965 10966 Returns number of bytes that could not be copied. 10967 On success, this will be zero. 10968 </para><para> 10969 10970 If some data could not be copied, this function will pad the copied 10971 data to the requested size using zero bytes. 10972 </para><para> 10973 10974 An alternate version - <function>__copy_from_user_inatomic</function> - may be called from 10975 atomic context and will fail rather than sleep. In this case the 10976 uncopied bytes will *NOT* be padded with zeros. See fs/filemap.h 10977 for explanation of why this is needed. 10978</para> 10979</refsect1> 10980</refentry> 10981 10982<!-- arch/x86/lib/usercopy_32.c --> 10983<refentry id="API-clear-user"> 10984<refentryinfo> 10985 <title>LINUX</title> 10986 <productname>Kernel Hackers Manual</productname> 10987 <date>July 2017</date> 10988</refentryinfo> 10989<refmeta> 10990 <refentrytitle><phrase>clear_user</phrase></refentrytitle> 10991 <manvolnum>9</manvolnum> 10992 <refmiscinfo class="version">4.1.27</refmiscinfo> 10993</refmeta> 10994<refnamediv> 10995 <refname>clear_user</refname> 10996 <refpurpose> 10997 Zero a block of memory in user space. 10998 </refpurpose> 10999</refnamediv> 11000<refsynopsisdiv> 11001 <title>Synopsis</title> 11002 <funcsynopsis><funcprototype> 11003 <funcdef>unsigned long <function>clear_user </function></funcdef> 11004 <paramdef>void __user * <parameter>to</parameter></paramdef> 11005 <paramdef>unsigned long <parameter>n</parameter></paramdef> 11006 </funcprototype></funcsynopsis> 11007</refsynopsisdiv> 11008<refsect1> 11009 <title>Arguments</title> 11010 <variablelist> 11011 <varlistentry> 11012 <term><parameter>to</parameter></term> 11013 <listitem> 11014 <para> 11015 Destination address, in user space. 11016 </para> 11017 </listitem> 11018 </varlistentry> 11019 <varlistentry> 11020 <term><parameter>n</parameter></term> 11021 <listitem> 11022 <para> 11023 Number of bytes to zero. 11024 </para> 11025 </listitem> 11026 </varlistentry> 11027 </variablelist> 11028</refsect1> 11029<refsect1> 11030<title>Description</title> 11031<para> 11032 Zero a block of memory in user space. 11033 </para><para> 11034 11035 Returns number of bytes that could not be cleared. 11036 On success, this will be zero. 11037</para> 11038</refsect1> 11039</refentry> 11040 11041<refentry id="API---clear-user"> 11042<refentryinfo> 11043 <title>LINUX</title> 11044 <productname>Kernel Hackers Manual</productname> 11045 <date>July 2017</date> 11046</refentryinfo> 11047<refmeta> 11048 <refentrytitle><phrase>__clear_user</phrase></refentrytitle> 11049 <manvolnum>9</manvolnum> 11050 <refmiscinfo class="version">4.1.27</refmiscinfo> 11051</refmeta> 11052<refnamediv> 11053 <refname>__clear_user</refname> 11054 <refpurpose> 11055 Zero a block of memory in user space, with less checking. 11056 </refpurpose> 11057</refnamediv> 11058<refsynopsisdiv> 11059 <title>Synopsis</title> 11060 <funcsynopsis><funcprototype> 11061 <funcdef>unsigned long <function>__clear_user </function></funcdef> 11062 <paramdef>void __user * <parameter>to</parameter></paramdef> 11063 <paramdef>unsigned long <parameter>n</parameter></paramdef> 11064 </funcprototype></funcsynopsis> 11065</refsynopsisdiv> 11066<refsect1> 11067 <title>Arguments</title> 11068 <variablelist> 11069 <varlistentry> 11070 <term><parameter>to</parameter></term> 11071 <listitem> 11072 <para> 11073 Destination address, in user space. 11074 </para> 11075 </listitem> 11076 </varlistentry> 11077 <varlistentry> 11078 <term><parameter>n</parameter></term> 11079 <listitem> 11080 <para> 11081 Number of bytes to zero. 11082 </para> 11083 </listitem> 11084 </varlistentry> 11085 </variablelist> 11086</refsect1> 11087<refsect1> 11088<title>Description</title> 11089<para> 11090 Zero a block of memory in user space. Caller must check 11091 the specified block with <function>access_ok</function> before calling this function. 11092 </para><para> 11093 11094 Returns number of bytes that could not be cleared. 11095 On success, this will be zero. 11096</para> 11097</refsect1> 11098</refentry> 11099 11100<refentry id="API--copy-to-user"> 11101<refentryinfo> 11102 <title>LINUX</title> 11103 <productname>Kernel Hackers Manual</productname> 11104 <date>July 2017</date> 11105</refentryinfo> 11106<refmeta> 11107 <refentrytitle><phrase>_copy_to_user</phrase></refentrytitle> 11108 <manvolnum>9</manvolnum> 11109 <refmiscinfo class="version">4.1.27</refmiscinfo> 11110</refmeta> 11111<refnamediv> 11112 <refname>_copy_to_user</refname> 11113 <refpurpose> 11114 Copy a block of data into user space. 11115 </refpurpose> 11116</refnamediv> 11117<refsynopsisdiv> 11118 <title>Synopsis</title> 11119 <funcsynopsis><funcprototype> 11120 <funcdef>unsigned long <function>_copy_to_user </function></funcdef> 11121 <paramdef>void __user * <parameter>to</parameter></paramdef> 11122 <paramdef>const void * <parameter>from</parameter></paramdef> 11123 <paramdef>unsigned <parameter>n</parameter></paramdef> 11124 </funcprototype></funcsynopsis> 11125</refsynopsisdiv> 11126<refsect1> 11127 <title>Arguments</title> 11128 <variablelist> 11129 <varlistentry> 11130 <term><parameter>to</parameter></term> 11131 <listitem> 11132 <para> 11133 Destination address, in user space. 11134 </para> 11135 </listitem> 11136 </varlistentry> 11137 <varlistentry> 11138 <term><parameter>from</parameter></term> 11139 <listitem> 11140 <para> 11141 Source address, in kernel space. 11142 </para> 11143 </listitem> 11144 </varlistentry> 11145 <varlistentry> 11146 <term><parameter>n</parameter></term> 11147 <listitem> 11148 <para> 11149 Number of bytes to copy. 11150 </para> 11151 </listitem> 11152 </varlistentry> 11153 </variablelist> 11154</refsect1> 11155<refsect1> 11156<title>Context</title> 11157<para> 11158 User context only. This function may sleep. 11159</para> 11160</refsect1> 11161<refsect1> 11162<title>Description</title> 11163<para> 11164 Copy data from kernel space to user space. 11165 </para><para> 11166 11167 Returns number of bytes that could not be copied. 11168 On success, this will be zero. 11169</para> 11170</refsect1> 11171</refentry> 11172 11173<refentry id="API--copy-from-user"> 11174<refentryinfo> 11175 <title>LINUX</title> 11176 <productname>Kernel Hackers Manual</productname> 11177 <date>July 2017</date> 11178</refentryinfo> 11179<refmeta> 11180 <refentrytitle><phrase>_copy_from_user</phrase></refentrytitle> 11181 <manvolnum>9</manvolnum> 11182 <refmiscinfo class="version">4.1.27</refmiscinfo> 11183</refmeta> 11184<refnamediv> 11185 <refname>_copy_from_user</refname> 11186 <refpurpose> 11187 Copy a block of data from user space. 11188 </refpurpose> 11189</refnamediv> 11190<refsynopsisdiv> 11191 <title>Synopsis</title> 11192 <funcsynopsis><funcprototype> 11193 <funcdef>unsigned long <function>_copy_from_user </function></funcdef> 11194 <paramdef>void * <parameter>to</parameter></paramdef> 11195 <paramdef>const void __user * <parameter>from</parameter></paramdef> 11196 <paramdef>unsigned <parameter>n</parameter></paramdef> 11197 </funcprototype></funcsynopsis> 11198</refsynopsisdiv> 11199<refsect1> 11200 <title>Arguments</title> 11201 <variablelist> 11202 <varlistentry> 11203 <term><parameter>to</parameter></term> 11204 <listitem> 11205 <para> 11206 Destination address, in kernel space. 11207 </para> 11208 </listitem> 11209 </varlistentry> 11210 <varlistentry> 11211 <term><parameter>from</parameter></term> 11212 <listitem> 11213 <para> 11214 Source address, in user space. 11215 </para> 11216 </listitem> 11217 </varlistentry> 11218 <varlistentry> 11219 <term><parameter>n</parameter></term> 11220 <listitem> 11221 <para> 11222 Number of bytes to copy. 11223 </para> 11224 </listitem> 11225 </varlistentry> 11226 </variablelist> 11227</refsect1> 11228<refsect1> 11229<title>Context</title> 11230<para> 11231 User context only. This function may sleep. 11232</para> 11233</refsect1> 11234<refsect1> 11235<title>Description</title> 11236<para> 11237 Copy data from user space to kernel space. 11238 </para><para> 11239 11240 Returns number of bytes that could not be copied. 11241 On success, this will be zero. 11242 </para><para> 11243 11244 If some data could not be copied, this function will pad the copied 11245 data to the requested size using zero bytes. 11246</para> 11247</refsect1> 11248</refentry> 11249 11250 </sect1> 11251 <sect1><title>More Memory Management Functions</title> 11252<!-- mm/readahead.c --> 11253<refentry id="API-read-cache-pages"> 11254<refentryinfo> 11255 <title>LINUX</title> 11256 <productname>Kernel Hackers Manual</productname> 11257 <date>July 2017</date> 11258</refentryinfo> 11259<refmeta> 11260 <refentrytitle><phrase>read_cache_pages</phrase></refentrytitle> 11261 <manvolnum>9</manvolnum> 11262 <refmiscinfo class="version">4.1.27</refmiscinfo> 11263</refmeta> 11264<refnamediv> 11265 <refname>read_cache_pages</refname> 11266 <refpurpose> 11267 populate an address space with some pages & start reads against them 11268 </refpurpose> 11269</refnamediv> 11270<refsynopsisdiv> 11271 <title>Synopsis</title> 11272 <funcsynopsis><funcprototype> 11273 <funcdef>int <function>read_cache_pages </function></funcdef> 11274 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 11275 <paramdef>struct list_head * <parameter>pages</parameter></paramdef> 11276 <paramdef>int (*<parameter>filler</parameter>) 11277 <funcparams>void *, struct page *</funcparams></paramdef> 11278 <paramdef>void * <parameter>data</parameter></paramdef> 11279 </funcprototype></funcsynopsis> 11280</refsynopsisdiv> 11281<refsect1> 11282 <title>Arguments</title> 11283 <variablelist> 11284 <varlistentry> 11285 <term><parameter>mapping</parameter></term> 11286 <listitem> 11287 <para> 11288 the address_space 11289 </para> 11290 </listitem> 11291 </varlistentry> 11292 <varlistentry> 11293 <term><parameter>pages</parameter></term> 11294 <listitem> 11295 <para> 11296 The address of a list_head which contains the target pages. These 11297 pages have their ->index populated and are otherwise uninitialised. 11298 </para> 11299 </listitem> 11300 </varlistentry> 11301 <varlistentry> 11302 <term><parameter>filler</parameter></term> 11303 <listitem> 11304 <para> 11305 callback routine for filling a single page. 11306 </para> 11307 </listitem> 11308 </varlistentry> 11309 <varlistentry> 11310 <term><parameter>data</parameter></term> 11311 <listitem> 11312 <para> 11313 private data for the callback routine. 11314 </para> 11315 </listitem> 11316 </varlistentry> 11317 </variablelist> 11318</refsect1> 11319<refsect1> 11320<title>Description</title> 11321<para> 11322 Hides the details of the LRU cache etc from the filesystems. 11323</para> 11324</refsect1> 11325</refentry> 11326 11327<refentry id="API-page-cache-sync-readahead"> 11328<refentryinfo> 11329 <title>LINUX</title> 11330 <productname>Kernel Hackers Manual</productname> 11331 <date>July 2017</date> 11332</refentryinfo> 11333<refmeta> 11334 <refentrytitle><phrase>page_cache_sync_readahead</phrase></refentrytitle> 11335 <manvolnum>9</manvolnum> 11336 <refmiscinfo class="version">4.1.27</refmiscinfo> 11337</refmeta> 11338<refnamediv> 11339 <refname>page_cache_sync_readahead</refname> 11340 <refpurpose> 11341 generic file readahead 11342 </refpurpose> 11343</refnamediv> 11344<refsynopsisdiv> 11345 <title>Synopsis</title> 11346 <funcsynopsis><funcprototype> 11347 <funcdef>void <function>page_cache_sync_readahead </function></funcdef> 11348 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 11349 <paramdef>struct file_ra_state * <parameter>ra</parameter></paramdef> 11350 <paramdef>struct file * <parameter>filp</parameter></paramdef> 11351 <paramdef>pgoff_t <parameter>offset</parameter></paramdef> 11352 <paramdef>unsigned long <parameter>req_size</parameter></paramdef> 11353 </funcprototype></funcsynopsis> 11354</refsynopsisdiv> 11355<refsect1> 11356 <title>Arguments</title> 11357 <variablelist> 11358 <varlistentry> 11359 <term><parameter>mapping</parameter></term> 11360 <listitem> 11361 <para> 11362 address_space which holds the pagecache and I/O vectors 11363 </para> 11364 </listitem> 11365 </varlistentry> 11366 <varlistentry> 11367 <term><parameter>ra</parameter></term> 11368 <listitem> 11369 <para> 11370 file_ra_state which holds the readahead state 11371 </para> 11372 </listitem> 11373 </varlistentry> 11374 <varlistentry> 11375 <term><parameter>filp</parameter></term> 11376 <listitem> 11377 <para> 11378 passed on to -><function>readpage</function> and -><function>readpages</function> 11379 </para> 11380 </listitem> 11381 </varlistentry> 11382 <varlistentry> 11383 <term><parameter>offset</parameter></term> 11384 <listitem> 11385 <para> 11386 start offset into <parameter>mapping</parameter>, in pagecache page-sized units 11387 </para> 11388 </listitem> 11389 </varlistentry> 11390 <varlistentry> 11391 <term><parameter>req_size</parameter></term> 11392 <listitem> 11393 <para> 11394 hint: total size of the read which the caller is performing in 11395 pagecache pages 11396 </para> 11397 </listitem> 11398 </varlistentry> 11399 </variablelist> 11400</refsect1> 11401<refsect1> 11402<title>Description</title> 11403<para> 11404 <function>page_cache_sync_readahead</function> should be called when a cache miss happened: 11405 it will submit the read. The readahead logic may decide to piggyback more 11406 pages onto the read request if access patterns suggest it will improve 11407 performance. 11408</para> 11409</refsect1> 11410</refentry> 11411 11412<refentry id="API-page-cache-async-readahead"> 11413<refentryinfo> 11414 <title>LINUX</title> 11415 <productname>Kernel Hackers Manual</productname> 11416 <date>July 2017</date> 11417</refentryinfo> 11418<refmeta> 11419 <refentrytitle><phrase>page_cache_async_readahead</phrase></refentrytitle> 11420 <manvolnum>9</manvolnum> 11421 <refmiscinfo class="version">4.1.27</refmiscinfo> 11422</refmeta> 11423<refnamediv> 11424 <refname>page_cache_async_readahead</refname> 11425 <refpurpose> 11426 file readahead for marked pages 11427 </refpurpose> 11428</refnamediv> 11429<refsynopsisdiv> 11430 <title>Synopsis</title> 11431 <funcsynopsis><funcprototype> 11432 <funcdef>void <function>page_cache_async_readahead </function></funcdef> 11433 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 11434 <paramdef>struct file_ra_state * <parameter>ra</parameter></paramdef> 11435 <paramdef>struct file * <parameter>filp</parameter></paramdef> 11436 <paramdef>struct page * <parameter>page</parameter></paramdef> 11437 <paramdef>pgoff_t <parameter>offset</parameter></paramdef> 11438 <paramdef>unsigned long <parameter>req_size</parameter></paramdef> 11439 </funcprototype></funcsynopsis> 11440</refsynopsisdiv> 11441<refsect1> 11442 <title>Arguments</title> 11443 <variablelist> 11444 <varlistentry> 11445 <term><parameter>mapping</parameter></term> 11446 <listitem> 11447 <para> 11448 address_space which holds the pagecache and I/O vectors 11449 </para> 11450 </listitem> 11451 </varlistentry> 11452 <varlistentry> 11453 <term><parameter>ra</parameter></term> 11454 <listitem> 11455 <para> 11456 file_ra_state which holds the readahead state 11457 </para> 11458 </listitem> 11459 </varlistentry> 11460 <varlistentry> 11461 <term><parameter>filp</parameter></term> 11462 <listitem> 11463 <para> 11464 passed on to -><function>readpage</function> and -><function>readpages</function> 11465 </para> 11466 </listitem> 11467 </varlistentry> 11468 <varlistentry> 11469 <term><parameter>page</parameter></term> 11470 <listitem> 11471 <para> 11472 the page at <parameter>offset</parameter> which has the PG_readahead flag set 11473 </para> 11474 </listitem> 11475 </varlistentry> 11476 <varlistentry> 11477 <term><parameter>offset</parameter></term> 11478 <listitem> 11479 <para> 11480 start offset into <parameter>mapping</parameter>, in pagecache page-sized units 11481 </para> 11482 </listitem> 11483 </varlistentry> 11484 <varlistentry> 11485 <term><parameter>req_size</parameter></term> 11486 <listitem> 11487 <para> 11488 hint: total size of the read which the caller is performing in 11489 pagecache pages 11490 </para> 11491 </listitem> 11492 </varlistentry> 11493 </variablelist> 11494</refsect1> 11495<refsect1> 11496<title>Description</title> 11497<para> 11498 <function>page_cache_async_readahead</function> should be called when a page is used which 11499 has the PG_readahead flag; this is a marker to suggest that the application 11500 has used up enough of the readahead window that we should start pulling in 11501 more pages. 11502</para> 11503</refsect1> 11504</refentry> 11505 11506<!-- mm/filemap.c --> 11507<refentry id="API-delete-from-page-cache"> 11508<refentryinfo> 11509 <title>LINUX</title> 11510 <productname>Kernel Hackers Manual</productname> 11511 <date>July 2017</date> 11512</refentryinfo> 11513<refmeta> 11514 <refentrytitle><phrase>delete_from_page_cache</phrase></refentrytitle> 11515 <manvolnum>9</manvolnum> 11516 <refmiscinfo class="version">4.1.27</refmiscinfo> 11517</refmeta> 11518<refnamediv> 11519 <refname>delete_from_page_cache</refname> 11520 <refpurpose> 11521 delete page from page cache 11522 </refpurpose> 11523</refnamediv> 11524<refsynopsisdiv> 11525 <title>Synopsis</title> 11526 <funcsynopsis><funcprototype> 11527 <funcdef>void <function>delete_from_page_cache </function></funcdef> 11528 <paramdef>struct page * <parameter>page</parameter></paramdef> 11529 </funcprototype></funcsynopsis> 11530</refsynopsisdiv> 11531<refsect1> 11532 <title>Arguments</title> 11533 <variablelist> 11534 <varlistentry> 11535 <term><parameter>page</parameter></term> 11536 <listitem> 11537 <para> 11538 the page which the kernel is trying to remove from page cache 11539 </para> 11540 </listitem> 11541 </varlistentry> 11542 </variablelist> 11543</refsect1> 11544<refsect1> 11545<title>Description</title> 11546<para> 11547 This must be called only on pages that have been verified to be in the page 11548 cache and locked. It will never put the page into the free list, the caller 11549 has a reference on the page. 11550</para> 11551</refsect1> 11552</refentry> 11553 11554<refentry id="API-filemap-flush"> 11555<refentryinfo> 11556 <title>LINUX</title> 11557 <productname>Kernel Hackers Manual</productname> 11558 <date>July 2017</date> 11559</refentryinfo> 11560<refmeta> 11561 <refentrytitle><phrase>filemap_flush</phrase></refentrytitle> 11562 <manvolnum>9</manvolnum> 11563 <refmiscinfo class="version">4.1.27</refmiscinfo> 11564</refmeta> 11565<refnamediv> 11566 <refname>filemap_flush</refname> 11567 <refpurpose> 11568 mostly a non-blocking flush 11569 </refpurpose> 11570</refnamediv> 11571<refsynopsisdiv> 11572 <title>Synopsis</title> 11573 <funcsynopsis><funcprototype> 11574 <funcdef>int <function>filemap_flush </function></funcdef> 11575 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 11576 </funcprototype></funcsynopsis> 11577</refsynopsisdiv> 11578<refsect1> 11579 <title>Arguments</title> 11580 <variablelist> 11581 <varlistentry> 11582 <term><parameter>mapping</parameter></term> 11583 <listitem> 11584 <para> 11585 target address_space 11586 </para> 11587 </listitem> 11588 </varlistentry> 11589 </variablelist> 11590</refsect1> 11591<refsect1> 11592<title>Description</title> 11593<para> 11594 This is a mostly non-blocking flush. Not suitable for data-integrity 11595 purposes - I/O may not be started against all dirty pages. 11596</para> 11597</refsect1> 11598</refentry> 11599 11600<refentry id="API-filemap-fdatawait-range"> 11601<refentryinfo> 11602 <title>LINUX</title> 11603 <productname>Kernel Hackers Manual</productname> 11604 <date>July 2017</date> 11605</refentryinfo> 11606<refmeta> 11607 <refentrytitle><phrase>filemap_fdatawait_range</phrase></refentrytitle> 11608 <manvolnum>9</manvolnum> 11609 <refmiscinfo class="version">4.1.27</refmiscinfo> 11610</refmeta> 11611<refnamediv> 11612 <refname>filemap_fdatawait_range</refname> 11613 <refpurpose> 11614 wait for writeback to complete 11615 </refpurpose> 11616</refnamediv> 11617<refsynopsisdiv> 11618 <title>Synopsis</title> 11619 <funcsynopsis><funcprototype> 11620 <funcdef>int <function>filemap_fdatawait_range </function></funcdef> 11621 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 11622 <paramdef>loff_t <parameter>start_byte</parameter></paramdef> 11623 <paramdef>loff_t <parameter>end_byte</parameter></paramdef> 11624 </funcprototype></funcsynopsis> 11625</refsynopsisdiv> 11626<refsect1> 11627 <title>Arguments</title> 11628 <variablelist> 11629 <varlistentry> 11630 <term><parameter>mapping</parameter></term> 11631 <listitem> 11632 <para> 11633 address space structure to wait for 11634 </para> 11635 </listitem> 11636 </varlistentry> 11637 <varlistentry> 11638 <term><parameter>start_byte</parameter></term> 11639 <listitem> 11640 <para> 11641 offset in bytes where the range starts 11642 </para> 11643 </listitem> 11644 </varlistentry> 11645 <varlistentry> 11646 <term><parameter>end_byte</parameter></term> 11647 <listitem> 11648 <para> 11649 offset in bytes where the range ends (inclusive) 11650 </para> 11651 </listitem> 11652 </varlistentry> 11653 </variablelist> 11654</refsect1> 11655<refsect1> 11656<title>Description</title> 11657<para> 11658 Walk the list of under-writeback pages of the given address space 11659 in the given range and wait for all of them. 11660</para> 11661</refsect1> 11662</refentry> 11663 11664<refentry id="API-filemap-fdatawait"> 11665<refentryinfo> 11666 <title>LINUX</title> 11667 <productname>Kernel Hackers Manual</productname> 11668 <date>July 2017</date> 11669</refentryinfo> 11670<refmeta> 11671 <refentrytitle><phrase>filemap_fdatawait</phrase></refentrytitle> 11672 <manvolnum>9</manvolnum> 11673 <refmiscinfo class="version">4.1.27</refmiscinfo> 11674</refmeta> 11675<refnamediv> 11676 <refname>filemap_fdatawait</refname> 11677 <refpurpose> 11678 wait for all under-writeback pages to complete 11679 </refpurpose> 11680</refnamediv> 11681<refsynopsisdiv> 11682 <title>Synopsis</title> 11683 <funcsynopsis><funcprototype> 11684 <funcdef>int <function>filemap_fdatawait </function></funcdef> 11685 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 11686 </funcprototype></funcsynopsis> 11687</refsynopsisdiv> 11688<refsect1> 11689 <title>Arguments</title> 11690 <variablelist> 11691 <varlistentry> 11692 <term><parameter>mapping</parameter></term> 11693 <listitem> 11694 <para> 11695 address space structure to wait for 11696 </para> 11697 </listitem> 11698 </varlistentry> 11699 </variablelist> 11700</refsect1> 11701<refsect1> 11702<title>Description</title> 11703<para> 11704 Walk the list of under-writeback pages of the given address space 11705 and wait for all of them. 11706</para> 11707</refsect1> 11708</refentry> 11709 11710<refentry id="API-filemap-write-and-wait-range"> 11711<refentryinfo> 11712 <title>LINUX</title> 11713 <productname>Kernel Hackers Manual</productname> 11714 <date>July 2017</date> 11715</refentryinfo> 11716<refmeta> 11717 <refentrytitle><phrase>filemap_write_and_wait_range</phrase></refentrytitle> 11718 <manvolnum>9</manvolnum> 11719 <refmiscinfo class="version">4.1.27</refmiscinfo> 11720</refmeta> 11721<refnamediv> 11722 <refname>filemap_write_and_wait_range</refname> 11723 <refpurpose> 11724 write out & wait on a file range 11725 </refpurpose> 11726</refnamediv> 11727<refsynopsisdiv> 11728 <title>Synopsis</title> 11729 <funcsynopsis><funcprototype> 11730 <funcdef>int <function>filemap_write_and_wait_range </function></funcdef> 11731 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 11732 <paramdef>loff_t <parameter>lstart</parameter></paramdef> 11733 <paramdef>loff_t <parameter>lend</parameter></paramdef> 11734 </funcprototype></funcsynopsis> 11735</refsynopsisdiv> 11736<refsect1> 11737 <title>Arguments</title> 11738 <variablelist> 11739 <varlistentry> 11740 <term><parameter>mapping</parameter></term> 11741 <listitem> 11742 <para> 11743 the address_space for the pages 11744 </para> 11745 </listitem> 11746 </varlistentry> 11747 <varlistentry> 11748 <term><parameter>lstart</parameter></term> 11749 <listitem> 11750 <para> 11751 offset in bytes where the range starts 11752 </para> 11753 </listitem> 11754 </varlistentry> 11755 <varlistentry> 11756 <term><parameter>lend</parameter></term> 11757 <listitem> 11758 <para> 11759 offset in bytes where the range ends (inclusive) 11760 </para> 11761 </listitem> 11762 </varlistentry> 11763 </variablelist> 11764</refsect1> 11765<refsect1> 11766<title>Description</title> 11767<para> 11768 Write out and wait upon file offsets lstart->lend, inclusive. 11769 </para><para> 11770 11771 Note that `lend' is inclusive (describes the last byte to be written) so 11772 that this function can be used to write to the very end-of-file (end = -1). 11773</para> 11774</refsect1> 11775</refentry> 11776 11777<refentry id="API-replace-page-cache-page"> 11778<refentryinfo> 11779 <title>LINUX</title> 11780 <productname>Kernel Hackers Manual</productname> 11781 <date>July 2017</date> 11782</refentryinfo> 11783<refmeta> 11784 <refentrytitle><phrase>replace_page_cache_page</phrase></refentrytitle> 11785 <manvolnum>9</manvolnum> 11786 <refmiscinfo class="version">4.1.27</refmiscinfo> 11787</refmeta> 11788<refnamediv> 11789 <refname>replace_page_cache_page</refname> 11790 <refpurpose> 11791 replace a pagecache page with a new one 11792 </refpurpose> 11793</refnamediv> 11794<refsynopsisdiv> 11795 <title>Synopsis</title> 11796 <funcsynopsis><funcprototype> 11797 <funcdef>int <function>replace_page_cache_page </function></funcdef> 11798 <paramdef>struct page * <parameter>old</parameter></paramdef> 11799 <paramdef>struct page * <parameter>new</parameter></paramdef> 11800 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 11801 </funcprototype></funcsynopsis> 11802</refsynopsisdiv> 11803<refsect1> 11804 <title>Arguments</title> 11805 <variablelist> 11806 <varlistentry> 11807 <term><parameter>old</parameter></term> 11808 <listitem> 11809 <para> 11810 page to be replaced 11811 </para> 11812 </listitem> 11813 </varlistentry> 11814 <varlistentry> 11815 <term><parameter>new</parameter></term> 11816 <listitem> 11817 <para> 11818 page to replace with 11819 </para> 11820 </listitem> 11821 </varlistentry> 11822 <varlistentry> 11823 <term><parameter>gfp_mask</parameter></term> 11824 <listitem> 11825 <para> 11826 allocation mode 11827 </para> 11828 </listitem> 11829 </varlistentry> 11830 </variablelist> 11831</refsect1> 11832<refsect1> 11833<title>Description</title> 11834<para> 11835 This function replaces a page in the pagecache with a new one. On 11836 success it acquires the pagecache reference for the new page and 11837 drops it for the old page. Both the old and new pages must be 11838 locked. This function does not add the new page to the LRU, the 11839 caller must do that. 11840 </para><para> 11841 11842 The remove + add is atomic. The only way this function can fail is 11843 memory allocation failure. 11844</para> 11845</refsect1> 11846</refentry> 11847 11848<refentry id="API-add-to-page-cache-locked"> 11849<refentryinfo> 11850 <title>LINUX</title> 11851 <productname>Kernel Hackers Manual</productname> 11852 <date>July 2017</date> 11853</refentryinfo> 11854<refmeta> 11855 <refentrytitle><phrase>add_to_page_cache_locked</phrase></refentrytitle> 11856 <manvolnum>9</manvolnum> 11857 <refmiscinfo class="version">4.1.27</refmiscinfo> 11858</refmeta> 11859<refnamediv> 11860 <refname>add_to_page_cache_locked</refname> 11861 <refpurpose> 11862 add a locked page to the pagecache 11863 </refpurpose> 11864</refnamediv> 11865<refsynopsisdiv> 11866 <title>Synopsis</title> 11867 <funcsynopsis><funcprototype> 11868 <funcdef>int <function>add_to_page_cache_locked </function></funcdef> 11869 <paramdef>struct page * <parameter>page</parameter></paramdef> 11870 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 11871 <paramdef>pgoff_t <parameter>offset</parameter></paramdef> 11872 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 11873 </funcprototype></funcsynopsis> 11874</refsynopsisdiv> 11875<refsect1> 11876 <title>Arguments</title> 11877 <variablelist> 11878 <varlistentry> 11879 <term><parameter>page</parameter></term> 11880 <listitem> 11881 <para> 11882 page to add 11883 </para> 11884 </listitem> 11885 </varlistentry> 11886 <varlistentry> 11887 <term><parameter>mapping</parameter></term> 11888 <listitem> 11889 <para> 11890 the page's address_space 11891 </para> 11892 </listitem> 11893 </varlistentry> 11894 <varlistentry> 11895 <term><parameter>offset</parameter></term> 11896 <listitem> 11897 <para> 11898 page index 11899 </para> 11900 </listitem> 11901 </varlistentry> 11902 <varlistentry> 11903 <term><parameter>gfp_mask</parameter></term> 11904 <listitem> 11905 <para> 11906 page allocation mode 11907 </para> 11908 </listitem> 11909 </varlistentry> 11910 </variablelist> 11911</refsect1> 11912<refsect1> 11913<title>Description</title> 11914<para> 11915 This function is used to add a page to the pagecache. It must be locked. 11916 This function does not add the page to the LRU. The caller must do that. 11917</para> 11918</refsect1> 11919</refentry> 11920 11921<refentry id="API-add-page-wait-queue"> 11922<refentryinfo> 11923 <title>LINUX</title> 11924 <productname>Kernel Hackers Manual</productname> 11925 <date>July 2017</date> 11926</refentryinfo> 11927<refmeta> 11928 <refentrytitle><phrase>add_page_wait_queue</phrase></refentrytitle> 11929 <manvolnum>9</manvolnum> 11930 <refmiscinfo class="version">4.1.27</refmiscinfo> 11931</refmeta> 11932<refnamediv> 11933 <refname>add_page_wait_queue</refname> 11934 <refpurpose> 11935 Add an arbitrary waiter to a page's wait queue 11936 </refpurpose> 11937</refnamediv> 11938<refsynopsisdiv> 11939 <title>Synopsis</title> 11940 <funcsynopsis><funcprototype> 11941 <funcdef>void <function>add_page_wait_queue </function></funcdef> 11942 <paramdef>struct page * <parameter>page</parameter></paramdef> 11943 <paramdef>wait_queue_t * <parameter>waiter</parameter></paramdef> 11944 </funcprototype></funcsynopsis> 11945</refsynopsisdiv> 11946<refsect1> 11947 <title>Arguments</title> 11948 <variablelist> 11949 <varlistentry> 11950 <term><parameter>page</parameter></term> 11951 <listitem> 11952 <para> 11953 Page defining the wait queue of interest 11954 </para> 11955 </listitem> 11956 </varlistentry> 11957 <varlistentry> 11958 <term><parameter>waiter</parameter></term> 11959 <listitem> 11960 <para> 11961 Waiter to add to the queue 11962 </para> 11963 </listitem> 11964 </varlistentry> 11965 </variablelist> 11966</refsect1> 11967<refsect1> 11968<title>Description</title> 11969<para> 11970 Add an arbitrary <parameter>waiter</parameter> to the wait queue for the nominated <parameter>page</parameter>. 11971</para> 11972</refsect1> 11973</refentry> 11974 11975<refentry id="API-unlock-page"> 11976<refentryinfo> 11977 <title>LINUX</title> 11978 <productname>Kernel Hackers Manual</productname> 11979 <date>July 2017</date> 11980</refentryinfo> 11981<refmeta> 11982 <refentrytitle><phrase>unlock_page</phrase></refentrytitle> 11983 <manvolnum>9</manvolnum> 11984 <refmiscinfo class="version">4.1.27</refmiscinfo> 11985</refmeta> 11986<refnamediv> 11987 <refname>unlock_page</refname> 11988 <refpurpose> 11989 unlock a locked page 11990 </refpurpose> 11991</refnamediv> 11992<refsynopsisdiv> 11993 <title>Synopsis</title> 11994 <funcsynopsis><funcprototype> 11995 <funcdef>void <function>unlock_page </function></funcdef> 11996 <paramdef>struct page * <parameter>page</parameter></paramdef> 11997 </funcprototype></funcsynopsis> 11998</refsynopsisdiv> 11999<refsect1> 12000 <title>Arguments</title> 12001 <variablelist> 12002 <varlistentry> 12003 <term><parameter>page</parameter></term> 12004 <listitem> 12005 <para> 12006 the page 12007 </para> 12008 </listitem> 12009 </varlistentry> 12010 </variablelist> 12011</refsect1> 12012<refsect1> 12013<title>Description</title> 12014<para> 12015 Unlocks the page and wakes up sleepers in <function>___wait_on_page_locked</function>. 12016 Also wakes sleepers in <function>wait_on_page_writeback</function> because the wakeup 12017 mechanism between PageLocked pages and PageWriteback pages is shared. 12018 But that's OK - sleepers in <function>wait_on_page_writeback</function> just go back to sleep. 12019 </para><para> 12020 12021 The mb is necessary to enforce ordering between the clear_bit and the read 12022 of the waitqueue (to avoid SMP races with a parallel <function>wait_on_page_locked</function>). 12023</para> 12024</refsect1> 12025</refentry> 12026 12027<refentry id="API-end-page-writeback"> 12028<refentryinfo> 12029 <title>LINUX</title> 12030 <productname>Kernel Hackers Manual</productname> 12031 <date>July 2017</date> 12032</refentryinfo> 12033<refmeta> 12034 <refentrytitle><phrase>end_page_writeback</phrase></refentrytitle> 12035 <manvolnum>9</manvolnum> 12036 <refmiscinfo class="version">4.1.27</refmiscinfo> 12037</refmeta> 12038<refnamediv> 12039 <refname>end_page_writeback</refname> 12040 <refpurpose> 12041 end writeback against a page 12042 </refpurpose> 12043</refnamediv> 12044<refsynopsisdiv> 12045 <title>Synopsis</title> 12046 <funcsynopsis><funcprototype> 12047 <funcdef>void <function>end_page_writeback </function></funcdef> 12048 <paramdef>struct page * <parameter>page</parameter></paramdef> 12049 </funcprototype></funcsynopsis> 12050</refsynopsisdiv> 12051<refsect1> 12052 <title>Arguments</title> 12053 <variablelist> 12054 <varlistentry> 12055 <term><parameter>page</parameter></term> 12056 <listitem> 12057 <para> 12058 the page 12059 </para> 12060 </listitem> 12061 </varlistentry> 12062 </variablelist> 12063</refsect1> 12064</refentry> 12065 12066<refentry id="API---lock-page"> 12067<refentryinfo> 12068 <title>LINUX</title> 12069 <productname>Kernel Hackers Manual</productname> 12070 <date>July 2017</date> 12071</refentryinfo> 12072<refmeta> 12073 <refentrytitle><phrase>__lock_page</phrase></refentrytitle> 12074 <manvolnum>9</manvolnum> 12075 <refmiscinfo class="version">4.1.27</refmiscinfo> 12076</refmeta> 12077<refnamediv> 12078 <refname>__lock_page</refname> 12079 <refpurpose> 12080 get a lock on the page, assuming we need to sleep to get it 12081 </refpurpose> 12082</refnamediv> 12083<refsynopsisdiv> 12084 <title>Synopsis</title> 12085 <funcsynopsis><funcprototype> 12086 <funcdef>void <function>__lock_page </function></funcdef> 12087 <paramdef>struct page * <parameter>page</parameter></paramdef> 12088 </funcprototype></funcsynopsis> 12089</refsynopsisdiv> 12090<refsect1> 12091 <title>Arguments</title> 12092 <variablelist> 12093 <varlistentry> 12094 <term><parameter>page</parameter></term> 12095 <listitem> 12096 <para> 12097 the page to lock 12098 </para> 12099 </listitem> 12100 </varlistentry> 12101 </variablelist> 12102</refsect1> 12103</refentry> 12104 12105<refentry id="API-page-cache-next-hole"> 12106<refentryinfo> 12107 <title>LINUX</title> 12108 <productname>Kernel Hackers Manual</productname> 12109 <date>July 2017</date> 12110</refentryinfo> 12111<refmeta> 12112 <refentrytitle><phrase>page_cache_next_hole</phrase></refentrytitle> 12113 <manvolnum>9</manvolnum> 12114 <refmiscinfo class="version">4.1.27</refmiscinfo> 12115</refmeta> 12116<refnamediv> 12117 <refname>page_cache_next_hole</refname> 12118 <refpurpose> 12119 find the next hole (not-present entry) 12120 </refpurpose> 12121</refnamediv> 12122<refsynopsisdiv> 12123 <title>Synopsis</title> 12124 <funcsynopsis><funcprototype> 12125 <funcdef>pgoff_t <function>page_cache_next_hole </function></funcdef> 12126 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 12127 <paramdef>pgoff_t <parameter>index</parameter></paramdef> 12128 <paramdef>unsigned long <parameter>max_scan</parameter></paramdef> 12129 </funcprototype></funcsynopsis> 12130</refsynopsisdiv> 12131<refsect1> 12132 <title>Arguments</title> 12133 <variablelist> 12134 <varlistentry> 12135 <term><parameter>mapping</parameter></term> 12136 <listitem> 12137 <para> 12138 mapping 12139 </para> 12140 </listitem> 12141 </varlistentry> 12142 <varlistentry> 12143 <term><parameter>index</parameter></term> 12144 <listitem> 12145 <para> 12146 index 12147 </para> 12148 </listitem> 12149 </varlistentry> 12150 <varlistentry> 12151 <term><parameter>max_scan</parameter></term> 12152 <listitem> 12153 <para> 12154 maximum range to search 12155 </para> 12156 </listitem> 12157 </varlistentry> 12158 </variablelist> 12159</refsect1> 12160<refsect1> 12161<title>Description</title> 12162<para> 12163 Search the set [index, min(index+max_scan-1, MAX_INDEX)] for the 12164 lowest indexed hole. 12165</para> 12166</refsect1> 12167<refsect1> 12168<title>Returns</title> 12169<para> 12170 the index of the hole if found, otherwise returns an index 12171 outside of the set specified (in which case 'return - index >= 12172 max_scan' will be true). In rare cases of index wrap-around, 0 will 12173 be returned. 12174 </para><para> 12175 12176 page_cache_next_hole may be called under rcu_read_lock. However, 12177 like radix_tree_gang_lookup, this will not atomically search a 12178 snapshot of the tree at a single point in time. For example, if a 12179 hole is created at index 5, then subsequently a hole is created at 12180 index 10, page_cache_next_hole covering both indexes may return 10 12181 if called under rcu_read_lock. 12182</para> 12183</refsect1> 12184</refentry> 12185 12186<refentry id="API-page-cache-prev-hole"> 12187<refentryinfo> 12188 <title>LINUX</title> 12189 <productname>Kernel Hackers Manual</productname> 12190 <date>July 2017</date> 12191</refentryinfo> 12192<refmeta> 12193 <refentrytitle><phrase>page_cache_prev_hole</phrase></refentrytitle> 12194 <manvolnum>9</manvolnum> 12195 <refmiscinfo class="version">4.1.27</refmiscinfo> 12196</refmeta> 12197<refnamediv> 12198 <refname>page_cache_prev_hole</refname> 12199 <refpurpose> 12200 find the prev hole (not-present entry) 12201 </refpurpose> 12202</refnamediv> 12203<refsynopsisdiv> 12204 <title>Synopsis</title> 12205 <funcsynopsis><funcprototype> 12206 <funcdef>pgoff_t <function>page_cache_prev_hole </function></funcdef> 12207 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 12208 <paramdef>pgoff_t <parameter>index</parameter></paramdef> 12209 <paramdef>unsigned long <parameter>max_scan</parameter></paramdef> 12210 </funcprototype></funcsynopsis> 12211</refsynopsisdiv> 12212<refsect1> 12213 <title>Arguments</title> 12214 <variablelist> 12215 <varlistentry> 12216 <term><parameter>mapping</parameter></term> 12217 <listitem> 12218 <para> 12219 mapping 12220 </para> 12221 </listitem> 12222 </varlistentry> 12223 <varlistentry> 12224 <term><parameter>index</parameter></term> 12225 <listitem> 12226 <para> 12227 index 12228 </para> 12229 </listitem> 12230 </varlistentry> 12231 <varlistentry> 12232 <term><parameter>max_scan</parameter></term> 12233 <listitem> 12234 <para> 12235 maximum range to search 12236 </para> 12237 </listitem> 12238 </varlistentry> 12239 </variablelist> 12240</refsect1> 12241<refsect1> 12242<title>Description</title> 12243<para> 12244 Search backwards in the range [max(index-max_scan+1, 0), index] for 12245 the first hole. 12246</para> 12247</refsect1> 12248<refsect1> 12249<title>Returns</title> 12250<para> 12251 the index of the hole if found, otherwise returns an index 12252 outside of the set specified (in which case 'index - return >= 12253 max_scan' will be true). In rare cases of wrap-around, ULONG_MAX 12254 will be returned. 12255 </para><para> 12256 12257 page_cache_prev_hole may be called under rcu_read_lock. However, 12258 like radix_tree_gang_lookup, this will not atomically search a 12259 snapshot of the tree at a single point in time. For example, if a 12260 hole is created at index 10, then subsequently a hole is created at 12261 index 5, page_cache_prev_hole covering both indexes may return 5 if 12262 called under rcu_read_lock. 12263</para> 12264</refsect1> 12265</refentry> 12266 12267<refentry id="API-find-get-entry"> 12268<refentryinfo> 12269 <title>LINUX</title> 12270 <productname>Kernel Hackers Manual</productname> 12271 <date>July 2017</date> 12272</refentryinfo> 12273<refmeta> 12274 <refentrytitle><phrase>find_get_entry</phrase></refentrytitle> 12275 <manvolnum>9</manvolnum> 12276 <refmiscinfo class="version">4.1.27</refmiscinfo> 12277</refmeta> 12278<refnamediv> 12279 <refname>find_get_entry</refname> 12280 <refpurpose> 12281 find and get a page cache entry 12282 </refpurpose> 12283</refnamediv> 12284<refsynopsisdiv> 12285 <title>Synopsis</title> 12286 <funcsynopsis><funcprototype> 12287 <funcdef>struct page * <function>find_get_entry </function></funcdef> 12288 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 12289 <paramdef>pgoff_t <parameter>offset</parameter></paramdef> 12290 </funcprototype></funcsynopsis> 12291</refsynopsisdiv> 12292<refsect1> 12293 <title>Arguments</title> 12294 <variablelist> 12295 <varlistentry> 12296 <term><parameter>mapping</parameter></term> 12297 <listitem> 12298 <para> 12299 the address_space to search 12300 </para> 12301 </listitem> 12302 </varlistentry> 12303 <varlistentry> 12304 <term><parameter>offset</parameter></term> 12305 <listitem> 12306 <para> 12307 the page cache index 12308 </para> 12309 </listitem> 12310 </varlistentry> 12311 </variablelist> 12312</refsect1> 12313<refsect1> 12314<title>Description</title> 12315<para> 12316 Looks up the page cache slot at <parameter>mapping</parameter> & <parameter>offset</parameter>. If there is a 12317 page cache page, it is returned with an increased refcount. 12318 </para><para> 12319 12320 If the slot holds a shadow entry of a previously evicted page, or a 12321 swap entry from shmem/tmpfs, it is returned. 12322 </para><para> 12323 12324 Otherwise, <constant>NULL</constant> is returned. 12325</para> 12326</refsect1> 12327</refentry> 12328 12329<refentry id="API-find-lock-entry"> 12330<refentryinfo> 12331 <title>LINUX</title> 12332 <productname>Kernel Hackers Manual</productname> 12333 <date>July 2017</date> 12334</refentryinfo> 12335<refmeta> 12336 <refentrytitle><phrase>find_lock_entry</phrase></refentrytitle> 12337 <manvolnum>9</manvolnum> 12338 <refmiscinfo class="version">4.1.27</refmiscinfo> 12339</refmeta> 12340<refnamediv> 12341 <refname>find_lock_entry</refname> 12342 <refpurpose> 12343 locate, pin and lock a page cache entry 12344 </refpurpose> 12345</refnamediv> 12346<refsynopsisdiv> 12347 <title>Synopsis</title> 12348 <funcsynopsis><funcprototype> 12349 <funcdef>struct page * <function>find_lock_entry </function></funcdef> 12350 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 12351 <paramdef>pgoff_t <parameter>offset</parameter></paramdef> 12352 </funcprototype></funcsynopsis> 12353</refsynopsisdiv> 12354<refsect1> 12355 <title>Arguments</title> 12356 <variablelist> 12357 <varlistentry> 12358 <term><parameter>mapping</parameter></term> 12359 <listitem> 12360 <para> 12361 the address_space to search 12362 </para> 12363 </listitem> 12364 </varlistentry> 12365 <varlistentry> 12366 <term><parameter>offset</parameter></term> 12367 <listitem> 12368 <para> 12369 the page cache index 12370 </para> 12371 </listitem> 12372 </varlistentry> 12373 </variablelist> 12374</refsect1> 12375<refsect1> 12376<title>Description</title> 12377<para> 12378 Looks up the page cache slot at <parameter>mapping</parameter> & <parameter>offset</parameter>. If there is a 12379 page cache page, it is returned locked and with an increased 12380 refcount. 12381 </para><para> 12382 12383 If the slot holds a shadow entry of a previously evicted page, or a 12384 swap entry from shmem/tmpfs, it is returned. 12385 </para><para> 12386 12387 Otherwise, <constant>NULL</constant> is returned. 12388 </para><para> 12389 12390 <function>find_lock_entry</function> may sleep. 12391</para> 12392</refsect1> 12393</refentry> 12394 12395<refentry id="API-pagecache-get-page"> 12396<refentryinfo> 12397 <title>LINUX</title> 12398 <productname>Kernel Hackers Manual</productname> 12399 <date>July 2017</date> 12400</refentryinfo> 12401<refmeta> 12402 <refentrytitle><phrase>pagecache_get_page</phrase></refentrytitle> 12403 <manvolnum>9</manvolnum> 12404 <refmiscinfo class="version">4.1.27</refmiscinfo> 12405</refmeta> 12406<refnamediv> 12407 <refname>pagecache_get_page</refname> 12408 <refpurpose> 12409 find and get a page reference 12410 </refpurpose> 12411</refnamediv> 12412<refsynopsisdiv> 12413 <title>Synopsis</title> 12414 <funcsynopsis><funcprototype> 12415 <funcdef>struct page * <function>pagecache_get_page </function></funcdef> 12416 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 12417 <paramdef>pgoff_t <parameter>offset</parameter></paramdef> 12418 <paramdef>int <parameter>fgp_flags</parameter></paramdef> 12419 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 12420 </funcprototype></funcsynopsis> 12421</refsynopsisdiv> 12422<refsect1> 12423 <title>Arguments</title> 12424 <variablelist> 12425 <varlistentry> 12426 <term><parameter>mapping</parameter></term> 12427 <listitem> 12428 <para> 12429 the address_space to search 12430 </para> 12431 </listitem> 12432 </varlistentry> 12433 <varlistentry> 12434 <term><parameter>offset</parameter></term> 12435 <listitem> 12436 <para> 12437 the page index 12438 </para> 12439 </listitem> 12440 </varlistentry> 12441 <varlistentry> 12442 <term><parameter>fgp_flags</parameter></term> 12443 <listitem> 12444 <para> 12445 PCG flags 12446 </para> 12447 </listitem> 12448 </varlistentry> 12449 <varlistentry> 12450 <term><parameter>gfp_mask</parameter></term> 12451 <listitem> 12452 <para> 12453 gfp mask to use for the page cache data page allocation 12454 </para> 12455 </listitem> 12456 </varlistentry> 12457 </variablelist> 12458</refsect1> 12459<refsect1> 12460<title>Description</title> 12461<para> 12462 Looks up the page cache slot at <parameter>mapping</parameter> & <parameter>offset</parameter>. 12463 </para><para> 12464 12465 PCG flags modify how the page is returned. 12466</para> 12467</refsect1> 12468<refsect1> 12469<title>FGP_ACCESSED</title> 12470<para> 12471 the page will be marked accessed 12472</para> 12473</refsect1> 12474<refsect1> 12475<title>FGP_LOCK</title> 12476<para> 12477 Page is return locked 12478</para> 12479</refsect1> 12480<refsect1> 12481<title>FGP_CREAT</title> 12482<para> 12483 If page is not present then a new page is allocated using 12484 <parameter>gfp_mask</parameter> and added to the page cache and the VM's LRU 12485 list. The page is returned locked and with an increased 12486 refcount. Otherwise, <constant>NULL</constant> is returned. 12487 </para><para> 12488 12489 If FGP_LOCK or FGP_CREAT are specified then the function may sleep even 12490 if the GFP flags specified for FGP_CREAT are atomic. 12491 </para><para> 12492 12493 If there is a page cache page, it is returned with an increased refcount. 12494</para> 12495</refsect1> 12496</refentry> 12497 12498<refentry id="API-find-get-pages-contig"> 12499<refentryinfo> 12500 <title>LINUX</title> 12501 <productname>Kernel Hackers Manual</productname> 12502 <date>July 2017</date> 12503</refentryinfo> 12504<refmeta> 12505 <refentrytitle><phrase>find_get_pages_contig</phrase></refentrytitle> 12506 <manvolnum>9</manvolnum> 12507 <refmiscinfo class="version">4.1.27</refmiscinfo> 12508</refmeta> 12509<refnamediv> 12510 <refname>find_get_pages_contig</refname> 12511 <refpurpose> 12512 gang contiguous pagecache lookup 12513 </refpurpose> 12514</refnamediv> 12515<refsynopsisdiv> 12516 <title>Synopsis</title> 12517 <funcsynopsis><funcprototype> 12518 <funcdef>unsigned <function>find_get_pages_contig </function></funcdef> 12519 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 12520 <paramdef>pgoff_t <parameter>index</parameter></paramdef> 12521 <paramdef>unsigned int <parameter>nr_pages</parameter></paramdef> 12522 <paramdef>struct page ** <parameter>pages</parameter></paramdef> 12523 </funcprototype></funcsynopsis> 12524</refsynopsisdiv> 12525<refsect1> 12526 <title>Arguments</title> 12527 <variablelist> 12528 <varlistentry> 12529 <term><parameter>mapping</parameter></term> 12530 <listitem> 12531 <para> 12532 The address_space to search 12533 </para> 12534 </listitem> 12535 </varlistentry> 12536 <varlistentry> 12537 <term><parameter>index</parameter></term> 12538 <listitem> 12539 <para> 12540 The starting page index 12541 </para> 12542 </listitem> 12543 </varlistentry> 12544 <varlistentry> 12545 <term><parameter>nr_pages</parameter></term> 12546 <listitem> 12547 <para> 12548 The maximum number of pages 12549 </para> 12550 </listitem> 12551 </varlistentry> 12552 <varlistentry> 12553 <term><parameter>pages</parameter></term> 12554 <listitem> 12555 <para> 12556 Where the resulting pages are placed 12557 </para> 12558 </listitem> 12559 </varlistentry> 12560 </variablelist> 12561</refsect1> 12562<refsect1> 12563<title>Description</title> 12564<para> 12565 <function>find_get_pages_contig</function> works exactly like <function>find_get_pages</function>, except 12566 that the returned number of pages are guaranteed to be contiguous. 12567 </para><para> 12568 12569 <function>find_get_pages_contig</function> returns the number of pages which were found. 12570</para> 12571</refsect1> 12572</refentry> 12573 12574<refentry id="API-find-get-pages-tag"> 12575<refentryinfo> 12576 <title>LINUX</title> 12577 <productname>Kernel Hackers Manual</productname> 12578 <date>July 2017</date> 12579</refentryinfo> 12580<refmeta> 12581 <refentrytitle><phrase>find_get_pages_tag</phrase></refentrytitle> 12582 <manvolnum>9</manvolnum> 12583 <refmiscinfo class="version">4.1.27</refmiscinfo> 12584</refmeta> 12585<refnamediv> 12586 <refname>find_get_pages_tag</refname> 12587 <refpurpose> 12588 find and return pages that match <parameter>tag</parameter> 12589 </refpurpose> 12590</refnamediv> 12591<refsynopsisdiv> 12592 <title>Synopsis</title> 12593 <funcsynopsis><funcprototype> 12594 <funcdef>unsigned <function>find_get_pages_tag </function></funcdef> 12595 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 12596 <paramdef>pgoff_t * <parameter>index</parameter></paramdef> 12597 <paramdef>int <parameter>tag</parameter></paramdef> 12598 <paramdef>unsigned int <parameter>nr_pages</parameter></paramdef> 12599 <paramdef>struct page ** <parameter>pages</parameter></paramdef> 12600 </funcprototype></funcsynopsis> 12601</refsynopsisdiv> 12602<refsect1> 12603 <title>Arguments</title> 12604 <variablelist> 12605 <varlistentry> 12606 <term><parameter>mapping</parameter></term> 12607 <listitem> 12608 <para> 12609 the address_space to search 12610 </para> 12611 </listitem> 12612 </varlistentry> 12613 <varlistentry> 12614 <term><parameter>index</parameter></term> 12615 <listitem> 12616 <para> 12617 the starting page index 12618 </para> 12619 </listitem> 12620 </varlistentry> 12621 <varlistentry> 12622 <term><parameter>tag</parameter></term> 12623 <listitem> 12624 <para> 12625 the tag index 12626 </para> 12627 </listitem> 12628 </varlistentry> 12629 <varlistentry> 12630 <term><parameter>nr_pages</parameter></term> 12631 <listitem> 12632 <para> 12633 the maximum number of pages 12634 </para> 12635 </listitem> 12636 </varlistentry> 12637 <varlistentry> 12638 <term><parameter>pages</parameter></term> 12639 <listitem> 12640 <para> 12641 where the resulting pages are placed 12642 </para> 12643 </listitem> 12644 </varlistentry> 12645 </variablelist> 12646</refsect1> 12647<refsect1> 12648<title>Description</title> 12649<para> 12650 Like find_get_pages, except we only return pages which are tagged with 12651 <parameter>tag</parameter>. We update <parameter>index</parameter> to index the next page for the traversal. 12652</para> 12653</refsect1> 12654</refentry> 12655 12656<refentry id="API-generic-file-read-iter"> 12657<refentryinfo> 12658 <title>LINUX</title> 12659 <productname>Kernel Hackers Manual</productname> 12660 <date>July 2017</date> 12661</refentryinfo> 12662<refmeta> 12663 <refentrytitle><phrase>generic_file_read_iter</phrase></refentrytitle> 12664 <manvolnum>9</manvolnum> 12665 <refmiscinfo class="version">4.1.27</refmiscinfo> 12666</refmeta> 12667<refnamediv> 12668 <refname>generic_file_read_iter</refname> 12669 <refpurpose> 12670 generic filesystem read routine 12671 </refpurpose> 12672</refnamediv> 12673<refsynopsisdiv> 12674 <title>Synopsis</title> 12675 <funcsynopsis><funcprototype> 12676 <funcdef>ssize_t <function>generic_file_read_iter </function></funcdef> 12677 <paramdef>struct kiocb * <parameter>iocb</parameter></paramdef> 12678 <paramdef>struct iov_iter * <parameter>iter</parameter></paramdef> 12679 </funcprototype></funcsynopsis> 12680</refsynopsisdiv> 12681<refsect1> 12682 <title>Arguments</title> 12683 <variablelist> 12684 <varlistentry> 12685 <term><parameter>iocb</parameter></term> 12686 <listitem> 12687 <para> 12688 kernel I/O control block 12689 </para> 12690 </listitem> 12691 </varlistentry> 12692 <varlistentry> 12693 <term><parameter>iter</parameter></term> 12694 <listitem> 12695 <para> 12696 destination for the data read 12697 </para> 12698 </listitem> 12699 </varlistentry> 12700 </variablelist> 12701</refsect1> 12702<refsect1> 12703<title>Description</title> 12704<para> 12705 This is the <quote><function>read_iter</function></quote> routine for all filesystems 12706 that can use the page cache directly. 12707</para> 12708</refsect1> 12709</refentry> 12710 12711<refentry id="API-filemap-fault"> 12712<refentryinfo> 12713 <title>LINUX</title> 12714 <productname>Kernel Hackers Manual</productname> 12715 <date>July 2017</date> 12716</refentryinfo> 12717<refmeta> 12718 <refentrytitle><phrase>filemap_fault</phrase></refentrytitle> 12719 <manvolnum>9</manvolnum> 12720 <refmiscinfo class="version">4.1.27</refmiscinfo> 12721</refmeta> 12722<refnamediv> 12723 <refname>filemap_fault</refname> 12724 <refpurpose> 12725 read in file data for page fault handling 12726 </refpurpose> 12727</refnamediv> 12728<refsynopsisdiv> 12729 <title>Synopsis</title> 12730 <funcsynopsis><funcprototype> 12731 <funcdef>int <function>filemap_fault </function></funcdef> 12732 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 12733 <paramdef>struct vm_fault * <parameter>vmf</parameter></paramdef> 12734 </funcprototype></funcsynopsis> 12735</refsynopsisdiv> 12736<refsect1> 12737 <title>Arguments</title> 12738 <variablelist> 12739 <varlistentry> 12740 <term><parameter>vma</parameter></term> 12741 <listitem> 12742 <para> 12743 vma in which the fault was taken 12744 </para> 12745 </listitem> 12746 </varlistentry> 12747 <varlistentry> 12748 <term><parameter>vmf</parameter></term> 12749 <listitem> 12750 <para> 12751 struct vm_fault containing details of the fault 12752 </para> 12753 </listitem> 12754 </varlistentry> 12755 </variablelist> 12756</refsect1> 12757<refsect1> 12758<title>Description</title> 12759<para> 12760 <function>filemap_fault</function> is invoked via the vma operations vector for a 12761 mapped memory region to read in file data during a page fault. 12762 </para><para> 12763 12764 The goto's are kind of ugly, but this streamlines the normal case of having 12765 it in the page cache, and handles the special cases reasonably without 12766 having a lot of duplicated code. 12767 </para><para> 12768 12769 vma->vm_mm->mmap_sem must be held on entry. 12770 </para><para> 12771 12772 If our return value has VM_FAULT_RETRY set, it's because 12773 <function>lock_page_or_retry</function> returned 0. 12774 The mmap_sem has usually been released in this case. 12775 See <function>__lock_page_or_retry</function> for the exception. 12776 </para><para> 12777 12778 If our return value does not have VM_FAULT_RETRY set, the mmap_sem 12779 has not been released. 12780 </para><para> 12781 12782 We never return with VM_FAULT_RETRY and a bit from VM_FAULT_ERROR set. 12783</para> 12784</refsect1> 12785</refentry> 12786 12787<refentry id="API-read-cache-page"> 12788<refentryinfo> 12789 <title>LINUX</title> 12790 <productname>Kernel Hackers Manual</productname> 12791 <date>July 2017</date> 12792</refentryinfo> 12793<refmeta> 12794 <refentrytitle><phrase>read_cache_page</phrase></refentrytitle> 12795 <manvolnum>9</manvolnum> 12796 <refmiscinfo class="version">4.1.27</refmiscinfo> 12797</refmeta> 12798<refnamediv> 12799 <refname>read_cache_page</refname> 12800 <refpurpose> 12801 read into page cache, fill it if needed 12802 </refpurpose> 12803</refnamediv> 12804<refsynopsisdiv> 12805 <title>Synopsis</title> 12806 <funcsynopsis><funcprototype> 12807 <funcdef>struct page * <function>read_cache_page </function></funcdef> 12808 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 12809 <paramdef>pgoff_t <parameter>index</parameter></paramdef> 12810 <paramdef>int (*<parameter>filler</parameter>) 12811 <funcparams>void *, struct page *</funcparams></paramdef> 12812 <paramdef>void * <parameter>data</parameter></paramdef> 12813 </funcprototype></funcsynopsis> 12814</refsynopsisdiv> 12815<refsect1> 12816 <title>Arguments</title> 12817 <variablelist> 12818 <varlistentry> 12819 <term><parameter>mapping</parameter></term> 12820 <listitem> 12821 <para> 12822 the page's address_space 12823 </para> 12824 </listitem> 12825 </varlistentry> 12826 <varlistentry> 12827 <term><parameter>index</parameter></term> 12828 <listitem> 12829 <para> 12830 the page index 12831 </para> 12832 </listitem> 12833 </varlistentry> 12834 <varlistentry> 12835 <term><parameter>filler</parameter></term> 12836 <listitem> 12837 <para> 12838 function to perform the read 12839 </para> 12840 </listitem> 12841 </varlistentry> 12842 <varlistentry> 12843 <term><parameter>data</parameter></term> 12844 <listitem> 12845 <para> 12846 first arg to filler(data, page) function, often left as NULL 12847 </para> 12848 </listitem> 12849 </varlistentry> 12850 </variablelist> 12851</refsect1> 12852<refsect1> 12853<title>Description</title> 12854<para> 12855 Read into the page cache. If a page already exists, and <function>PageUptodate</function> is 12856 not set, try to fill the page and wait for it to become unlocked. 12857 </para><para> 12858 12859 If the page does not get brought uptodate, return -EIO. 12860</para> 12861</refsect1> 12862</refentry> 12863 12864<refentry id="API-read-cache-page-gfp"> 12865<refentryinfo> 12866 <title>LINUX</title> 12867 <productname>Kernel Hackers Manual</productname> 12868 <date>July 2017</date> 12869</refentryinfo> 12870<refmeta> 12871 <refentrytitle><phrase>read_cache_page_gfp</phrase></refentrytitle> 12872 <manvolnum>9</manvolnum> 12873 <refmiscinfo class="version">4.1.27</refmiscinfo> 12874</refmeta> 12875<refnamediv> 12876 <refname>read_cache_page_gfp</refname> 12877 <refpurpose> 12878 read into page cache, using specified page allocation flags. 12879 </refpurpose> 12880</refnamediv> 12881<refsynopsisdiv> 12882 <title>Synopsis</title> 12883 <funcsynopsis><funcprototype> 12884 <funcdef>struct page * <function>read_cache_page_gfp </function></funcdef> 12885 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 12886 <paramdef>pgoff_t <parameter>index</parameter></paramdef> 12887 <paramdef>gfp_t <parameter>gfp</parameter></paramdef> 12888 </funcprototype></funcsynopsis> 12889</refsynopsisdiv> 12890<refsect1> 12891 <title>Arguments</title> 12892 <variablelist> 12893 <varlistentry> 12894 <term><parameter>mapping</parameter></term> 12895 <listitem> 12896 <para> 12897 the page's address_space 12898 </para> 12899 </listitem> 12900 </varlistentry> 12901 <varlistentry> 12902 <term><parameter>index</parameter></term> 12903 <listitem> 12904 <para> 12905 the page index 12906 </para> 12907 </listitem> 12908 </varlistentry> 12909 <varlistentry> 12910 <term><parameter>gfp</parameter></term> 12911 <listitem> 12912 <para> 12913 the page allocator flags to use if allocating 12914 </para> 12915 </listitem> 12916 </varlistentry> 12917 </variablelist> 12918</refsect1> 12919<refsect1> 12920<title>Description</title> 12921<para> 12922 This is the same as <quote>read_mapping_page(mapping, index, NULL)</quote>, but with 12923 any new page allocations done using the specified allocation flags. 12924 </para><para> 12925 12926 If the page does not get brought uptodate, return -EIO. 12927</para> 12928</refsect1> 12929</refentry> 12930 12931<refentry id="API---generic-file-write-iter"> 12932<refentryinfo> 12933 <title>LINUX</title> 12934 <productname>Kernel Hackers Manual</productname> 12935 <date>July 2017</date> 12936</refentryinfo> 12937<refmeta> 12938 <refentrytitle><phrase>__generic_file_write_iter</phrase></refentrytitle> 12939 <manvolnum>9</manvolnum> 12940 <refmiscinfo class="version">4.1.27</refmiscinfo> 12941</refmeta> 12942<refnamediv> 12943 <refname>__generic_file_write_iter</refname> 12944 <refpurpose> 12945 write data to a file 12946 </refpurpose> 12947</refnamediv> 12948<refsynopsisdiv> 12949 <title>Synopsis</title> 12950 <funcsynopsis><funcprototype> 12951 <funcdef>ssize_t <function>__generic_file_write_iter </function></funcdef> 12952 <paramdef>struct kiocb * <parameter>iocb</parameter></paramdef> 12953 <paramdef>struct iov_iter * <parameter>from</parameter></paramdef> 12954 </funcprototype></funcsynopsis> 12955</refsynopsisdiv> 12956<refsect1> 12957 <title>Arguments</title> 12958 <variablelist> 12959 <varlistentry> 12960 <term><parameter>iocb</parameter></term> 12961 <listitem> 12962 <para> 12963 IO state structure (file, offset, etc.) 12964 </para> 12965 </listitem> 12966 </varlistentry> 12967 <varlistentry> 12968 <term><parameter>from</parameter></term> 12969 <listitem> 12970 <para> 12971 iov_iter with data to write 12972 </para> 12973 </listitem> 12974 </varlistentry> 12975 </variablelist> 12976</refsect1> 12977<refsect1> 12978<title>Description</title> 12979<para> 12980 This function does all the work needed for actually writing data to a 12981 file. It does all basic checks, removes SUID from the file, updates 12982 modification times and calls proper subroutines depending on whether we 12983 do direct IO or a standard buffered write. 12984 </para><para> 12985 12986 It expects i_mutex to be grabbed unless we work on a block device or similar 12987 object which does not need locking at all. 12988 </para><para> 12989 12990 This function does *not* take care of syncing data in case of O_SYNC write. 12991 A caller has to handle it. This is mainly due to the fact that we want to 12992 avoid syncing under i_mutex. 12993</para> 12994</refsect1> 12995</refentry> 12996 12997<refentry id="API-generic-file-write-iter"> 12998<refentryinfo> 12999 <title>LINUX</title> 13000 <productname>Kernel Hackers Manual</productname> 13001 <date>July 2017</date> 13002</refentryinfo> 13003<refmeta> 13004 <refentrytitle><phrase>generic_file_write_iter</phrase></refentrytitle> 13005 <manvolnum>9</manvolnum> 13006 <refmiscinfo class="version">4.1.27</refmiscinfo> 13007</refmeta> 13008<refnamediv> 13009 <refname>generic_file_write_iter</refname> 13010 <refpurpose> 13011 write data to a file 13012 </refpurpose> 13013</refnamediv> 13014<refsynopsisdiv> 13015 <title>Synopsis</title> 13016 <funcsynopsis><funcprototype> 13017 <funcdef>ssize_t <function>generic_file_write_iter </function></funcdef> 13018 <paramdef>struct kiocb * <parameter>iocb</parameter></paramdef> 13019 <paramdef>struct iov_iter * <parameter>from</parameter></paramdef> 13020 </funcprototype></funcsynopsis> 13021</refsynopsisdiv> 13022<refsect1> 13023 <title>Arguments</title> 13024 <variablelist> 13025 <varlistentry> 13026 <term><parameter>iocb</parameter></term> 13027 <listitem> 13028 <para> 13029 IO state structure 13030 </para> 13031 </listitem> 13032 </varlistentry> 13033 <varlistentry> 13034 <term><parameter>from</parameter></term> 13035 <listitem> 13036 <para> 13037 iov_iter with data to write 13038 </para> 13039 </listitem> 13040 </varlistentry> 13041 </variablelist> 13042</refsect1> 13043<refsect1> 13044<title>Description</title> 13045<para> 13046 This is a wrapper around <function>__generic_file_write_iter</function> to be used by most 13047 filesystems. It takes care of syncing the file in case of O_SYNC file 13048 and acquires i_mutex as needed. 13049</para> 13050</refsect1> 13051</refentry> 13052 13053<refentry id="API-try-to-release-page"> 13054<refentryinfo> 13055 <title>LINUX</title> 13056 <productname>Kernel Hackers Manual</productname> 13057 <date>July 2017</date> 13058</refentryinfo> 13059<refmeta> 13060 <refentrytitle><phrase>try_to_release_page</phrase></refentrytitle> 13061 <manvolnum>9</manvolnum> 13062 <refmiscinfo class="version">4.1.27</refmiscinfo> 13063</refmeta> 13064<refnamediv> 13065 <refname>try_to_release_page</refname> 13066 <refpurpose> 13067 release old fs-specific metadata on a page 13068 </refpurpose> 13069</refnamediv> 13070<refsynopsisdiv> 13071 <title>Synopsis</title> 13072 <funcsynopsis><funcprototype> 13073 <funcdef>int <function>try_to_release_page </function></funcdef> 13074 <paramdef>struct page * <parameter>page</parameter></paramdef> 13075 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 13076 </funcprototype></funcsynopsis> 13077</refsynopsisdiv> 13078<refsect1> 13079 <title>Arguments</title> 13080 <variablelist> 13081 <varlistentry> 13082 <term><parameter>page</parameter></term> 13083 <listitem> 13084 <para> 13085 the page which the kernel is trying to free 13086 </para> 13087 </listitem> 13088 </varlistentry> 13089 <varlistentry> 13090 <term><parameter>gfp_mask</parameter></term> 13091 <listitem> 13092 <para> 13093 memory allocation flags (and I/O mode) 13094 </para> 13095 </listitem> 13096 </varlistentry> 13097 </variablelist> 13098</refsect1> 13099<refsect1> 13100<title>Description</title> 13101<para> 13102 The address_space is to try to release any data against the page 13103 (presumably at page->private). If the release was successful, return `1'. 13104 Otherwise return zero. 13105 </para><para> 13106 13107 This may also be called if PG_fscache is set on a page, indicating that the 13108 page is known to the local caching routines. 13109 </para><para> 13110 13111 The <parameter>gfp_mask</parameter> argument specifies whether I/O may be performed to release 13112 this page (__GFP_IO), and whether the call may block (__GFP_WAIT & __GFP_FS). 13113</para> 13114</refsect1> 13115</refentry> 13116 13117<!-- mm/memory.c --> 13118<refentry id="API-zap-vma-ptes"> 13119<refentryinfo> 13120 <title>LINUX</title> 13121 <productname>Kernel Hackers Manual</productname> 13122 <date>July 2017</date> 13123</refentryinfo> 13124<refmeta> 13125 <refentrytitle><phrase>zap_vma_ptes</phrase></refentrytitle> 13126 <manvolnum>9</manvolnum> 13127 <refmiscinfo class="version">4.1.27</refmiscinfo> 13128</refmeta> 13129<refnamediv> 13130 <refname>zap_vma_ptes</refname> 13131 <refpurpose> 13132 remove ptes mapping the vma 13133 </refpurpose> 13134</refnamediv> 13135<refsynopsisdiv> 13136 <title>Synopsis</title> 13137 <funcsynopsis><funcprototype> 13138 <funcdef>int <function>zap_vma_ptes </function></funcdef> 13139 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 13140 <paramdef>unsigned long <parameter>address</parameter></paramdef> 13141 <paramdef>unsigned long <parameter>size</parameter></paramdef> 13142 </funcprototype></funcsynopsis> 13143</refsynopsisdiv> 13144<refsect1> 13145 <title>Arguments</title> 13146 <variablelist> 13147 <varlistentry> 13148 <term><parameter>vma</parameter></term> 13149 <listitem> 13150 <para> 13151 vm_area_struct holding ptes to be zapped 13152 </para> 13153 </listitem> 13154 </varlistentry> 13155 <varlistentry> 13156 <term><parameter>address</parameter></term> 13157 <listitem> 13158 <para> 13159 starting address of pages to zap 13160 </para> 13161 </listitem> 13162 </varlistentry> 13163 <varlistentry> 13164 <term><parameter>size</parameter></term> 13165 <listitem> 13166 <para> 13167 number of bytes to zap 13168 </para> 13169 </listitem> 13170 </varlistentry> 13171 </variablelist> 13172</refsect1> 13173<refsect1> 13174<title>Description</title> 13175<para> 13176 This function only unmaps ptes assigned to VM_PFNMAP vmas. 13177 </para><para> 13178 13179 The entire address range must be fully contained within the vma. 13180 </para><para> 13181 13182 Returns 0 if successful. 13183</para> 13184</refsect1> 13185</refentry> 13186 13187<refentry id="API-vm-insert-page"> 13188<refentryinfo> 13189 <title>LINUX</title> 13190 <productname>Kernel Hackers Manual</productname> 13191 <date>July 2017</date> 13192</refentryinfo> 13193<refmeta> 13194 <refentrytitle><phrase>vm_insert_page</phrase></refentrytitle> 13195 <manvolnum>9</manvolnum> 13196 <refmiscinfo class="version">4.1.27</refmiscinfo> 13197</refmeta> 13198<refnamediv> 13199 <refname>vm_insert_page</refname> 13200 <refpurpose> 13201 insert single page into user vma 13202 </refpurpose> 13203</refnamediv> 13204<refsynopsisdiv> 13205 <title>Synopsis</title> 13206 <funcsynopsis><funcprototype> 13207 <funcdef>int <function>vm_insert_page </function></funcdef> 13208 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 13209 <paramdef>unsigned long <parameter>addr</parameter></paramdef> 13210 <paramdef>struct page * <parameter>page</parameter></paramdef> 13211 </funcprototype></funcsynopsis> 13212</refsynopsisdiv> 13213<refsect1> 13214 <title>Arguments</title> 13215 <variablelist> 13216 <varlistentry> 13217 <term><parameter>vma</parameter></term> 13218 <listitem> 13219 <para> 13220 user vma to map to 13221 </para> 13222 </listitem> 13223 </varlistentry> 13224 <varlistentry> 13225 <term><parameter>addr</parameter></term> 13226 <listitem> 13227 <para> 13228 target user address of this page 13229 </para> 13230 </listitem> 13231 </varlistentry> 13232 <varlistentry> 13233 <term><parameter>page</parameter></term> 13234 <listitem> 13235 <para> 13236 source kernel page 13237 </para> 13238 </listitem> 13239 </varlistentry> 13240 </variablelist> 13241</refsect1> 13242<refsect1> 13243<title>Description</title> 13244<para> 13245 This allows drivers to insert individual pages they've allocated 13246 into a user vma. 13247 </para><para> 13248 13249 The page has to be a nice clean _individual_ kernel allocation. 13250 If you allocate a compound page, you need to have marked it as 13251 such (__GFP_COMP), or manually just split the page up yourself 13252 (see <function>split_page</function>). 13253 </para><para> 13254 13255 NOTE! Traditionally this was done with <quote><function>remap_pfn_range</function></quote> which 13256 took an arbitrary page protection parameter. This doesn't allow 13257 that. Your vma protection will have to be set up correctly, which 13258 means that if you want a shared writable mapping, you'd better 13259 ask for a shared writable mapping! 13260 </para><para> 13261 13262 The page does not need to be reserved. 13263 </para><para> 13264 13265 Usually this function is called from f_op-><function>mmap</function> handler 13266 under mm->mmap_sem write-lock, so it can change vma->vm_flags. 13267 Caller must set VM_MIXEDMAP on vma if it wants to call this 13268 function from other places, for example from page-fault handler. 13269</para> 13270</refsect1> 13271</refentry> 13272 13273<refentry id="API-vm-insert-pfn"> 13274<refentryinfo> 13275 <title>LINUX</title> 13276 <productname>Kernel Hackers Manual</productname> 13277 <date>July 2017</date> 13278</refentryinfo> 13279<refmeta> 13280 <refentrytitle><phrase>vm_insert_pfn</phrase></refentrytitle> 13281 <manvolnum>9</manvolnum> 13282 <refmiscinfo class="version">4.1.27</refmiscinfo> 13283</refmeta> 13284<refnamediv> 13285 <refname>vm_insert_pfn</refname> 13286 <refpurpose> 13287 insert single pfn into user vma 13288 </refpurpose> 13289</refnamediv> 13290<refsynopsisdiv> 13291 <title>Synopsis</title> 13292 <funcsynopsis><funcprototype> 13293 <funcdef>int <function>vm_insert_pfn </function></funcdef> 13294 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 13295 <paramdef>unsigned long <parameter>addr</parameter></paramdef> 13296 <paramdef>unsigned long <parameter>pfn</parameter></paramdef> 13297 </funcprototype></funcsynopsis> 13298</refsynopsisdiv> 13299<refsect1> 13300 <title>Arguments</title> 13301 <variablelist> 13302 <varlistentry> 13303 <term><parameter>vma</parameter></term> 13304 <listitem> 13305 <para> 13306 user vma to map to 13307 </para> 13308 </listitem> 13309 </varlistentry> 13310 <varlistentry> 13311 <term><parameter>addr</parameter></term> 13312 <listitem> 13313 <para> 13314 target user address of this page 13315 </para> 13316 </listitem> 13317 </varlistentry> 13318 <varlistentry> 13319 <term><parameter>pfn</parameter></term> 13320 <listitem> 13321 <para> 13322 source kernel pfn 13323 </para> 13324 </listitem> 13325 </varlistentry> 13326 </variablelist> 13327</refsect1> 13328<refsect1> 13329<title>Description</title> 13330<para> 13331 Similar to vm_insert_page, this allows drivers to insert individual pages 13332 they've allocated into a user vma. Same comments apply. 13333 </para><para> 13334 13335 This function should only be called from a vm_ops->fault handler, and 13336 in that case the handler should return NULL. 13337 </para><para> 13338 13339 vma cannot be a COW mapping. 13340 </para><para> 13341 13342 As this is called only for pages that do not currently exist, we 13343 do not need to flush old virtual caches or the TLB. 13344</para> 13345</refsect1> 13346</refentry> 13347 13348<refentry id="API-remap-pfn-range"> 13349<refentryinfo> 13350 <title>LINUX</title> 13351 <productname>Kernel Hackers Manual</productname> 13352 <date>July 2017</date> 13353</refentryinfo> 13354<refmeta> 13355 <refentrytitle><phrase>remap_pfn_range</phrase></refentrytitle> 13356 <manvolnum>9</manvolnum> 13357 <refmiscinfo class="version">4.1.27</refmiscinfo> 13358</refmeta> 13359<refnamediv> 13360 <refname>remap_pfn_range</refname> 13361 <refpurpose> 13362 remap kernel memory to userspace 13363 </refpurpose> 13364</refnamediv> 13365<refsynopsisdiv> 13366 <title>Synopsis</title> 13367 <funcsynopsis><funcprototype> 13368 <funcdef>int <function>remap_pfn_range </function></funcdef> 13369 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 13370 <paramdef>unsigned long <parameter>addr</parameter></paramdef> 13371 <paramdef>unsigned long <parameter>pfn</parameter></paramdef> 13372 <paramdef>unsigned long <parameter>size</parameter></paramdef> 13373 <paramdef>pgprot_t <parameter>prot</parameter></paramdef> 13374 </funcprototype></funcsynopsis> 13375</refsynopsisdiv> 13376<refsect1> 13377 <title>Arguments</title> 13378 <variablelist> 13379 <varlistentry> 13380 <term><parameter>vma</parameter></term> 13381 <listitem> 13382 <para> 13383 user vma to map to 13384 </para> 13385 </listitem> 13386 </varlistentry> 13387 <varlistentry> 13388 <term><parameter>addr</parameter></term> 13389 <listitem> 13390 <para> 13391 target user address to start at 13392 </para> 13393 </listitem> 13394 </varlistentry> 13395 <varlistentry> 13396 <term><parameter>pfn</parameter></term> 13397 <listitem> 13398 <para> 13399 physical address of kernel memory 13400 </para> 13401 </listitem> 13402 </varlistentry> 13403 <varlistentry> 13404 <term><parameter>size</parameter></term> 13405 <listitem> 13406 <para> 13407 size of map area 13408 </para> 13409 </listitem> 13410 </varlistentry> 13411 <varlistentry> 13412 <term><parameter>prot</parameter></term> 13413 <listitem> 13414 <para> 13415 page protection flags for this mapping 13416 </para> 13417 </listitem> 13418 </varlistentry> 13419 </variablelist> 13420</refsect1> 13421<refsect1> 13422<title>Note</title> 13423<para> 13424 this is only safe if the mm semaphore is held when called. 13425</para> 13426</refsect1> 13427</refentry> 13428 13429<refentry id="API-vm-iomap-memory"> 13430<refentryinfo> 13431 <title>LINUX</title> 13432 <productname>Kernel Hackers Manual</productname> 13433 <date>July 2017</date> 13434</refentryinfo> 13435<refmeta> 13436 <refentrytitle><phrase>vm_iomap_memory</phrase></refentrytitle> 13437 <manvolnum>9</manvolnum> 13438 <refmiscinfo class="version">4.1.27</refmiscinfo> 13439</refmeta> 13440<refnamediv> 13441 <refname>vm_iomap_memory</refname> 13442 <refpurpose> 13443 remap memory to userspace 13444 </refpurpose> 13445</refnamediv> 13446<refsynopsisdiv> 13447 <title>Synopsis</title> 13448 <funcsynopsis><funcprototype> 13449 <funcdef>int <function>vm_iomap_memory </function></funcdef> 13450 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 13451 <paramdef>phys_addr_t <parameter>start</parameter></paramdef> 13452 <paramdef>unsigned long <parameter>len</parameter></paramdef> 13453 </funcprototype></funcsynopsis> 13454</refsynopsisdiv> 13455<refsect1> 13456 <title>Arguments</title> 13457 <variablelist> 13458 <varlistentry> 13459 <term><parameter>vma</parameter></term> 13460 <listitem> 13461 <para> 13462 user vma to map to 13463 </para> 13464 </listitem> 13465 </varlistentry> 13466 <varlistentry> 13467 <term><parameter>start</parameter></term> 13468 <listitem> 13469 <para> 13470 start of area 13471 </para> 13472 </listitem> 13473 </varlistentry> 13474 <varlistentry> 13475 <term><parameter>len</parameter></term> 13476 <listitem> 13477 <para> 13478 size of area 13479 </para> 13480 </listitem> 13481 </varlistentry> 13482 </variablelist> 13483</refsect1> 13484<refsect1> 13485<title>Description</title> 13486<para> 13487 This is a simplified <function>io_remap_pfn_range</function> for common driver use. The 13488 driver just needs to give us the physical memory range to be mapped, 13489 we'll figure out the rest from the vma information. 13490 </para><para> 13491 13492 NOTE! Some drivers might want to tweak vma->vm_page_prot first to get 13493 whatever write-combining details or similar. 13494</para> 13495</refsect1> 13496</refentry> 13497 13498<refentry id="API-unmap-mapping-range"> 13499<refentryinfo> 13500 <title>LINUX</title> 13501 <productname>Kernel Hackers Manual</productname> 13502 <date>July 2017</date> 13503</refentryinfo> 13504<refmeta> 13505 <refentrytitle><phrase>unmap_mapping_range</phrase></refentrytitle> 13506 <manvolnum>9</manvolnum> 13507 <refmiscinfo class="version">4.1.27</refmiscinfo> 13508</refmeta> 13509<refnamediv> 13510 <refname>unmap_mapping_range</refname> 13511 <refpurpose> 13512 unmap the portion of all mmaps in the specified address_space corresponding to the specified page range in the underlying file. 13513 </refpurpose> 13514</refnamediv> 13515<refsynopsisdiv> 13516 <title>Synopsis</title> 13517 <funcsynopsis><funcprototype> 13518 <funcdef>void <function>unmap_mapping_range </function></funcdef> 13519 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 13520 <paramdef>loff_t const <parameter>holebegin</parameter></paramdef> 13521 <paramdef>loff_t const <parameter>holelen</parameter></paramdef> 13522 <paramdef>int <parameter>even_cows</parameter></paramdef> 13523 </funcprototype></funcsynopsis> 13524</refsynopsisdiv> 13525<refsect1> 13526 <title>Arguments</title> 13527 <variablelist> 13528 <varlistentry> 13529 <term><parameter>mapping</parameter></term> 13530 <listitem> 13531 <para> 13532 the address space containing mmaps to be unmapped. 13533 </para> 13534 </listitem> 13535 </varlistentry> 13536 <varlistentry> 13537 <term><parameter>holebegin</parameter></term> 13538 <listitem> 13539 <para> 13540 byte in first page to unmap, relative to the start of 13541 the underlying file. This will be rounded down to a PAGE_SIZE 13542 boundary. Note that this is different from <function>truncate_pagecache</function>, which 13543 must keep the partial page. In contrast, we must get rid of 13544 partial pages. 13545 </para> 13546 </listitem> 13547 </varlistentry> 13548 <varlistentry> 13549 <term><parameter>holelen</parameter></term> 13550 <listitem> 13551 <para> 13552 size of prospective hole in bytes. This will be rounded 13553 up to a PAGE_SIZE boundary. A holelen of zero truncates to the 13554 end of the file. 13555 </para> 13556 </listitem> 13557 </varlistentry> 13558 <varlistentry> 13559 <term><parameter>even_cows</parameter></term> 13560 <listitem> 13561 <para> 13562 1 when truncating a file, unmap even private COWed pages; 13563 but 0 when invalidating pagecache, don't throw away private data. 13564 </para> 13565 </listitem> 13566 </varlistentry> 13567 </variablelist> 13568</refsect1> 13569</refentry> 13570 13571<refentry id="API-follow-pfn"> 13572<refentryinfo> 13573 <title>LINUX</title> 13574 <productname>Kernel Hackers Manual</productname> 13575 <date>July 2017</date> 13576</refentryinfo> 13577<refmeta> 13578 <refentrytitle><phrase>follow_pfn</phrase></refentrytitle> 13579 <manvolnum>9</manvolnum> 13580 <refmiscinfo class="version">4.1.27</refmiscinfo> 13581</refmeta> 13582<refnamediv> 13583 <refname>follow_pfn</refname> 13584 <refpurpose> 13585 look up PFN at a user virtual address 13586 </refpurpose> 13587</refnamediv> 13588<refsynopsisdiv> 13589 <title>Synopsis</title> 13590 <funcsynopsis><funcprototype> 13591 <funcdef>int <function>follow_pfn </function></funcdef> 13592 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 13593 <paramdef>unsigned long <parameter>address</parameter></paramdef> 13594 <paramdef>unsigned long * <parameter>pfn</parameter></paramdef> 13595 </funcprototype></funcsynopsis> 13596</refsynopsisdiv> 13597<refsect1> 13598 <title>Arguments</title> 13599 <variablelist> 13600 <varlistentry> 13601 <term><parameter>vma</parameter></term> 13602 <listitem> 13603 <para> 13604 memory mapping 13605 </para> 13606 </listitem> 13607 </varlistentry> 13608 <varlistentry> 13609 <term><parameter>address</parameter></term> 13610 <listitem> 13611 <para> 13612 user virtual address 13613 </para> 13614 </listitem> 13615 </varlistentry> 13616 <varlistentry> 13617 <term><parameter>pfn</parameter></term> 13618 <listitem> 13619 <para> 13620 location to store found PFN 13621 </para> 13622 </listitem> 13623 </varlistentry> 13624 </variablelist> 13625</refsect1> 13626<refsect1> 13627<title>Description</title> 13628<para> 13629 Only IO mappings and raw PFN mappings are allowed. 13630 </para><para> 13631 13632 Returns zero and the pfn at <parameter>pfn</parameter> on success, -ve otherwise. 13633</para> 13634</refsect1> 13635</refentry> 13636 13637<!-- mm/vmalloc.c --> 13638<refentry id="API-vm-unmap-aliases"> 13639<refentryinfo> 13640 <title>LINUX</title> 13641 <productname>Kernel Hackers Manual</productname> 13642 <date>July 2017</date> 13643</refentryinfo> 13644<refmeta> 13645 <refentrytitle><phrase>vm_unmap_aliases</phrase></refentrytitle> 13646 <manvolnum>9</manvolnum> 13647 <refmiscinfo class="version">4.1.27</refmiscinfo> 13648</refmeta> 13649<refnamediv> 13650 <refname>vm_unmap_aliases</refname> 13651 <refpurpose> 13652 unmap outstanding lazy aliases in the vmap layer 13653 </refpurpose> 13654</refnamediv> 13655<refsynopsisdiv> 13656 <title>Synopsis</title> 13657 <funcsynopsis><funcprototype> 13658 <funcdef>void <function>vm_unmap_aliases </function></funcdef> 13659 <paramdef> <parameter>void</parameter></paramdef> 13660 </funcprototype></funcsynopsis> 13661</refsynopsisdiv> 13662<refsect1> 13663 <title>Arguments</title> 13664 <variablelist> 13665 <varlistentry> 13666 <term><parameter>void</parameter></term> 13667 <listitem> 13668 <para> 13669 no arguments 13670 </para> 13671 </listitem> 13672 </varlistentry> 13673 </variablelist> 13674</refsect1> 13675<refsect1> 13676<title>Description</title> 13677<para> 13678 </para><para> 13679 13680 The vmap/vmalloc layer lazily flushes kernel virtual mappings primarily 13681 to amortize TLB flushing overheads. What this means is that any page you 13682 have now, may, in a former life, have been mapped into kernel virtual 13683 address by the vmap layer and so there might be some CPUs with TLB entries 13684 still referencing that page (additional to the regular 1:1 kernel mapping). 13685 </para><para> 13686 13687 vm_unmap_aliases flushes all such lazy mappings. After it returns, we can 13688 be sure that none of the pages we have control over will have any aliases 13689 from the vmap layer. 13690</para> 13691</refsect1> 13692</refentry> 13693 13694<refentry id="API-vm-unmap-ram"> 13695<refentryinfo> 13696 <title>LINUX</title> 13697 <productname>Kernel Hackers Manual</productname> 13698 <date>July 2017</date> 13699</refentryinfo> 13700<refmeta> 13701 <refentrytitle><phrase>vm_unmap_ram</phrase></refentrytitle> 13702 <manvolnum>9</manvolnum> 13703 <refmiscinfo class="version">4.1.27</refmiscinfo> 13704</refmeta> 13705<refnamediv> 13706 <refname>vm_unmap_ram</refname> 13707 <refpurpose> 13708 unmap linear kernel address space set up by vm_map_ram 13709 </refpurpose> 13710</refnamediv> 13711<refsynopsisdiv> 13712 <title>Synopsis</title> 13713 <funcsynopsis><funcprototype> 13714 <funcdef>void <function>vm_unmap_ram </function></funcdef> 13715 <paramdef>const void * <parameter>mem</parameter></paramdef> 13716 <paramdef>unsigned int <parameter>count</parameter></paramdef> 13717 </funcprototype></funcsynopsis> 13718</refsynopsisdiv> 13719<refsect1> 13720 <title>Arguments</title> 13721 <variablelist> 13722 <varlistentry> 13723 <term><parameter>mem</parameter></term> 13724 <listitem> 13725 <para> 13726 the pointer returned by vm_map_ram 13727 </para> 13728 </listitem> 13729 </varlistentry> 13730 <varlistentry> 13731 <term><parameter>count</parameter></term> 13732 <listitem> 13733 <para> 13734 the count passed to that vm_map_ram call (cannot unmap partial) 13735 </para> 13736 </listitem> 13737 </varlistentry> 13738 </variablelist> 13739</refsect1> 13740</refentry> 13741 13742<refentry id="API-vm-map-ram"> 13743<refentryinfo> 13744 <title>LINUX</title> 13745 <productname>Kernel Hackers Manual</productname> 13746 <date>July 2017</date> 13747</refentryinfo> 13748<refmeta> 13749 <refentrytitle><phrase>vm_map_ram</phrase></refentrytitle> 13750 <manvolnum>9</manvolnum> 13751 <refmiscinfo class="version">4.1.27</refmiscinfo> 13752</refmeta> 13753<refnamediv> 13754 <refname>vm_map_ram</refname> 13755 <refpurpose> 13756 map pages linearly into kernel virtual address (vmalloc space) 13757 </refpurpose> 13758</refnamediv> 13759<refsynopsisdiv> 13760 <title>Synopsis</title> 13761 <funcsynopsis><funcprototype> 13762 <funcdef>void * <function>vm_map_ram </function></funcdef> 13763 <paramdef>struct page ** <parameter>pages</parameter></paramdef> 13764 <paramdef>unsigned int <parameter>count</parameter></paramdef> 13765 <paramdef>int <parameter>node</parameter></paramdef> 13766 <paramdef>pgprot_t <parameter>prot</parameter></paramdef> 13767 </funcprototype></funcsynopsis> 13768</refsynopsisdiv> 13769<refsect1> 13770 <title>Arguments</title> 13771 <variablelist> 13772 <varlistentry> 13773 <term><parameter>pages</parameter></term> 13774 <listitem> 13775 <para> 13776 an array of pointers to the pages to be mapped 13777 </para> 13778 </listitem> 13779 </varlistentry> 13780 <varlistentry> 13781 <term><parameter>count</parameter></term> 13782 <listitem> 13783 <para> 13784 number of pages 13785 </para> 13786 </listitem> 13787 </varlistentry> 13788 <varlistentry> 13789 <term><parameter>node</parameter></term> 13790 <listitem> 13791 <para> 13792 prefer to allocate data structures on this node 13793 </para> 13794 </listitem> 13795 </varlistentry> 13796 <varlistentry> 13797 <term><parameter>prot</parameter></term> 13798 <listitem> 13799 <para> 13800 memory protection to use. PAGE_KERNEL for regular RAM 13801 </para> 13802 </listitem> 13803 </varlistentry> 13804 </variablelist> 13805</refsect1> 13806<refsect1> 13807<title>Description</title> 13808<para> 13809 If you use this function for less than VMAP_MAX_ALLOC pages, it could be 13810 faster than vmap so it's good. But if you mix long-life and short-life 13811 objects with <function>vm_map_ram</function>, it could consume lots of address space through 13812 fragmentation (especially on a 32bit machine). You could see failures in 13813 the end. Please use this function for short-lived objects. 13814</para> 13815</refsect1> 13816<refsect1> 13817<title>Returns</title> 13818<para> 13819 a pointer to the address that has been mapped, or <constant>NULL</constant> on failure 13820</para> 13821</refsect1> 13822</refentry> 13823 13824<refentry id="API-unmap-kernel-range-noflush"> 13825<refentryinfo> 13826 <title>LINUX</title> 13827 <productname>Kernel Hackers Manual</productname> 13828 <date>July 2017</date> 13829</refentryinfo> 13830<refmeta> 13831 <refentrytitle><phrase>unmap_kernel_range_noflush</phrase></refentrytitle> 13832 <manvolnum>9</manvolnum> 13833 <refmiscinfo class="version">4.1.27</refmiscinfo> 13834</refmeta> 13835<refnamediv> 13836 <refname>unmap_kernel_range_noflush</refname> 13837 <refpurpose> 13838 unmap kernel VM area 13839 </refpurpose> 13840</refnamediv> 13841<refsynopsisdiv> 13842 <title>Synopsis</title> 13843 <funcsynopsis><funcprototype> 13844 <funcdef>void <function>unmap_kernel_range_noflush </function></funcdef> 13845 <paramdef>unsigned long <parameter>addr</parameter></paramdef> 13846 <paramdef>unsigned long <parameter>size</parameter></paramdef> 13847 </funcprototype></funcsynopsis> 13848</refsynopsisdiv> 13849<refsect1> 13850 <title>Arguments</title> 13851 <variablelist> 13852 <varlistentry> 13853 <term><parameter>addr</parameter></term> 13854 <listitem> 13855 <para> 13856 start of the VM area to unmap 13857 </para> 13858 </listitem> 13859 </varlistentry> 13860 <varlistentry> 13861 <term><parameter>size</parameter></term> 13862 <listitem> 13863 <para> 13864 size of the VM area to unmap 13865 </para> 13866 </listitem> 13867 </varlistentry> 13868 </variablelist> 13869</refsect1> 13870<refsect1> 13871<title>Description</title> 13872<para> 13873 Unmap PFN_UP(<parameter>size</parameter>) pages at <parameter>addr</parameter>. The VM area <parameter>addr</parameter> and <parameter>size</parameter> 13874 specify should have been allocated using <function>get_vm_area</function> and its 13875 friends. 13876</para> 13877</refsect1> 13878<refsect1> 13879<title>NOTE</title> 13880<para> 13881 This function does NOT do any cache flushing. The caller is 13882 responsible for calling <function>flush_cache_vunmap</function> on to-be-mapped areas 13883 before calling this function and <function>flush_tlb_kernel_range</function> after. 13884</para> 13885</refsect1> 13886</refentry> 13887 13888<refentry id="API-unmap-kernel-range"> 13889<refentryinfo> 13890 <title>LINUX</title> 13891 <productname>Kernel Hackers Manual</productname> 13892 <date>July 2017</date> 13893</refentryinfo> 13894<refmeta> 13895 <refentrytitle><phrase>unmap_kernel_range</phrase></refentrytitle> 13896 <manvolnum>9</manvolnum> 13897 <refmiscinfo class="version">4.1.27</refmiscinfo> 13898</refmeta> 13899<refnamediv> 13900 <refname>unmap_kernel_range</refname> 13901 <refpurpose> 13902 unmap kernel VM area and flush cache and TLB 13903 </refpurpose> 13904</refnamediv> 13905<refsynopsisdiv> 13906 <title>Synopsis</title> 13907 <funcsynopsis><funcprototype> 13908 <funcdef>void <function>unmap_kernel_range </function></funcdef> 13909 <paramdef>unsigned long <parameter>addr</parameter></paramdef> 13910 <paramdef>unsigned long <parameter>size</parameter></paramdef> 13911 </funcprototype></funcsynopsis> 13912</refsynopsisdiv> 13913<refsect1> 13914 <title>Arguments</title> 13915 <variablelist> 13916 <varlistentry> 13917 <term><parameter>addr</parameter></term> 13918 <listitem> 13919 <para> 13920 start of the VM area to unmap 13921 </para> 13922 </listitem> 13923 </varlistentry> 13924 <varlistentry> 13925 <term><parameter>size</parameter></term> 13926 <listitem> 13927 <para> 13928 size of the VM area to unmap 13929 </para> 13930 </listitem> 13931 </varlistentry> 13932 </variablelist> 13933</refsect1> 13934<refsect1> 13935<title>Description</title> 13936<para> 13937 Similar to <function>unmap_kernel_range_noflush</function> but flushes vcache before 13938 the unmapping and tlb after. 13939</para> 13940</refsect1> 13941</refentry> 13942 13943<refentry id="API-vfree"> 13944<refentryinfo> 13945 <title>LINUX</title> 13946 <productname>Kernel Hackers Manual</productname> 13947 <date>July 2017</date> 13948</refentryinfo> 13949<refmeta> 13950 <refentrytitle><phrase>vfree</phrase></refentrytitle> 13951 <manvolnum>9</manvolnum> 13952 <refmiscinfo class="version">4.1.27</refmiscinfo> 13953</refmeta> 13954<refnamediv> 13955 <refname>vfree</refname> 13956 <refpurpose> 13957 release memory allocated by <function>vmalloc</function> 13958 </refpurpose> 13959</refnamediv> 13960<refsynopsisdiv> 13961 <title>Synopsis</title> 13962 <funcsynopsis><funcprototype> 13963 <funcdef>void <function>vfree </function></funcdef> 13964 <paramdef>const void * <parameter>addr</parameter></paramdef> 13965 </funcprototype></funcsynopsis> 13966</refsynopsisdiv> 13967<refsect1> 13968 <title>Arguments</title> 13969 <variablelist> 13970 <varlistentry> 13971 <term><parameter>addr</parameter></term> 13972 <listitem> 13973 <para> 13974 memory base address 13975 </para> 13976 </listitem> 13977 </varlistentry> 13978 </variablelist> 13979</refsect1> 13980<refsect1> 13981<title>Description</title> 13982<para> 13983 Free the virtually continuous memory area starting at <parameter>addr</parameter>, as 13984 obtained from <function>vmalloc</function>, <function>vmalloc_32</function> or <function>__vmalloc</function>. If <parameter>addr</parameter> is 13985 NULL, no operation is performed. 13986 </para><para> 13987 13988 Must not be called in NMI context (strictly speaking, only if we don't 13989 have CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG, but making the calling 13990 conventions for <function>vfree</function> arch-depenedent would be a really bad idea) 13991</para> 13992</refsect1> 13993<refsect1> 13994<title>NOTE</title> 13995<para> 13996 assumes that the object at *addr has a size >= sizeof(llist_node) 13997</para> 13998</refsect1> 13999</refentry> 14000 14001<refentry id="API-vunmap"> 14002<refentryinfo> 14003 <title>LINUX</title> 14004 <productname>Kernel Hackers Manual</productname> 14005 <date>July 2017</date> 14006</refentryinfo> 14007<refmeta> 14008 <refentrytitle><phrase>vunmap</phrase></refentrytitle> 14009 <manvolnum>9</manvolnum> 14010 <refmiscinfo class="version">4.1.27</refmiscinfo> 14011</refmeta> 14012<refnamediv> 14013 <refname>vunmap</refname> 14014 <refpurpose> 14015 release virtual mapping obtained by <function>vmap</function> 14016 </refpurpose> 14017</refnamediv> 14018<refsynopsisdiv> 14019 <title>Synopsis</title> 14020 <funcsynopsis><funcprototype> 14021 <funcdef>void <function>vunmap </function></funcdef> 14022 <paramdef>const void * <parameter>addr</parameter></paramdef> 14023 </funcprototype></funcsynopsis> 14024</refsynopsisdiv> 14025<refsect1> 14026 <title>Arguments</title> 14027 <variablelist> 14028 <varlistentry> 14029 <term><parameter>addr</parameter></term> 14030 <listitem> 14031 <para> 14032 memory base address 14033 </para> 14034 </listitem> 14035 </varlistentry> 14036 </variablelist> 14037</refsect1> 14038<refsect1> 14039<title>Description</title> 14040<para> 14041 Free the virtually contiguous memory area starting at <parameter>addr</parameter>, 14042 which was created from the page array passed to <function>vmap</function>. 14043 </para><para> 14044 14045 Must not be called in interrupt context. 14046</para> 14047</refsect1> 14048</refentry> 14049 14050<refentry id="API-vmap"> 14051<refentryinfo> 14052 <title>LINUX</title> 14053 <productname>Kernel Hackers Manual</productname> 14054 <date>July 2017</date> 14055</refentryinfo> 14056<refmeta> 14057 <refentrytitle><phrase>vmap</phrase></refentrytitle> 14058 <manvolnum>9</manvolnum> 14059 <refmiscinfo class="version">4.1.27</refmiscinfo> 14060</refmeta> 14061<refnamediv> 14062 <refname>vmap</refname> 14063 <refpurpose> 14064 map an array of pages into virtually contiguous space 14065 </refpurpose> 14066</refnamediv> 14067<refsynopsisdiv> 14068 <title>Synopsis</title> 14069 <funcsynopsis><funcprototype> 14070 <funcdef>void * <function>vmap </function></funcdef> 14071 <paramdef>struct page ** <parameter>pages</parameter></paramdef> 14072 <paramdef>unsigned int <parameter>count</parameter></paramdef> 14073 <paramdef>unsigned long <parameter>flags</parameter></paramdef> 14074 <paramdef>pgprot_t <parameter>prot</parameter></paramdef> 14075 </funcprototype></funcsynopsis> 14076</refsynopsisdiv> 14077<refsect1> 14078 <title>Arguments</title> 14079 <variablelist> 14080 <varlistentry> 14081 <term><parameter>pages</parameter></term> 14082 <listitem> 14083 <para> 14084 array of page pointers 14085 </para> 14086 </listitem> 14087 </varlistentry> 14088 <varlistentry> 14089 <term><parameter>count</parameter></term> 14090 <listitem> 14091 <para> 14092 number of pages to map 14093 </para> 14094 </listitem> 14095 </varlistentry> 14096 <varlistentry> 14097 <term><parameter>flags</parameter></term> 14098 <listitem> 14099 <para> 14100 vm_area->flags 14101 </para> 14102 </listitem> 14103 </varlistentry> 14104 <varlistentry> 14105 <term><parameter>prot</parameter></term> 14106 <listitem> 14107 <para> 14108 page protection for the mapping 14109 </para> 14110 </listitem> 14111 </varlistentry> 14112 </variablelist> 14113</refsect1> 14114<refsect1> 14115<title>Description</title> 14116<para> 14117 Maps <parameter>count</parameter> pages from <parameter>pages</parameter> into contiguous kernel virtual 14118 space. 14119</para> 14120</refsect1> 14121</refentry> 14122 14123<refentry id="API-vmalloc"> 14124<refentryinfo> 14125 <title>LINUX</title> 14126 <productname>Kernel Hackers Manual</productname> 14127 <date>July 2017</date> 14128</refentryinfo> 14129<refmeta> 14130 <refentrytitle><phrase>vmalloc</phrase></refentrytitle> 14131 <manvolnum>9</manvolnum> 14132 <refmiscinfo class="version">4.1.27</refmiscinfo> 14133</refmeta> 14134<refnamediv> 14135 <refname>vmalloc</refname> 14136 <refpurpose> 14137 allocate virtually contiguous memory 14138 </refpurpose> 14139</refnamediv> 14140<refsynopsisdiv> 14141 <title>Synopsis</title> 14142 <funcsynopsis><funcprototype> 14143 <funcdef>void * <function>vmalloc </function></funcdef> 14144 <paramdef>unsigned long <parameter>size</parameter></paramdef> 14145 </funcprototype></funcsynopsis> 14146</refsynopsisdiv> 14147<refsect1> 14148 <title>Arguments</title> 14149 <variablelist> 14150 <varlistentry> 14151 <term><parameter>size</parameter></term> 14152 <listitem> 14153 <para> 14154 allocation size 14155 Allocate enough pages to cover <parameter>size</parameter> from the page level 14156 allocator and map them into contiguous kernel virtual space. 14157 </para> 14158 </listitem> 14159 </varlistentry> 14160 </variablelist> 14161</refsect1> 14162<refsect1> 14163<title>Description</title> 14164<para> 14165 For tight control over page level allocator and protection flags 14166 use <function>__vmalloc</function> instead. 14167</para> 14168</refsect1> 14169</refentry> 14170 14171<refentry id="API-vzalloc"> 14172<refentryinfo> 14173 <title>LINUX</title> 14174 <productname>Kernel Hackers Manual</productname> 14175 <date>July 2017</date> 14176</refentryinfo> 14177<refmeta> 14178 <refentrytitle><phrase>vzalloc</phrase></refentrytitle> 14179 <manvolnum>9</manvolnum> 14180 <refmiscinfo class="version">4.1.27</refmiscinfo> 14181</refmeta> 14182<refnamediv> 14183 <refname>vzalloc</refname> 14184 <refpurpose> 14185 allocate virtually contiguous memory with zero fill 14186 </refpurpose> 14187</refnamediv> 14188<refsynopsisdiv> 14189 <title>Synopsis</title> 14190 <funcsynopsis><funcprototype> 14191 <funcdef>void * <function>vzalloc </function></funcdef> 14192 <paramdef>unsigned long <parameter>size</parameter></paramdef> 14193 </funcprototype></funcsynopsis> 14194</refsynopsisdiv> 14195<refsect1> 14196 <title>Arguments</title> 14197 <variablelist> 14198 <varlistentry> 14199 <term><parameter>size</parameter></term> 14200 <listitem> 14201 <para> 14202 allocation size 14203 Allocate enough pages to cover <parameter>size</parameter> from the page level 14204 allocator and map them into contiguous kernel virtual space. 14205 The memory allocated is set to zero. 14206 </para> 14207 </listitem> 14208 </varlistentry> 14209 </variablelist> 14210</refsect1> 14211<refsect1> 14212<title>Description</title> 14213<para> 14214 For tight control over page level allocator and protection flags 14215 use <function>__vmalloc</function> instead. 14216</para> 14217</refsect1> 14218</refentry> 14219 14220<refentry id="API-vmalloc-user"> 14221<refentryinfo> 14222 <title>LINUX</title> 14223 <productname>Kernel Hackers Manual</productname> 14224 <date>July 2017</date> 14225</refentryinfo> 14226<refmeta> 14227 <refentrytitle><phrase>vmalloc_user</phrase></refentrytitle> 14228 <manvolnum>9</manvolnum> 14229 <refmiscinfo class="version">4.1.27</refmiscinfo> 14230</refmeta> 14231<refnamediv> 14232 <refname>vmalloc_user</refname> 14233 <refpurpose> 14234 allocate zeroed virtually contiguous memory for userspace 14235 </refpurpose> 14236</refnamediv> 14237<refsynopsisdiv> 14238 <title>Synopsis</title> 14239 <funcsynopsis><funcprototype> 14240 <funcdef>void * <function>vmalloc_user </function></funcdef> 14241 <paramdef>unsigned long <parameter>size</parameter></paramdef> 14242 </funcprototype></funcsynopsis> 14243</refsynopsisdiv> 14244<refsect1> 14245 <title>Arguments</title> 14246 <variablelist> 14247 <varlistentry> 14248 <term><parameter>size</parameter></term> 14249 <listitem> 14250 <para> 14251 allocation size 14252 </para> 14253 </listitem> 14254 </varlistentry> 14255 </variablelist> 14256</refsect1> 14257<refsect1> 14258<title>Description</title> 14259<para> 14260 The resulting memory area is zeroed so it can be mapped to userspace 14261 without leaking data. 14262</para> 14263</refsect1> 14264</refentry> 14265 14266<refentry id="API-vmalloc-node"> 14267<refentryinfo> 14268 <title>LINUX</title> 14269 <productname>Kernel Hackers Manual</productname> 14270 <date>July 2017</date> 14271</refentryinfo> 14272<refmeta> 14273 <refentrytitle><phrase>vmalloc_node</phrase></refentrytitle> 14274 <manvolnum>9</manvolnum> 14275 <refmiscinfo class="version">4.1.27</refmiscinfo> 14276</refmeta> 14277<refnamediv> 14278 <refname>vmalloc_node</refname> 14279 <refpurpose> 14280 allocate memory on a specific node 14281 </refpurpose> 14282</refnamediv> 14283<refsynopsisdiv> 14284 <title>Synopsis</title> 14285 <funcsynopsis><funcprototype> 14286 <funcdef>void * <function>vmalloc_node </function></funcdef> 14287 <paramdef>unsigned long <parameter>size</parameter></paramdef> 14288 <paramdef>int <parameter>node</parameter></paramdef> 14289 </funcprototype></funcsynopsis> 14290</refsynopsisdiv> 14291<refsect1> 14292 <title>Arguments</title> 14293 <variablelist> 14294 <varlistentry> 14295 <term><parameter>size</parameter></term> 14296 <listitem> 14297 <para> 14298 allocation size 14299 </para> 14300 </listitem> 14301 </varlistentry> 14302 <varlistentry> 14303 <term><parameter>node</parameter></term> 14304 <listitem> 14305 <para> 14306 numa node 14307 </para> 14308 </listitem> 14309 </varlistentry> 14310 </variablelist> 14311</refsect1> 14312<refsect1> 14313<title>Description</title> 14314<para> 14315 Allocate enough pages to cover <parameter>size</parameter> from the page level 14316 allocator and map them into contiguous kernel virtual space. 14317 </para><para> 14318 14319 For tight control over page level allocator and protection flags 14320 use <function>__vmalloc</function> instead. 14321</para> 14322</refsect1> 14323</refentry> 14324 14325<refentry id="API-vzalloc-node"> 14326<refentryinfo> 14327 <title>LINUX</title> 14328 <productname>Kernel Hackers Manual</productname> 14329 <date>July 2017</date> 14330</refentryinfo> 14331<refmeta> 14332 <refentrytitle><phrase>vzalloc_node</phrase></refentrytitle> 14333 <manvolnum>9</manvolnum> 14334 <refmiscinfo class="version">4.1.27</refmiscinfo> 14335</refmeta> 14336<refnamediv> 14337 <refname>vzalloc_node</refname> 14338 <refpurpose> 14339 allocate memory on a specific node with zero fill 14340 </refpurpose> 14341</refnamediv> 14342<refsynopsisdiv> 14343 <title>Synopsis</title> 14344 <funcsynopsis><funcprototype> 14345 <funcdef>void * <function>vzalloc_node </function></funcdef> 14346 <paramdef>unsigned long <parameter>size</parameter></paramdef> 14347 <paramdef>int <parameter>node</parameter></paramdef> 14348 </funcprototype></funcsynopsis> 14349</refsynopsisdiv> 14350<refsect1> 14351 <title>Arguments</title> 14352 <variablelist> 14353 <varlistentry> 14354 <term><parameter>size</parameter></term> 14355 <listitem> 14356 <para> 14357 allocation size 14358 </para> 14359 </listitem> 14360 </varlistentry> 14361 <varlistentry> 14362 <term><parameter>node</parameter></term> 14363 <listitem> 14364 <para> 14365 numa node 14366 </para> 14367 </listitem> 14368 </varlistentry> 14369 </variablelist> 14370</refsect1> 14371<refsect1> 14372<title>Description</title> 14373<para> 14374 Allocate enough pages to cover <parameter>size</parameter> from the page level 14375 allocator and map them into contiguous kernel virtual space. 14376 The memory allocated is set to zero. 14377 </para><para> 14378 14379 For tight control over page level allocator and protection flags 14380 use <function>__vmalloc_node</function> instead. 14381</para> 14382</refsect1> 14383</refentry> 14384 14385<refentry id="API-vmalloc-32"> 14386<refentryinfo> 14387 <title>LINUX</title> 14388 <productname>Kernel Hackers Manual</productname> 14389 <date>July 2017</date> 14390</refentryinfo> 14391<refmeta> 14392 <refentrytitle><phrase>vmalloc_32</phrase></refentrytitle> 14393 <manvolnum>9</manvolnum> 14394 <refmiscinfo class="version">4.1.27</refmiscinfo> 14395</refmeta> 14396<refnamediv> 14397 <refname>vmalloc_32</refname> 14398 <refpurpose> 14399 allocate virtually contiguous memory (32bit addressable) 14400 </refpurpose> 14401</refnamediv> 14402<refsynopsisdiv> 14403 <title>Synopsis</title> 14404 <funcsynopsis><funcprototype> 14405 <funcdef>void * <function>vmalloc_32 </function></funcdef> 14406 <paramdef>unsigned long <parameter>size</parameter></paramdef> 14407 </funcprototype></funcsynopsis> 14408</refsynopsisdiv> 14409<refsect1> 14410 <title>Arguments</title> 14411 <variablelist> 14412 <varlistentry> 14413 <term><parameter>size</parameter></term> 14414 <listitem> 14415 <para> 14416 allocation size 14417 </para> 14418 </listitem> 14419 </varlistentry> 14420 </variablelist> 14421</refsect1> 14422<refsect1> 14423<title>Description</title> 14424<para> 14425 Allocate enough 32bit PA addressable pages to cover <parameter>size</parameter> from the 14426 page level allocator and map them into contiguous kernel virtual space. 14427</para> 14428</refsect1> 14429</refentry> 14430 14431<refentry id="API-vmalloc-32-user"> 14432<refentryinfo> 14433 <title>LINUX</title> 14434 <productname>Kernel Hackers Manual</productname> 14435 <date>July 2017</date> 14436</refentryinfo> 14437<refmeta> 14438 <refentrytitle><phrase>vmalloc_32_user</phrase></refentrytitle> 14439 <manvolnum>9</manvolnum> 14440 <refmiscinfo class="version">4.1.27</refmiscinfo> 14441</refmeta> 14442<refnamediv> 14443 <refname>vmalloc_32_user</refname> 14444 <refpurpose> 14445 allocate zeroed virtually contiguous 32bit memory 14446 </refpurpose> 14447</refnamediv> 14448<refsynopsisdiv> 14449 <title>Synopsis</title> 14450 <funcsynopsis><funcprototype> 14451 <funcdef>void * <function>vmalloc_32_user </function></funcdef> 14452 <paramdef>unsigned long <parameter>size</parameter></paramdef> 14453 </funcprototype></funcsynopsis> 14454</refsynopsisdiv> 14455<refsect1> 14456 <title>Arguments</title> 14457 <variablelist> 14458 <varlistentry> 14459 <term><parameter>size</parameter></term> 14460 <listitem> 14461 <para> 14462 allocation size 14463 </para> 14464 </listitem> 14465 </varlistentry> 14466 </variablelist> 14467</refsect1> 14468<refsect1> 14469<title>Description</title> 14470<para> 14471 The resulting memory area is 32bit addressable and zeroed so it can be 14472 mapped to userspace without leaking data. 14473</para> 14474</refsect1> 14475</refentry> 14476 14477<refentry id="API-remap-vmalloc-range-partial"> 14478<refentryinfo> 14479 <title>LINUX</title> 14480 <productname>Kernel Hackers Manual</productname> 14481 <date>July 2017</date> 14482</refentryinfo> 14483<refmeta> 14484 <refentrytitle><phrase>remap_vmalloc_range_partial</phrase></refentrytitle> 14485 <manvolnum>9</manvolnum> 14486 <refmiscinfo class="version">4.1.27</refmiscinfo> 14487</refmeta> 14488<refnamediv> 14489 <refname>remap_vmalloc_range_partial</refname> 14490 <refpurpose> 14491 map vmalloc pages to userspace 14492 </refpurpose> 14493</refnamediv> 14494<refsynopsisdiv> 14495 <title>Synopsis</title> 14496 <funcsynopsis><funcprototype> 14497 <funcdef>int <function>remap_vmalloc_range_partial </function></funcdef> 14498 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 14499 <paramdef>unsigned long <parameter>uaddr</parameter></paramdef> 14500 <paramdef>void * <parameter>kaddr</parameter></paramdef> 14501 <paramdef>unsigned long <parameter>size</parameter></paramdef> 14502 </funcprototype></funcsynopsis> 14503</refsynopsisdiv> 14504<refsect1> 14505 <title>Arguments</title> 14506 <variablelist> 14507 <varlistentry> 14508 <term><parameter>vma</parameter></term> 14509 <listitem> 14510 <para> 14511 vma to cover 14512 </para> 14513 </listitem> 14514 </varlistentry> 14515 <varlistentry> 14516 <term><parameter>uaddr</parameter></term> 14517 <listitem> 14518 <para> 14519 target user address to start at 14520 </para> 14521 </listitem> 14522 </varlistentry> 14523 <varlistentry> 14524 <term><parameter>kaddr</parameter></term> 14525 <listitem> 14526 <para> 14527 virtual address of vmalloc kernel memory 14528 </para> 14529 </listitem> 14530 </varlistentry> 14531 <varlistentry> 14532 <term><parameter>size</parameter></term> 14533 <listitem> 14534 <para> 14535 size of map area 14536 </para> 14537 </listitem> 14538 </varlistentry> 14539 </variablelist> 14540</refsect1> 14541<refsect1> 14542<title>Returns</title> 14543<para> 14544 0 for success, -Exxx on failure 14545 </para><para> 14546 14547 This function checks that <parameter>kaddr</parameter> is a valid vmalloc'ed area, 14548 and that it is big enough to cover the range starting at 14549 <parameter>uaddr</parameter> in <parameter>vma</parameter>. Will return failure if that criteria isn't 14550 met. 14551 </para><para> 14552 14553 Similar to <function>remap_pfn_range</function> (see mm/memory.c) 14554</para> 14555</refsect1> 14556</refentry> 14557 14558<refentry id="API-remap-vmalloc-range"> 14559<refentryinfo> 14560 <title>LINUX</title> 14561 <productname>Kernel Hackers Manual</productname> 14562 <date>July 2017</date> 14563</refentryinfo> 14564<refmeta> 14565 <refentrytitle><phrase>remap_vmalloc_range</phrase></refentrytitle> 14566 <manvolnum>9</manvolnum> 14567 <refmiscinfo class="version">4.1.27</refmiscinfo> 14568</refmeta> 14569<refnamediv> 14570 <refname>remap_vmalloc_range</refname> 14571 <refpurpose> 14572 map vmalloc pages to userspace 14573 </refpurpose> 14574</refnamediv> 14575<refsynopsisdiv> 14576 <title>Synopsis</title> 14577 <funcsynopsis><funcprototype> 14578 <funcdef>int <function>remap_vmalloc_range </function></funcdef> 14579 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 14580 <paramdef>void * <parameter>addr</parameter></paramdef> 14581 <paramdef>unsigned long <parameter>pgoff</parameter></paramdef> 14582 </funcprototype></funcsynopsis> 14583</refsynopsisdiv> 14584<refsect1> 14585 <title>Arguments</title> 14586 <variablelist> 14587 <varlistentry> 14588 <term><parameter>vma</parameter></term> 14589 <listitem> 14590 <para> 14591 vma to cover (map full range of vma) 14592 </para> 14593 </listitem> 14594 </varlistentry> 14595 <varlistentry> 14596 <term><parameter>addr</parameter></term> 14597 <listitem> 14598 <para> 14599 vmalloc memory 14600 </para> 14601 </listitem> 14602 </varlistentry> 14603 <varlistentry> 14604 <term><parameter>pgoff</parameter></term> 14605 <listitem> 14606 <para> 14607 number of pages into addr before first page to map 14608 </para> 14609 </listitem> 14610 </varlistentry> 14611 </variablelist> 14612</refsect1> 14613<refsect1> 14614<title>Returns</title> 14615<para> 14616 0 for success, -Exxx on failure 14617 </para><para> 14618 14619 This function checks that addr is a valid vmalloc'ed area, and 14620 that it is big enough to cover the vma. Will return failure if 14621 that criteria isn't met. 14622 </para><para> 14623 14624 Similar to <function>remap_pfn_range</function> (see mm/memory.c) 14625</para> 14626</refsect1> 14627</refentry> 14628 14629<refentry id="API-alloc-vm-area"> 14630<refentryinfo> 14631 <title>LINUX</title> 14632 <productname>Kernel Hackers Manual</productname> 14633 <date>July 2017</date> 14634</refentryinfo> 14635<refmeta> 14636 <refentrytitle><phrase>alloc_vm_area</phrase></refentrytitle> 14637 <manvolnum>9</manvolnum> 14638 <refmiscinfo class="version">4.1.27</refmiscinfo> 14639</refmeta> 14640<refnamediv> 14641 <refname>alloc_vm_area</refname> 14642 <refpurpose> 14643 allocate a range of kernel address space 14644 </refpurpose> 14645</refnamediv> 14646<refsynopsisdiv> 14647 <title>Synopsis</title> 14648 <funcsynopsis><funcprototype> 14649 <funcdef>struct vm_struct * <function>alloc_vm_area </function></funcdef> 14650 <paramdef>size_t <parameter>size</parameter></paramdef> 14651 <paramdef>pte_t ** <parameter>ptes</parameter></paramdef> 14652 </funcprototype></funcsynopsis> 14653</refsynopsisdiv> 14654<refsect1> 14655 <title>Arguments</title> 14656 <variablelist> 14657 <varlistentry> 14658 <term><parameter>size</parameter></term> 14659 <listitem> 14660 <para> 14661 size of the area 14662 </para> 14663 </listitem> 14664 </varlistentry> 14665 <varlistentry> 14666 <term><parameter>ptes</parameter></term> 14667 <listitem> 14668 <para> 14669 returns the PTEs for the address space 14670 </para> 14671 </listitem> 14672 </varlistentry> 14673 </variablelist> 14674</refsect1> 14675<refsect1> 14676<title>Returns</title> 14677<para> 14678 NULL on failure, vm_struct on success 14679 </para><para> 14680 14681 This function reserves a range of kernel address space, and 14682 allocates pagetables to map that range. No actual mappings 14683 are created. 14684 </para><para> 14685 14686 If <parameter>ptes</parameter> is non-NULL, pointers to the PTEs (in init_mm) 14687 allocated for the VM area are returned. 14688</para> 14689</refsect1> 14690</refentry> 14691 14692<!-- mm/page_alloc.c --> 14693<refentry id="API-alloc-pages-exact-nid"> 14694<refentryinfo> 14695 <title>LINUX</title> 14696 <productname>Kernel Hackers Manual</productname> 14697 <date>July 2017</date> 14698</refentryinfo> 14699<refmeta> 14700 <refentrytitle><phrase>alloc_pages_exact_nid</phrase></refentrytitle> 14701 <manvolnum>9</manvolnum> 14702 <refmiscinfo class="version">4.1.27</refmiscinfo> 14703</refmeta> 14704<refnamediv> 14705 <refname>alloc_pages_exact_nid</refname> 14706 <refpurpose> 14707 allocate an exact number of physically-contiguous pages on a node. 14708 </refpurpose> 14709</refnamediv> 14710<refsynopsisdiv> 14711 <title>Synopsis</title> 14712 <funcsynopsis><funcprototype> 14713 <funcdef>void * <function>alloc_pages_exact_nid </function></funcdef> 14714 <paramdef>int <parameter>nid</parameter></paramdef> 14715 <paramdef>size_t <parameter>size</parameter></paramdef> 14716 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 14717 </funcprototype></funcsynopsis> 14718</refsynopsisdiv> 14719<refsect1> 14720 <title>Arguments</title> 14721 <variablelist> 14722 <varlistentry> 14723 <term><parameter>nid</parameter></term> 14724 <listitem> 14725 <para> 14726 the preferred node ID where memory should be allocated 14727 </para> 14728 </listitem> 14729 </varlistentry> 14730 <varlistentry> 14731 <term><parameter>size</parameter></term> 14732 <listitem> 14733 <para> 14734 the number of bytes to allocate 14735 </para> 14736 </listitem> 14737 </varlistentry> 14738 <varlistentry> 14739 <term><parameter>gfp_mask</parameter></term> 14740 <listitem> 14741 <para> 14742 GFP flags for the allocation 14743 </para> 14744 </listitem> 14745 </varlistentry> 14746 </variablelist> 14747</refsect1> 14748<refsect1> 14749<title>Description</title> 14750<para> 14751 Like <function>alloc_pages_exact</function>, but try to allocate on node nid first before falling 14752 back. 14753 Note this is not <function>alloc_pages_exact_node</function> which allocates on a specific node, 14754 but is not exact. 14755</para> 14756</refsect1> 14757</refentry> 14758 14759<refentry id="API-nr-free-zone-pages"> 14760<refentryinfo> 14761 <title>LINUX</title> 14762 <productname>Kernel Hackers Manual</productname> 14763 <date>July 2017</date> 14764</refentryinfo> 14765<refmeta> 14766 <refentrytitle><phrase>nr_free_zone_pages</phrase></refentrytitle> 14767 <manvolnum>9</manvolnum> 14768 <refmiscinfo class="version">4.1.27</refmiscinfo> 14769</refmeta> 14770<refnamediv> 14771 <refname>nr_free_zone_pages</refname> 14772 <refpurpose> 14773 count number of pages beyond high watermark 14774 </refpurpose> 14775</refnamediv> 14776<refsynopsisdiv> 14777 <title>Synopsis</title> 14778 <funcsynopsis><funcprototype> 14779 <funcdef>unsigned long <function>nr_free_zone_pages </function></funcdef> 14780 <paramdef>int <parameter>offset</parameter></paramdef> 14781 </funcprototype></funcsynopsis> 14782</refsynopsisdiv> 14783<refsect1> 14784 <title>Arguments</title> 14785 <variablelist> 14786 <varlistentry> 14787 <term><parameter>offset</parameter></term> 14788 <listitem> 14789 <para> 14790 The zone index of the highest zone 14791 </para> 14792 </listitem> 14793 </varlistentry> 14794 </variablelist> 14795</refsect1> 14796<refsect1> 14797<title>Description</title> 14798<para> 14799 <function>nr_free_zone_pages</function> counts the number of counts pages which are beyond the 14800 high watermark within all zones at or below a given zone index. For each 14801 zone, the number of pages is calculated as: 14802 managed_pages - high_pages 14803</para> 14804</refsect1> 14805</refentry> 14806 14807<refentry id="API-nr-free-pagecache-pages"> 14808<refentryinfo> 14809 <title>LINUX</title> 14810 <productname>Kernel Hackers Manual</productname> 14811 <date>July 2017</date> 14812</refentryinfo> 14813<refmeta> 14814 <refentrytitle><phrase>nr_free_pagecache_pages</phrase></refentrytitle> 14815 <manvolnum>9</manvolnum> 14816 <refmiscinfo class="version">4.1.27</refmiscinfo> 14817</refmeta> 14818<refnamediv> 14819 <refname>nr_free_pagecache_pages</refname> 14820 <refpurpose> 14821 count number of pages beyond high watermark 14822 </refpurpose> 14823</refnamediv> 14824<refsynopsisdiv> 14825 <title>Synopsis</title> 14826 <funcsynopsis><funcprototype> 14827 <funcdef>unsigned long <function>nr_free_pagecache_pages </function></funcdef> 14828 <paramdef> <parameter>void</parameter></paramdef> 14829 </funcprototype></funcsynopsis> 14830</refsynopsisdiv> 14831<refsect1> 14832 <title>Arguments</title> 14833 <variablelist> 14834 <varlistentry> 14835 <term><parameter>void</parameter></term> 14836 <listitem> 14837 <para> 14838 no arguments 14839 </para> 14840 </listitem> 14841 </varlistentry> 14842 </variablelist> 14843</refsect1> 14844<refsect1> 14845<title>Description</title> 14846<para> 14847 </para><para> 14848 14849 <function>nr_free_pagecache_pages</function> counts the number of pages which are beyond the 14850 high watermark within all zones. 14851</para> 14852</refsect1> 14853</refentry> 14854 14855<refentry id="API-find-next-best-node"> 14856<refentryinfo> 14857 <title>LINUX</title> 14858 <productname>Kernel Hackers Manual</productname> 14859 <date>July 2017</date> 14860</refentryinfo> 14861<refmeta> 14862 <refentrytitle><phrase>find_next_best_node</phrase></refentrytitle> 14863 <manvolnum>9</manvolnum> 14864 <refmiscinfo class="version">4.1.27</refmiscinfo> 14865</refmeta> 14866<refnamediv> 14867 <refname>find_next_best_node</refname> 14868 <refpurpose> 14869 find the next node that should appear in a given node's fallback list 14870 </refpurpose> 14871</refnamediv> 14872<refsynopsisdiv> 14873 <title>Synopsis</title> 14874 <funcsynopsis><funcprototype> 14875 <funcdef>int <function>find_next_best_node </function></funcdef> 14876 <paramdef>int <parameter>node</parameter></paramdef> 14877 <paramdef>nodemask_t * <parameter>used_node_mask</parameter></paramdef> 14878 </funcprototype></funcsynopsis> 14879</refsynopsisdiv> 14880<refsect1> 14881 <title>Arguments</title> 14882 <variablelist> 14883 <varlistentry> 14884 <term><parameter>node</parameter></term> 14885 <listitem> 14886 <para> 14887 node whose fallback list we're appending 14888 </para> 14889 </listitem> 14890 </varlistentry> 14891 <varlistentry> 14892 <term><parameter>used_node_mask</parameter></term> 14893 <listitem> 14894 <para> 14895 nodemask_t of already used nodes 14896 </para> 14897 </listitem> 14898 </varlistentry> 14899 </variablelist> 14900</refsect1> 14901<refsect1> 14902<title>Description</title> 14903<para> 14904 We use a number of factors to determine which is the next node that should 14905 appear on a given node's fallback list. The node should not have appeared 14906 already in <parameter>node</parameter>'s fallback list, and it should be the next closest node 14907 according to the distance array (which contains arbitrary distance values 14908 from each node to each node in the system), and should also prefer nodes 14909 with no CPUs, since presumably they'll have very little allocation pressure 14910 on them otherwise. 14911 It returns -1 if no node is found. 14912</para> 14913</refsect1> 14914</refentry> 14915 14916<refentry id="API-free-bootmem-with-active-regions"> 14917<refentryinfo> 14918 <title>LINUX</title> 14919 <productname>Kernel Hackers Manual</productname> 14920 <date>July 2017</date> 14921</refentryinfo> 14922<refmeta> 14923 <refentrytitle><phrase>free_bootmem_with_active_regions</phrase></refentrytitle> 14924 <manvolnum>9</manvolnum> 14925 <refmiscinfo class="version">4.1.27</refmiscinfo> 14926</refmeta> 14927<refnamediv> 14928 <refname>free_bootmem_with_active_regions</refname> 14929 <refpurpose> 14930 Call memblock_free_early_nid for each active range 14931 </refpurpose> 14932</refnamediv> 14933<refsynopsisdiv> 14934 <title>Synopsis</title> 14935 <funcsynopsis><funcprototype> 14936 <funcdef>void <function>free_bootmem_with_active_regions </function></funcdef> 14937 <paramdef>int <parameter>nid</parameter></paramdef> 14938 <paramdef>unsigned long <parameter>max_low_pfn</parameter></paramdef> 14939 </funcprototype></funcsynopsis> 14940</refsynopsisdiv> 14941<refsect1> 14942 <title>Arguments</title> 14943 <variablelist> 14944 <varlistentry> 14945 <term><parameter>nid</parameter></term> 14946 <listitem> 14947 <para> 14948 The node to free memory on. If MAX_NUMNODES, all nodes are freed. 14949 </para> 14950 </listitem> 14951 </varlistentry> 14952 <varlistentry> 14953 <term><parameter>max_low_pfn</parameter></term> 14954 <listitem> 14955 <para> 14956 The highest PFN that will be passed to memblock_free_early_nid 14957 </para> 14958 </listitem> 14959 </varlistentry> 14960 </variablelist> 14961</refsect1> 14962<refsect1> 14963<title>Description</title> 14964<para> 14965 If an architecture guarantees that all ranges registered contain no holes 14966 and may be freed, this this function may be used instead of calling 14967 <function>memblock_free_early_nid</function> manually. 14968</para> 14969</refsect1> 14970</refentry> 14971 14972<refentry id="API-sparse-memory-present-with-active-regions"> 14973<refentryinfo> 14974 <title>LINUX</title> 14975 <productname>Kernel Hackers Manual</productname> 14976 <date>July 2017</date> 14977</refentryinfo> 14978<refmeta> 14979 <refentrytitle><phrase>sparse_memory_present_with_active_regions</phrase></refentrytitle> 14980 <manvolnum>9</manvolnum> 14981 <refmiscinfo class="version">4.1.27</refmiscinfo> 14982</refmeta> 14983<refnamediv> 14984 <refname>sparse_memory_present_with_active_regions</refname> 14985 <refpurpose> 14986 Call memory_present for each active range 14987 </refpurpose> 14988</refnamediv> 14989<refsynopsisdiv> 14990 <title>Synopsis</title> 14991 <funcsynopsis><funcprototype> 14992 <funcdef>void <function>sparse_memory_present_with_active_regions </function></funcdef> 14993 <paramdef>int <parameter>nid</parameter></paramdef> 14994 </funcprototype></funcsynopsis> 14995</refsynopsisdiv> 14996<refsect1> 14997 <title>Arguments</title> 14998 <variablelist> 14999 <varlistentry> 15000 <term><parameter>nid</parameter></term> 15001 <listitem> 15002 <para> 15003 The node to call memory_present for. If MAX_NUMNODES, all nodes will be used. 15004 </para> 15005 </listitem> 15006 </varlistentry> 15007 </variablelist> 15008</refsect1> 15009<refsect1> 15010<title>Description</title> 15011<para> 15012 If an architecture guarantees that all ranges registered contain no holes and may 15013 be freed, this function may be used instead of calling <function>memory_present</function> manually. 15014</para> 15015</refsect1> 15016</refentry> 15017 15018<refentry id="API-get-pfn-range-for-nid"> 15019<refentryinfo> 15020 <title>LINUX</title> 15021 <productname>Kernel Hackers Manual</productname> 15022 <date>July 2017</date> 15023</refentryinfo> 15024<refmeta> 15025 <refentrytitle><phrase>get_pfn_range_for_nid</phrase></refentrytitle> 15026 <manvolnum>9</manvolnum> 15027 <refmiscinfo class="version">4.1.27</refmiscinfo> 15028</refmeta> 15029<refnamediv> 15030 <refname>get_pfn_range_for_nid</refname> 15031 <refpurpose> 15032 Return the start and end page frames for a node 15033 </refpurpose> 15034</refnamediv> 15035<refsynopsisdiv> 15036 <title>Synopsis</title> 15037 <funcsynopsis><funcprototype> 15038 <funcdef>void <function>get_pfn_range_for_nid </function></funcdef> 15039 <paramdef>unsigned int <parameter>nid</parameter></paramdef> 15040 <paramdef>unsigned long * <parameter>start_pfn</parameter></paramdef> 15041 <paramdef>unsigned long * <parameter>end_pfn</parameter></paramdef> 15042 </funcprototype></funcsynopsis> 15043</refsynopsisdiv> 15044<refsect1> 15045 <title>Arguments</title> 15046 <variablelist> 15047 <varlistentry> 15048 <term><parameter>nid</parameter></term> 15049 <listitem> 15050 <para> 15051 The nid to return the range for. If MAX_NUMNODES, the min and max PFN are returned. 15052 </para> 15053 </listitem> 15054 </varlistentry> 15055 <varlistentry> 15056 <term><parameter>start_pfn</parameter></term> 15057 <listitem> 15058 <para> 15059 Passed by reference. On return, it will have the node start_pfn. 15060 </para> 15061 </listitem> 15062 </varlistentry> 15063 <varlistentry> 15064 <term><parameter>end_pfn</parameter></term> 15065 <listitem> 15066 <para> 15067 Passed by reference. On return, it will have the node end_pfn. 15068 </para> 15069 </listitem> 15070 </varlistentry> 15071 </variablelist> 15072</refsect1> 15073<refsect1> 15074<title>Description</title> 15075<para> 15076 It returns the start and end page frame of a node based on information 15077 provided by <function>memblock_set_node</function>. If called for a node 15078 with no available memory, a warning is printed and the start and end 15079 PFNs will be 0. 15080</para> 15081</refsect1> 15082</refentry> 15083 15084<refentry id="API-absent-pages-in-range"> 15085<refentryinfo> 15086 <title>LINUX</title> 15087 <productname>Kernel Hackers Manual</productname> 15088 <date>July 2017</date> 15089</refentryinfo> 15090<refmeta> 15091 <refentrytitle><phrase>absent_pages_in_range</phrase></refentrytitle> 15092 <manvolnum>9</manvolnum> 15093 <refmiscinfo class="version">4.1.27</refmiscinfo> 15094</refmeta> 15095<refnamediv> 15096 <refname>absent_pages_in_range</refname> 15097 <refpurpose> 15098 Return number of page frames in holes within a range 15099 </refpurpose> 15100</refnamediv> 15101<refsynopsisdiv> 15102 <title>Synopsis</title> 15103 <funcsynopsis><funcprototype> 15104 <funcdef>unsigned long <function>absent_pages_in_range </function></funcdef> 15105 <paramdef>unsigned long <parameter>start_pfn</parameter></paramdef> 15106 <paramdef>unsigned long <parameter>end_pfn</parameter></paramdef> 15107 </funcprototype></funcsynopsis> 15108</refsynopsisdiv> 15109<refsect1> 15110 <title>Arguments</title> 15111 <variablelist> 15112 <varlistentry> 15113 <term><parameter>start_pfn</parameter></term> 15114 <listitem> 15115 <para> 15116 The start PFN to start searching for holes 15117 </para> 15118 </listitem> 15119 </varlistentry> 15120 <varlistentry> 15121 <term><parameter>end_pfn</parameter></term> 15122 <listitem> 15123 <para> 15124 The end PFN to stop searching for holes 15125 </para> 15126 </listitem> 15127 </varlistentry> 15128 </variablelist> 15129</refsect1> 15130<refsect1> 15131<title>Description</title> 15132<para> 15133 It returns the number of pages frames in memory holes within a range. 15134</para> 15135</refsect1> 15136</refentry> 15137 15138<refentry id="API-node-map-pfn-alignment"> 15139<refentryinfo> 15140 <title>LINUX</title> 15141 <productname>Kernel Hackers Manual</productname> 15142 <date>July 2017</date> 15143</refentryinfo> 15144<refmeta> 15145 <refentrytitle><phrase>node_map_pfn_alignment</phrase></refentrytitle> 15146 <manvolnum>9</manvolnum> 15147 <refmiscinfo class="version">4.1.27</refmiscinfo> 15148</refmeta> 15149<refnamediv> 15150 <refname>node_map_pfn_alignment</refname> 15151 <refpurpose> 15152 determine the maximum internode alignment 15153 </refpurpose> 15154</refnamediv> 15155<refsynopsisdiv> 15156 <title>Synopsis</title> 15157 <funcsynopsis><funcprototype> 15158 <funcdef>unsigned long <function>node_map_pfn_alignment </function></funcdef> 15159 <paramdef> <parameter>void</parameter></paramdef> 15160 </funcprototype></funcsynopsis> 15161</refsynopsisdiv> 15162<refsect1> 15163 <title>Arguments</title> 15164 <variablelist> 15165 <varlistentry> 15166 <term><parameter>void</parameter></term> 15167 <listitem> 15168 <para> 15169 no arguments 15170 </para> 15171 </listitem> 15172 </varlistentry> 15173 </variablelist> 15174</refsect1> 15175<refsect1> 15176<title>Description</title> 15177<para> 15178 </para><para> 15179 15180 This function should be called after node map is populated and sorted. 15181 It calculates the maximum power of two alignment which can distinguish 15182 all the nodes. 15183 </para><para> 15184 15185 For example, if all nodes are 1GiB and aligned to 1GiB, the return value 15186 would indicate 1GiB alignment with (1 << (30 - PAGE_SHIFT)). If the 15187 nodes are shifted by 256MiB, 256MiB. Note that if only the last node is 15188 shifted, 1GiB is enough and this function will indicate so. 15189 </para><para> 15190 15191 This is used to test whether pfn -> nid mapping of the chosen memory 15192 model has fine enough granularity to avoid incorrect mapping for the 15193 populated node map. 15194 </para><para> 15195 15196 Returns the determined alignment in pfn's. 0 if there is no alignment 15197 requirement (single node). 15198</para> 15199</refsect1> 15200</refentry> 15201 15202<refentry id="API-find-min-pfn-with-active-regions"> 15203<refentryinfo> 15204 <title>LINUX</title> 15205 <productname>Kernel Hackers Manual</productname> 15206 <date>July 2017</date> 15207</refentryinfo> 15208<refmeta> 15209 <refentrytitle><phrase>find_min_pfn_with_active_regions</phrase></refentrytitle> 15210 <manvolnum>9</manvolnum> 15211 <refmiscinfo class="version">4.1.27</refmiscinfo> 15212</refmeta> 15213<refnamediv> 15214 <refname>find_min_pfn_with_active_regions</refname> 15215 <refpurpose> 15216 Find the minimum PFN registered 15217 </refpurpose> 15218</refnamediv> 15219<refsynopsisdiv> 15220 <title>Synopsis</title> 15221 <funcsynopsis><funcprototype> 15222 <funcdef>unsigned long <function>find_min_pfn_with_active_regions </function></funcdef> 15223 <paramdef> <parameter>void</parameter></paramdef> 15224 </funcprototype></funcsynopsis> 15225</refsynopsisdiv> 15226<refsect1> 15227 <title>Arguments</title> 15228 <variablelist> 15229 <varlistentry> 15230 <term><parameter>void</parameter></term> 15231 <listitem> 15232 <para> 15233 no arguments 15234 </para> 15235 </listitem> 15236 </varlistentry> 15237 </variablelist> 15238</refsect1> 15239<refsect1> 15240<title>Description</title> 15241<para> 15242 </para><para> 15243 15244 It returns the minimum PFN based on information provided via 15245 <function>memblock_set_node</function>. 15246</para> 15247</refsect1> 15248</refentry> 15249 15250<refentry id="API-free-area-init-nodes"> 15251<refentryinfo> 15252 <title>LINUX</title> 15253 <productname>Kernel Hackers Manual</productname> 15254 <date>July 2017</date> 15255</refentryinfo> 15256<refmeta> 15257 <refentrytitle><phrase>free_area_init_nodes</phrase></refentrytitle> 15258 <manvolnum>9</manvolnum> 15259 <refmiscinfo class="version">4.1.27</refmiscinfo> 15260</refmeta> 15261<refnamediv> 15262 <refname>free_area_init_nodes</refname> 15263 <refpurpose> 15264 Initialise all pg_data_t and zone data 15265 </refpurpose> 15266</refnamediv> 15267<refsynopsisdiv> 15268 <title>Synopsis</title> 15269 <funcsynopsis><funcprototype> 15270 <funcdef>void <function>free_area_init_nodes </function></funcdef> 15271 <paramdef>unsigned long * <parameter>max_zone_pfn</parameter></paramdef> 15272 </funcprototype></funcsynopsis> 15273</refsynopsisdiv> 15274<refsect1> 15275 <title>Arguments</title> 15276 <variablelist> 15277 <varlistentry> 15278 <term><parameter>max_zone_pfn</parameter></term> 15279 <listitem> 15280 <para> 15281 an array of max PFNs for each zone 15282 </para> 15283 </listitem> 15284 </varlistentry> 15285 </variablelist> 15286</refsect1> 15287<refsect1> 15288<title>Description</title> 15289<para> 15290 This will call <function>free_area_init_node</function> for each active node in the system. 15291 Using the page ranges provided by <function>memblock_set_node</function>, the size of each 15292 zone in each node and their holes is calculated. If the maximum PFN 15293 between two adjacent zones match, it is assumed that the zone is empty. 15294 For example, if arch_max_dma_pfn == arch_max_dma32_pfn, it is assumed 15295 that arch_max_dma32_pfn has no pages. It is also assumed that a zone 15296 starts where the previous one ended. For example, ZONE_DMA32 starts 15297 at arch_max_dma_pfn. 15298</para> 15299</refsect1> 15300</refentry> 15301 15302<refentry id="API-set-dma-reserve"> 15303<refentryinfo> 15304 <title>LINUX</title> 15305 <productname>Kernel Hackers Manual</productname> 15306 <date>July 2017</date> 15307</refentryinfo> 15308<refmeta> 15309 <refentrytitle><phrase>set_dma_reserve</phrase></refentrytitle> 15310 <manvolnum>9</manvolnum> 15311 <refmiscinfo class="version">4.1.27</refmiscinfo> 15312</refmeta> 15313<refnamediv> 15314 <refname>set_dma_reserve</refname> 15315 <refpurpose> 15316 set the specified number of pages reserved in the first zone 15317 </refpurpose> 15318</refnamediv> 15319<refsynopsisdiv> 15320 <title>Synopsis</title> 15321 <funcsynopsis><funcprototype> 15322 <funcdef>void <function>set_dma_reserve </function></funcdef> 15323 <paramdef>unsigned long <parameter>new_dma_reserve</parameter></paramdef> 15324 </funcprototype></funcsynopsis> 15325</refsynopsisdiv> 15326<refsect1> 15327 <title>Arguments</title> 15328 <variablelist> 15329 <varlistentry> 15330 <term><parameter>new_dma_reserve</parameter></term> 15331 <listitem> 15332 <para> 15333 The number of pages to mark reserved 15334 </para> 15335 </listitem> 15336 </varlistentry> 15337 </variablelist> 15338</refsect1> 15339<refsect1> 15340<title>Description</title> 15341<para> 15342 The per-cpu batchsize and zone watermarks are determined by present_pages. 15343 In the DMA zone, a significant percentage may be consumed by kernel image 15344 and other unfreeable allocations which can skew the watermarks badly. This 15345 function may optionally be used to account for unfreeable pages in the 15346 first zone (e.g., ZONE_DMA). The effect will be lower watermarks and 15347 smaller per-cpu batchsize. 15348</para> 15349</refsect1> 15350</refentry> 15351 15352<refentry id="API-setup-per-zone-wmarks"> 15353<refentryinfo> 15354 <title>LINUX</title> 15355 <productname>Kernel Hackers Manual</productname> 15356 <date>July 2017</date> 15357</refentryinfo> 15358<refmeta> 15359 <refentrytitle><phrase>setup_per_zone_wmarks</phrase></refentrytitle> 15360 <manvolnum>9</manvolnum> 15361 <refmiscinfo class="version">4.1.27</refmiscinfo> 15362</refmeta> 15363<refnamediv> 15364 <refname>setup_per_zone_wmarks</refname> 15365 <refpurpose> 15366 called when min_free_kbytes changes or when memory is hot-{added|removed} 15367 </refpurpose> 15368</refnamediv> 15369<refsynopsisdiv> 15370 <title>Synopsis</title> 15371 <funcsynopsis><funcprototype> 15372 <funcdef>void <function>setup_per_zone_wmarks </function></funcdef> 15373 <paramdef> <parameter>void</parameter></paramdef> 15374 </funcprototype></funcsynopsis> 15375</refsynopsisdiv> 15376<refsect1> 15377 <title>Arguments</title> 15378 <variablelist> 15379 <varlistentry> 15380 <term><parameter>void</parameter></term> 15381 <listitem> 15382 <para> 15383 no arguments 15384 </para> 15385 </listitem> 15386 </varlistentry> 15387 </variablelist> 15388</refsect1> 15389<refsect1> 15390<title>Description</title> 15391<para> 15392 </para><para> 15393 15394 Ensures that the watermark[min,low,high] values for each zone are set 15395 correctly with respect to min_free_kbytes. 15396</para> 15397</refsect1> 15398</refentry> 15399 15400<refentry id="API-get-pfnblock-flags-mask"> 15401<refentryinfo> 15402 <title>LINUX</title> 15403 <productname>Kernel Hackers Manual</productname> 15404 <date>July 2017</date> 15405</refentryinfo> 15406<refmeta> 15407 <refentrytitle><phrase>get_pfnblock_flags_mask</phrase></refentrytitle> 15408 <manvolnum>9</manvolnum> 15409 <refmiscinfo class="version">4.1.27</refmiscinfo> 15410</refmeta> 15411<refnamediv> 15412 <refname>get_pfnblock_flags_mask</refname> 15413 <refpurpose> 15414 Return the requested group of flags for the pageblock_nr_pages block of pages 15415 </refpurpose> 15416</refnamediv> 15417<refsynopsisdiv> 15418 <title>Synopsis</title> 15419 <funcsynopsis><funcprototype> 15420 <funcdef>unsigned long <function>get_pfnblock_flags_mask </function></funcdef> 15421 <paramdef>struct page * <parameter>page</parameter></paramdef> 15422 <paramdef>unsigned long <parameter>pfn</parameter></paramdef> 15423 <paramdef>unsigned long <parameter>end_bitidx</parameter></paramdef> 15424 <paramdef>unsigned long <parameter>mask</parameter></paramdef> 15425 </funcprototype></funcsynopsis> 15426</refsynopsisdiv> 15427<refsect1> 15428 <title>Arguments</title> 15429 <variablelist> 15430 <varlistentry> 15431 <term><parameter>page</parameter></term> 15432 <listitem> 15433 <para> 15434 The page within the block of interest 15435 </para> 15436 </listitem> 15437 </varlistentry> 15438 <varlistentry> 15439 <term><parameter>pfn</parameter></term> 15440 <listitem> 15441 <para> 15442 The target page frame number 15443 </para> 15444 </listitem> 15445 </varlistentry> 15446 <varlistentry> 15447 <term><parameter>end_bitidx</parameter></term> 15448 <listitem> 15449 <para> 15450 The last bit of interest to retrieve 15451 </para> 15452 </listitem> 15453 </varlistentry> 15454 <varlistentry> 15455 <term><parameter>mask</parameter></term> 15456 <listitem> 15457 <para> 15458 mask of bits that the caller is interested in 15459 </para> 15460 </listitem> 15461 </varlistentry> 15462 </variablelist> 15463</refsect1> 15464<refsect1> 15465<title>Return</title> 15466<para> 15467 pageblock_bits flags 15468</para> 15469</refsect1> 15470</refentry> 15471 15472<refentry id="API-set-pfnblock-flags-mask"> 15473<refentryinfo> 15474 <title>LINUX</title> 15475 <productname>Kernel Hackers Manual</productname> 15476 <date>July 2017</date> 15477</refentryinfo> 15478<refmeta> 15479 <refentrytitle><phrase>set_pfnblock_flags_mask</phrase></refentrytitle> 15480 <manvolnum>9</manvolnum> 15481 <refmiscinfo class="version">4.1.27</refmiscinfo> 15482</refmeta> 15483<refnamediv> 15484 <refname>set_pfnblock_flags_mask</refname> 15485 <refpurpose> 15486 Set the requested group of flags for a pageblock_nr_pages block of pages 15487 </refpurpose> 15488</refnamediv> 15489<refsynopsisdiv> 15490 <title>Synopsis</title> 15491 <funcsynopsis><funcprototype> 15492 <funcdef>void <function>set_pfnblock_flags_mask </function></funcdef> 15493 <paramdef>struct page * <parameter>page</parameter></paramdef> 15494 <paramdef>unsigned long <parameter>flags</parameter></paramdef> 15495 <paramdef>unsigned long <parameter>pfn</parameter></paramdef> 15496 <paramdef>unsigned long <parameter>end_bitidx</parameter></paramdef> 15497 <paramdef>unsigned long <parameter>mask</parameter></paramdef> 15498 </funcprototype></funcsynopsis> 15499</refsynopsisdiv> 15500<refsect1> 15501 <title>Arguments</title> 15502 <variablelist> 15503 <varlistentry> 15504 <term><parameter>page</parameter></term> 15505 <listitem> 15506 <para> 15507 The page within the block of interest 15508 </para> 15509 </listitem> 15510 </varlistentry> 15511 <varlistentry> 15512 <term><parameter>flags</parameter></term> 15513 <listitem> 15514 <para> 15515 The flags to set 15516 </para> 15517 </listitem> 15518 </varlistentry> 15519 <varlistentry> 15520 <term><parameter>pfn</parameter></term> 15521 <listitem> 15522 <para> 15523 The target page frame number 15524 </para> 15525 </listitem> 15526 </varlistentry> 15527 <varlistentry> 15528 <term><parameter>end_bitidx</parameter></term> 15529 <listitem> 15530 <para> 15531 The last bit of interest 15532 </para> 15533 </listitem> 15534 </varlistentry> 15535 <varlistentry> 15536 <term><parameter>mask</parameter></term> 15537 <listitem> 15538 <para> 15539 mask of bits that the caller is interested in 15540 </para> 15541 </listitem> 15542 </varlistentry> 15543 </variablelist> 15544</refsect1> 15545</refentry> 15546 15547<refentry id="API-alloc-contig-range"> 15548<refentryinfo> 15549 <title>LINUX</title> 15550 <productname>Kernel Hackers Manual</productname> 15551 <date>July 2017</date> 15552</refentryinfo> 15553<refmeta> 15554 <refentrytitle><phrase>alloc_contig_range</phrase></refentrytitle> 15555 <manvolnum>9</manvolnum> 15556 <refmiscinfo class="version">4.1.27</refmiscinfo> 15557</refmeta> 15558<refnamediv> 15559 <refname>alloc_contig_range</refname> 15560 <refpurpose> 15561 - tries to allocate given range of pages 15562 </refpurpose> 15563</refnamediv> 15564<refsynopsisdiv> 15565 <title>Synopsis</title> 15566 <funcsynopsis><funcprototype> 15567 <funcdef>int <function>alloc_contig_range </function></funcdef> 15568 <paramdef>unsigned long <parameter>start</parameter></paramdef> 15569 <paramdef>unsigned long <parameter>end</parameter></paramdef> 15570 <paramdef>unsigned <parameter>migratetype</parameter></paramdef> 15571 </funcprototype></funcsynopsis> 15572</refsynopsisdiv> 15573<refsect1> 15574 <title>Arguments</title> 15575 <variablelist> 15576 <varlistentry> 15577 <term><parameter>start</parameter></term> 15578 <listitem> 15579 <para> 15580 start PFN to allocate 15581 </para> 15582 </listitem> 15583 </varlistentry> 15584 <varlistentry> 15585 <term><parameter>end</parameter></term> 15586 <listitem> 15587 <para> 15588 one-past-the-last PFN to allocate 15589 </para> 15590 </listitem> 15591 </varlistentry> 15592 <varlistentry> 15593 <term><parameter>migratetype</parameter></term> 15594 <listitem> 15595 <para> 15596 migratetype of the underlaying pageblocks (either 15597 #MIGRATE_MOVABLE or #MIGRATE_CMA). All pageblocks 15598 in range must have the same migratetype and it must 15599 be either of the two. 15600 </para> 15601 </listitem> 15602 </varlistentry> 15603 </variablelist> 15604</refsect1> 15605<refsect1> 15606<title>Description</title> 15607<para> 15608 The PFN range does not have to be pageblock or MAX_ORDER_NR_PAGES 15609 aligned, however it's the caller's responsibility to guarantee that 15610 we are the only thread that changes migrate type of pageblocks the 15611 pages fall in. 15612 </para><para> 15613 15614 The PFN range must belong to a single zone. 15615 </para><para> 15616 15617 Returns zero on success or negative error code. On success all 15618 pages which PFN is in [start, end) are allocated for the caller and 15619 need to be freed with <function>free_contig_range</function>. 15620</para> 15621</refsect1> 15622</refentry> 15623 15624<!-- mm/mempool.c --> 15625<refentry id="API-mempool-destroy"> 15626<refentryinfo> 15627 <title>LINUX</title> 15628 <productname>Kernel Hackers Manual</productname> 15629 <date>July 2017</date> 15630</refentryinfo> 15631<refmeta> 15632 <refentrytitle><phrase>mempool_destroy</phrase></refentrytitle> 15633 <manvolnum>9</manvolnum> 15634 <refmiscinfo class="version">4.1.27</refmiscinfo> 15635</refmeta> 15636<refnamediv> 15637 <refname>mempool_destroy</refname> 15638 <refpurpose> 15639 deallocate a memory pool 15640 </refpurpose> 15641</refnamediv> 15642<refsynopsisdiv> 15643 <title>Synopsis</title> 15644 <funcsynopsis><funcprototype> 15645 <funcdef>void <function>mempool_destroy </function></funcdef> 15646 <paramdef>mempool_t * <parameter>pool</parameter></paramdef> 15647 </funcprototype></funcsynopsis> 15648</refsynopsisdiv> 15649<refsect1> 15650 <title>Arguments</title> 15651 <variablelist> 15652 <varlistentry> 15653 <term><parameter>pool</parameter></term> 15654 <listitem> 15655 <para> 15656 pointer to the memory pool which was allocated via 15657 <function>mempool_create</function>. 15658 </para> 15659 </listitem> 15660 </varlistentry> 15661 </variablelist> 15662</refsect1> 15663<refsect1> 15664<title>Description</title> 15665<para> 15666 Free all reserved elements in <parameter>pool</parameter> and <parameter>pool</parameter> itself. This function 15667 only sleeps if the <function>free_fn</function> function sleeps. 15668</para> 15669</refsect1> 15670</refentry> 15671 15672<refentry id="API-mempool-create"> 15673<refentryinfo> 15674 <title>LINUX</title> 15675 <productname>Kernel Hackers Manual</productname> 15676 <date>July 2017</date> 15677</refentryinfo> 15678<refmeta> 15679 <refentrytitle><phrase>mempool_create</phrase></refentrytitle> 15680 <manvolnum>9</manvolnum> 15681 <refmiscinfo class="version">4.1.27</refmiscinfo> 15682</refmeta> 15683<refnamediv> 15684 <refname>mempool_create</refname> 15685 <refpurpose> 15686 create a memory pool 15687 </refpurpose> 15688</refnamediv> 15689<refsynopsisdiv> 15690 <title>Synopsis</title> 15691 <funcsynopsis><funcprototype> 15692 <funcdef>mempool_t * <function>mempool_create </function></funcdef> 15693 <paramdef>int <parameter>min_nr</parameter></paramdef> 15694 <paramdef>mempool_alloc_t * <parameter>alloc_fn</parameter></paramdef> 15695 <paramdef>mempool_free_t * <parameter>free_fn</parameter></paramdef> 15696 <paramdef>void * <parameter>pool_data</parameter></paramdef> 15697 </funcprototype></funcsynopsis> 15698</refsynopsisdiv> 15699<refsect1> 15700 <title>Arguments</title> 15701 <variablelist> 15702 <varlistentry> 15703 <term><parameter>min_nr</parameter></term> 15704 <listitem> 15705 <para> 15706 the minimum number of elements guaranteed to be 15707 allocated for this pool. 15708 </para> 15709 </listitem> 15710 </varlistentry> 15711 <varlistentry> 15712 <term><parameter>alloc_fn</parameter></term> 15713 <listitem> 15714 <para> 15715 user-defined element-allocation function. 15716 </para> 15717 </listitem> 15718 </varlistentry> 15719 <varlistentry> 15720 <term><parameter>free_fn</parameter></term> 15721 <listitem> 15722 <para> 15723 user-defined element-freeing function. 15724 </para> 15725 </listitem> 15726 </varlistentry> 15727 <varlistentry> 15728 <term><parameter>pool_data</parameter></term> 15729 <listitem> 15730 <para> 15731 optional private data available to the user-defined functions. 15732 </para> 15733 </listitem> 15734 </varlistentry> 15735 </variablelist> 15736</refsect1> 15737<refsect1> 15738<title>Description</title> 15739<para> 15740 this function creates and allocates a guaranteed size, preallocated 15741 memory pool. The pool can be used from the <function>mempool_alloc</function> and <function>mempool_free</function> 15742 functions. This function might sleep. Both the <function>alloc_fn</function> and the <function>free_fn</function> 15743 functions might sleep - as long as the <function>mempool_alloc</function> function is not called 15744 from IRQ contexts. 15745</para> 15746</refsect1> 15747</refentry> 15748 15749<refentry id="API-mempool-resize"> 15750<refentryinfo> 15751 <title>LINUX</title> 15752 <productname>Kernel Hackers Manual</productname> 15753 <date>July 2017</date> 15754</refentryinfo> 15755<refmeta> 15756 <refentrytitle><phrase>mempool_resize</phrase></refentrytitle> 15757 <manvolnum>9</manvolnum> 15758 <refmiscinfo class="version">4.1.27</refmiscinfo> 15759</refmeta> 15760<refnamediv> 15761 <refname>mempool_resize</refname> 15762 <refpurpose> 15763 resize an existing memory pool 15764 </refpurpose> 15765</refnamediv> 15766<refsynopsisdiv> 15767 <title>Synopsis</title> 15768 <funcsynopsis><funcprototype> 15769 <funcdef>int <function>mempool_resize </function></funcdef> 15770 <paramdef>mempool_t * <parameter>pool</parameter></paramdef> 15771 <paramdef>int <parameter>new_min_nr</parameter></paramdef> 15772 </funcprototype></funcsynopsis> 15773</refsynopsisdiv> 15774<refsect1> 15775 <title>Arguments</title> 15776 <variablelist> 15777 <varlistentry> 15778 <term><parameter>pool</parameter></term> 15779 <listitem> 15780 <para> 15781 pointer to the memory pool which was allocated via 15782 <function>mempool_create</function>. 15783 </para> 15784 </listitem> 15785 </varlistentry> 15786 <varlistentry> 15787 <term><parameter>new_min_nr</parameter></term> 15788 <listitem> 15789 <para> 15790 the new minimum number of elements guaranteed to be 15791 allocated for this pool. 15792 </para> 15793 </listitem> 15794 </varlistentry> 15795 </variablelist> 15796</refsect1> 15797<refsect1> 15798<title>Description</title> 15799<para> 15800 This function shrinks/grows the pool. In the case of growing, 15801 it cannot be guaranteed that the pool will be grown to the new 15802 size immediately, but new <function>mempool_free</function> calls will refill it. 15803 This function may sleep. 15804 </para><para> 15805 15806 Note, the caller must guarantee that no mempool_destroy is called 15807 while this function is running. <function>mempool_alloc</function> & <function>mempool_free</function> 15808 might be called (eg. from IRQ contexts) while this function executes. 15809</para> 15810</refsect1> 15811</refentry> 15812 15813<refentry id="API-mempool-alloc"> 15814<refentryinfo> 15815 <title>LINUX</title> 15816 <productname>Kernel Hackers Manual</productname> 15817 <date>July 2017</date> 15818</refentryinfo> 15819<refmeta> 15820 <refentrytitle><phrase>mempool_alloc</phrase></refentrytitle> 15821 <manvolnum>9</manvolnum> 15822 <refmiscinfo class="version">4.1.27</refmiscinfo> 15823</refmeta> 15824<refnamediv> 15825 <refname>mempool_alloc</refname> 15826 <refpurpose> 15827 allocate an element from a specific memory pool 15828 </refpurpose> 15829</refnamediv> 15830<refsynopsisdiv> 15831 <title>Synopsis</title> 15832 <funcsynopsis><funcprototype> 15833 <funcdef>void * <function>mempool_alloc </function></funcdef> 15834 <paramdef>mempool_t * <parameter>pool</parameter></paramdef> 15835 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 15836 </funcprototype></funcsynopsis> 15837</refsynopsisdiv> 15838<refsect1> 15839 <title>Arguments</title> 15840 <variablelist> 15841 <varlistentry> 15842 <term><parameter>pool</parameter></term> 15843 <listitem> 15844 <para> 15845 pointer to the memory pool which was allocated via 15846 <function>mempool_create</function>. 15847 </para> 15848 </listitem> 15849 </varlistentry> 15850 <varlistentry> 15851 <term><parameter>gfp_mask</parameter></term> 15852 <listitem> 15853 <para> 15854 the usual allocation bitmask. 15855 </para> 15856 </listitem> 15857 </varlistentry> 15858 </variablelist> 15859</refsect1> 15860<refsect1> 15861<title>Description</title> 15862<para> 15863 this function only sleeps if the <function>alloc_fn</function> function sleeps or 15864 returns NULL. Note that due to preallocation, this function 15865 *never* fails when called from process contexts. (it might 15866 fail if called from an IRQ context.) 15867</para> 15868</refsect1> 15869<refsect1> 15870<title>Note</title> 15871<para> 15872 using __GFP_ZERO is not supported. 15873</para> 15874</refsect1> 15875</refentry> 15876 15877<refentry id="API-mempool-free"> 15878<refentryinfo> 15879 <title>LINUX</title> 15880 <productname>Kernel Hackers Manual</productname> 15881 <date>July 2017</date> 15882</refentryinfo> 15883<refmeta> 15884 <refentrytitle><phrase>mempool_free</phrase></refentrytitle> 15885 <manvolnum>9</manvolnum> 15886 <refmiscinfo class="version">4.1.27</refmiscinfo> 15887</refmeta> 15888<refnamediv> 15889 <refname>mempool_free</refname> 15890 <refpurpose> 15891 return an element to the pool. 15892 </refpurpose> 15893</refnamediv> 15894<refsynopsisdiv> 15895 <title>Synopsis</title> 15896 <funcsynopsis><funcprototype> 15897 <funcdef>void <function>mempool_free </function></funcdef> 15898 <paramdef>void * <parameter>element</parameter></paramdef> 15899 <paramdef>mempool_t * <parameter>pool</parameter></paramdef> 15900 </funcprototype></funcsynopsis> 15901</refsynopsisdiv> 15902<refsect1> 15903 <title>Arguments</title> 15904 <variablelist> 15905 <varlistentry> 15906 <term><parameter>element</parameter></term> 15907 <listitem> 15908 <para> 15909 pool element pointer. 15910 </para> 15911 </listitem> 15912 </varlistentry> 15913 <varlistentry> 15914 <term><parameter>pool</parameter></term> 15915 <listitem> 15916 <para> 15917 pointer to the memory pool which was allocated via 15918 <function>mempool_create</function>. 15919 </para> 15920 </listitem> 15921 </varlistentry> 15922 </variablelist> 15923</refsect1> 15924<refsect1> 15925<title>Description</title> 15926<para> 15927 this function only sleeps if the <function>free_fn</function> function sleeps. 15928</para> 15929</refsect1> 15930</refentry> 15931 15932<!-- mm/dmapool.c --> 15933<refentry id="API-dma-pool-create"> 15934<refentryinfo> 15935 <title>LINUX</title> 15936 <productname>Kernel Hackers Manual</productname> 15937 <date>July 2017</date> 15938</refentryinfo> 15939<refmeta> 15940 <refentrytitle><phrase>dma_pool_create</phrase></refentrytitle> 15941 <manvolnum>9</manvolnum> 15942 <refmiscinfo class="version">4.1.27</refmiscinfo> 15943</refmeta> 15944<refnamediv> 15945 <refname>dma_pool_create</refname> 15946 <refpurpose> 15947 Creates a pool of consistent memory blocks, for dma. 15948 </refpurpose> 15949</refnamediv> 15950<refsynopsisdiv> 15951 <title>Synopsis</title> 15952 <funcsynopsis><funcprototype> 15953 <funcdef>struct dma_pool * <function>dma_pool_create </function></funcdef> 15954 <paramdef>const char * <parameter>name</parameter></paramdef> 15955 <paramdef>struct device * <parameter>dev</parameter></paramdef> 15956 <paramdef>size_t <parameter>size</parameter></paramdef> 15957 <paramdef>size_t <parameter>align</parameter></paramdef> 15958 <paramdef>size_t <parameter>boundary</parameter></paramdef> 15959 </funcprototype></funcsynopsis> 15960</refsynopsisdiv> 15961<refsect1> 15962 <title>Arguments</title> 15963 <variablelist> 15964 <varlistentry> 15965 <term><parameter>name</parameter></term> 15966 <listitem> 15967 <para> 15968 name of pool, for diagnostics 15969 </para> 15970 </listitem> 15971 </varlistentry> 15972 <varlistentry> 15973 <term><parameter>dev</parameter></term> 15974 <listitem> 15975 <para> 15976 device that will be doing the DMA 15977 </para> 15978 </listitem> 15979 </varlistentry> 15980 <varlistentry> 15981 <term><parameter>size</parameter></term> 15982 <listitem> 15983 <para> 15984 size of the blocks in this pool. 15985 </para> 15986 </listitem> 15987 </varlistentry> 15988 <varlistentry> 15989 <term><parameter>align</parameter></term> 15990 <listitem> 15991 <para> 15992 alignment requirement for blocks; must be a power of two 15993 </para> 15994 </listitem> 15995 </varlistentry> 15996 <varlistentry> 15997 <term><parameter>boundary</parameter></term> 15998 <listitem> 15999 <para> 16000 returned blocks won't cross this power of two boundary 16001 </para> 16002 </listitem> 16003 </varlistentry> 16004 </variablelist> 16005</refsect1> 16006<refsect1> 16007<title>Context</title> 16008<para> 16009 !<function>in_interrupt</function> 16010</para> 16011</refsect1> 16012<refsect1> 16013<title>Description</title> 16014<para> 16015 Returns a dma allocation pool with the requested characteristics, or 16016 null if one can't be created. Given one of these pools, <function>dma_pool_alloc</function> 16017 may be used to allocate memory. Such memory will all have <quote>consistent</quote> 16018 DMA mappings, accessible by the device and its driver without using 16019 cache flushing primitives. The actual size of blocks allocated may be 16020 larger than requested because of alignment. 16021 </para><para> 16022 16023 If <parameter>boundary</parameter> is nonzero, objects returned from <function>dma_pool_alloc</function> won't 16024 cross that size boundary. This is useful for devices which have 16025 addressing restrictions on individual DMA transfers, such as not crossing 16026 boundaries of 4KBytes. 16027</para> 16028</refsect1> 16029</refentry> 16030 16031<refentry id="API-dma-pool-destroy"> 16032<refentryinfo> 16033 <title>LINUX</title> 16034 <productname>Kernel Hackers Manual</productname> 16035 <date>July 2017</date> 16036</refentryinfo> 16037<refmeta> 16038 <refentrytitle><phrase>dma_pool_destroy</phrase></refentrytitle> 16039 <manvolnum>9</manvolnum> 16040 <refmiscinfo class="version">4.1.27</refmiscinfo> 16041</refmeta> 16042<refnamediv> 16043 <refname>dma_pool_destroy</refname> 16044 <refpurpose> 16045 destroys a pool of dma memory blocks. 16046 </refpurpose> 16047</refnamediv> 16048<refsynopsisdiv> 16049 <title>Synopsis</title> 16050 <funcsynopsis><funcprototype> 16051 <funcdef>void <function>dma_pool_destroy </function></funcdef> 16052 <paramdef>struct dma_pool * <parameter>pool</parameter></paramdef> 16053 </funcprototype></funcsynopsis> 16054</refsynopsisdiv> 16055<refsect1> 16056 <title>Arguments</title> 16057 <variablelist> 16058 <varlistentry> 16059 <term><parameter>pool</parameter></term> 16060 <listitem> 16061 <para> 16062 dma pool that will be destroyed 16063 </para> 16064 </listitem> 16065 </varlistentry> 16066 </variablelist> 16067</refsect1> 16068<refsect1> 16069<title>Context</title> 16070<para> 16071 !<function>in_interrupt</function> 16072</para> 16073</refsect1> 16074<refsect1> 16075<title>Description</title> 16076<para> 16077 Caller guarantees that no more memory from the pool is in use, 16078 and that nothing will try to use the pool after this call. 16079</para> 16080</refsect1> 16081</refentry> 16082 16083<refentry id="API-dma-pool-alloc"> 16084<refentryinfo> 16085 <title>LINUX</title> 16086 <productname>Kernel Hackers Manual</productname> 16087 <date>July 2017</date> 16088</refentryinfo> 16089<refmeta> 16090 <refentrytitle><phrase>dma_pool_alloc</phrase></refentrytitle> 16091 <manvolnum>9</manvolnum> 16092 <refmiscinfo class="version">4.1.27</refmiscinfo> 16093</refmeta> 16094<refnamediv> 16095 <refname>dma_pool_alloc</refname> 16096 <refpurpose> 16097 get a block of consistent memory 16098 </refpurpose> 16099</refnamediv> 16100<refsynopsisdiv> 16101 <title>Synopsis</title> 16102 <funcsynopsis><funcprototype> 16103 <funcdef>void * <function>dma_pool_alloc </function></funcdef> 16104 <paramdef>struct dma_pool * <parameter>pool</parameter></paramdef> 16105 <paramdef>gfp_t <parameter>mem_flags</parameter></paramdef> 16106 <paramdef>dma_addr_t * <parameter>handle</parameter></paramdef> 16107 </funcprototype></funcsynopsis> 16108</refsynopsisdiv> 16109<refsect1> 16110 <title>Arguments</title> 16111 <variablelist> 16112 <varlistentry> 16113 <term><parameter>pool</parameter></term> 16114 <listitem> 16115 <para> 16116 dma pool that will produce the block 16117 </para> 16118 </listitem> 16119 </varlistentry> 16120 <varlistentry> 16121 <term><parameter>mem_flags</parameter></term> 16122 <listitem> 16123 <para> 16124 GFP_* bitmask 16125 </para> 16126 </listitem> 16127 </varlistentry> 16128 <varlistentry> 16129 <term><parameter>handle</parameter></term> 16130 <listitem> 16131 <para> 16132 pointer to dma address of block 16133 </para> 16134 </listitem> 16135 </varlistentry> 16136 </variablelist> 16137</refsect1> 16138<refsect1> 16139<title>Description</title> 16140<para> 16141 This returns the kernel virtual address of a currently unused block, 16142 and reports its dma address through the handle. 16143 If such a memory block can't be allocated, <constant>NULL</constant> is returned. 16144</para> 16145</refsect1> 16146</refentry> 16147 16148<refentry id="API-dma-pool-free"> 16149<refentryinfo> 16150 <title>LINUX</title> 16151 <productname>Kernel Hackers Manual</productname> 16152 <date>July 2017</date> 16153</refentryinfo> 16154<refmeta> 16155 <refentrytitle><phrase>dma_pool_free</phrase></refentrytitle> 16156 <manvolnum>9</manvolnum> 16157 <refmiscinfo class="version">4.1.27</refmiscinfo> 16158</refmeta> 16159<refnamediv> 16160 <refname>dma_pool_free</refname> 16161 <refpurpose> 16162 put block back into dma pool 16163 </refpurpose> 16164</refnamediv> 16165<refsynopsisdiv> 16166 <title>Synopsis</title> 16167 <funcsynopsis><funcprototype> 16168 <funcdef>void <function>dma_pool_free </function></funcdef> 16169 <paramdef>struct dma_pool * <parameter>pool</parameter></paramdef> 16170 <paramdef>void * <parameter>vaddr</parameter></paramdef> 16171 <paramdef>dma_addr_t <parameter>dma</parameter></paramdef> 16172 </funcprototype></funcsynopsis> 16173</refsynopsisdiv> 16174<refsect1> 16175 <title>Arguments</title> 16176 <variablelist> 16177 <varlistentry> 16178 <term><parameter>pool</parameter></term> 16179 <listitem> 16180 <para> 16181 the dma pool holding the block 16182 </para> 16183 </listitem> 16184 </varlistentry> 16185 <varlistentry> 16186 <term><parameter>vaddr</parameter></term> 16187 <listitem> 16188 <para> 16189 virtual address of block 16190 </para> 16191 </listitem> 16192 </varlistentry> 16193 <varlistentry> 16194 <term><parameter>dma</parameter></term> 16195 <listitem> 16196 <para> 16197 dma address of block 16198 </para> 16199 </listitem> 16200 </varlistentry> 16201 </variablelist> 16202</refsect1> 16203<refsect1> 16204<title>Description</title> 16205<para> 16206 Caller promises neither device nor driver will again touch this block 16207 unless it is first re-allocated. 16208</para> 16209</refsect1> 16210</refentry> 16211 16212<refentry id="API-dmam-pool-create"> 16213<refentryinfo> 16214 <title>LINUX</title> 16215 <productname>Kernel Hackers Manual</productname> 16216 <date>July 2017</date> 16217</refentryinfo> 16218<refmeta> 16219 <refentrytitle><phrase>dmam_pool_create</phrase></refentrytitle> 16220 <manvolnum>9</manvolnum> 16221 <refmiscinfo class="version">4.1.27</refmiscinfo> 16222</refmeta> 16223<refnamediv> 16224 <refname>dmam_pool_create</refname> 16225 <refpurpose> 16226 Managed <function>dma_pool_create</function> 16227 </refpurpose> 16228</refnamediv> 16229<refsynopsisdiv> 16230 <title>Synopsis</title> 16231 <funcsynopsis><funcprototype> 16232 <funcdef>struct dma_pool * <function>dmam_pool_create </function></funcdef> 16233 <paramdef>const char * <parameter>name</parameter></paramdef> 16234 <paramdef>struct device * <parameter>dev</parameter></paramdef> 16235 <paramdef>size_t <parameter>size</parameter></paramdef> 16236 <paramdef>size_t <parameter>align</parameter></paramdef> 16237 <paramdef>size_t <parameter>allocation</parameter></paramdef> 16238 </funcprototype></funcsynopsis> 16239</refsynopsisdiv> 16240<refsect1> 16241 <title>Arguments</title> 16242 <variablelist> 16243 <varlistentry> 16244 <term><parameter>name</parameter></term> 16245 <listitem> 16246 <para> 16247 name of pool, for diagnostics 16248 </para> 16249 </listitem> 16250 </varlistentry> 16251 <varlistentry> 16252 <term><parameter>dev</parameter></term> 16253 <listitem> 16254 <para> 16255 device that will be doing the DMA 16256 </para> 16257 </listitem> 16258 </varlistentry> 16259 <varlistentry> 16260 <term><parameter>size</parameter></term> 16261 <listitem> 16262 <para> 16263 size of the blocks in this pool. 16264 </para> 16265 </listitem> 16266 </varlistentry> 16267 <varlistentry> 16268 <term><parameter>align</parameter></term> 16269 <listitem> 16270 <para> 16271 alignment requirement for blocks; must be a power of two 16272 </para> 16273 </listitem> 16274 </varlistentry> 16275 <varlistentry> 16276 <term><parameter>allocation</parameter></term> 16277 <listitem> 16278 <para> 16279 returned blocks won't cross this boundary (or zero) 16280 </para> 16281 </listitem> 16282 </varlistentry> 16283 </variablelist> 16284</refsect1> 16285<refsect1> 16286<title>Description</title> 16287<para> 16288 Managed <function>dma_pool_create</function>. DMA pool created with this function is 16289 automatically destroyed on driver detach. 16290</para> 16291</refsect1> 16292</refentry> 16293 16294<refentry id="API-dmam-pool-destroy"> 16295<refentryinfo> 16296 <title>LINUX</title> 16297 <productname>Kernel Hackers Manual</productname> 16298 <date>July 2017</date> 16299</refentryinfo> 16300<refmeta> 16301 <refentrytitle><phrase>dmam_pool_destroy</phrase></refentrytitle> 16302 <manvolnum>9</manvolnum> 16303 <refmiscinfo class="version">4.1.27</refmiscinfo> 16304</refmeta> 16305<refnamediv> 16306 <refname>dmam_pool_destroy</refname> 16307 <refpurpose> 16308 Managed <function>dma_pool_destroy</function> 16309 </refpurpose> 16310</refnamediv> 16311<refsynopsisdiv> 16312 <title>Synopsis</title> 16313 <funcsynopsis><funcprototype> 16314 <funcdef>void <function>dmam_pool_destroy </function></funcdef> 16315 <paramdef>struct dma_pool * <parameter>pool</parameter></paramdef> 16316 </funcprototype></funcsynopsis> 16317</refsynopsisdiv> 16318<refsect1> 16319 <title>Arguments</title> 16320 <variablelist> 16321 <varlistentry> 16322 <term><parameter>pool</parameter></term> 16323 <listitem> 16324 <para> 16325 dma pool that will be destroyed 16326 </para> 16327 </listitem> 16328 </varlistentry> 16329 </variablelist> 16330</refsect1> 16331<refsect1> 16332<title>Description</title> 16333<para> 16334 Managed <function>dma_pool_destroy</function>. 16335</para> 16336</refsect1> 16337</refentry> 16338 16339<!-- mm/page-writeback.c --> 16340<refentry id="API-balance-dirty-pages-ratelimited"> 16341<refentryinfo> 16342 <title>LINUX</title> 16343 <productname>Kernel Hackers Manual</productname> 16344 <date>July 2017</date> 16345</refentryinfo> 16346<refmeta> 16347 <refentrytitle><phrase>balance_dirty_pages_ratelimited</phrase></refentrytitle> 16348 <manvolnum>9</manvolnum> 16349 <refmiscinfo class="version">4.1.27</refmiscinfo> 16350</refmeta> 16351<refnamediv> 16352 <refname>balance_dirty_pages_ratelimited</refname> 16353 <refpurpose> 16354 balance dirty memory state 16355 </refpurpose> 16356</refnamediv> 16357<refsynopsisdiv> 16358 <title>Synopsis</title> 16359 <funcsynopsis><funcprototype> 16360 <funcdef>void <function>balance_dirty_pages_ratelimited </function></funcdef> 16361 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 16362 </funcprototype></funcsynopsis> 16363</refsynopsisdiv> 16364<refsect1> 16365 <title>Arguments</title> 16366 <variablelist> 16367 <varlistentry> 16368 <term><parameter>mapping</parameter></term> 16369 <listitem> 16370 <para> 16371 address_space which was dirtied 16372 </para> 16373 </listitem> 16374 </varlistentry> 16375 </variablelist> 16376</refsect1> 16377<refsect1> 16378<title>Description</title> 16379<para> 16380 Processes which are dirtying memory should call in here once for each page 16381 which was newly dirtied. The function will periodically check the system's 16382 dirty state and will initiate writeback if needed. 16383 </para><para> 16384 16385 On really big machines, get_writeback_state is expensive, so try to avoid 16386 calling it too often (ratelimiting). But once we're over the dirty memory 16387 limit we decrease the ratelimiting by a lot, to prevent individual processes 16388 from overshooting the limit by (ratelimit_pages) each. 16389</para> 16390</refsect1> 16391</refentry> 16392 16393<refentry id="API-tag-pages-for-writeback"> 16394<refentryinfo> 16395 <title>LINUX</title> 16396 <productname>Kernel Hackers Manual</productname> 16397 <date>July 2017</date> 16398</refentryinfo> 16399<refmeta> 16400 <refentrytitle><phrase>tag_pages_for_writeback</phrase></refentrytitle> 16401 <manvolnum>9</manvolnum> 16402 <refmiscinfo class="version">4.1.27</refmiscinfo> 16403</refmeta> 16404<refnamediv> 16405 <refname>tag_pages_for_writeback</refname> 16406 <refpurpose> 16407 tag pages to be written by write_cache_pages 16408 </refpurpose> 16409</refnamediv> 16410<refsynopsisdiv> 16411 <title>Synopsis</title> 16412 <funcsynopsis><funcprototype> 16413 <funcdef>void <function>tag_pages_for_writeback </function></funcdef> 16414 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 16415 <paramdef>pgoff_t <parameter>start</parameter></paramdef> 16416 <paramdef>pgoff_t <parameter>end</parameter></paramdef> 16417 </funcprototype></funcsynopsis> 16418</refsynopsisdiv> 16419<refsect1> 16420 <title>Arguments</title> 16421 <variablelist> 16422 <varlistentry> 16423 <term><parameter>mapping</parameter></term> 16424 <listitem> 16425 <para> 16426 address space structure to write 16427 </para> 16428 </listitem> 16429 </varlistentry> 16430 <varlistentry> 16431 <term><parameter>start</parameter></term> 16432 <listitem> 16433 <para> 16434 starting page index 16435 </para> 16436 </listitem> 16437 </varlistentry> 16438 <varlistentry> 16439 <term><parameter>end</parameter></term> 16440 <listitem> 16441 <para> 16442 ending page index (inclusive) 16443 </para> 16444 </listitem> 16445 </varlistentry> 16446 </variablelist> 16447</refsect1> 16448<refsect1> 16449<title>Description</title> 16450<para> 16451 This function scans the page range from <parameter>start</parameter> to <parameter>end</parameter> (inclusive) and tags 16452 all pages that have DIRTY tag set with a special TOWRITE tag. The idea is 16453 that write_cache_pages (or whoever calls this function) will then use 16454 TOWRITE tag to identify pages eligible for writeback. This mechanism is 16455 used to avoid livelocking of writeback by a process steadily creating new 16456 dirty pages in the file (thus it is important for this function to be quick 16457 so that it can tag pages faster than a dirtying process can create them). 16458</para> 16459</refsect1> 16460</refentry> 16461 16462<refentry id="API-write-cache-pages"> 16463<refentryinfo> 16464 <title>LINUX</title> 16465 <productname>Kernel Hackers Manual</productname> 16466 <date>July 2017</date> 16467</refentryinfo> 16468<refmeta> 16469 <refentrytitle><phrase>write_cache_pages</phrase></refentrytitle> 16470 <manvolnum>9</manvolnum> 16471 <refmiscinfo class="version">4.1.27</refmiscinfo> 16472</refmeta> 16473<refnamediv> 16474 <refname>write_cache_pages</refname> 16475 <refpurpose> 16476 walk the list of dirty pages of the given address space and write all of them. 16477 </refpurpose> 16478</refnamediv> 16479<refsynopsisdiv> 16480 <title>Synopsis</title> 16481 <funcsynopsis><funcprototype> 16482 <funcdef>int <function>write_cache_pages </function></funcdef> 16483 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 16484 <paramdef>struct writeback_control * <parameter>wbc</parameter></paramdef> 16485 <paramdef>writepage_t <parameter>writepage</parameter></paramdef> 16486 <paramdef>void * <parameter>data</parameter></paramdef> 16487 </funcprototype></funcsynopsis> 16488</refsynopsisdiv> 16489<refsect1> 16490 <title>Arguments</title> 16491 <variablelist> 16492 <varlistentry> 16493 <term><parameter>mapping</parameter></term> 16494 <listitem> 16495 <para> 16496 address space structure to write 16497 </para> 16498 </listitem> 16499 </varlistentry> 16500 <varlistentry> 16501 <term><parameter>wbc</parameter></term> 16502 <listitem> 16503 <para> 16504 subtract the number of written pages from *<parameter>wbc</parameter>->nr_to_write 16505 </para> 16506 </listitem> 16507 </varlistentry> 16508 <varlistentry> 16509 <term><parameter>writepage</parameter></term> 16510 <listitem> 16511 <para> 16512 function called for each page 16513 </para> 16514 </listitem> 16515 </varlistentry> 16516 <varlistentry> 16517 <term><parameter>data</parameter></term> 16518 <listitem> 16519 <para> 16520 data passed to writepage function 16521 </para> 16522 </listitem> 16523 </varlistentry> 16524 </variablelist> 16525</refsect1> 16526<refsect1> 16527<title>Description</title> 16528<para> 16529 If a page is already under I/O, <function>write_cache_pages</function> skips it, even 16530 if it's dirty. This is desirable behaviour for memory-cleaning writeback, 16531 but it is INCORRECT for data-integrity system calls such as <function>fsync</function>. <function>fsync</function> 16532 and <function>msync</function> need to guarantee that all the data which was dirty at the time 16533 the call was made get new I/O started against them. If wbc->sync_mode is 16534 WB_SYNC_ALL then we were called for data integrity and we must wait for 16535 existing IO to complete. 16536 </para><para> 16537 16538 To avoid livelocks (when other process dirties new pages), we first tag 16539 pages which should be written back with TOWRITE tag and only then start 16540 writing them. For data-integrity sync we have to be careful so that we do 16541 not miss some pages (e.g., because some other process has cleared TOWRITE 16542 tag we set). The rule we follow is that TOWRITE tag can be cleared only 16543 by the process clearing the DIRTY tag (and submitting the page for IO). 16544</para> 16545</refsect1> 16546</refentry> 16547 16548<refentry id="API-generic-writepages"> 16549<refentryinfo> 16550 <title>LINUX</title> 16551 <productname>Kernel Hackers Manual</productname> 16552 <date>July 2017</date> 16553</refentryinfo> 16554<refmeta> 16555 <refentrytitle><phrase>generic_writepages</phrase></refentrytitle> 16556 <manvolnum>9</manvolnum> 16557 <refmiscinfo class="version">4.1.27</refmiscinfo> 16558</refmeta> 16559<refnamediv> 16560 <refname>generic_writepages</refname> 16561 <refpurpose> 16562 walk the list of dirty pages of the given address space and <function>writepage</function> all of them. 16563 </refpurpose> 16564</refnamediv> 16565<refsynopsisdiv> 16566 <title>Synopsis</title> 16567 <funcsynopsis><funcprototype> 16568 <funcdef>int <function>generic_writepages </function></funcdef> 16569 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 16570 <paramdef>struct writeback_control * <parameter>wbc</parameter></paramdef> 16571 </funcprototype></funcsynopsis> 16572</refsynopsisdiv> 16573<refsect1> 16574 <title>Arguments</title> 16575 <variablelist> 16576 <varlistentry> 16577 <term><parameter>mapping</parameter></term> 16578 <listitem> 16579 <para> 16580 address space structure to write 16581 </para> 16582 </listitem> 16583 </varlistentry> 16584 <varlistentry> 16585 <term><parameter>wbc</parameter></term> 16586 <listitem> 16587 <para> 16588 subtract the number of written pages from *<parameter>wbc</parameter>->nr_to_write 16589 </para> 16590 </listitem> 16591 </varlistentry> 16592 </variablelist> 16593</refsect1> 16594<refsect1> 16595<title>Description</title> 16596<para> 16597 This is a library function, which implements the <function>writepages</function> 16598 address_space_operation. 16599</para> 16600</refsect1> 16601</refentry> 16602 16603<refentry id="API-write-one-page"> 16604<refentryinfo> 16605 <title>LINUX</title> 16606 <productname>Kernel Hackers Manual</productname> 16607 <date>July 2017</date> 16608</refentryinfo> 16609<refmeta> 16610 <refentrytitle><phrase>write_one_page</phrase></refentrytitle> 16611 <manvolnum>9</manvolnum> 16612 <refmiscinfo class="version">4.1.27</refmiscinfo> 16613</refmeta> 16614<refnamediv> 16615 <refname>write_one_page</refname> 16616 <refpurpose> 16617 write out a single page and optionally wait on I/O 16618 </refpurpose> 16619</refnamediv> 16620<refsynopsisdiv> 16621 <title>Synopsis</title> 16622 <funcsynopsis><funcprototype> 16623 <funcdef>int <function>write_one_page </function></funcdef> 16624 <paramdef>struct page * <parameter>page</parameter></paramdef> 16625 <paramdef>int <parameter>wait</parameter></paramdef> 16626 </funcprototype></funcsynopsis> 16627</refsynopsisdiv> 16628<refsect1> 16629 <title>Arguments</title> 16630 <variablelist> 16631 <varlistentry> 16632 <term><parameter>page</parameter></term> 16633 <listitem> 16634 <para> 16635 the page to write 16636 </para> 16637 </listitem> 16638 </varlistentry> 16639 <varlistentry> 16640 <term><parameter>wait</parameter></term> 16641 <listitem> 16642 <para> 16643 if true, wait on writeout 16644 </para> 16645 </listitem> 16646 </varlistentry> 16647 </variablelist> 16648</refsect1> 16649<refsect1> 16650<title>Description</title> 16651<para> 16652 The page must be locked by the caller and will be unlocked upon return. 16653 </para><para> 16654 16655 <function>write_one_page</function> returns a negative error code if I/O failed. 16656</para> 16657</refsect1> 16658</refentry> 16659 16660<refentry id="API-wait-for-stable-page"> 16661<refentryinfo> 16662 <title>LINUX</title> 16663 <productname>Kernel Hackers Manual</productname> 16664 <date>July 2017</date> 16665</refentryinfo> 16666<refmeta> 16667 <refentrytitle><phrase>wait_for_stable_page</phrase></refentrytitle> 16668 <manvolnum>9</manvolnum> 16669 <refmiscinfo class="version">4.1.27</refmiscinfo> 16670</refmeta> 16671<refnamediv> 16672 <refname>wait_for_stable_page</refname> 16673 <refpurpose> 16674 wait for writeback to finish, if necessary. 16675 </refpurpose> 16676</refnamediv> 16677<refsynopsisdiv> 16678 <title>Synopsis</title> 16679 <funcsynopsis><funcprototype> 16680 <funcdef>void <function>wait_for_stable_page </function></funcdef> 16681 <paramdef>struct page * <parameter>page</parameter></paramdef> 16682 </funcprototype></funcsynopsis> 16683</refsynopsisdiv> 16684<refsect1> 16685 <title>Arguments</title> 16686 <variablelist> 16687 <varlistentry> 16688 <term><parameter>page</parameter></term> 16689 <listitem> 16690 <para> 16691 The page to wait on. 16692 </para> 16693 </listitem> 16694 </varlistentry> 16695 </variablelist> 16696</refsect1> 16697<refsect1> 16698<title>Description</title> 16699<para> 16700 This function determines if the given page is related to a backing device 16701 that requires page contents to be held stable during writeback. If so, then 16702 it will wait for any pending writeback to complete. 16703</para> 16704</refsect1> 16705</refentry> 16706 16707<!-- mm/truncate.c --> 16708<refentry id="API-truncate-inode-pages-range"> 16709<refentryinfo> 16710 <title>LINUX</title> 16711 <productname>Kernel Hackers Manual</productname> 16712 <date>July 2017</date> 16713</refentryinfo> 16714<refmeta> 16715 <refentrytitle><phrase>truncate_inode_pages_range</phrase></refentrytitle> 16716 <manvolnum>9</manvolnum> 16717 <refmiscinfo class="version">4.1.27</refmiscinfo> 16718</refmeta> 16719<refnamediv> 16720 <refname>truncate_inode_pages_range</refname> 16721 <refpurpose> 16722 truncate range of pages specified by start & end byte offsets 16723 </refpurpose> 16724</refnamediv> 16725<refsynopsisdiv> 16726 <title>Synopsis</title> 16727 <funcsynopsis><funcprototype> 16728 <funcdef>void <function>truncate_inode_pages_range </function></funcdef> 16729 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 16730 <paramdef>loff_t <parameter>lstart</parameter></paramdef> 16731 <paramdef>loff_t <parameter>lend</parameter></paramdef> 16732 </funcprototype></funcsynopsis> 16733</refsynopsisdiv> 16734<refsect1> 16735 <title>Arguments</title> 16736 <variablelist> 16737 <varlistentry> 16738 <term><parameter>mapping</parameter></term> 16739 <listitem> 16740 <para> 16741 mapping to truncate 16742 </para> 16743 </listitem> 16744 </varlistentry> 16745 <varlistentry> 16746 <term><parameter>lstart</parameter></term> 16747 <listitem> 16748 <para> 16749 offset from which to truncate 16750 </para> 16751 </listitem> 16752 </varlistentry> 16753 <varlistentry> 16754 <term><parameter>lend</parameter></term> 16755 <listitem> 16756 <para> 16757 offset to which to truncate (inclusive) 16758 </para> 16759 </listitem> 16760 </varlistentry> 16761 </variablelist> 16762</refsect1> 16763<refsect1> 16764<title>Description</title> 16765<para> 16766 Truncate the page cache, removing the pages that are between 16767 specified offsets (and zeroing out partial pages 16768 if lstart or lend + 1 is not page aligned). 16769 </para><para> 16770 16771 Truncate takes two passes - the first pass is nonblocking. It will not 16772 block on page locks and it will not block on writeback. The second pass 16773 will wait. This is to prevent as much IO as possible in the affected region. 16774 The first pass will remove most pages, so the search cost of the second pass 16775 is low. 16776 </para><para> 16777 16778 We pass down the cache-hot hint to the page freeing code. Even if the 16779 mapping is large, it is probably the case that the final pages are the most 16780 recently touched, and freeing happens in ascending file offset order. 16781 </para><para> 16782 16783 Note that since -><function>invalidatepage</function> accepts range to invalidate 16784 truncate_inode_pages_range is able to handle cases where lend + 1 is not 16785 page aligned properly. 16786</para> 16787</refsect1> 16788</refentry> 16789 16790<refentry id="API-truncate-inode-pages"> 16791<refentryinfo> 16792 <title>LINUX</title> 16793 <productname>Kernel Hackers Manual</productname> 16794 <date>July 2017</date> 16795</refentryinfo> 16796<refmeta> 16797 <refentrytitle><phrase>truncate_inode_pages</phrase></refentrytitle> 16798 <manvolnum>9</manvolnum> 16799 <refmiscinfo class="version">4.1.27</refmiscinfo> 16800</refmeta> 16801<refnamediv> 16802 <refname>truncate_inode_pages</refname> 16803 <refpurpose> 16804 truncate *all* the pages from an offset 16805 </refpurpose> 16806</refnamediv> 16807<refsynopsisdiv> 16808 <title>Synopsis</title> 16809 <funcsynopsis><funcprototype> 16810 <funcdef>void <function>truncate_inode_pages </function></funcdef> 16811 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 16812 <paramdef>loff_t <parameter>lstart</parameter></paramdef> 16813 </funcprototype></funcsynopsis> 16814</refsynopsisdiv> 16815<refsect1> 16816 <title>Arguments</title> 16817 <variablelist> 16818 <varlistentry> 16819 <term><parameter>mapping</parameter></term> 16820 <listitem> 16821 <para> 16822 mapping to truncate 16823 </para> 16824 </listitem> 16825 </varlistentry> 16826 <varlistentry> 16827 <term><parameter>lstart</parameter></term> 16828 <listitem> 16829 <para> 16830 offset from which to truncate 16831 </para> 16832 </listitem> 16833 </varlistentry> 16834 </variablelist> 16835</refsect1> 16836<refsect1> 16837<title>Description</title> 16838<para> 16839 Called under (and serialised by) inode->i_mutex. 16840</para> 16841</refsect1> 16842<refsect1> 16843<title>Note</title> 16844<para> 16845 When this function returns, there can be a page in the process of 16846 deletion (inside <function>__delete_from_page_cache</function>) in the specified range. Thus 16847 mapping->nrpages can be non-zero when this function returns even after 16848 truncation of the whole mapping. 16849</para> 16850</refsect1> 16851</refentry> 16852 16853<refentry id="API-truncate-inode-pages-final"> 16854<refentryinfo> 16855 <title>LINUX</title> 16856 <productname>Kernel Hackers Manual</productname> 16857 <date>July 2017</date> 16858</refentryinfo> 16859<refmeta> 16860 <refentrytitle><phrase>truncate_inode_pages_final</phrase></refentrytitle> 16861 <manvolnum>9</manvolnum> 16862 <refmiscinfo class="version">4.1.27</refmiscinfo> 16863</refmeta> 16864<refnamediv> 16865 <refname>truncate_inode_pages_final</refname> 16866 <refpurpose> 16867 truncate *all* pages before inode dies 16868 </refpurpose> 16869</refnamediv> 16870<refsynopsisdiv> 16871 <title>Synopsis</title> 16872 <funcsynopsis><funcprototype> 16873 <funcdef>void <function>truncate_inode_pages_final </function></funcdef> 16874 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 16875 </funcprototype></funcsynopsis> 16876</refsynopsisdiv> 16877<refsect1> 16878 <title>Arguments</title> 16879 <variablelist> 16880 <varlistentry> 16881 <term><parameter>mapping</parameter></term> 16882 <listitem> 16883 <para> 16884 mapping to truncate 16885 </para> 16886 </listitem> 16887 </varlistentry> 16888 </variablelist> 16889</refsect1> 16890<refsect1> 16891<title>Description</title> 16892<para> 16893 Called under (and serialized by) inode->i_mutex. 16894 </para><para> 16895 16896 Filesystems have to use this in the .evict_inode path to inform the 16897 VM that this is the final truncate and the inode is going away. 16898</para> 16899</refsect1> 16900</refentry> 16901 16902<refentry id="API-invalidate-mapping-pages"> 16903<refentryinfo> 16904 <title>LINUX</title> 16905 <productname>Kernel Hackers Manual</productname> 16906 <date>July 2017</date> 16907</refentryinfo> 16908<refmeta> 16909 <refentrytitle><phrase>invalidate_mapping_pages</phrase></refentrytitle> 16910 <manvolnum>9</manvolnum> 16911 <refmiscinfo class="version">4.1.27</refmiscinfo> 16912</refmeta> 16913<refnamediv> 16914 <refname>invalidate_mapping_pages</refname> 16915 <refpurpose> 16916 Invalidate all the unlocked pages of one inode 16917 </refpurpose> 16918</refnamediv> 16919<refsynopsisdiv> 16920 <title>Synopsis</title> 16921 <funcsynopsis><funcprototype> 16922 <funcdef>unsigned long <function>invalidate_mapping_pages </function></funcdef> 16923 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 16924 <paramdef>pgoff_t <parameter>start</parameter></paramdef> 16925 <paramdef>pgoff_t <parameter>end</parameter></paramdef> 16926 </funcprototype></funcsynopsis> 16927</refsynopsisdiv> 16928<refsect1> 16929 <title>Arguments</title> 16930 <variablelist> 16931 <varlistentry> 16932 <term><parameter>mapping</parameter></term> 16933 <listitem> 16934 <para> 16935 the address_space which holds the pages to invalidate 16936 </para> 16937 </listitem> 16938 </varlistentry> 16939 <varlistentry> 16940 <term><parameter>start</parameter></term> 16941 <listitem> 16942 <para> 16943 the offset 'from' which to invalidate 16944 </para> 16945 </listitem> 16946 </varlistentry> 16947 <varlistentry> 16948 <term><parameter>end</parameter></term> 16949 <listitem> 16950 <para> 16951 the offset 'to' which to invalidate (inclusive) 16952 </para> 16953 </listitem> 16954 </varlistentry> 16955 </variablelist> 16956</refsect1> 16957<refsect1> 16958<title>Description</title> 16959<para> 16960 This function only removes the unlocked pages, if you want to 16961 remove all the pages of one inode, you must call truncate_inode_pages. 16962 </para><para> 16963 16964 <function>invalidate_mapping_pages</function> will not block on IO activity. It will not 16965 invalidate pages which are dirty, locked, under writeback or mapped into 16966 pagetables. 16967</para> 16968</refsect1> 16969</refentry> 16970 16971<refentry id="API-invalidate-inode-pages2-range"> 16972<refentryinfo> 16973 <title>LINUX</title> 16974 <productname>Kernel Hackers Manual</productname> 16975 <date>July 2017</date> 16976</refentryinfo> 16977<refmeta> 16978 <refentrytitle><phrase>invalidate_inode_pages2_range</phrase></refentrytitle> 16979 <manvolnum>9</manvolnum> 16980 <refmiscinfo class="version">4.1.27</refmiscinfo> 16981</refmeta> 16982<refnamediv> 16983 <refname>invalidate_inode_pages2_range</refname> 16984 <refpurpose> 16985 remove range of pages from an address_space 16986 </refpurpose> 16987</refnamediv> 16988<refsynopsisdiv> 16989 <title>Synopsis</title> 16990 <funcsynopsis><funcprototype> 16991 <funcdef>int <function>invalidate_inode_pages2_range </function></funcdef> 16992 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 16993 <paramdef>pgoff_t <parameter>start</parameter></paramdef> 16994 <paramdef>pgoff_t <parameter>end</parameter></paramdef> 16995 </funcprototype></funcsynopsis> 16996</refsynopsisdiv> 16997<refsect1> 16998 <title>Arguments</title> 16999 <variablelist> 17000 <varlistentry> 17001 <term><parameter>mapping</parameter></term> 17002 <listitem> 17003 <para> 17004 the address_space 17005 </para> 17006 </listitem> 17007 </varlistentry> 17008 <varlistentry> 17009 <term><parameter>start</parameter></term> 17010 <listitem> 17011 <para> 17012 the page offset 'from' which to invalidate 17013 </para> 17014 </listitem> 17015 </varlistentry> 17016 <varlistentry> 17017 <term><parameter>end</parameter></term> 17018 <listitem> 17019 <para> 17020 the page offset 'to' which to invalidate (inclusive) 17021 </para> 17022 </listitem> 17023 </varlistentry> 17024 </variablelist> 17025</refsect1> 17026<refsect1> 17027<title>Description</title> 17028<para> 17029 Any pages which are found to be mapped into pagetables are unmapped prior to 17030 invalidation. 17031 </para><para> 17032 17033 Returns -EBUSY if any pages could not be invalidated. 17034</para> 17035</refsect1> 17036</refentry> 17037 17038<refentry id="API-invalidate-inode-pages2"> 17039<refentryinfo> 17040 <title>LINUX</title> 17041 <productname>Kernel Hackers Manual</productname> 17042 <date>July 2017</date> 17043</refentryinfo> 17044<refmeta> 17045 <refentrytitle><phrase>invalidate_inode_pages2</phrase></refentrytitle> 17046 <manvolnum>9</manvolnum> 17047 <refmiscinfo class="version">4.1.27</refmiscinfo> 17048</refmeta> 17049<refnamediv> 17050 <refname>invalidate_inode_pages2</refname> 17051 <refpurpose> 17052 remove all pages from an address_space 17053 </refpurpose> 17054</refnamediv> 17055<refsynopsisdiv> 17056 <title>Synopsis</title> 17057 <funcsynopsis><funcprototype> 17058 <funcdef>int <function>invalidate_inode_pages2 </function></funcdef> 17059 <paramdef>struct address_space * <parameter>mapping</parameter></paramdef> 17060 </funcprototype></funcsynopsis> 17061</refsynopsisdiv> 17062<refsect1> 17063 <title>Arguments</title> 17064 <variablelist> 17065 <varlistentry> 17066 <term><parameter>mapping</parameter></term> 17067 <listitem> 17068 <para> 17069 the address_space 17070 </para> 17071 </listitem> 17072 </varlistentry> 17073 </variablelist> 17074</refsect1> 17075<refsect1> 17076<title>Description</title> 17077<para> 17078 Any pages which are found to be mapped into pagetables are unmapped prior to 17079 invalidation. 17080 </para><para> 17081 17082 Returns -EBUSY if any pages could not be invalidated. 17083</para> 17084</refsect1> 17085</refentry> 17086 17087<refentry id="API-truncate-pagecache"> 17088<refentryinfo> 17089 <title>LINUX</title> 17090 <productname>Kernel Hackers Manual</productname> 17091 <date>July 2017</date> 17092</refentryinfo> 17093<refmeta> 17094 <refentrytitle><phrase>truncate_pagecache</phrase></refentrytitle> 17095 <manvolnum>9</manvolnum> 17096 <refmiscinfo class="version">4.1.27</refmiscinfo> 17097</refmeta> 17098<refnamediv> 17099 <refname>truncate_pagecache</refname> 17100 <refpurpose> 17101 unmap and remove pagecache that has been truncated 17102 </refpurpose> 17103</refnamediv> 17104<refsynopsisdiv> 17105 <title>Synopsis</title> 17106 <funcsynopsis><funcprototype> 17107 <funcdef>void <function>truncate_pagecache </function></funcdef> 17108 <paramdef>struct inode * <parameter>inode</parameter></paramdef> 17109 <paramdef>loff_t <parameter>newsize</parameter></paramdef> 17110 </funcprototype></funcsynopsis> 17111</refsynopsisdiv> 17112<refsect1> 17113 <title>Arguments</title> 17114 <variablelist> 17115 <varlistentry> 17116 <term><parameter>inode</parameter></term> 17117 <listitem> 17118 <para> 17119 inode 17120 </para> 17121 </listitem> 17122 </varlistentry> 17123 <varlistentry> 17124 <term><parameter>newsize</parameter></term> 17125 <listitem> 17126 <para> 17127 new file size 17128 </para> 17129 </listitem> 17130 </varlistentry> 17131 </variablelist> 17132</refsect1> 17133<refsect1> 17134<title>Description</title> 17135<para> 17136 inode's new i_size must already be written before truncate_pagecache 17137 is called. 17138 </para><para> 17139 17140 This function should typically be called before the filesystem 17141 releases resources associated with the freed range (eg. deallocates 17142 blocks). This way, pagecache will always stay logically coherent 17143 with on-disk format, and the filesystem would not have to deal with 17144 situations such as writepage being called for a page that has already 17145 had its underlying blocks deallocated. 17146</para> 17147</refsect1> 17148</refentry> 17149 17150<refentry id="API-truncate-setsize"> 17151<refentryinfo> 17152 <title>LINUX</title> 17153 <productname>Kernel Hackers Manual</productname> 17154 <date>July 2017</date> 17155</refentryinfo> 17156<refmeta> 17157 <refentrytitle><phrase>truncate_setsize</phrase></refentrytitle> 17158 <manvolnum>9</manvolnum> 17159 <refmiscinfo class="version">4.1.27</refmiscinfo> 17160</refmeta> 17161<refnamediv> 17162 <refname>truncate_setsize</refname> 17163 <refpurpose> 17164 update inode and pagecache for a new file size 17165 </refpurpose> 17166</refnamediv> 17167<refsynopsisdiv> 17168 <title>Synopsis</title> 17169 <funcsynopsis><funcprototype> 17170 <funcdef>void <function>truncate_setsize </function></funcdef> 17171 <paramdef>struct inode * <parameter>inode</parameter></paramdef> 17172 <paramdef>loff_t <parameter>newsize</parameter></paramdef> 17173 </funcprototype></funcsynopsis> 17174</refsynopsisdiv> 17175<refsect1> 17176 <title>Arguments</title> 17177 <variablelist> 17178 <varlistentry> 17179 <term><parameter>inode</parameter></term> 17180 <listitem> 17181 <para> 17182 inode 17183 </para> 17184 </listitem> 17185 </varlistentry> 17186 <varlistentry> 17187 <term><parameter>newsize</parameter></term> 17188 <listitem> 17189 <para> 17190 new file size 17191 </para> 17192 </listitem> 17193 </varlistentry> 17194 </variablelist> 17195</refsect1> 17196<refsect1> 17197<title>Description</title> 17198<para> 17199 truncate_setsize updates i_size and performs pagecache truncation (if 17200 necessary) to <parameter>newsize</parameter>. It will be typically be called from the filesystem's 17201 setattr function when ATTR_SIZE is passed in. 17202 </para><para> 17203 17204 Must be called with a lock serializing truncates and writes (generally 17205 i_mutex but e.g. xfs uses a different lock) and before all filesystem 17206 specific block truncation has been performed. 17207</para> 17208</refsect1> 17209</refentry> 17210 17211<refentry id="API-pagecache-isize-extended"> 17212<refentryinfo> 17213 <title>LINUX</title> 17214 <productname>Kernel Hackers Manual</productname> 17215 <date>July 2017</date> 17216</refentryinfo> 17217<refmeta> 17218 <refentrytitle><phrase>pagecache_isize_extended</phrase></refentrytitle> 17219 <manvolnum>9</manvolnum> 17220 <refmiscinfo class="version">4.1.27</refmiscinfo> 17221</refmeta> 17222<refnamediv> 17223 <refname>pagecache_isize_extended</refname> 17224 <refpurpose> 17225 update pagecache after extension of i_size 17226 </refpurpose> 17227</refnamediv> 17228<refsynopsisdiv> 17229 <title>Synopsis</title> 17230 <funcsynopsis><funcprototype> 17231 <funcdef>void <function>pagecache_isize_extended </function></funcdef> 17232 <paramdef>struct inode * <parameter>inode</parameter></paramdef> 17233 <paramdef>loff_t <parameter>from</parameter></paramdef> 17234 <paramdef>loff_t <parameter>to</parameter></paramdef> 17235 </funcprototype></funcsynopsis> 17236</refsynopsisdiv> 17237<refsect1> 17238 <title>Arguments</title> 17239 <variablelist> 17240 <varlistentry> 17241 <term><parameter>inode</parameter></term> 17242 <listitem> 17243 <para> 17244 inode for which i_size was extended 17245 </para> 17246 </listitem> 17247 </varlistentry> 17248 <varlistentry> 17249 <term><parameter>from</parameter></term> 17250 <listitem> 17251 <para> 17252 original inode size 17253 </para> 17254 </listitem> 17255 </varlistentry> 17256 <varlistentry> 17257 <term><parameter>to</parameter></term> 17258 <listitem> 17259 <para> 17260 new inode size 17261 </para> 17262 </listitem> 17263 </varlistentry> 17264 </variablelist> 17265</refsect1> 17266<refsect1> 17267<title>Description</title> 17268<para> 17269 Handle extension of inode size either caused by extending truncate or by 17270 write starting after current i_size. We mark the page straddling current 17271 i_size RO so that <function>page_mkwrite</function> is called on the nearest write access to 17272 the page. This way filesystem can be sure that <function>page_mkwrite</function> is called on 17273 the page before user writes to the page via mmap after the i_size has been 17274 changed. 17275 </para><para> 17276 17277 The function must be called after i_size is updated so that page fault 17278 coming after we unlock the page will already see the new i_size. 17279 The function must be called while we still hold i_mutex - this not only 17280 makes sure i_size is stable but also that userspace cannot observe new 17281 i_size value before we are prepared to store mmap writes at new inode size. 17282</para> 17283</refsect1> 17284</refentry> 17285 17286<refentry id="API-truncate-pagecache-range"> 17287<refentryinfo> 17288 <title>LINUX</title> 17289 <productname>Kernel Hackers Manual</productname> 17290 <date>July 2017</date> 17291</refentryinfo> 17292<refmeta> 17293 <refentrytitle><phrase>truncate_pagecache_range</phrase></refentrytitle> 17294 <manvolnum>9</manvolnum> 17295 <refmiscinfo class="version">4.1.27</refmiscinfo> 17296</refmeta> 17297<refnamediv> 17298 <refname>truncate_pagecache_range</refname> 17299 <refpurpose> 17300 unmap and remove pagecache that is hole-punched 17301 </refpurpose> 17302</refnamediv> 17303<refsynopsisdiv> 17304 <title>Synopsis</title> 17305 <funcsynopsis><funcprototype> 17306 <funcdef>void <function>truncate_pagecache_range </function></funcdef> 17307 <paramdef>struct inode * <parameter>inode</parameter></paramdef> 17308 <paramdef>loff_t <parameter>lstart</parameter></paramdef> 17309 <paramdef>loff_t <parameter>lend</parameter></paramdef> 17310 </funcprototype></funcsynopsis> 17311</refsynopsisdiv> 17312<refsect1> 17313 <title>Arguments</title> 17314 <variablelist> 17315 <varlistentry> 17316 <term><parameter>inode</parameter></term> 17317 <listitem> 17318 <para> 17319 inode 17320 </para> 17321 </listitem> 17322 </varlistentry> 17323 <varlistentry> 17324 <term><parameter>lstart</parameter></term> 17325 <listitem> 17326 <para> 17327 offset of beginning of hole 17328 </para> 17329 </listitem> 17330 </varlistentry> 17331 <varlistentry> 17332 <term><parameter>lend</parameter></term> 17333 <listitem> 17334 <para> 17335 offset of last byte of hole 17336 </para> 17337 </listitem> 17338 </varlistentry> 17339 </variablelist> 17340</refsect1> 17341<refsect1> 17342<title>Description</title> 17343<para> 17344 This function should typically be called before the filesystem 17345 releases resources associated with the freed range (eg. deallocates 17346 blocks). This way, pagecache will always stay logically coherent 17347 with on-disk format, and the filesystem would not have to deal with 17348 situations such as writepage being called for a page that has already 17349 had its underlying blocks deallocated. 17350</para> 17351</refsect1> 17352</refentry> 17353 17354 </sect1> 17355 </chapter> 17356 17357 17358 <chapter id="ipc"> 17359 <title>Kernel IPC facilities</title> 17360 17361 <sect1><title>IPC utilities</title> 17362<!-- ipc/util.c --> 17363<refentry id="API-ipc-init"> 17364<refentryinfo> 17365 <title>LINUX</title> 17366 <productname>Kernel Hackers Manual</productname> 17367 <date>July 2017</date> 17368</refentryinfo> 17369<refmeta> 17370 <refentrytitle><phrase>ipc_init</phrase></refentrytitle> 17371 <manvolnum>9</manvolnum> 17372 <refmiscinfo class="version">4.1.27</refmiscinfo> 17373</refmeta> 17374<refnamediv> 17375 <refname>ipc_init</refname> 17376 <refpurpose> 17377 initialise ipc subsystem 17378 </refpurpose> 17379</refnamediv> 17380<refsynopsisdiv> 17381 <title>Synopsis</title> 17382 <funcsynopsis><funcprototype> 17383 <funcdef>int <function>ipc_init </function></funcdef> 17384 <paramdef> <parameter>void</parameter></paramdef> 17385 </funcprototype></funcsynopsis> 17386</refsynopsisdiv> 17387<refsect1> 17388 <title>Arguments</title> 17389 <variablelist> 17390 <varlistentry> 17391 <term><parameter>void</parameter></term> 17392 <listitem> 17393 <para> 17394 no arguments 17395 </para> 17396 </listitem> 17397 </varlistentry> 17398 </variablelist> 17399</refsect1> 17400<refsect1> 17401<title>Description</title> 17402<para> 17403 </para><para> 17404 17405 The various sysv ipc resources (semaphores, messages and shared 17406 memory) are initialised. 17407 </para><para> 17408 17409 A callback routine is registered into the memory hotplug notifier 17410</para> 17411</refsect1> 17412<refsect1> 17413<title>chain</title> 17414<para> 17415 since msgmni scales to lowmem this callback routine will be 17416 called upon successful memory add / remove to recompute msmgni. 17417</para> 17418</refsect1> 17419</refentry> 17420 17421<refentry id="API-ipc-init-ids"> 17422<refentryinfo> 17423 <title>LINUX</title> 17424 <productname>Kernel Hackers Manual</productname> 17425 <date>July 2017</date> 17426</refentryinfo> 17427<refmeta> 17428 <refentrytitle><phrase>ipc_init_ids</phrase></refentrytitle> 17429 <manvolnum>9</manvolnum> 17430 <refmiscinfo class="version">4.1.27</refmiscinfo> 17431</refmeta> 17432<refnamediv> 17433 <refname>ipc_init_ids</refname> 17434 <refpurpose> 17435 initialise ipc identifiers 17436 </refpurpose> 17437</refnamediv> 17438<refsynopsisdiv> 17439 <title>Synopsis</title> 17440 <funcsynopsis><funcprototype> 17441 <funcdef>void <function>ipc_init_ids </function></funcdef> 17442 <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef> 17443 </funcprototype></funcsynopsis> 17444</refsynopsisdiv> 17445<refsect1> 17446 <title>Arguments</title> 17447 <variablelist> 17448 <varlistentry> 17449 <term><parameter>ids</parameter></term> 17450 <listitem> 17451 <para> 17452 ipc identifier set 17453 </para> 17454 </listitem> 17455 </varlistentry> 17456 </variablelist> 17457</refsect1> 17458<refsect1> 17459<title>Description</title> 17460<para> 17461 Set up the sequence range to use for the ipc identifier range (limited 17462 below IPCMNI) then initialise the ids idr. 17463</para> 17464</refsect1> 17465</refentry> 17466 17467<refentry id="API-ipc-init-proc-interface"> 17468<refentryinfo> 17469 <title>LINUX</title> 17470 <productname>Kernel Hackers Manual</productname> 17471 <date>July 2017</date> 17472</refentryinfo> 17473<refmeta> 17474 <refentrytitle><phrase>ipc_init_proc_interface</phrase></refentrytitle> 17475 <manvolnum>9</manvolnum> 17476 <refmiscinfo class="version">4.1.27</refmiscinfo> 17477</refmeta> 17478<refnamediv> 17479 <refname>ipc_init_proc_interface</refname> 17480 <refpurpose> 17481 create a proc interface for sysipc types using a seq_file interface. 17482 </refpurpose> 17483</refnamediv> 17484<refsynopsisdiv> 17485 <title>Synopsis</title> 17486 <funcsynopsis><funcprototype> 17487 <funcdef>void <function>ipc_init_proc_interface </function></funcdef> 17488 <paramdef>const char * <parameter>path</parameter></paramdef> 17489 <paramdef>const char * <parameter>header</parameter></paramdef> 17490 <paramdef>int <parameter>ids</parameter></paramdef> 17491 <paramdef>int (*<parameter>show</parameter>) 17492 <funcparams>struct seq_file *, void *</funcparams></paramdef> 17493 </funcprototype></funcsynopsis> 17494</refsynopsisdiv> 17495<refsect1> 17496 <title>Arguments</title> 17497 <variablelist> 17498 <varlistentry> 17499 <term><parameter>path</parameter></term> 17500 <listitem> 17501 <para> 17502 Path in procfs 17503 </para> 17504 </listitem> 17505 </varlistentry> 17506 <varlistentry> 17507 <term><parameter>header</parameter></term> 17508 <listitem> 17509 <para> 17510 Banner to be printed at the beginning of the file. 17511 </para> 17512 </listitem> 17513 </varlistentry> 17514 <varlistentry> 17515 <term><parameter>ids</parameter></term> 17516 <listitem> 17517 <para> 17518 ipc id table to iterate. 17519 </para> 17520 </listitem> 17521 </varlistentry> 17522 <varlistentry> 17523 <term><parameter>show</parameter></term> 17524 <listitem> 17525 <para> 17526 show routine. 17527 </para> 17528 </listitem> 17529 </varlistentry> 17530 </variablelist> 17531</refsect1> 17532</refentry> 17533 17534<refentry id="API-ipc-findkey"> 17535<refentryinfo> 17536 <title>LINUX</title> 17537 <productname>Kernel Hackers Manual</productname> 17538 <date>July 2017</date> 17539</refentryinfo> 17540<refmeta> 17541 <refentrytitle><phrase>ipc_findkey</phrase></refentrytitle> 17542 <manvolnum>9</manvolnum> 17543 <refmiscinfo class="version">4.1.27</refmiscinfo> 17544</refmeta> 17545<refnamediv> 17546 <refname>ipc_findkey</refname> 17547 <refpurpose> 17548 find a key in an ipc identifier set 17549 </refpurpose> 17550</refnamediv> 17551<refsynopsisdiv> 17552 <title>Synopsis</title> 17553 <funcsynopsis><funcprototype> 17554 <funcdef>struct kern_ipc_perm * <function>ipc_findkey </function></funcdef> 17555 <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef> 17556 <paramdef>key_t <parameter>key</parameter></paramdef> 17557 </funcprototype></funcsynopsis> 17558</refsynopsisdiv> 17559<refsect1> 17560 <title>Arguments</title> 17561 <variablelist> 17562 <varlistentry> 17563 <term><parameter>ids</parameter></term> 17564 <listitem> 17565 <para> 17566 ipc identifier set 17567 </para> 17568 </listitem> 17569 </varlistentry> 17570 <varlistentry> 17571 <term><parameter>key</parameter></term> 17572 <listitem> 17573 <para> 17574 key to find 17575 </para> 17576 </listitem> 17577 </varlistentry> 17578 </variablelist> 17579</refsect1> 17580<refsect1> 17581<title>Description</title> 17582<para> 17583 Returns the locked pointer to the ipc structure if found or NULL 17584 otherwise. If key is found ipc points to the owning ipc structure 17585 </para><para> 17586 17587 Called with ipc_ids.rwsem held. 17588</para> 17589</refsect1> 17590</refentry> 17591 17592<refentry id="API-ipc-get-maxid"> 17593<refentryinfo> 17594 <title>LINUX</title> 17595 <productname>Kernel Hackers Manual</productname> 17596 <date>July 2017</date> 17597</refentryinfo> 17598<refmeta> 17599 <refentrytitle><phrase>ipc_get_maxid</phrase></refentrytitle> 17600 <manvolnum>9</manvolnum> 17601 <refmiscinfo class="version">4.1.27</refmiscinfo> 17602</refmeta> 17603<refnamediv> 17604 <refname>ipc_get_maxid</refname> 17605 <refpurpose> 17606 get the last assigned id 17607 </refpurpose> 17608</refnamediv> 17609<refsynopsisdiv> 17610 <title>Synopsis</title> 17611 <funcsynopsis><funcprototype> 17612 <funcdef>int <function>ipc_get_maxid </function></funcdef> 17613 <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef> 17614 </funcprototype></funcsynopsis> 17615</refsynopsisdiv> 17616<refsect1> 17617 <title>Arguments</title> 17618 <variablelist> 17619 <varlistentry> 17620 <term><parameter>ids</parameter></term> 17621 <listitem> 17622 <para> 17623 ipc identifier set 17624 </para> 17625 </listitem> 17626 </varlistentry> 17627 </variablelist> 17628</refsect1> 17629<refsect1> 17630<title>Description</title> 17631<para> 17632 Called with ipc_ids.rwsem held. 17633</para> 17634</refsect1> 17635</refentry> 17636 17637<refentry id="API-ipc-addid"> 17638<refentryinfo> 17639 <title>LINUX</title> 17640 <productname>Kernel Hackers Manual</productname> 17641 <date>July 2017</date> 17642</refentryinfo> 17643<refmeta> 17644 <refentrytitle><phrase>ipc_addid</phrase></refentrytitle> 17645 <manvolnum>9</manvolnum> 17646 <refmiscinfo class="version">4.1.27</refmiscinfo> 17647</refmeta> 17648<refnamediv> 17649 <refname>ipc_addid</refname> 17650 <refpurpose> 17651 add an ipc identifier 17652 </refpurpose> 17653</refnamediv> 17654<refsynopsisdiv> 17655 <title>Synopsis</title> 17656 <funcsynopsis><funcprototype> 17657 <funcdef>int <function>ipc_addid </function></funcdef> 17658 <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef> 17659 <paramdef>struct kern_ipc_perm * <parameter>new</parameter></paramdef> 17660 <paramdef>int <parameter>size</parameter></paramdef> 17661 </funcprototype></funcsynopsis> 17662</refsynopsisdiv> 17663<refsect1> 17664 <title>Arguments</title> 17665 <variablelist> 17666 <varlistentry> 17667 <term><parameter>ids</parameter></term> 17668 <listitem> 17669 <para> 17670 ipc identifier set 17671 </para> 17672 </listitem> 17673 </varlistentry> 17674 <varlistentry> 17675 <term><parameter>new</parameter></term> 17676 <listitem> 17677 <para> 17678 new ipc permission set 17679 </para> 17680 </listitem> 17681 </varlistentry> 17682 <varlistentry> 17683 <term><parameter>size</parameter></term> 17684 <listitem> 17685 <para> 17686 limit for the number of used ids 17687 </para> 17688 </listitem> 17689 </varlistentry> 17690 </variablelist> 17691</refsect1> 17692<refsect1> 17693<title>Description</title> 17694<para> 17695 Add an entry 'new' to the ipc ids idr. The permissions object is 17696 initialised and the first free entry is set up and the id assigned 17697 is returned. The 'new' entry is returned in a locked state on success. 17698 On failure the entry is not locked and a negative err-code is returned. 17699 </para><para> 17700 17701 Called with writer ipc_ids.rwsem held. 17702</para> 17703</refsect1> 17704</refentry> 17705 17706<refentry id="API-ipcget-new"> 17707<refentryinfo> 17708 <title>LINUX</title> 17709 <productname>Kernel Hackers Manual</productname> 17710 <date>July 2017</date> 17711</refentryinfo> 17712<refmeta> 17713 <refentrytitle><phrase>ipcget_new</phrase></refentrytitle> 17714 <manvolnum>9</manvolnum> 17715 <refmiscinfo class="version">4.1.27</refmiscinfo> 17716</refmeta> 17717<refnamediv> 17718 <refname>ipcget_new</refname> 17719 <refpurpose> 17720 create a new ipc object 17721 </refpurpose> 17722</refnamediv> 17723<refsynopsisdiv> 17724 <title>Synopsis</title> 17725 <funcsynopsis><funcprototype> 17726 <funcdef>int <function>ipcget_new </function></funcdef> 17727 <paramdef>struct ipc_namespace * <parameter>ns</parameter></paramdef> 17728 <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef> 17729 <paramdef>const struct ipc_ops * <parameter>ops</parameter></paramdef> 17730 <paramdef>struct ipc_params * <parameter>params</parameter></paramdef> 17731 </funcprototype></funcsynopsis> 17732</refsynopsisdiv> 17733<refsect1> 17734 <title>Arguments</title> 17735 <variablelist> 17736 <varlistentry> 17737 <term><parameter>ns</parameter></term> 17738 <listitem> 17739 <para> 17740 ipc namespace 17741 </para> 17742 </listitem> 17743 </varlistentry> 17744 <varlistentry> 17745 <term><parameter>ids</parameter></term> 17746 <listitem> 17747 <para> 17748 ipc identifier set 17749 </para> 17750 </listitem> 17751 </varlistentry> 17752 <varlistentry> 17753 <term><parameter>ops</parameter></term> 17754 <listitem> 17755 <para> 17756 the actual creation routine to call 17757 </para> 17758 </listitem> 17759 </varlistentry> 17760 <varlistentry> 17761 <term><parameter>params</parameter></term> 17762 <listitem> 17763 <para> 17764 its parameters 17765 </para> 17766 </listitem> 17767 </varlistentry> 17768 </variablelist> 17769</refsect1> 17770<refsect1> 17771<title>Description</title> 17772<para> 17773 This routine is called by sys_msgget, <function>sys_semget</function> and <function>sys_shmget</function> 17774 when the key is IPC_PRIVATE. 17775</para> 17776</refsect1> 17777</refentry> 17778 17779<refentry id="API-ipc-check-perms"> 17780<refentryinfo> 17781 <title>LINUX</title> 17782 <productname>Kernel Hackers Manual</productname> 17783 <date>July 2017</date> 17784</refentryinfo> 17785<refmeta> 17786 <refentrytitle><phrase>ipc_check_perms</phrase></refentrytitle> 17787 <manvolnum>9</manvolnum> 17788 <refmiscinfo class="version">4.1.27</refmiscinfo> 17789</refmeta> 17790<refnamediv> 17791 <refname>ipc_check_perms</refname> 17792 <refpurpose> 17793 check security and permissions for an ipc object 17794 </refpurpose> 17795</refnamediv> 17796<refsynopsisdiv> 17797 <title>Synopsis</title> 17798 <funcsynopsis><funcprototype> 17799 <funcdef>int <function>ipc_check_perms </function></funcdef> 17800 <paramdef>struct ipc_namespace * <parameter>ns</parameter></paramdef> 17801 <paramdef>struct kern_ipc_perm * <parameter>ipcp</parameter></paramdef> 17802 <paramdef>const struct ipc_ops * <parameter>ops</parameter></paramdef> 17803 <paramdef>struct ipc_params * <parameter>params</parameter></paramdef> 17804 </funcprototype></funcsynopsis> 17805</refsynopsisdiv> 17806<refsect1> 17807 <title>Arguments</title> 17808 <variablelist> 17809 <varlistentry> 17810 <term><parameter>ns</parameter></term> 17811 <listitem> 17812 <para> 17813 ipc namespace 17814 </para> 17815 </listitem> 17816 </varlistentry> 17817 <varlistentry> 17818 <term><parameter>ipcp</parameter></term> 17819 <listitem> 17820 <para> 17821 ipc permission set 17822 </para> 17823 </listitem> 17824 </varlistentry> 17825 <varlistentry> 17826 <term><parameter>ops</parameter></term> 17827 <listitem> 17828 <para> 17829 the actual security routine to call 17830 </para> 17831 </listitem> 17832 </varlistentry> 17833 <varlistentry> 17834 <term><parameter>params</parameter></term> 17835 <listitem> 17836 <para> 17837 its parameters 17838 </para> 17839 </listitem> 17840 </varlistentry> 17841 </variablelist> 17842</refsect1> 17843<refsect1> 17844<title>Description</title> 17845<para> 17846 This routine is called by <function>sys_msgget</function>, <function>sys_semget</function> and <function>sys_shmget</function> 17847 when the key is not IPC_PRIVATE and that key already exists in the 17848 ds IDR. 17849 </para><para> 17850 17851 On success, the ipc id is returned. 17852 </para><para> 17853 17854 It is called with ipc_ids.rwsem and ipcp->lock held. 17855</para> 17856</refsect1> 17857</refentry> 17858 17859<refentry id="API-ipcget-public"> 17860<refentryinfo> 17861 <title>LINUX</title> 17862 <productname>Kernel Hackers Manual</productname> 17863 <date>July 2017</date> 17864</refentryinfo> 17865<refmeta> 17866 <refentrytitle><phrase>ipcget_public</phrase></refentrytitle> 17867 <manvolnum>9</manvolnum> 17868 <refmiscinfo class="version">4.1.27</refmiscinfo> 17869</refmeta> 17870<refnamediv> 17871 <refname>ipcget_public</refname> 17872 <refpurpose> 17873 get an ipc object or create a new one 17874 </refpurpose> 17875</refnamediv> 17876<refsynopsisdiv> 17877 <title>Synopsis</title> 17878 <funcsynopsis><funcprototype> 17879 <funcdef>int <function>ipcget_public </function></funcdef> 17880 <paramdef>struct ipc_namespace * <parameter>ns</parameter></paramdef> 17881 <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef> 17882 <paramdef>const struct ipc_ops * <parameter>ops</parameter></paramdef> 17883 <paramdef>struct ipc_params * <parameter>params</parameter></paramdef> 17884 </funcprototype></funcsynopsis> 17885</refsynopsisdiv> 17886<refsect1> 17887 <title>Arguments</title> 17888 <variablelist> 17889 <varlistentry> 17890 <term><parameter>ns</parameter></term> 17891 <listitem> 17892 <para> 17893 ipc namespace 17894 </para> 17895 </listitem> 17896 </varlistentry> 17897 <varlistentry> 17898 <term><parameter>ids</parameter></term> 17899 <listitem> 17900 <para> 17901 ipc identifier set 17902 </para> 17903 </listitem> 17904 </varlistentry> 17905 <varlistentry> 17906 <term><parameter>ops</parameter></term> 17907 <listitem> 17908 <para> 17909 the actual creation routine to call 17910 </para> 17911 </listitem> 17912 </varlistentry> 17913 <varlistentry> 17914 <term><parameter>params</parameter></term> 17915 <listitem> 17916 <para> 17917 its parameters 17918 </para> 17919 </listitem> 17920 </varlistentry> 17921 </variablelist> 17922</refsect1> 17923<refsect1> 17924<title>Description</title> 17925<para> 17926 This routine is called by sys_msgget, <function>sys_semget</function> and <function>sys_shmget</function> 17927 when the key is not IPC_PRIVATE. 17928 It adds a new entry if the key is not found and does some permission 17929 / security checkings if the key is found. 17930 </para><para> 17931 17932 On success, the ipc id is returned. 17933</para> 17934</refsect1> 17935</refentry> 17936 17937<refentry id="API-ipc-rmid"> 17938<refentryinfo> 17939 <title>LINUX</title> 17940 <productname>Kernel Hackers Manual</productname> 17941 <date>July 2017</date> 17942</refentryinfo> 17943<refmeta> 17944 <refentrytitle><phrase>ipc_rmid</phrase></refentrytitle> 17945 <manvolnum>9</manvolnum> 17946 <refmiscinfo class="version">4.1.27</refmiscinfo> 17947</refmeta> 17948<refnamediv> 17949 <refname>ipc_rmid</refname> 17950 <refpurpose> 17951 remove an ipc identifier 17952 </refpurpose> 17953</refnamediv> 17954<refsynopsisdiv> 17955 <title>Synopsis</title> 17956 <funcsynopsis><funcprototype> 17957 <funcdef>void <function>ipc_rmid </function></funcdef> 17958 <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef> 17959 <paramdef>struct kern_ipc_perm * <parameter>ipcp</parameter></paramdef> 17960 </funcprototype></funcsynopsis> 17961</refsynopsisdiv> 17962<refsect1> 17963 <title>Arguments</title> 17964 <variablelist> 17965 <varlistentry> 17966 <term><parameter>ids</parameter></term> 17967 <listitem> 17968 <para> 17969 ipc identifier set 17970 </para> 17971 </listitem> 17972 </varlistentry> 17973 <varlistentry> 17974 <term><parameter>ipcp</parameter></term> 17975 <listitem> 17976 <para> 17977 ipc perm structure containing the identifier to remove 17978 </para> 17979 </listitem> 17980 </varlistentry> 17981 </variablelist> 17982</refsect1> 17983<refsect1> 17984<title>Description</title> 17985<para> 17986 ipc_ids.rwsem (as a writer) and the spinlock for this ID are held 17987 before this function is called, and remain locked on the exit. 17988</para> 17989</refsect1> 17990</refentry> 17991 17992<refentry id="API-ipc-alloc"> 17993<refentryinfo> 17994 <title>LINUX</title> 17995 <productname>Kernel Hackers Manual</productname> 17996 <date>July 2017</date> 17997</refentryinfo> 17998<refmeta> 17999 <refentrytitle><phrase>ipc_alloc</phrase></refentrytitle> 18000 <manvolnum>9</manvolnum> 18001 <refmiscinfo class="version">4.1.27</refmiscinfo> 18002</refmeta> 18003<refnamediv> 18004 <refname>ipc_alloc</refname> 18005 <refpurpose> 18006 allocate ipc space 18007 </refpurpose> 18008</refnamediv> 18009<refsynopsisdiv> 18010 <title>Synopsis</title> 18011 <funcsynopsis><funcprototype> 18012 <funcdef>void * <function>ipc_alloc </function></funcdef> 18013 <paramdef>int <parameter>size</parameter></paramdef> 18014 </funcprototype></funcsynopsis> 18015</refsynopsisdiv> 18016<refsect1> 18017 <title>Arguments</title> 18018 <variablelist> 18019 <varlistentry> 18020 <term><parameter>size</parameter></term> 18021 <listitem> 18022 <para> 18023 size desired 18024 </para> 18025 </listitem> 18026 </varlistentry> 18027 </variablelist> 18028</refsect1> 18029<refsect1> 18030<title>Description</title> 18031<para> 18032 Allocate memory from the appropriate pools and return a pointer to it. 18033 NULL is returned if the allocation fails 18034</para> 18035</refsect1> 18036</refentry> 18037 18038<refentry id="API-ipc-free"> 18039<refentryinfo> 18040 <title>LINUX</title> 18041 <productname>Kernel Hackers Manual</productname> 18042 <date>July 2017</date> 18043</refentryinfo> 18044<refmeta> 18045 <refentrytitle><phrase>ipc_free</phrase></refentrytitle> 18046 <manvolnum>9</manvolnum> 18047 <refmiscinfo class="version">4.1.27</refmiscinfo> 18048</refmeta> 18049<refnamediv> 18050 <refname>ipc_free</refname> 18051 <refpurpose> 18052 free ipc space 18053 </refpurpose> 18054</refnamediv> 18055<refsynopsisdiv> 18056 <title>Synopsis</title> 18057 <funcsynopsis><funcprototype> 18058 <funcdef>void <function>ipc_free </function></funcdef> 18059 <paramdef>void * <parameter>ptr</parameter></paramdef> 18060 <paramdef>int <parameter>size</parameter></paramdef> 18061 </funcprototype></funcsynopsis> 18062</refsynopsisdiv> 18063<refsect1> 18064 <title>Arguments</title> 18065 <variablelist> 18066 <varlistentry> 18067 <term><parameter>ptr</parameter></term> 18068 <listitem> 18069 <para> 18070 pointer returned by ipc_alloc 18071 </para> 18072 </listitem> 18073 </varlistentry> 18074 <varlistentry> 18075 <term><parameter>size</parameter></term> 18076 <listitem> 18077 <para> 18078 size of block 18079 </para> 18080 </listitem> 18081 </varlistentry> 18082 </variablelist> 18083</refsect1> 18084<refsect1> 18085<title>Description</title> 18086<para> 18087 Free a block created with <function>ipc_alloc</function>. The caller must know the size 18088 used in the allocation call. 18089</para> 18090</refsect1> 18091</refentry> 18092 18093<refentry id="API-ipc-rcu-alloc"> 18094<refentryinfo> 18095 <title>LINUX</title> 18096 <productname>Kernel Hackers Manual</productname> 18097 <date>July 2017</date> 18098</refentryinfo> 18099<refmeta> 18100 <refentrytitle><phrase>ipc_rcu_alloc</phrase></refentrytitle> 18101 <manvolnum>9</manvolnum> 18102 <refmiscinfo class="version">4.1.27</refmiscinfo> 18103</refmeta> 18104<refnamediv> 18105 <refname>ipc_rcu_alloc</refname> 18106 <refpurpose> 18107 allocate ipc and rcu space 18108 </refpurpose> 18109</refnamediv> 18110<refsynopsisdiv> 18111 <title>Synopsis</title> 18112 <funcsynopsis><funcprototype> 18113 <funcdef>void * <function>ipc_rcu_alloc </function></funcdef> 18114 <paramdef>int <parameter>size</parameter></paramdef> 18115 </funcprototype></funcsynopsis> 18116</refsynopsisdiv> 18117<refsect1> 18118 <title>Arguments</title> 18119 <variablelist> 18120 <varlistentry> 18121 <term><parameter>size</parameter></term> 18122 <listitem> 18123 <para> 18124 size desired 18125 </para> 18126 </listitem> 18127 </varlistentry> 18128 </variablelist> 18129</refsect1> 18130<refsect1> 18131<title>Description</title> 18132<para> 18133 Allocate memory for the rcu header structure + the object. 18134 Returns the pointer to the object or NULL upon failure. 18135</para> 18136</refsect1> 18137</refentry> 18138 18139<refentry id="API-ipcperms"> 18140<refentryinfo> 18141 <title>LINUX</title> 18142 <productname>Kernel Hackers Manual</productname> 18143 <date>July 2017</date> 18144</refentryinfo> 18145<refmeta> 18146 <refentrytitle><phrase>ipcperms</phrase></refentrytitle> 18147 <manvolnum>9</manvolnum> 18148 <refmiscinfo class="version">4.1.27</refmiscinfo> 18149</refmeta> 18150<refnamediv> 18151 <refname>ipcperms</refname> 18152 <refpurpose> 18153 check ipc permissions 18154 </refpurpose> 18155</refnamediv> 18156<refsynopsisdiv> 18157 <title>Synopsis</title> 18158 <funcsynopsis><funcprototype> 18159 <funcdef>int <function>ipcperms </function></funcdef> 18160 <paramdef>struct ipc_namespace * <parameter>ns</parameter></paramdef> 18161 <paramdef>struct kern_ipc_perm * <parameter>ipcp</parameter></paramdef> 18162 <paramdef>short <parameter>flag</parameter></paramdef> 18163 </funcprototype></funcsynopsis> 18164</refsynopsisdiv> 18165<refsect1> 18166 <title>Arguments</title> 18167 <variablelist> 18168 <varlistentry> 18169 <term><parameter>ns</parameter></term> 18170 <listitem> 18171 <para> 18172 ipc namespace 18173 </para> 18174 </listitem> 18175 </varlistentry> 18176 <varlistentry> 18177 <term><parameter>ipcp</parameter></term> 18178 <listitem> 18179 <para> 18180 ipc permission set 18181 </para> 18182 </listitem> 18183 </varlistentry> 18184 <varlistentry> 18185 <term><parameter>flag</parameter></term> 18186 <listitem> 18187 <para> 18188 desired permission set 18189 </para> 18190 </listitem> 18191 </varlistentry> 18192 </variablelist> 18193</refsect1> 18194<refsect1> 18195<title>Description</title> 18196<para> 18197 Check user, group, other permissions for access 18198 to ipc resources. return 0 if allowed 18199 </para><para> 18200 18201 <parameter>flag</parameter> will most probably be 0 or S_...UGO from <linux/stat.h> 18202</para> 18203</refsect1> 18204</refentry> 18205 18206<refentry id="API-kernel-to-ipc64-perm"> 18207<refentryinfo> 18208 <title>LINUX</title> 18209 <productname>Kernel Hackers Manual</productname> 18210 <date>July 2017</date> 18211</refentryinfo> 18212<refmeta> 18213 <refentrytitle><phrase>kernel_to_ipc64_perm</phrase></refentrytitle> 18214 <manvolnum>9</manvolnum> 18215 <refmiscinfo class="version">4.1.27</refmiscinfo> 18216</refmeta> 18217<refnamediv> 18218 <refname>kernel_to_ipc64_perm</refname> 18219 <refpurpose> 18220 convert kernel ipc permissions to user 18221 </refpurpose> 18222</refnamediv> 18223<refsynopsisdiv> 18224 <title>Synopsis</title> 18225 <funcsynopsis><funcprototype> 18226 <funcdef>void <function>kernel_to_ipc64_perm </function></funcdef> 18227 <paramdef>struct kern_ipc_perm * <parameter>in</parameter></paramdef> 18228 <paramdef>struct ipc64_perm * <parameter>out</parameter></paramdef> 18229 </funcprototype></funcsynopsis> 18230</refsynopsisdiv> 18231<refsect1> 18232 <title>Arguments</title> 18233 <variablelist> 18234 <varlistentry> 18235 <term><parameter>in</parameter></term> 18236 <listitem> 18237 <para> 18238 kernel permissions 18239 </para> 18240 </listitem> 18241 </varlistentry> 18242 <varlistentry> 18243 <term><parameter>out</parameter></term> 18244 <listitem> 18245 <para> 18246 new style ipc permissions 18247 </para> 18248 </listitem> 18249 </varlistentry> 18250 </variablelist> 18251</refsect1> 18252<refsect1> 18253<title>Description</title> 18254<para> 18255 Turn the kernel object <parameter>in</parameter> into a set of permissions descriptions 18256 for returning to userspace (<parameter>out</parameter>). 18257</para> 18258</refsect1> 18259</refentry> 18260 18261<refentry id="API-ipc64-perm-to-ipc-perm"> 18262<refentryinfo> 18263 <title>LINUX</title> 18264 <productname>Kernel Hackers Manual</productname> 18265 <date>July 2017</date> 18266</refentryinfo> 18267<refmeta> 18268 <refentrytitle><phrase>ipc64_perm_to_ipc_perm</phrase></refentrytitle> 18269 <manvolnum>9</manvolnum> 18270 <refmiscinfo class="version">4.1.27</refmiscinfo> 18271</refmeta> 18272<refnamediv> 18273 <refname>ipc64_perm_to_ipc_perm</refname> 18274 <refpurpose> 18275 convert new ipc permissions to old 18276 </refpurpose> 18277</refnamediv> 18278<refsynopsisdiv> 18279 <title>Synopsis</title> 18280 <funcsynopsis><funcprototype> 18281 <funcdef>void <function>ipc64_perm_to_ipc_perm </function></funcdef> 18282 <paramdef>struct ipc64_perm * <parameter>in</parameter></paramdef> 18283 <paramdef>struct ipc_perm * <parameter>out</parameter></paramdef> 18284 </funcprototype></funcsynopsis> 18285</refsynopsisdiv> 18286<refsect1> 18287 <title>Arguments</title> 18288 <variablelist> 18289 <varlistentry> 18290 <term><parameter>in</parameter></term> 18291 <listitem> 18292 <para> 18293 new style ipc permissions 18294 </para> 18295 </listitem> 18296 </varlistentry> 18297 <varlistentry> 18298 <term><parameter>out</parameter></term> 18299 <listitem> 18300 <para> 18301 old style ipc permissions 18302 </para> 18303 </listitem> 18304 </varlistentry> 18305 </variablelist> 18306</refsect1> 18307<refsect1> 18308<title>Description</title> 18309<para> 18310 Turn the new style permissions object <parameter>in</parameter> into a compatibility 18311 object and store it into the <parameter>out</parameter> pointer. 18312</para> 18313</refsect1> 18314</refentry> 18315 18316<refentry id="API-ipc-obtain-object"> 18317<refentryinfo> 18318 <title>LINUX</title> 18319 <productname>Kernel Hackers Manual</productname> 18320 <date>July 2017</date> 18321</refentryinfo> 18322<refmeta> 18323 <refentrytitle><phrase>ipc_obtain_object</phrase></refentrytitle> 18324 <manvolnum>9</manvolnum> 18325 <refmiscinfo class="version">4.1.27</refmiscinfo> 18326</refmeta> 18327<refnamediv> 18328 <refname>ipc_obtain_object</refname> 18329 <refpurpose> 18330 </refpurpose> 18331</refnamediv> 18332<refsynopsisdiv> 18333 <title>Synopsis</title> 18334 <funcsynopsis><funcprototype> 18335 <funcdef>struct kern_ipc_perm * <function>ipc_obtain_object </function></funcdef> 18336 <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef> 18337 <paramdef>int <parameter>id</parameter></paramdef> 18338 </funcprototype></funcsynopsis> 18339</refsynopsisdiv> 18340<refsect1> 18341 <title>Arguments</title> 18342 <variablelist> 18343 <varlistentry> 18344 <term><parameter>ids</parameter></term> 18345 <listitem> 18346 <para> 18347 ipc identifier set 18348 </para> 18349 </listitem> 18350 </varlistentry> 18351 <varlistentry> 18352 <term><parameter>id</parameter></term> 18353 <listitem> 18354 <para> 18355 ipc id to look for 18356 </para> 18357 </listitem> 18358 </varlistentry> 18359 </variablelist> 18360</refsect1> 18361<refsect1> 18362<title>Description</title> 18363<para> 18364 Look for an id in the ipc ids idr and return associated ipc object. 18365 </para><para> 18366 18367 Call inside the RCU critical section. 18368 The ipc object is *not* locked on exit. 18369</para> 18370</refsect1> 18371</refentry> 18372 18373<refentry id="API-ipc-lock"> 18374<refentryinfo> 18375 <title>LINUX</title> 18376 <productname>Kernel Hackers Manual</productname> 18377 <date>July 2017</date> 18378</refentryinfo> 18379<refmeta> 18380 <refentrytitle><phrase>ipc_lock</phrase></refentrytitle> 18381 <manvolnum>9</manvolnum> 18382 <refmiscinfo class="version">4.1.27</refmiscinfo> 18383</refmeta> 18384<refnamediv> 18385 <refname>ipc_lock</refname> 18386 <refpurpose> 18387 lock an ipc structure without rwsem held 18388 </refpurpose> 18389</refnamediv> 18390<refsynopsisdiv> 18391 <title>Synopsis</title> 18392 <funcsynopsis><funcprototype> 18393 <funcdef>struct kern_ipc_perm * <function>ipc_lock </function></funcdef> 18394 <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef> 18395 <paramdef>int <parameter>id</parameter></paramdef> 18396 </funcprototype></funcsynopsis> 18397</refsynopsisdiv> 18398<refsect1> 18399 <title>Arguments</title> 18400 <variablelist> 18401 <varlistentry> 18402 <term><parameter>ids</parameter></term> 18403 <listitem> 18404 <para> 18405 ipc identifier set 18406 </para> 18407 </listitem> 18408 </varlistentry> 18409 <varlistentry> 18410 <term><parameter>id</parameter></term> 18411 <listitem> 18412 <para> 18413 ipc id to look for 18414 </para> 18415 </listitem> 18416 </varlistentry> 18417 </variablelist> 18418</refsect1> 18419<refsect1> 18420<title>Description</title> 18421<para> 18422 Look for an id in the ipc ids idr and lock the associated ipc object. 18423 </para><para> 18424 18425 The ipc object is locked on successful exit. 18426</para> 18427</refsect1> 18428</refentry> 18429 18430<refentry id="API-ipc-obtain-object-check"> 18431<refentryinfo> 18432 <title>LINUX</title> 18433 <productname>Kernel Hackers Manual</productname> 18434 <date>July 2017</date> 18435</refentryinfo> 18436<refmeta> 18437 <refentrytitle><phrase>ipc_obtain_object_check</phrase></refentrytitle> 18438 <manvolnum>9</manvolnum> 18439 <refmiscinfo class="version">4.1.27</refmiscinfo> 18440</refmeta> 18441<refnamediv> 18442 <refname>ipc_obtain_object_check</refname> 18443 <refpurpose> 18444 </refpurpose> 18445</refnamediv> 18446<refsynopsisdiv> 18447 <title>Synopsis</title> 18448 <funcsynopsis><funcprototype> 18449 <funcdef>struct kern_ipc_perm * <function>ipc_obtain_object_check </function></funcdef> 18450 <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef> 18451 <paramdef>int <parameter>id</parameter></paramdef> 18452 </funcprototype></funcsynopsis> 18453</refsynopsisdiv> 18454<refsect1> 18455 <title>Arguments</title> 18456 <variablelist> 18457 <varlistentry> 18458 <term><parameter>ids</parameter></term> 18459 <listitem> 18460 <para> 18461 ipc identifier set 18462 </para> 18463 </listitem> 18464 </varlistentry> 18465 <varlistentry> 18466 <term><parameter>id</parameter></term> 18467 <listitem> 18468 <para> 18469 ipc id to look for 18470 </para> 18471 </listitem> 18472 </varlistentry> 18473 </variablelist> 18474</refsect1> 18475<refsect1> 18476<title>Description</title> 18477<para> 18478 Similar to <function>ipc_obtain_object</function> but also checks 18479 the ipc object reference counter. 18480 </para><para> 18481 18482 Call inside the RCU critical section. 18483 The ipc object is *not* locked on exit. 18484</para> 18485</refsect1> 18486</refentry> 18487 18488<refentry id="API-ipcget"> 18489<refentryinfo> 18490 <title>LINUX</title> 18491 <productname>Kernel Hackers Manual</productname> 18492 <date>July 2017</date> 18493</refentryinfo> 18494<refmeta> 18495 <refentrytitle><phrase>ipcget</phrase></refentrytitle> 18496 <manvolnum>9</manvolnum> 18497 <refmiscinfo class="version">4.1.27</refmiscinfo> 18498</refmeta> 18499<refnamediv> 18500 <refname>ipcget</refname> 18501 <refpurpose> 18502 Common sys_*<function>get</function> code 18503 </refpurpose> 18504</refnamediv> 18505<refsynopsisdiv> 18506 <title>Synopsis</title> 18507 <funcsynopsis><funcprototype> 18508 <funcdef>int <function>ipcget </function></funcdef> 18509 <paramdef>struct ipc_namespace * <parameter>ns</parameter></paramdef> 18510 <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef> 18511 <paramdef>const struct ipc_ops * <parameter>ops</parameter></paramdef> 18512 <paramdef>struct ipc_params * <parameter>params</parameter></paramdef> 18513 </funcprototype></funcsynopsis> 18514</refsynopsisdiv> 18515<refsect1> 18516 <title>Arguments</title> 18517 <variablelist> 18518 <varlistentry> 18519 <term><parameter>ns</parameter></term> 18520 <listitem> 18521 <para> 18522 namespace 18523 </para> 18524 </listitem> 18525 </varlistentry> 18526 <varlistentry> 18527 <term><parameter>ids</parameter></term> 18528 <listitem> 18529 <para> 18530 ipc identifier set 18531 </para> 18532 </listitem> 18533 </varlistentry> 18534 <varlistentry> 18535 <term><parameter>ops</parameter></term> 18536 <listitem> 18537 <para> 18538 operations to be called on ipc object creation, permission checks 18539 and further checks 18540 </para> 18541 </listitem> 18542 </varlistentry> 18543 <varlistentry> 18544 <term><parameter>params</parameter></term> 18545 <listitem> 18546 <para> 18547 the parameters needed by the previous operations. 18548 </para> 18549 </listitem> 18550 </varlistentry> 18551 </variablelist> 18552</refsect1> 18553<refsect1> 18554<title>Description</title> 18555<para> 18556 Common routine called by <function>sys_msgget</function>, <function>sys_semget</function> and <function>sys_shmget</function>. 18557</para> 18558</refsect1> 18559</refentry> 18560 18561<refentry id="API-ipc-update-perm"> 18562<refentryinfo> 18563 <title>LINUX</title> 18564 <productname>Kernel Hackers Manual</productname> 18565 <date>July 2017</date> 18566</refentryinfo> 18567<refmeta> 18568 <refentrytitle><phrase>ipc_update_perm</phrase></refentrytitle> 18569 <manvolnum>9</manvolnum> 18570 <refmiscinfo class="version">4.1.27</refmiscinfo> 18571</refmeta> 18572<refnamediv> 18573 <refname>ipc_update_perm</refname> 18574 <refpurpose> 18575 update the permissions of an ipc object 18576 </refpurpose> 18577</refnamediv> 18578<refsynopsisdiv> 18579 <title>Synopsis</title> 18580 <funcsynopsis><funcprototype> 18581 <funcdef>int <function>ipc_update_perm </function></funcdef> 18582 <paramdef>struct ipc64_perm * <parameter>in</parameter></paramdef> 18583 <paramdef>struct kern_ipc_perm * <parameter>out</parameter></paramdef> 18584 </funcprototype></funcsynopsis> 18585</refsynopsisdiv> 18586<refsect1> 18587 <title>Arguments</title> 18588 <variablelist> 18589 <varlistentry> 18590 <term><parameter>in</parameter></term> 18591 <listitem> 18592 <para> 18593 the permission given as input. 18594 </para> 18595 </listitem> 18596 </varlistentry> 18597 <varlistentry> 18598 <term><parameter>out</parameter></term> 18599 <listitem> 18600 <para> 18601 the permission of the ipc to set. 18602 </para> 18603 </listitem> 18604 </varlistentry> 18605 </variablelist> 18606</refsect1> 18607</refentry> 18608 18609<refentry id="API-ipcctl-pre-down-nolock"> 18610<refentryinfo> 18611 <title>LINUX</title> 18612 <productname>Kernel Hackers Manual</productname> 18613 <date>July 2017</date> 18614</refentryinfo> 18615<refmeta> 18616 <refentrytitle><phrase>ipcctl_pre_down_nolock</phrase></refentrytitle> 18617 <manvolnum>9</manvolnum> 18618 <refmiscinfo class="version">4.1.27</refmiscinfo> 18619</refmeta> 18620<refnamediv> 18621 <refname>ipcctl_pre_down_nolock</refname> 18622 <refpurpose> 18623 retrieve an ipc and check permissions for some IPC_XXX cmd 18624 </refpurpose> 18625</refnamediv> 18626<refsynopsisdiv> 18627 <title>Synopsis</title> 18628 <funcsynopsis><funcprototype> 18629 <funcdef>struct kern_ipc_perm * <function>ipcctl_pre_down_nolock </function></funcdef> 18630 <paramdef>struct ipc_namespace * <parameter>ns</parameter></paramdef> 18631 <paramdef>struct ipc_ids * <parameter>ids</parameter></paramdef> 18632 <paramdef>int <parameter>id</parameter></paramdef> 18633 <paramdef>int <parameter>cmd</parameter></paramdef> 18634 <paramdef>struct ipc64_perm * <parameter>perm</parameter></paramdef> 18635 <paramdef>int <parameter>extra_perm</parameter></paramdef> 18636 </funcprototype></funcsynopsis> 18637</refsynopsisdiv> 18638<refsect1> 18639 <title>Arguments</title> 18640 <variablelist> 18641 <varlistentry> 18642 <term><parameter>ns</parameter></term> 18643 <listitem> 18644 <para> 18645 ipc namespace 18646 </para> 18647 </listitem> 18648 </varlistentry> 18649 <varlistentry> 18650 <term><parameter>ids</parameter></term> 18651 <listitem> 18652 <para> 18653 the table of ids where to look for the ipc 18654 </para> 18655 </listitem> 18656 </varlistentry> 18657 <varlistentry> 18658 <term><parameter>id</parameter></term> 18659 <listitem> 18660 <para> 18661 the id of the ipc to retrieve 18662 </para> 18663 </listitem> 18664 </varlistentry> 18665 <varlistentry> 18666 <term><parameter>cmd</parameter></term> 18667 <listitem> 18668 <para> 18669 the cmd to check 18670 </para> 18671 </listitem> 18672 </varlistentry> 18673 <varlistentry> 18674 <term><parameter>perm</parameter></term> 18675 <listitem> 18676 <para> 18677 the permission to set 18678 </para> 18679 </listitem> 18680 </varlistentry> 18681 <varlistentry> 18682 <term><parameter>extra_perm</parameter></term> 18683 <listitem> 18684 <para> 18685 one extra permission parameter used by msq 18686 </para> 18687 </listitem> 18688 </varlistentry> 18689 </variablelist> 18690</refsect1> 18691<refsect1> 18692<title>Description</title> 18693<para> 18694 This function does some common audit and permissions check for some IPC_XXX 18695 cmd and is called from semctl_down, shmctl_down and msgctl_down. 18696 It must be called without any lock held and 18697 - retrieves the ipc with the given id in the given table. 18698 - performs some audit and permission check, depending on the given cmd 18699 - returns a pointer to the ipc object or otherwise, the corresponding error. 18700 </para><para> 18701 18702 Call holding the both the rwsem and the rcu read lock. 18703</para> 18704</refsect1> 18705</refentry> 18706 18707<refentry id="API-ipc-parse-version"> 18708<refentryinfo> 18709 <title>LINUX</title> 18710 <productname>Kernel Hackers Manual</productname> 18711 <date>July 2017</date> 18712</refentryinfo> 18713<refmeta> 18714 <refentrytitle><phrase>ipc_parse_version</phrase></refentrytitle> 18715 <manvolnum>9</manvolnum> 18716 <refmiscinfo class="version">4.1.27</refmiscinfo> 18717</refmeta> 18718<refnamediv> 18719 <refname>ipc_parse_version</refname> 18720 <refpurpose> 18721 ipc call version 18722 </refpurpose> 18723</refnamediv> 18724<refsynopsisdiv> 18725 <title>Synopsis</title> 18726 <funcsynopsis><funcprototype> 18727 <funcdef>int <function>ipc_parse_version </function></funcdef> 18728 <paramdef>int * <parameter>cmd</parameter></paramdef> 18729 </funcprototype></funcsynopsis> 18730</refsynopsisdiv> 18731<refsect1> 18732 <title>Arguments</title> 18733 <variablelist> 18734 <varlistentry> 18735 <term><parameter>cmd</parameter></term> 18736 <listitem> 18737 <para> 18738 pointer to command 18739 </para> 18740 </listitem> 18741 </varlistentry> 18742 </variablelist> 18743</refsect1> 18744<refsect1> 18745<title>Description</title> 18746<para> 18747 Return IPC_64 for new style IPC and IPC_OLD for old style IPC. 18748 The <parameter>cmd</parameter> value is turned from an encoding command and version into 18749 just the command code. 18750</para> 18751</refsect1> 18752</refentry> 18753 18754 </sect1> 18755 </chapter> 18756 18757 <chapter id="kfifo"> 18758 <title>FIFO Buffer</title> 18759 <sect1><title>kfifo interface</title> 18760<!-- include/linux/kfifo.h --> 18761<refentry id="API-DECLARE-KFIFO-PTR"> 18762<refentryinfo> 18763 <title>LINUX</title> 18764 <productname>Kernel Hackers Manual</productname> 18765 <date>July 2017</date> 18766</refentryinfo> 18767<refmeta> 18768 <refentrytitle><phrase>DECLARE_KFIFO_PTR</phrase></refentrytitle> 18769 <manvolnum>9</manvolnum> 18770 <refmiscinfo class="version">4.1.27</refmiscinfo> 18771</refmeta> 18772<refnamediv> 18773 <refname>DECLARE_KFIFO_PTR</refname> 18774 <refpurpose> 18775 macro to declare a fifo pointer object 18776 </refpurpose> 18777</refnamediv> 18778<refsynopsisdiv> 18779 <title>Synopsis</title> 18780 <funcsynopsis><funcprototype> 18781 <funcdef> <function>DECLARE_KFIFO_PTR </function></funcdef> 18782 <paramdef> <parameter>fifo</parameter></paramdef> 18783 <paramdef> <parameter>type</parameter></paramdef> 18784 </funcprototype></funcsynopsis> 18785</refsynopsisdiv> 18786<refsect1> 18787 <title>Arguments</title> 18788 <variablelist> 18789 <varlistentry> 18790 <term><parameter>fifo</parameter></term> 18791 <listitem> 18792 <para> 18793 name of the declared fifo 18794 </para> 18795 </listitem> 18796 </varlistentry> 18797 <varlistentry> 18798 <term><parameter>type</parameter></term> 18799 <listitem> 18800 <para> 18801 type of the fifo elements 18802 </para> 18803 </listitem> 18804 </varlistentry> 18805 </variablelist> 18806</refsect1> 18807</refentry> 18808 18809<refentry id="API-DECLARE-KFIFO"> 18810<refentryinfo> 18811 <title>LINUX</title> 18812 <productname>Kernel Hackers Manual</productname> 18813 <date>July 2017</date> 18814</refentryinfo> 18815<refmeta> 18816 <refentrytitle><phrase>DECLARE_KFIFO</phrase></refentrytitle> 18817 <manvolnum>9</manvolnum> 18818 <refmiscinfo class="version">4.1.27</refmiscinfo> 18819</refmeta> 18820<refnamediv> 18821 <refname>DECLARE_KFIFO</refname> 18822 <refpurpose> 18823 macro to declare a fifo object 18824 </refpurpose> 18825</refnamediv> 18826<refsynopsisdiv> 18827 <title>Synopsis</title> 18828 <funcsynopsis><funcprototype> 18829 <funcdef> <function>DECLARE_KFIFO </function></funcdef> 18830 <paramdef> <parameter>fifo</parameter></paramdef> 18831 <paramdef> <parameter>type</parameter></paramdef> 18832 <paramdef> <parameter>size</parameter></paramdef> 18833 </funcprototype></funcsynopsis> 18834</refsynopsisdiv> 18835<refsect1> 18836 <title>Arguments</title> 18837 <variablelist> 18838 <varlistentry> 18839 <term><parameter>fifo</parameter></term> 18840 <listitem> 18841 <para> 18842 name of the declared fifo 18843 </para> 18844 </listitem> 18845 </varlistentry> 18846 <varlistentry> 18847 <term><parameter>type</parameter></term> 18848 <listitem> 18849 <para> 18850 type of the fifo elements 18851 </para> 18852 </listitem> 18853 </varlistentry> 18854 <varlistentry> 18855 <term><parameter>size</parameter></term> 18856 <listitem> 18857 <para> 18858 the number of elements in the fifo, this must be a power of 2 18859 </para> 18860 </listitem> 18861 </varlistentry> 18862 </variablelist> 18863</refsect1> 18864</refentry> 18865 18866<refentry id="API-INIT-KFIFO"> 18867<refentryinfo> 18868 <title>LINUX</title> 18869 <productname>Kernel Hackers Manual</productname> 18870 <date>July 2017</date> 18871</refentryinfo> 18872<refmeta> 18873 <refentrytitle><phrase>INIT_KFIFO</phrase></refentrytitle> 18874 <manvolnum>9</manvolnum> 18875 <refmiscinfo class="version">4.1.27</refmiscinfo> 18876</refmeta> 18877<refnamediv> 18878 <refname>INIT_KFIFO</refname> 18879 <refpurpose> 18880 Initialize a fifo declared by DECLARE_KFIFO 18881 </refpurpose> 18882</refnamediv> 18883<refsynopsisdiv> 18884 <title>Synopsis</title> 18885 <funcsynopsis><funcprototype> 18886 <funcdef> <function>INIT_KFIFO </function></funcdef> 18887 <paramdef> <parameter>fifo</parameter></paramdef> 18888 </funcprototype></funcsynopsis> 18889</refsynopsisdiv> 18890<refsect1> 18891 <title>Arguments</title> 18892 <variablelist> 18893 <varlistentry> 18894 <term><parameter>fifo</parameter></term> 18895 <listitem> 18896 <para> 18897 name of the declared fifo datatype 18898 </para> 18899 </listitem> 18900 </varlistentry> 18901 </variablelist> 18902</refsect1> 18903</refentry> 18904 18905<refentry id="API-DEFINE-KFIFO"> 18906<refentryinfo> 18907 <title>LINUX</title> 18908 <productname>Kernel Hackers Manual</productname> 18909 <date>July 2017</date> 18910</refentryinfo> 18911<refmeta> 18912 <refentrytitle><phrase>DEFINE_KFIFO</phrase></refentrytitle> 18913 <manvolnum>9</manvolnum> 18914 <refmiscinfo class="version">4.1.27</refmiscinfo> 18915</refmeta> 18916<refnamediv> 18917 <refname>DEFINE_KFIFO</refname> 18918 <refpurpose> 18919 macro to define and initialize a fifo 18920 </refpurpose> 18921</refnamediv> 18922<refsynopsisdiv> 18923 <title>Synopsis</title> 18924 <funcsynopsis><funcprototype> 18925 <funcdef> <function>DEFINE_KFIFO </function></funcdef> 18926 <paramdef> <parameter>fifo</parameter></paramdef> 18927 <paramdef> <parameter>type</parameter></paramdef> 18928 <paramdef> <parameter>size</parameter></paramdef> 18929 </funcprototype></funcsynopsis> 18930</refsynopsisdiv> 18931<refsect1> 18932 <title>Arguments</title> 18933 <variablelist> 18934 <varlistentry> 18935 <term><parameter>fifo</parameter></term> 18936 <listitem> 18937 <para> 18938 name of the declared fifo datatype 18939 </para> 18940 </listitem> 18941 </varlistentry> 18942 <varlistentry> 18943 <term><parameter>type</parameter></term> 18944 <listitem> 18945 <para> 18946 type of the fifo elements 18947 </para> 18948 </listitem> 18949 </varlistentry> 18950 <varlistentry> 18951 <term><parameter>size</parameter></term> 18952 <listitem> 18953 <para> 18954 the number of elements in the fifo, this must be a power of 2 18955 </para> 18956 </listitem> 18957 </varlistentry> 18958 </variablelist> 18959</refsect1> 18960<refsect1> 18961<title>Note</title> 18962<para> 18963 the macro can be used for global and local fifo data type variables. 18964</para> 18965</refsect1> 18966</refentry> 18967 18968<refentry id="API-kfifo-initialized"> 18969<refentryinfo> 18970 <title>LINUX</title> 18971 <productname>Kernel Hackers Manual</productname> 18972 <date>July 2017</date> 18973</refentryinfo> 18974<refmeta> 18975 <refentrytitle><phrase>kfifo_initialized</phrase></refentrytitle> 18976 <manvolnum>9</manvolnum> 18977 <refmiscinfo class="version">4.1.27</refmiscinfo> 18978</refmeta> 18979<refnamediv> 18980 <refname>kfifo_initialized</refname> 18981 <refpurpose> 18982 Check if the fifo is initialized 18983 </refpurpose> 18984</refnamediv> 18985<refsynopsisdiv> 18986 <title>Synopsis</title> 18987 <funcsynopsis><funcprototype> 18988 <funcdef> <function>kfifo_initialized </function></funcdef> 18989 <paramdef> <parameter>fifo</parameter></paramdef> 18990 </funcprototype></funcsynopsis> 18991</refsynopsisdiv> 18992<refsect1> 18993 <title>Arguments</title> 18994 <variablelist> 18995 <varlistentry> 18996 <term><parameter>fifo</parameter></term> 18997 <listitem> 18998 <para> 18999 address of the fifo to check 19000 </para> 19001 </listitem> 19002 </varlistentry> 19003 </variablelist> 19004</refsect1> 19005<refsect1> 19006<title>Description</title> 19007<para> 19008 Return <constant>true</constant> if fifo is initialized, otherwise <constant>false</constant>. 19009 Assumes the fifo was 0 before. 19010</para> 19011</refsect1> 19012</refentry> 19013 19014<refentry id="API-kfifo-esize"> 19015<refentryinfo> 19016 <title>LINUX</title> 19017 <productname>Kernel Hackers Manual</productname> 19018 <date>July 2017</date> 19019</refentryinfo> 19020<refmeta> 19021 <refentrytitle><phrase>kfifo_esize</phrase></refentrytitle> 19022 <manvolnum>9</manvolnum> 19023 <refmiscinfo class="version">4.1.27</refmiscinfo> 19024</refmeta> 19025<refnamediv> 19026 <refname>kfifo_esize</refname> 19027 <refpurpose> 19028 returns the size of the element managed by the fifo 19029 </refpurpose> 19030</refnamediv> 19031<refsynopsisdiv> 19032 <title>Synopsis</title> 19033 <funcsynopsis><funcprototype> 19034 <funcdef> <function>kfifo_esize </function></funcdef> 19035 <paramdef> <parameter>fifo</parameter></paramdef> 19036 </funcprototype></funcsynopsis> 19037</refsynopsisdiv> 19038<refsect1> 19039 <title>Arguments</title> 19040 <variablelist> 19041 <varlistentry> 19042 <term><parameter>fifo</parameter></term> 19043 <listitem> 19044 <para> 19045 address of the fifo to be used 19046 </para> 19047 </listitem> 19048 </varlistentry> 19049 </variablelist> 19050</refsect1> 19051</refentry> 19052 19053<refentry id="API-kfifo-recsize"> 19054<refentryinfo> 19055 <title>LINUX</title> 19056 <productname>Kernel Hackers Manual</productname> 19057 <date>July 2017</date> 19058</refentryinfo> 19059<refmeta> 19060 <refentrytitle><phrase>kfifo_recsize</phrase></refentrytitle> 19061 <manvolnum>9</manvolnum> 19062 <refmiscinfo class="version">4.1.27</refmiscinfo> 19063</refmeta> 19064<refnamediv> 19065 <refname>kfifo_recsize</refname> 19066 <refpurpose> 19067 returns the size of the record length field 19068 </refpurpose> 19069</refnamediv> 19070<refsynopsisdiv> 19071 <title>Synopsis</title> 19072 <funcsynopsis><funcprototype> 19073 <funcdef> <function>kfifo_recsize </function></funcdef> 19074 <paramdef> <parameter>fifo</parameter></paramdef> 19075 </funcprototype></funcsynopsis> 19076</refsynopsisdiv> 19077<refsect1> 19078 <title>Arguments</title> 19079 <variablelist> 19080 <varlistentry> 19081 <term><parameter>fifo</parameter></term> 19082 <listitem> 19083 <para> 19084 address of the fifo to be used 19085 </para> 19086 </listitem> 19087 </varlistentry> 19088 </variablelist> 19089</refsect1> 19090</refentry> 19091 19092<refentry id="API-kfifo-size"> 19093<refentryinfo> 19094 <title>LINUX</title> 19095 <productname>Kernel Hackers Manual</productname> 19096 <date>July 2017</date> 19097</refentryinfo> 19098<refmeta> 19099 <refentrytitle><phrase>kfifo_size</phrase></refentrytitle> 19100 <manvolnum>9</manvolnum> 19101 <refmiscinfo class="version">4.1.27</refmiscinfo> 19102</refmeta> 19103<refnamediv> 19104 <refname>kfifo_size</refname> 19105 <refpurpose> 19106 returns the size of the fifo in elements 19107 </refpurpose> 19108</refnamediv> 19109<refsynopsisdiv> 19110 <title>Synopsis</title> 19111 <funcsynopsis><funcprototype> 19112 <funcdef> <function>kfifo_size </function></funcdef> 19113 <paramdef> <parameter>fifo</parameter></paramdef> 19114 </funcprototype></funcsynopsis> 19115</refsynopsisdiv> 19116<refsect1> 19117 <title>Arguments</title> 19118 <variablelist> 19119 <varlistentry> 19120 <term><parameter>fifo</parameter></term> 19121 <listitem> 19122 <para> 19123 address of the fifo to be used 19124 </para> 19125 </listitem> 19126 </varlistentry> 19127 </variablelist> 19128</refsect1> 19129</refentry> 19130 19131<refentry id="API-kfifo-reset"> 19132<refentryinfo> 19133 <title>LINUX</title> 19134 <productname>Kernel Hackers Manual</productname> 19135 <date>July 2017</date> 19136</refentryinfo> 19137<refmeta> 19138 <refentrytitle><phrase>kfifo_reset</phrase></refentrytitle> 19139 <manvolnum>9</manvolnum> 19140 <refmiscinfo class="version">4.1.27</refmiscinfo> 19141</refmeta> 19142<refnamediv> 19143 <refname>kfifo_reset</refname> 19144 <refpurpose> 19145 removes the entire fifo content 19146 </refpurpose> 19147</refnamediv> 19148<refsynopsisdiv> 19149 <title>Synopsis</title> 19150 <funcsynopsis><funcprototype> 19151 <funcdef> <function>kfifo_reset </function></funcdef> 19152 <paramdef> <parameter>fifo</parameter></paramdef> 19153 </funcprototype></funcsynopsis> 19154</refsynopsisdiv> 19155<refsect1> 19156 <title>Arguments</title> 19157 <variablelist> 19158 <varlistentry> 19159 <term><parameter>fifo</parameter></term> 19160 <listitem> 19161 <para> 19162 address of the fifo to be used 19163 </para> 19164 </listitem> 19165 </varlistentry> 19166 </variablelist> 19167</refsect1> 19168<refsect1> 19169<title>Note</title> 19170<para> 19171 usage of <function>kfifo_reset</function> is dangerous. It should be only called when the 19172 fifo is exclusived locked or when it is secured that no other thread is 19173 accessing the fifo. 19174</para> 19175</refsect1> 19176</refentry> 19177 19178<refentry id="API-kfifo-reset-out"> 19179<refentryinfo> 19180 <title>LINUX</title> 19181 <productname>Kernel Hackers Manual</productname> 19182 <date>July 2017</date> 19183</refentryinfo> 19184<refmeta> 19185 <refentrytitle><phrase>kfifo_reset_out</phrase></refentrytitle> 19186 <manvolnum>9</manvolnum> 19187 <refmiscinfo class="version">4.1.27</refmiscinfo> 19188</refmeta> 19189<refnamediv> 19190 <refname>kfifo_reset_out</refname> 19191 <refpurpose> 19192 skip fifo content 19193 </refpurpose> 19194</refnamediv> 19195<refsynopsisdiv> 19196 <title>Synopsis</title> 19197 <funcsynopsis><funcprototype> 19198 <funcdef> <function>kfifo_reset_out </function></funcdef> 19199 <paramdef> <parameter>fifo</parameter></paramdef> 19200 </funcprototype></funcsynopsis> 19201</refsynopsisdiv> 19202<refsect1> 19203 <title>Arguments</title> 19204 <variablelist> 19205 <varlistentry> 19206 <term><parameter>fifo</parameter></term> 19207 <listitem> 19208 <para> 19209 address of the fifo to be used 19210 </para> 19211 </listitem> 19212 </varlistentry> 19213 </variablelist> 19214</refsect1> 19215<refsect1> 19216<title>Note</title> 19217<para> 19218 The usage of <function>kfifo_reset_out</function> is safe until it will be only called 19219 from the reader thread and there is only one concurrent reader. Otherwise 19220 it is dangerous and must be handled in the same way as <function>kfifo_reset</function>. 19221</para> 19222</refsect1> 19223</refentry> 19224 19225<refentry id="API-kfifo-len"> 19226<refentryinfo> 19227 <title>LINUX</title> 19228 <productname>Kernel Hackers Manual</productname> 19229 <date>July 2017</date> 19230</refentryinfo> 19231<refmeta> 19232 <refentrytitle><phrase>kfifo_len</phrase></refentrytitle> 19233 <manvolnum>9</manvolnum> 19234 <refmiscinfo class="version">4.1.27</refmiscinfo> 19235</refmeta> 19236<refnamediv> 19237 <refname>kfifo_len</refname> 19238 <refpurpose> 19239 returns the number of used elements in the fifo 19240 </refpurpose> 19241</refnamediv> 19242<refsynopsisdiv> 19243 <title>Synopsis</title> 19244 <funcsynopsis><funcprototype> 19245 <funcdef> <function>kfifo_len </function></funcdef> 19246 <paramdef> <parameter>fifo</parameter></paramdef> 19247 </funcprototype></funcsynopsis> 19248</refsynopsisdiv> 19249<refsect1> 19250 <title>Arguments</title> 19251 <variablelist> 19252 <varlistentry> 19253 <term><parameter>fifo</parameter></term> 19254 <listitem> 19255 <para> 19256 address of the fifo to be used 19257 </para> 19258 </listitem> 19259 </varlistentry> 19260 </variablelist> 19261</refsect1> 19262</refentry> 19263 19264<refentry id="API-kfifo-is-empty"> 19265<refentryinfo> 19266 <title>LINUX</title> 19267 <productname>Kernel Hackers Manual</productname> 19268 <date>July 2017</date> 19269</refentryinfo> 19270<refmeta> 19271 <refentrytitle><phrase>kfifo_is_empty</phrase></refentrytitle> 19272 <manvolnum>9</manvolnum> 19273 <refmiscinfo class="version">4.1.27</refmiscinfo> 19274</refmeta> 19275<refnamediv> 19276 <refname>kfifo_is_empty</refname> 19277 <refpurpose> 19278 returns true if the fifo is empty 19279 </refpurpose> 19280</refnamediv> 19281<refsynopsisdiv> 19282 <title>Synopsis</title> 19283 <funcsynopsis><funcprototype> 19284 <funcdef> <function>kfifo_is_empty </function></funcdef> 19285 <paramdef> <parameter>fifo</parameter></paramdef> 19286 </funcprototype></funcsynopsis> 19287</refsynopsisdiv> 19288<refsect1> 19289 <title>Arguments</title> 19290 <variablelist> 19291 <varlistentry> 19292 <term><parameter>fifo</parameter></term> 19293 <listitem> 19294 <para> 19295 address of the fifo to be used 19296 </para> 19297 </listitem> 19298 </varlistentry> 19299 </variablelist> 19300</refsect1> 19301</refentry> 19302 19303<refentry id="API-kfifo-is-full"> 19304<refentryinfo> 19305 <title>LINUX</title> 19306 <productname>Kernel Hackers Manual</productname> 19307 <date>July 2017</date> 19308</refentryinfo> 19309<refmeta> 19310 <refentrytitle><phrase>kfifo_is_full</phrase></refentrytitle> 19311 <manvolnum>9</manvolnum> 19312 <refmiscinfo class="version">4.1.27</refmiscinfo> 19313</refmeta> 19314<refnamediv> 19315 <refname>kfifo_is_full</refname> 19316 <refpurpose> 19317 returns true if the fifo is full 19318 </refpurpose> 19319</refnamediv> 19320<refsynopsisdiv> 19321 <title>Synopsis</title> 19322 <funcsynopsis><funcprototype> 19323 <funcdef> <function>kfifo_is_full </function></funcdef> 19324 <paramdef> <parameter>fifo</parameter></paramdef> 19325 </funcprototype></funcsynopsis> 19326</refsynopsisdiv> 19327<refsect1> 19328 <title>Arguments</title> 19329 <variablelist> 19330 <varlistentry> 19331 <term><parameter>fifo</parameter></term> 19332 <listitem> 19333 <para> 19334 address of the fifo to be used 19335 </para> 19336 </listitem> 19337 </varlistentry> 19338 </variablelist> 19339</refsect1> 19340</refentry> 19341 19342<refentry id="API-kfifo-avail"> 19343<refentryinfo> 19344 <title>LINUX</title> 19345 <productname>Kernel Hackers Manual</productname> 19346 <date>July 2017</date> 19347</refentryinfo> 19348<refmeta> 19349 <refentrytitle><phrase>kfifo_avail</phrase></refentrytitle> 19350 <manvolnum>9</manvolnum> 19351 <refmiscinfo class="version">4.1.27</refmiscinfo> 19352</refmeta> 19353<refnamediv> 19354 <refname>kfifo_avail</refname> 19355 <refpurpose> 19356 returns the number of unused elements in the fifo 19357 </refpurpose> 19358</refnamediv> 19359<refsynopsisdiv> 19360 <title>Synopsis</title> 19361 <funcsynopsis><funcprototype> 19362 <funcdef> <function>kfifo_avail </function></funcdef> 19363 <paramdef> <parameter>fifo</parameter></paramdef> 19364 </funcprototype></funcsynopsis> 19365</refsynopsisdiv> 19366<refsect1> 19367 <title>Arguments</title> 19368 <variablelist> 19369 <varlistentry> 19370 <term><parameter>fifo</parameter></term> 19371 <listitem> 19372 <para> 19373 address of the fifo to be used 19374 </para> 19375 </listitem> 19376 </varlistentry> 19377 </variablelist> 19378</refsect1> 19379</refentry> 19380 19381<refentry id="API-kfifo-skip"> 19382<refentryinfo> 19383 <title>LINUX</title> 19384 <productname>Kernel Hackers Manual</productname> 19385 <date>July 2017</date> 19386</refentryinfo> 19387<refmeta> 19388 <refentrytitle><phrase>kfifo_skip</phrase></refentrytitle> 19389 <manvolnum>9</manvolnum> 19390 <refmiscinfo class="version">4.1.27</refmiscinfo> 19391</refmeta> 19392<refnamediv> 19393 <refname>kfifo_skip</refname> 19394 <refpurpose> 19395 skip output data 19396 </refpurpose> 19397</refnamediv> 19398<refsynopsisdiv> 19399 <title>Synopsis</title> 19400 <funcsynopsis><funcprototype> 19401 <funcdef> <function>kfifo_skip </function></funcdef> 19402 <paramdef> <parameter>fifo</parameter></paramdef> 19403 </funcprototype></funcsynopsis> 19404</refsynopsisdiv> 19405<refsect1> 19406 <title>Arguments</title> 19407 <variablelist> 19408 <varlistentry> 19409 <term><parameter>fifo</parameter></term> 19410 <listitem> 19411 <para> 19412 address of the fifo to be used 19413 </para> 19414 </listitem> 19415 </varlistentry> 19416 </variablelist> 19417</refsect1> 19418</refentry> 19419 19420<refentry id="API-kfifo-peek-len"> 19421<refentryinfo> 19422 <title>LINUX</title> 19423 <productname>Kernel Hackers Manual</productname> 19424 <date>July 2017</date> 19425</refentryinfo> 19426<refmeta> 19427 <refentrytitle><phrase>kfifo_peek_len</phrase></refentrytitle> 19428 <manvolnum>9</manvolnum> 19429 <refmiscinfo class="version">4.1.27</refmiscinfo> 19430</refmeta> 19431<refnamediv> 19432 <refname>kfifo_peek_len</refname> 19433 <refpurpose> 19434 gets the size of the next fifo record 19435 </refpurpose> 19436</refnamediv> 19437<refsynopsisdiv> 19438 <title>Synopsis</title> 19439 <funcsynopsis><funcprototype> 19440 <funcdef> <function>kfifo_peek_len </function></funcdef> 19441 <paramdef> <parameter>fifo</parameter></paramdef> 19442 </funcprototype></funcsynopsis> 19443</refsynopsisdiv> 19444<refsect1> 19445 <title>Arguments</title> 19446 <variablelist> 19447 <varlistentry> 19448 <term><parameter>fifo</parameter></term> 19449 <listitem> 19450 <para> 19451 address of the fifo to be used 19452 </para> 19453 </listitem> 19454 </varlistentry> 19455 </variablelist> 19456</refsect1> 19457<refsect1> 19458<title>Description</title> 19459<para> 19460 This function returns the size of the next fifo record in number of bytes. 19461</para> 19462</refsect1> 19463</refentry> 19464 19465<refentry id="API-kfifo-alloc"> 19466<refentryinfo> 19467 <title>LINUX</title> 19468 <productname>Kernel Hackers Manual</productname> 19469 <date>July 2017</date> 19470</refentryinfo> 19471<refmeta> 19472 <refentrytitle><phrase>kfifo_alloc</phrase></refentrytitle> 19473 <manvolnum>9</manvolnum> 19474 <refmiscinfo class="version">4.1.27</refmiscinfo> 19475</refmeta> 19476<refnamediv> 19477 <refname>kfifo_alloc</refname> 19478 <refpurpose> 19479 dynamically allocates a new fifo buffer 19480 </refpurpose> 19481</refnamediv> 19482<refsynopsisdiv> 19483 <title>Synopsis</title> 19484 <funcsynopsis><funcprototype> 19485 <funcdef> <function>kfifo_alloc </function></funcdef> 19486 <paramdef> <parameter>fifo</parameter></paramdef> 19487 <paramdef> <parameter>size</parameter></paramdef> 19488 <paramdef> <parameter>gfp_mask</parameter></paramdef> 19489 </funcprototype></funcsynopsis> 19490</refsynopsisdiv> 19491<refsect1> 19492 <title>Arguments</title> 19493 <variablelist> 19494 <varlistentry> 19495 <term><parameter>fifo</parameter></term> 19496 <listitem> 19497 <para> 19498 pointer to the fifo 19499 </para> 19500 </listitem> 19501 </varlistentry> 19502 <varlistentry> 19503 <term><parameter>size</parameter></term> 19504 <listitem> 19505 <para> 19506 the number of elements in the fifo, this must be a power of 2 19507 </para> 19508 </listitem> 19509 </varlistentry> 19510 <varlistentry> 19511 <term><parameter>gfp_mask</parameter></term> 19512 <listitem> 19513 <para> 19514 get_free_pages mask, passed to <function>kmalloc</function> 19515 </para> 19516 </listitem> 19517 </varlistentry> 19518 </variablelist> 19519</refsect1> 19520<refsect1> 19521<title>Description</title> 19522<para> 19523 This macro dynamically allocates a new fifo buffer. 19524 </para><para> 19525 19526 The numer of elements will be rounded-up to a power of 2. 19527 The fifo will be release with <function>kfifo_free</function>. 19528 Return 0 if no error, otherwise an error code. 19529</para> 19530</refsect1> 19531</refentry> 19532 19533<refentry id="API-kfifo-free"> 19534<refentryinfo> 19535 <title>LINUX</title> 19536 <productname>Kernel Hackers Manual</productname> 19537 <date>July 2017</date> 19538</refentryinfo> 19539<refmeta> 19540 <refentrytitle><phrase>kfifo_free</phrase></refentrytitle> 19541 <manvolnum>9</manvolnum> 19542 <refmiscinfo class="version">4.1.27</refmiscinfo> 19543</refmeta> 19544<refnamediv> 19545 <refname>kfifo_free</refname> 19546 <refpurpose> 19547 frees the fifo 19548 </refpurpose> 19549</refnamediv> 19550<refsynopsisdiv> 19551 <title>Synopsis</title> 19552 <funcsynopsis><funcprototype> 19553 <funcdef> <function>kfifo_free </function></funcdef> 19554 <paramdef> <parameter>fifo</parameter></paramdef> 19555 </funcprototype></funcsynopsis> 19556</refsynopsisdiv> 19557<refsect1> 19558 <title>Arguments</title> 19559 <variablelist> 19560 <varlistentry> 19561 <term><parameter>fifo</parameter></term> 19562 <listitem> 19563 <para> 19564 the fifo to be freed 19565 </para> 19566 </listitem> 19567 </varlistentry> 19568 </variablelist> 19569</refsect1> 19570</refentry> 19571 19572<refentry id="API-kfifo-init"> 19573<refentryinfo> 19574 <title>LINUX</title> 19575 <productname>Kernel Hackers Manual</productname> 19576 <date>July 2017</date> 19577</refentryinfo> 19578<refmeta> 19579 <refentrytitle><phrase>kfifo_init</phrase></refentrytitle> 19580 <manvolnum>9</manvolnum> 19581 <refmiscinfo class="version">4.1.27</refmiscinfo> 19582</refmeta> 19583<refnamediv> 19584 <refname>kfifo_init</refname> 19585 <refpurpose> 19586 initialize a fifo using a preallocated buffer 19587 </refpurpose> 19588</refnamediv> 19589<refsynopsisdiv> 19590 <title>Synopsis</title> 19591 <funcsynopsis><funcprototype> 19592 <funcdef> <function>kfifo_init </function></funcdef> 19593 <paramdef> <parameter>fifo</parameter></paramdef> 19594 <paramdef> <parameter>buffer</parameter></paramdef> 19595 <paramdef> <parameter>size</parameter></paramdef> 19596 </funcprototype></funcsynopsis> 19597</refsynopsisdiv> 19598<refsect1> 19599 <title>Arguments</title> 19600 <variablelist> 19601 <varlistentry> 19602 <term><parameter>fifo</parameter></term> 19603 <listitem> 19604 <para> 19605 the fifo to assign the buffer 19606 </para> 19607 </listitem> 19608 </varlistentry> 19609 <varlistentry> 19610 <term><parameter>buffer</parameter></term> 19611 <listitem> 19612 <para> 19613 the preallocated buffer to be used 19614 </para> 19615 </listitem> 19616 </varlistentry> 19617 <varlistentry> 19618 <term><parameter>size</parameter></term> 19619 <listitem> 19620 <para> 19621 the size of the internal buffer, this have to be a power of 2 19622 </para> 19623 </listitem> 19624 </varlistentry> 19625 </variablelist> 19626</refsect1> 19627<refsect1> 19628<title>Description</title> 19629<para> 19630 This macro initialize a fifo using a preallocated buffer. 19631 </para><para> 19632 19633 The numer of elements will be rounded-up to a power of 2. 19634 Return 0 if no error, otherwise an error code. 19635</para> 19636</refsect1> 19637</refentry> 19638 19639<refentry id="API-kfifo-put"> 19640<refentryinfo> 19641 <title>LINUX</title> 19642 <productname>Kernel Hackers Manual</productname> 19643 <date>July 2017</date> 19644</refentryinfo> 19645<refmeta> 19646 <refentrytitle><phrase>kfifo_put</phrase></refentrytitle> 19647 <manvolnum>9</manvolnum> 19648 <refmiscinfo class="version">4.1.27</refmiscinfo> 19649</refmeta> 19650<refnamediv> 19651 <refname>kfifo_put</refname> 19652 <refpurpose> 19653 put data into the fifo 19654 </refpurpose> 19655</refnamediv> 19656<refsynopsisdiv> 19657 <title>Synopsis</title> 19658 <funcsynopsis><funcprototype> 19659 <funcdef> <function>kfifo_put </function></funcdef> 19660 <paramdef> <parameter>fifo</parameter></paramdef> 19661 <paramdef> <parameter>val</parameter></paramdef> 19662 </funcprototype></funcsynopsis> 19663</refsynopsisdiv> 19664<refsect1> 19665 <title>Arguments</title> 19666 <variablelist> 19667 <varlistentry> 19668 <term><parameter>fifo</parameter></term> 19669 <listitem> 19670 <para> 19671 address of the fifo to be used 19672 </para> 19673 </listitem> 19674 </varlistentry> 19675 <varlistentry> 19676 <term><parameter>val</parameter></term> 19677 <listitem> 19678 <para> 19679 the data to be added 19680 </para> 19681 </listitem> 19682 </varlistentry> 19683 </variablelist> 19684</refsect1> 19685<refsect1> 19686<title>Description</title> 19687<para> 19688 This macro copies the given value into the fifo. 19689 It returns 0 if the fifo was full. Otherwise it returns the number 19690 processed elements. 19691 </para><para> 19692 19693 Note that with only one concurrent reader and one concurrent 19694 writer, you don't need extra locking to use these macro. 19695</para> 19696</refsect1> 19697</refentry> 19698 19699<refentry id="API-kfifo-get"> 19700<refentryinfo> 19701 <title>LINUX</title> 19702 <productname>Kernel Hackers Manual</productname> 19703 <date>July 2017</date> 19704</refentryinfo> 19705<refmeta> 19706 <refentrytitle><phrase>kfifo_get</phrase></refentrytitle> 19707 <manvolnum>9</manvolnum> 19708 <refmiscinfo class="version">4.1.27</refmiscinfo> 19709</refmeta> 19710<refnamediv> 19711 <refname>kfifo_get</refname> 19712 <refpurpose> 19713 get data from the fifo 19714 </refpurpose> 19715</refnamediv> 19716<refsynopsisdiv> 19717 <title>Synopsis</title> 19718 <funcsynopsis><funcprototype> 19719 <funcdef> <function>kfifo_get </function></funcdef> 19720 <paramdef> <parameter>fifo</parameter></paramdef> 19721 <paramdef> <parameter>val</parameter></paramdef> 19722 </funcprototype></funcsynopsis> 19723</refsynopsisdiv> 19724<refsect1> 19725 <title>Arguments</title> 19726 <variablelist> 19727 <varlistentry> 19728 <term><parameter>fifo</parameter></term> 19729 <listitem> 19730 <para> 19731 address of the fifo to be used 19732 </para> 19733 </listitem> 19734 </varlistentry> 19735 <varlistentry> 19736 <term><parameter>val</parameter></term> 19737 <listitem> 19738 <para> 19739 address where to store the data 19740 </para> 19741 </listitem> 19742 </varlistentry> 19743 </variablelist> 19744</refsect1> 19745<refsect1> 19746<title>Description</title> 19747<para> 19748 This macro reads the data from the fifo. 19749 It returns 0 if the fifo was empty. Otherwise it returns the number 19750 processed elements. 19751 </para><para> 19752 19753 Note that with only one concurrent reader and one concurrent 19754 writer, you don't need extra locking to use these macro. 19755</para> 19756</refsect1> 19757</refentry> 19758 19759<refentry id="API-kfifo-peek"> 19760<refentryinfo> 19761 <title>LINUX</title> 19762 <productname>Kernel Hackers Manual</productname> 19763 <date>July 2017</date> 19764</refentryinfo> 19765<refmeta> 19766 <refentrytitle><phrase>kfifo_peek</phrase></refentrytitle> 19767 <manvolnum>9</manvolnum> 19768 <refmiscinfo class="version">4.1.27</refmiscinfo> 19769</refmeta> 19770<refnamediv> 19771 <refname>kfifo_peek</refname> 19772 <refpurpose> 19773 get data from the fifo without removing 19774 </refpurpose> 19775</refnamediv> 19776<refsynopsisdiv> 19777 <title>Synopsis</title> 19778 <funcsynopsis><funcprototype> 19779 <funcdef> <function>kfifo_peek </function></funcdef> 19780 <paramdef> <parameter>fifo</parameter></paramdef> 19781 <paramdef> <parameter>val</parameter></paramdef> 19782 </funcprototype></funcsynopsis> 19783</refsynopsisdiv> 19784<refsect1> 19785 <title>Arguments</title> 19786 <variablelist> 19787 <varlistentry> 19788 <term><parameter>fifo</parameter></term> 19789 <listitem> 19790 <para> 19791 address of the fifo to be used 19792 </para> 19793 </listitem> 19794 </varlistentry> 19795 <varlistentry> 19796 <term><parameter>val</parameter></term> 19797 <listitem> 19798 <para> 19799 address where to store the data 19800 </para> 19801 </listitem> 19802 </varlistentry> 19803 </variablelist> 19804</refsect1> 19805<refsect1> 19806<title>Description</title> 19807<para> 19808 This reads the data from the fifo without removing it from the fifo. 19809 It returns 0 if the fifo was empty. Otherwise it returns the number 19810 processed elements. 19811 </para><para> 19812 19813 Note that with only one concurrent reader and one concurrent 19814 writer, you don't need extra locking to use these macro. 19815</para> 19816</refsect1> 19817</refentry> 19818 19819<refentry id="API-kfifo-in"> 19820<refentryinfo> 19821 <title>LINUX</title> 19822 <productname>Kernel Hackers Manual</productname> 19823 <date>July 2017</date> 19824</refentryinfo> 19825<refmeta> 19826 <refentrytitle><phrase>kfifo_in</phrase></refentrytitle> 19827 <manvolnum>9</manvolnum> 19828 <refmiscinfo class="version">4.1.27</refmiscinfo> 19829</refmeta> 19830<refnamediv> 19831 <refname>kfifo_in</refname> 19832 <refpurpose> 19833 put data into the fifo 19834 </refpurpose> 19835</refnamediv> 19836<refsynopsisdiv> 19837 <title>Synopsis</title> 19838 <funcsynopsis><funcprototype> 19839 <funcdef> <function>kfifo_in </function></funcdef> 19840 <paramdef> <parameter>fifo</parameter></paramdef> 19841 <paramdef> <parameter>buf</parameter></paramdef> 19842 <paramdef> <parameter>n</parameter></paramdef> 19843 </funcprototype></funcsynopsis> 19844</refsynopsisdiv> 19845<refsect1> 19846 <title>Arguments</title> 19847 <variablelist> 19848 <varlistentry> 19849 <term><parameter>fifo</parameter></term> 19850 <listitem> 19851 <para> 19852 address of the fifo to be used 19853 </para> 19854 </listitem> 19855 </varlistentry> 19856 <varlistentry> 19857 <term><parameter>buf</parameter></term> 19858 <listitem> 19859 <para> 19860 the data to be added 19861 </para> 19862 </listitem> 19863 </varlistentry> 19864 <varlistentry> 19865 <term><parameter>n</parameter></term> 19866 <listitem> 19867 <para> 19868 number of elements to be added 19869 </para> 19870 </listitem> 19871 </varlistentry> 19872 </variablelist> 19873</refsect1> 19874<refsect1> 19875<title>Description</title> 19876<para> 19877 This macro copies the given buffer into the fifo and returns the 19878 number of copied elements. 19879 </para><para> 19880 19881 Note that with only one concurrent reader and one concurrent 19882 writer, you don't need extra locking to use these macro. 19883</para> 19884</refsect1> 19885</refentry> 19886 19887<refentry id="API-kfifo-in-spinlocked"> 19888<refentryinfo> 19889 <title>LINUX</title> 19890 <productname>Kernel Hackers Manual</productname> 19891 <date>July 2017</date> 19892</refentryinfo> 19893<refmeta> 19894 <refentrytitle><phrase>kfifo_in_spinlocked</phrase></refentrytitle> 19895 <manvolnum>9</manvolnum> 19896 <refmiscinfo class="version">4.1.27</refmiscinfo> 19897</refmeta> 19898<refnamediv> 19899 <refname>kfifo_in_spinlocked</refname> 19900 <refpurpose> 19901 put data into the fifo using a spinlock for locking 19902 </refpurpose> 19903</refnamediv> 19904<refsynopsisdiv> 19905 <title>Synopsis</title> 19906 <funcsynopsis><funcprototype> 19907 <funcdef> <function>kfifo_in_spinlocked </function></funcdef> 19908 <paramdef> <parameter>fifo</parameter></paramdef> 19909 <paramdef> <parameter>buf</parameter></paramdef> 19910 <paramdef> <parameter>n</parameter></paramdef> 19911 <paramdef> <parameter>lock</parameter></paramdef> 19912 </funcprototype></funcsynopsis> 19913</refsynopsisdiv> 19914<refsect1> 19915 <title>Arguments</title> 19916 <variablelist> 19917 <varlistentry> 19918 <term><parameter>fifo</parameter></term> 19919 <listitem> 19920 <para> 19921 address of the fifo to be used 19922 </para> 19923 </listitem> 19924 </varlistentry> 19925 <varlistentry> 19926 <term><parameter>buf</parameter></term> 19927 <listitem> 19928 <para> 19929 the data to be added 19930 </para> 19931 </listitem> 19932 </varlistentry> 19933 <varlistentry> 19934 <term><parameter>n</parameter></term> 19935 <listitem> 19936 <para> 19937 number of elements to be added 19938 </para> 19939 </listitem> 19940 </varlistentry> 19941 <varlistentry> 19942 <term><parameter>lock</parameter></term> 19943 <listitem> 19944 <para> 19945 pointer to the spinlock to use for locking 19946 </para> 19947 </listitem> 19948 </varlistentry> 19949 </variablelist> 19950</refsect1> 19951<refsect1> 19952<title>Description</title> 19953<para> 19954 This macro copies the given values buffer into the fifo and returns the 19955 number of copied elements. 19956</para> 19957</refsect1> 19958</refentry> 19959 19960<refentry id="API-kfifo-out"> 19961<refentryinfo> 19962 <title>LINUX</title> 19963 <productname>Kernel Hackers Manual</productname> 19964 <date>July 2017</date> 19965</refentryinfo> 19966<refmeta> 19967 <refentrytitle><phrase>kfifo_out</phrase></refentrytitle> 19968 <manvolnum>9</manvolnum> 19969 <refmiscinfo class="version">4.1.27</refmiscinfo> 19970</refmeta> 19971<refnamediv> 19972 <refname>kfifo_out</refname> 19973 <refpurpose> 19974 get data from the fifo 19975 </refpurpose> 19976</refnamediv> 19977<refsynopsisdiv> 19978 <title>Synopsis</title> 19979 <funcsynopsis><funcprototype> 19980 <funcdef> <function>kfifo_out </function></funcdef> 19981 <paramdef> <parameter>fifo</parameter></paramdef> 19982 <paramdef> <parameter>buf</parameter></paramdef> 19983 <paramdef> <parameter>n</parameter></paramdef> 19984 </funcprototype></funcsynopsis> 19985</refsynopsisdiv> 19986<refsect1> 19987 <title>Arguments</title> 19988 <variablelist> 19989 <varlistentry> 19990 <term><parameter>fifo</parameter></term> 19991 <listitem> 19992 <para> 19993 address of the fifo to be used 19994 </para> 19995 </listitem> 19996 </varlistentry> 19997 <varlistentry> 19998 <term><parameter>buf</parameter></term> 19999 <listitem> 20000 <para> 20001 pointer to the storage buffer 20002 </para> 20003 </listitem> 20004 </varlistentry> 20005 <varlistentry> 20006 <term><parameter>n</parameter></term> 20007 <listitem> 20008 <para> 20009 max. number of elements to get 20010 </para> 20011 </listitem> 20012 </varlistentry> 20013 </variablelist> 20014</refsect1> 20015<refsect1> 20016<title>Description</title> 20017<para> 20018 This macro get some data from the fifo and return the numbers of elements 20019 copied. 20020 </para><para> 20021 20022 Note that with only one concurrent reader and one concurrent 20023 writer, you don't need extra locking to use these macro. 20024</para> 20025</refsect1> 20026</refentry> 20027 20028<refentry id="API-kfifo-out-spinlocked"> 20029<refentryinfo> 20030 <title>LINUX</title> 20031 <productname>Kernel Hackers Manual</productname> 20032 <date>July 2017</date> 20033</refentryinfo> 20034<refmeta> 20035 <refentrytitle><phrase>kfifo_out_spinlocked</phrase></refentrytitle> 20036 <manvolnum>9</manvolnum> 20037 <refmiscinfo class="version">4.1.27</refmiscinfo> 20038</refmeta> 20039<refnamediv> 20040 <refname>kfifo_out_spinlocked</refname> 20041 <refpurpose> 20042 get data from the fifo using a spinlock for locking 20043 </refpurpose> 20044</refnamediv> 20045<refsynopsisdiv> 20046 <title>Synopsis</title> 20047 <funcsynopsis><funcprototype> 20048 <funcdef> <function>kfifo_out_spinlocked </function></funcdef> 20049 <paramdef> <parameter>fifo</parameter></paramdef> 20050 <paramdef> <parameter>buf</parameter></paramdef> 20051 <paramdef> <parameter>n</parameter></paramdef> 20052 <paramdef> <parameter>lock</parameter></paramdef> 20053 </funcprototype></funcsynopsis> 20054</refsynopsisdiv> 20055<refsect1> 20056 <title>Arguments</title> 20057 <variablelist> 20058 <varlistentry> 20059 <term><parameter>fifo</parameter></term> 20060 <listitem> 20061 <para> 20062 address of the fifo to be used 20063 </para> 20064 </listitem> 20065 </varlistentry> 20066 <varlistentry> 20067 <term><parameter>buf</parameter></term> 20068 <listitem> 20069 <para> 20070 pointer to the storage buffer 20071 </para> 20072 </listitem> 20073 </varlistentry> 20074 <varlistentry> 20075 <term><parameter>n</parameter></term> 20076 <listitem> 20077 <para> 20078 max. number of elements to get 20079 </para> 20080 </listitem> 20081 </varlistentry> 20082 <varlistentry> 20083 <term><parameter>lock</parameter></term> 20084 <listitem> 20085 <para> 20086 pointer to the spinlock to use for locking 20087 </para> 20088 </listitem> 20089 </varlistentry> 20090 </variablelist> 20091</refsect1> 20092<refsect1> 20093<title>Description</title> 20094<para> 20095 This macro get the data from the fifo and return the numbers of elements 20096 copied. 20097</para> 20098</refsect1> 20099</refentry> 20100 20101<refentry id="API-kfifo-from-user"> 20102<refentryinfo> 20103 <title>LINUX</title> 20104 <productname>Kernel Hackers Manual</productname> 20105 <date>July 2017</date> 20106</refentryinfo> 20107<refmeta> 20108 <refentrytitle><phrase>kfifo_from_user</phrase></refentrytitle> 20109 <manvolnum>9</manvolnum> 20110 <refmiscinfo class="version">4.1.27</refmiscinfo> 20111</refmeta> 20112<refnamediv> 20113 <refname>kfifo_from_user</refname> 20114 <refpurpose> 20115 puts some data from user space into the fifo 20116 </refpurpose> 20117</refnamediv> 20118<refsynopsisdiv> 20119 <title>Synopsis</title> 20120 <funcsynopsis><funcprototype> 20121 <funcdef> <function>kfifo_from_user </function></funcdef> 20122 <paramdef> <parameter>fifo</parameter></paramdef> 20123 <paramdef> <parameter>from</parameter></paramdef> 20124 <paramdef> <parameter>len</parameter></paramdef> 20125 <paramdef> <parameter>copied</parameter></paramdef> 20126 </funcprototype></funcsynopsis> 20127</refsynopsisdiv> 20128<refsect1> 20129 <title>Arguments</title> 20130 <variablelist> 20131 <varlistentry> 20132 <term><parameter>fifo</parameter></term> 20133 <listitem> 20134 <para> 20135 address of the fifo to be used 20136 </para> 20137 </listitem> 20138 </varlistentry> 20139 <varlistentry> 20140 <term><parameter>from</parameter></term> 20141 <listitem> 20142 <para> 20143 pointer to the data to be added 20144 </para> 20145 </listitem> 20146 </varlistentry> 20147 <varlistentry> 20148 <term><parameter>len</parameter></term> 20149 <listitem> 20150 <para> 20151 the length of the data to be added 20152 </para> 20153 </listitem> 20154 </varlistentry> 20155 <varlistentry> 20156 <term><parameter>copied</parameter></term> 20157 <listitem> 20158 <para> 20159 pointer to output variable to store the number of copied bytes 20160 </para> 20161 </listitem> 20162 </varlistentry> 20163 </variablelist> 20164</refsect1> 20165<refsect1> 20166<title>Description</title> 20167<para> 20168 This macro copies at most <parameter>len</parameter> bytes from the <parameter>from</parameter> into the 20169 fifo, depending of the available space and returns -EFAULT/0. 20170 </para><para> 20171 20172 Note that with only one concurrent reader and one concurrent 20173 writer, you don't need extra locking to use these macro. 20174</para> 20175</refsect1> 20176</refentry> 20177 20178<refentry id="API-kfifo-to-user"> 20179<refentryinfo> 20180 <title>LINUX</title> 20181 <productname>Kernel Hackers Manual</productname> 20182 <date>July 2017</date> 20183</refentryinfo> 20184<refmeta> 20185 <refentrytitle><phrase>kfifo_to_user</phrase></refentrytitle> 20186 <manvolnum>9</manvolnum> 20187 <refmiscinfo class="version">4.1.27</refmiscinfo> 20188</refmeta> 20189<refnamediv> 20190 <refname>kfifo_to_user</refname> 20191 <refpurpose> 20192 copies data from the fifo into user space 20193 </refpurpose> 20194</refnamediv> 20195<refsynopsisdiv> 20196 <title>Synopsis</title> 20197 <funcsynopsis><funcprototype> 20198 <funcdef> <function>kfifo_to_user </function></funcdef> 20199 <paramdef> <parameter>fifo</parameter></paramdef> 20200 <paramdef> <parameter>to</parameter></paramdef> 20201 <paramdef> <parameter>len</parameter></paramdef> 20202 <paramdef> <parameter>copied</parameter></paramdef> 20203 </funcprototype></funcsynopsis> 20204</refsynopsisdiv> 20205<refsect1> 20206 <title>Arguments</title> 20207 <variablelist> 20208 <varlistentry> 20209 <term><parameter>fifo</parameter></term> 20210 <listitem> 20211 <para> 20212 address of the fifo to be used 20213 </para> 20214 </listitem> 20215 </varlistentry> 20216 <varlistentry> 20217 <term><parameter>to</parameter></term> 20218 <listitem> 20219 <para> 20220 where the data must be copied 20221 </para> 20222 </listitem> 20223 </varlistentry> 20224 <varlistentry> 20225 <term><parameter>len</parameter></term> 20226 <listitem> 20227 <para> 20228 the size of the destination buffer 20229 </para> 20230 </listitem> 20231 </varlistentry> 20232 <varlistentry> 20233 <term><parameter>copied</parameter></term> 20234 <listitem> 20235 <para> 20236 pointer to output variable to store the number of copied bytes 20237 </para> 20238 </listitem> 20239 </varlistentry> 20240 </variablelist> 20241</refsect1> 20242<refsect1> 20243<title>Description</title> 20244<para> 20245 This macro copies at most <parameter>len</parameter> bytes from the fifo into the 20246 <parameter>to</parameter> buffer and returns -EFAULT/0. 20247 </para><para> 20248 20249 Note that with only one concurrent reader and one concurrent 20250 writer, you don't need extra locking to use these macro. 20251</para> 20252</refsect1> 20253</refentry> 20254 20255<refentry id="API-kfifo-dma-in-prepare"> 20256<refentryinfo> 20257 <title>LINUX</title> 20258 <productname>Kernel Hackers Manual</productname> 20259 <date>July 2017</date> 20260</refentryinfo> 20261<refmeta> 20262 <refentrytitle><phrase>kfifo_dma_in_prepare</phrase></refentrytitle> 20263 <manvolnum>9</manvolnum> 20264 <refmiscinfo class="version">4.1.27</refmiscinfo> 20265</refmeta> 20266<refnamediv> 20267 <refname>kfifo_dma_in_prepare</refname> 20268 <refpurpose> 20269 setup a scatterlist for DMA input 20270 </refpurpose> 20271</refnamediv> 20272<refsynopsisdiv> 20273 <title>Synopsis</title> 20274 <funcsynopsis><funcprototype> 20275 <funcdef> <function>kfifo_dma_in_prepare </function></funcdef> 20276 <paramdef> <parameter>fifo</parameter></paramdef> 20277 <paramdef> <parameter>sgl</parameter></paramdef> 20278 <paramdef> <parameter>nents</parameter></paramdef> 20279 <paramdef> <parameter>len</parameter></paramdef> 20280 </funcprototype></funcsynopsis> 20281</refsynopsisdiv> 20282<refsect1> 20283 <title>Arguments</title> 20284 <variablelist> 20285 <varlistentry> 20286 <term><parameter>fifo</parameter></term> 20287 <listitem> 20288 <para> 20289 address of the fifo to be used 20290 </para> 20291 </listitem> 20292 </varlistentry> 20293 <varlistentry> 20294 <term><parameter>sgl</parameter></term> 20295 <listitem> 20296 <para> 20297 pointer to the scatterlist array 20298 </para> 20299 </listitem> 20300 </varlistentry> 20301 <varlistentry> 20302 <term><parameter>nents</parameter></term> 20303 <listitem> 20304 <para> 20305 number of entries in the scatterlist array 20306 </para> 20307 </listitem> 20308 </varlistentry> 20309 <varlistentry> 20310 <term><parameter>len</parameter></term> 20311 <listitem> 20312 <para> 20313 number of elements to transfer 20314 </para> 20315 </listitem> 20316 </varlistentry> 20317 </variablelist> 20318</refsect1> 20319<refsect1> 20320<title>Description</title> 20321<para> 20322 This macro fills a scatterlist for DMA input. 20323 It returns the number entries in the scatterlist array. 20324 </para><para> 20325 20326 Note that with only one concurrent reader and one concurrent 20327 writer, you don't need extra locking to use these macros. 20328</para> 20329</refsect1> 20330</refentry> 20331 20332<refentry id="API-kfifo-dma-in-finish"> 20333<refentryinfo> 20334 <title>LINUX</title> 20335 <productname>Kernel Hackers Manual</productname> 20336 <date>July 2017</date> 20337</refentryinfo> 20338<refmeta> 20339 <refentrytitle><phrase>kfifo_dma_in_finish</phrase></refentrytitle> 20340 <manvolnum>9</manvolnum> 20341 <refmiscinfo class="version">4.1.27</refmiscinfo> 20342</refmeta> 20343<refnamediv> 20344 <refname>kfifo_dma_in_finish</refname> 20345 <refpurpose> 20346 finish a DMA IN operation 20347 </refpurpose> 20348</refnamediv> 20349<refsynopsisdiv> 20350 <title>Synopsis</title> 20351 <funcsynopsis><funcprototype> 20352 <funcdef> <function>kfifo_dma_in_finish </function></funcdef> 20353 <paramdef> <parameter>fifo</parameter></paramdef> 20354 <paramdef> <parameter>len</parameter></paramdef> 20355 </funcprototype></funcsynopsis> 20356</refsynopsisdiv> 20357<refsect1> 20358 <title>Arguments</title> 20359 <variablelist> 20360 <varlistentry> 20361 <term><parameter>fifo</parameter></term> 20362 <listitem> 20363 <para> 20364 address of the fifo to be used 20365 </para> 20366 </listitem> 20367 </varlistentry> 20368 <varlistentry> 20369 <term><parameter>len</parameter></term> 20370 <listitem> 20371 <para> 20372 number of bytes to received 20373 </para> 20374 </listitem> 20375 </varlistentry> 20376 </variablelist> 20377</refsect1> 20378<refsect1> 20379<title>Description</title> 20380<para> 20381 This macro finish a DMA IN operation. The in counter will be updated by 20382 the len parameter. No error checking will be done. 20383 </para><para> 20384 20385 Note that with only one concurrent reader and one concurrent 20386 writer, you don't need extra locking to use these macros. 20387</para> 20388</refsect1> 20389</refentry> 20390 20391<refentry id="API-kfifo-dma-out-prepare"> 20392<refentryinfo> 20393 <title>LINUX</title> 20394 <productname>Kernel Hackers Manual</productname> 20395 <date>July 2017</date> 20396</refentryinfo> 20397<refmeta> 20398 <refentrytitle><phrase>kfifo_dma_out_prepare</phrase></refentrytitle> 20399 <manvolnum>9</manvolnum> 20400 <refmiscinfo class="version">4.1.27</refmiscinfo> 20401</refmeta> 20402<refnamediv> 20403 <refname>kfifo_dma_out_prepare</refname> 20404 <refpurpose> 20405 setup a scatterlist for DMA output 20406 </refpurpose> 20407</refnamediv> 20408<refsynopsisdiv> 20409 <title>Synopsis</title> 20410 <funcsynopsis><funcprototype> 20411 <funcdef> <function>kfifo_dma_out_prepare </function></funcdef> 20412 <paramdef> <parameter>fifo</parameter></paramdef> 20413 <paramdef> <parameter>sgl</parameter></paramdef> 20414 <paramdef> <parameter>nents</parameter></paramdef> 20415 <paramdef> <parameter>len</parameter></paramdef> 20416 </funcprototype></funcsynopsis> 20417</refsynopsisdiv> 20418<refsect1> 20419 <title>Arguments</title> 20420 <variablelist> 20421 <varlistentry> 20422 <term><parameter>fifo</parameter></term> 20423 <listitem> 20424 <para> 20425 address of the fifo to be used 20426 </para> 20427 </listitem> 20428 </varlistentry> 20429 <varlistentry> 20430 <term><parameter>sgl</parameter></term> 20431 <listitem> 20432 <para> 20433 pointer to the scatterlist array 20434 </para> 20435 </listitem> 20436 </varlistentry> 20437 <varlistentry> 20438 <term><parameter>nents</parameter></term> 20439 <listitem> 20440 <para> 20441 number of entries in the scatterlist array 20442 </para> 20443 </listitem> 20444 </varlistentry> 20445 <varlistentry> 20446 <term><parameter>len</parameter></term> 20447 <listitem> 20448 <para> 20449 number of elements to transfer 20450 </para> 20451 </listitem> 20452 </varlistentry> 20453 </variablelist> 20454</refsect1> 20455<refsect1> 20456<title>Description</title> 20457<para> 20458 This macro fills a scatterlist for DMA output which at most <parameter>len</parameter> bytes 20459 to transfer. 20460 It returns the number entries in the scatterlist array. 20461 A zero means there is no space available and the scatterlist is not filled. 20462 </para><para> 20463 20464 Note that with only one concurrent reader and one concurrent 20465 writer, you don't need extra locking to use these macros. 20466</para> 20467</refsect1> 20468</refentry> 20469 20470<refentry id="API-kfifo-dma-out-finish"> 20471<refentryinfo> 20472 <title>LINUX</title> 20473 <productname>Kernel Hackers Manual</productname> 20474 <date>July 2017</date> 20475</refentryinfo> 20476<refmeta> 20477 <refentrytitle><phrase>kfifo_dma_out_finish</phrase></refentrytitle> 20478 <manvolnum>9</manvolnum> 20479 <refmiscinfo class="version">4.1.27</refmiscinfo> 20480</refmeta> 20481<refnamediv> 20482 <refname>kfifo_dma_out_finish</refname> 20483 <refpurpose> 20484 finish a DMA OUT operation 20485 </refpurpose> 20486</refnamediv> 20487<refsynopsisdiv> 20488 <title>Synopsis</title> 20489 <funcsynopsis><funcprototype> 20490 <funcdef> <function>kfifo_dma_out_finish </function></funcdef> 20491 <paramdef> <parameter>fifo</parameter></paramdef> 20492 <paramdef> <parameter>len</parameter></paramdef> 20493 </funcprototype></funcsynopsis> 20494</refsynopsisdiv> 20495<refsect1> 20496 <title>Arguments</title> 20497 <variablelist> 20498 <varlistentry> 20499 <term><parameter>fifo</parameter></term> 20500 <listitem> 20501 <para> 20502 address of the fifo to be used 20503 </para> 20504 </listitem> 20505 </varlistentry> 20506 <varlistentry> 20507 <term><parameter>len</parameter></term> 20508 <listitem> 20509 <para> 20510 number of bytes transferred 20511 </para> 20512 </listitem> 20513 </varlistentry> 20514 </variablelist> 20515</refsect1> 20516<refsect1> 20517<title>Description</title> 20518<para> 20519 This macro finish a DMA OUT operation. The out counter will be updated by 20520 the len parameter. No error checking will be done. 20521 </para><para> 20522 20523 Note that with only one concurrent reader and one concurrent 20524 writer, you don't need extra locking to use these macros. 20525</para> 20526</refsect1> 20527</refentry> 20528 20529<refentry id="API-kfifo-out-peek"> 20530<refentryinfo> 20531 <title>LINUX</title> 20532 <productname>Kernel Hackers Manual</productname> 20533 <date>July 2017</date> 20534</refentryinfo> 20535<refmeta> 20536 <refentrytitle><phrase>kfifo_out_peek</phrase></refentrytitle> 20537 <manvolnum>9</manvolnum> 20538 <refmiscinfo class="version">4.1.27</refmiscinfo> 20539</refmeta> 20540<refnamediv> 20541 <refname>kfifo_out_peek</refname> 20542 <refpurpose> 20543 gets some data from the fifo 20544 </refpurpose> 20545</refnamediv> 20546<refsynopsisdiv> 20547 <title>Synopsis</title> 20548 <funcsynopsis><funcprototype> 20549 <funcdef> <function>kfifo_out_peek </function></funcdef> 20550 <paramdef> <parameter>fifo</parameter></paramdef> 20551 <paramdef> <parameter>buf</parameter></paramdef> 20552 <paramdef> <parameter>n</parameter></paramdef> 20553 </funcprototype></funcsynopsis> 20554</refsynopsisdiv> 20555<refsect1> 20556 <title>Arguments</title> 20557 <variablelist> 20558 <varlistentry> 20559 <term><parameter>fifo</parameter></term> 20560 <listitem> 20561 <para> 20562 address of the fifo to be used 20563 </para> 20564 </listitem> 20565 </varlistentry> 20566 <varlistentry> 20567 <term><parameter>buf</parameter></term> 20568 <listitem> 20569 <para> 20570 pointer to the storage buffer 20571 </para> 20572 </listitem> 20573 </varlistentry> 20574 <varlistentry> 20575 <term><parameter>n</parameter></term> 20576 <listitem> 20577 <para> 20578 max. number of elements to get 20579 </para> 20580 </listitem> 20581 </varlistentry> 20582 </variablelist> 20583</refsect1> 20584<refsect1> 20585<title>Description</title> 20586<para> 20587 This macro get the data from the fifo and return the numbers of elements 20588 copied. The data is not removed from the fifo. 20589 </para><para> 20590 20591 Note that with only one concurrent reader and one concurrent 20592 writer, you don't need extra locking to use these macro. 20593</para> 20594</refsect1> 20595</refentry> 20596 20597 </sect1> 20598 </chapter> 20599 20600 <chapter id="relayfs"> 20601 <title>relay interface support</title> 20602 20603 <para> 20604 Relay interface support 20605 is designed to provide an efficient mechanism for tools and 20606 facilities to relay large amounts of data from kernel space to 20607 user space. 20608 </para> 20609 20610 <sect1><title>relay interface</title> 20611<!-- kernel/relay.c --> 20612<refentry id="API-relay-buf-full"> 20613<refentryinfo> 20614 <title>LINUX</title> 20615 <productname>Kernel Hackers Manual</productname> 20616 <date>July 2017</date> 20617</refentryinfo> 20618<refmeta> 20619 <refentrytitle><phrase>relay_buf_full</phrase></refentrytitle> 20620 <manvolnum>9</manvolnum> 20621 <refmiscinfo class="version">4.1.27</refmiscinfo> 20622</refmeta> 20623<refnamediv> 20624 <refname>relay_buf_full</refname> 20625 <refpurpose> 20626 boolean, is the channel buffer full? 20627 </refpurpose> 20628</refnamediv> 20629<refsynopsisdiv> 20630 <title>Synopsis</title> 20631 <funcsynopsis><funcprototype> 20632 <funcdef>int <function>relay_buf_full </function></funcdef> 20633 <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef> 20634 </funcprototype></funcsynopsis> 20635</refsynopsisdiv> 20636<refsect1> 20637 <title>Arguments</title> 20638 <variablelist> 20639 <varlistentry> 20640 <term><parameter>buf</parameter></term> 20641 <listitem> 20642 <para> 20643 channel buffer 20644 </para> 20645 </listitem> 20646 </varlistentry> 20647 </variablelist> 20648</refsect1> 20649<refsect1> 20650<title>Description</title> 20651<para> 20652 Returns 1 if the buffer is full, 0 otherwise. 20653</para> 20654</refsect1> 20655</refentry> 20656 20657<refentry id="API-relay-reset"> 20658<refentryinfo> 20659 <title>LINUX</title> 20660 <productname>Kernel Hackers Manual</productname> 20661 <date>July 2017</date> 20662</refentryinfo> 20663<refmeta> 20664 <refentrytitle><phrase>relay_reset</phrase></refentrytitle> 20665 <manvolnum>9</manvolnum> 20666 <refmiscinfo class="version">4.1.27</refmiscinfo> 20667</refmeta> 20668<refnamediv> 20669 <refname>relay_reset</refname> 20670 <refpurpose> 20671 reset the channel 20672 </refpurpose> 20673</refnamediv> 20674<refsynopsisdiv> 20675 <title>Synopsis</title> 20676 <funcsynopsis><funcprototype> 20677 <funcdef>void <function>relay_reset </function></funcdef> 20678 <paramdef>struct rchan * <parameter>chan</parameter></paramdef> 20679 </funcprototype></funcsynopsis> 20680</refsynopsisdiv> 20681<refsect1> 20682 <title>Arguments</title> 20683 <variablelist> 20684 <varlistentry> 20685 <term><parameter>chan</parameter></term> 20686 <listitem> 20687 <para> 20688 the channel 20689 </para> 20690 </listitem> 20691 </varlistentry> 20692 </variablelist> 20693</refsect1> 20694<refsect1> 20695<title>Description</title> 20696<para> 20697 This has the effect of erasing all data from all channel buffers 20698 and restarting the channel in its initial state. The buffers 20699 are not freed, so any mappings are still in effect. 20700 </para><para> 20701 20702 NOTE. Care should be taken that the channel isn't actually 20703 being used by anything when this call is made. 20704</para> 20705</refsect1> 20706</refentry> 20707 20708<refentry id="API-relay-open"> 20709<refentryinfo> 20710 <title>LINUX</title> 20711 <productname>Kernel Hackers Manual</productname> 20712 <date>July 2017</date> 20713</refentryinfo> 20714<refmeta> 20715 <refentrytitle><phrase>relay_open</phrase></refentrytitle> 20716 <manvolnum>9</manvolnum> 20717 <refmiscinfo class="version">4.1.27</refmiscinfo> 20718</refmeta> 20719<refnamediv> 20720 <refname>relay_open</refname> 20721 <refpurpose> 20722 create a new relay channel 20723 </refpurpose> 20724</refnamediv> 20725<refsynopsisdiv> 20726 <title>Synopsis</title> 20727 <funcsynopsis><funcprototype> 20728 <funcdef>struct rchan * <function>relay_open </function></funcdef> 20729 <paramdef>const char * <parameter>base_filename</parameter></paramdef> 20730 <paramdef>struct dentry * <parameter>parent</parameter></paramdef> 20731 <paramdef>size_t <parameter>subbuf_size</parameter></paramdef> 20732 <paramdef>size_t <parameter>n_subbufs</parameter></paramdef> 20733 <paramdef>struct rchan_callbacks * <parameter>cb</parameter></paramdef> 20734 <paramdef>void * <parameter>private_data</parameter></paramdef> 20735 </funcprototype></funcsynopsis> 20736</refsynopsisdiv> 20737<refsect1> 20738 <title>Arguments</title> 20739 <variablelist> 20740 <varlistentry> 20741 <term><parameter>base_filename</parameter></term> 20742 <listitem> 20743 <para> 20744 base name of files to create, <constant>NULL</constant> for buffering only 20745 </para> 20746 </listitem> 20747 </varlistentry> 20748 <varlistentry> 20749 <term><parameter>parent</parameter></term> 20750 <listitem> 20751 <para> 20752 dentry of parent directory, <constant>NULL</constant> for root directory or buffer 20753 </para> 20754 </listitem> 20755 </varlistentry> 20756 <varlistentry> 20757 <term><parameter>subbuf_size</parameter></term> 20758 <listitem> 20759 <para> 20760 size of sub-buffers 20761 </para> 20762 </listitem> 20763 </varlistentry> 20764 <varlistentry> 20765 <term><parameter>n_subbufs</parameter></term> 20766 <listitem> 20767 <para> 20768 number of sub-buffers 20769 </para> 20770 </listitem> 20771 </varlistentry> 20772 <varlistentry> 20773 <term><parameter>cb</parameter></term> 20774 <listitem> 20775 <para> 20776 client callback functions 20777 </para> 20778 </listitem> 20779 </varlistentry> 20780 <varlistentry> 20781 <term><parameter>private_data</parameter></term> 20782 <listitem> 20783 <para> 20784 user-defined data 20785 </para> 20786 </listitem> 20787 </varlistentry> 20788 </variablelist> 20789</refsect1> 20790<refsect1> 20791<title>Description</title> 20792<para> 20793 Returns channel pointer if successful, <constant>NULL</constant> otherwise. 20794 </para><para> 20795 20796 Creates a channel buffer for each cpu using the sizes and 20797 attributes specified. The created channel buffer files 20798 will be named base_filename0...base_filenameN-1. File 20799 permissions will be <constant>S_IRUSR</constant>. 20800</para> 20801</refsect1> 20802</refentry> 20803 20804<refentry id="API-relay-switch-subbuf"> 20805<refentryinfo> 20806 <title>LINUX</title> 20807 <productname>Kernel Hackers Manual</productname> 20808 <date>July 2017</date> 20809</refentryinfo> 20810<refmeta> 20811 <refentrytitle><phrase>relay_switch_subbuf</phrase></refentrytitle> 20812 <manvolnum>9</manvolnum> 20813 <refmiscinfo class="version">4.1.27</refmiscinfo> 20814</refmeta> 20815<refnamediv> 20816 <refname>relay_switch_subbuf</refname> 20817 <refpurpose> 20818 switch to a new sub-buffer 20819 </refpurpose> 20820</refnamediv> 20821<refsynopsisdiv> 20822 <title>Synopsis</title> 20823 <funcsynopsis><funcprototype> 20824 <funcdef>size_t <function>relay_switch_subbuf </function></funcdef> 20825 <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef> 20826 <paramdef>size_t <parameter>length</parameter></paramdef> 20827 </funcprototype></funcsynopsis> 20828</refsynopsisdiv> 20829<refsect1> 20830 <title>Arguments</title> 20831 <variablelist> 20832 <varlistentry> 20833 <term><parameter>buf</parameter></term> 20834 <listitem> 20835 <para> 20836 channel buffer 20837 </para> 20838 </listitem> 20839 </varlistentry> 20840 <varlistentry> 20841 <term><parameter>length</parameter></term> 20842 <listitem> 20843 <para> 20844 size of current event 20845 </para> 20846 </listitem> 20847 </varlistentry> 20848 </variablelist> 20849</refsect1> 20850<refsect1> 20851<title>Description</title> 20852<para> 20853 Returns either the length passed in or 0 if full. 20854 </para><para> 20855 20856 Performs sub-buffer-switch tasks such as invoking callbacks, 20857 updating padding counts, waking up readers, etc. 20858</para> 20859</refsect1> 20860</refentry> 20861 20862<refentry id="API-relay-subbufs-consumed"> 20863<refentryinfo> 20864 <title>LINUX</title> 20865 <productname>Kernel Hackers Manual</productname> 20866 <date>July 2017</date> 20867</refentryinfo> 20868<refmeta> 20869 <refentrytitle><phrase>relay_subbufs_consumed</phrase></refentrytitle> 20870 <manvolnum>9</manvolnum> 20871 <refmiscinfo class="version">4.1.27</refmiscinfo> 20872</refmeta> 20873<refnamediv> 20874 <refname>relay_subbufs_consumed</refname> 20875 <refpurpose> 20876 update the buffer's sub-buffers-consumed count 20877 </refpurpose> 20878</refnamediv> 20879<refsynopsisdiv> 20880 <title>Synopsis</title> 20881 <funcsynopsis><funcprototype> 20882 <funcdef>void <function>relay_subbufs_consumed </function></funcdef> 20883 <paramdef>struct rchan * <parameter>chan</parameter></paramdef> 20884 <paramdef>unsigned int <parameter>cpu</parameter></paramdef> 20885 <paramdef>size_t <parameter>subbufs_consumed</parameter></paramdef> 20886 </funcprototype></funcsynopsis> 20887</refsynopsisdiv> 20888<refsect1> 20889 <title>Arguments</title> 20890 <variablelist> 20891 <varlistentry> 20892 <term><parameter>chan</parameter></term> 20893 <listitem> 20894 <para> 20895 the channel 20896 </para> 20897 </listitem> 20898 </varlistentry> 20899 <varlistentry> 20900 <term><parameter>cpu</parameter></term> 20901 <listitem> 20902 <para> 20903 the cpu associated with the channel buffer to update 20904 </para> 20905 </listitem> 20906 </varlistentry> 20907 <varlistentry> 20908 <term><parameter>subbufs_consumed</parameter></term> 20909 <listitem> 20910 <para> 20911 number of sub-buffers to add to current buf's count 20912 </para> 20913 </listitem> 20914 </varlistentry> 20915 </variablelist> 20916</refsect1> 20917<refsect1> 20918<title>Description</title> 20919<para> 20920 Adds to the channel buffer's consumed sub-buffer count. 20921 subbufs_consumed should be the number of sub-buffers newly consumed, 20922 not the total consumed. 20923 </para><para> 20924 20925 NOTE. Kernel clients don't need to call this function if the channel 20926 mode is 'overwrite'. 20927</para> 20928</refsect1> 20929</refentry> 20930 20931<refentry id="API-relay-close"> 20932<refentryinfo> 20933 <title>LINUX</title> 20934 <productname>Kernel Hackers Manual</productname> 20935 <date>July 2017</date> 20936</refentryinfo> 20937<refmeta> 20938 <refentrytitle><phrase>relay_close</phrase></refentrytitle> 20939 <manvolnum>9</manvolnum> 20940 <refmiscinfo class="version">4.1.27</refmiscinfo> 20941</refmeta> 20942<refnamediv> 20943 <refname>relay_close</refname> 20944 <refpurpose> 20945 close the channel 20946 </refpurpose> 20947</refnamediv> 20948<refsynopsisdiv> 20949 <title>Synopsis</title> 20950 <funcsynopsis><funcprototype> 20951 <funcdef>void <function>relay_close </function></funcdef> 20952 <paramdef>struct rchan * <parameter>chan</parameter></paramdef> 20953 </funcprototype></funcsynopsis> 20954</refsynopsisdiv> 20955<refsect1> 20956 <title>Arguments</title> 20957 <variablelist> 20958 <varlistentry> 20959 <term><parameter>chan</parameter></term> 20960 <listitem> 20961 <para> 20962 the channel 20963 </para> 20964 </listitem> 20965 </varlistentry> 20966 </variablelist> 20967</refsect1> 20968<refsect1> 20969<title>Description</title> 20970<para> 20971 Closes all channel buffers and frees the channel. 20972</para> 20973</refsect1> 20974</refentry> 20975 20976<refentry id="API-relay-flush"> 20977<refentryinfo> 20978 <title>LINUX</title> 20979 <productname>Kernel Hackers Manual</productname> 20980 <date>July 2017</date> 20981</refentryinfo> 20982<refmeta> 20983 <refentrytitle><phrase>relay_flush</phrase></refentrytitle> 20984 <manvolnum>9</manvolnum> 20985 <refmiscinfo class="version">4.1.27</refmiscinfo> 20986</refmeta> 20987<refnamediv> 20988 <refname>relay_flush</refname> 20989 <refpurpose> 20990 close the channel 20991 </refpurpose> 20992</refnamediv> 20993<refsynopsisdiv> 20994 <title>Synopsis</title> 20995 <funcsynopsis><funcprototype> 20996 <funcdef>void <function>relay_flush </function></funcdef> 20997 <paramdef>struct rchan * <parameter>chan</parameter></paramdef> 20998 </funcprototype></funcsynopsis> 20999</refsynopsisdiv> 21000<refsect1> 21001 <title>Arguments</title> 21002 <variablelist> 21003 <varlistentry> 21004 <term><parameter>chan</parameter></term> 21005 <listitem> 21006 <para> 21007 the channel 21008 </para> 21009 </listitem> 21010 </varlistentry> 21011 </variablelist> 21012</refsect1> 21013<refsect1> 21014<title>Description</title> 21015<para> 21016 Flushes all channel buffers, i.e. forces buffer switch. 21017</para> 21018</refsect1> 21019</refentry> 21020 21021<!-- kernel/relay.c --> 21022<refentry id="API-relay-mmap-buf"> 21023<refentryinfo> 21024 <title>LINUX</title> 21025 <productname>Kernel Hackers Manual</productname> 21026 <date>July 2017</date> 21027</refentryinfo> 21028<refmeta> 21029 <refentrytitle><phrase>relay_mmap_buf</phrase></refentrytitle> 21030 <manvolnum>9</manvolnum> 21031 <refmiscinfo class="version">4.1.27</refmiscinfo> 21032</refmeta> 21033<refnamediv> 21034 <refname>relay_mmap_buf</refname> 21035 <refpurpose> 21036 mmap channel buffer to process address space 21037 </refpurpose> 21038</refnamediv> 21039<refsynopsisdiv> 21040 <title>Synopsis</title> 21041 <funcsynopsis><funcprototype> 21042 <funcdef>int <function>relay_mmap_buf </function></funcdef> 21043 <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef> 21044 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 21045 </funcprototype></funcsynopsis> 21046</refsynopsisdiv> 21047<refsect1> 21048 <title>Arguments</title> 21049 <variablelist> 21050 <varlistentry> 21051 <term><parameter>buf</parameter></term> 21052 <listitem> 21053 <para> 21054 relay channel buffer 21055 </para> 21056 </listitem> 21057 </varlistentry> 21058 <varlistentry> 21059 <term><parameter>vma</parameter></term> 21060 <listitem> 21061 <para> 21062 vm_area_struct describing memory to be mapped 21063 </para> 21064 </listitem> 21065 </varlistentry> 21066 </variablelist> 21067</refsect1> 21068<refsect1> 21069<title>Description</title> 21070<para> 21071 Returns 0 if ok, negative on error 21072 </para><para> 21073 21074 Caller should already have grabbed mmap_sem. 21075</para> 21076</refsect1> 21077</refentry> 21078 21079<refentry id="API-relay-alloc-buf"> 21080<refentryinfo> 21081 <title>LINUX</title> 21082 <productname>Kernel Hackers Manual</productname> 21083 <date>July 2017</date> 21084</refentryinfo> 21085<refmeta> 21086 <refentrytitle><phrase>relay_alloc_buf</phrase></refentrytitle> 21087 <manvolnum>9</manvolnum> 21088 <refmiscinfo class="version">4.1.27</refmiscinfo> 21089</refmeta> 21090<refnamediv> 21091 <refname>relay_alloc_buf</refname> 21092 <refpurpose> 21093 allocate a channel buffer 21094 </refpurpose> 21095</refnamediv> 21096<refsynopsisdiv> 21097 <title>Synopsis</title> 21098 <funcsynopsis><funcprototype> 21099 <funcdef>void * <function>relay_alloc_buf </function></funcdef> 21100 <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef> 21101 <paramdef>size_t * <parameter>size</parameter></paramdef> 21102 </funcprototype></funcsynopsis> 21103</refsynopsisdiv> 21104<refsect1> 21105 <title>Arguments</title> 21106 <variablelist> 21107 <varlistentry> 21108 <term><parameter>buf</parameter></term> 21109 <listitem> 21110 <para> 21111 the buffer struct 21112 </para> 21113 </listitem> 21114 </varlistentry> 21115 <varlistentry> 21116 <term><parameter>size</parameter></term> 21117 <listitem> 21118 <para> 21119 total size of the buffer 21120 </para> 21121 </listitem> 21122 </varlistentry> 21123 </variablelist> 21124</refsect1> 21125<refsect1> 21126<title>Description</title> 21127<para> 21128 Returns a pointer to the resulting buffer, <constant>NULL</constant> if unsuccessful. The 21129 passed in size will get page aligned, if it isn't already. 21130</para> 21131</refsect1> 21132</refentry> 21133 21134<refentry id="API-relay-create-buf"> 21135<refentryinfo> 21136 <title>LINUX</title> 21137 <productname>Kernel Hackers Manual</productname> 21138 <date>July 2017</date> 21139</refentryinfo> 21140<refmeta> 21141 <refentrytitle><phrase>relay_create_buf</phrase></refentrytitle> 21142 <manvolnum>9</manvolnum> 21143 <refmiscinfo class="version">4.1.27</refmiscinfo> 21144</refmeta> 21145<refnamediv> 21146 <refname>relay_create_buf</refname> 21147 <refpurpose> 21148 allocate and initialize a channel buffer 21149 </refpurpose> 21150</refnamediv> 21151<refsynopsisdiv> 21152 <title>Synopsis</title> 21153 <funcsynopsis><funcprototype> 21154 <funcdef>struct rchan_buf * <function>relay_create_buf </function></funcdef> 21155 <paramdef>struct rchan * <parameter>chan</parameter></paramdef> 21156 </funcprototype></funcsynopsis> 21157</refsynopsisdiv> 21158<refsect1> 21159 <title>Arguments</title> 21160 <variablelist> 21161 <varlistentry> 21162 <term><parameter>chan</parameter></term> 21163 <listitem> 21164 <para> 21165 the relay channel 21166 </para> 21167 </listitem> 21168 </varlistentry> 21169 </variablelist> 21170</refsect1> 21171<refsect1> 21172<title>Description</title> 21173<para> 21174 Returns channel buffer if successful, <constant>NULL</constant> otherwise. 21175</para> 21176</refsect1> 21177</refentry> 21178 21179<refentry id="API-relay-destroy-channel"> 21180<refentryinfo> 21181 <title>LINUX</title> 21182 <productname>Kernel Hackers Manual</productname> 21183 <date>July 2017</date> 21184</refentryinfo> 21185<refmeta> 21186 <refentrytitle><phrase>relay_destroy_channel</phrase></refentrytitle> 21187 <manvolnum>9</manvolnum> 21188 <refmiscinfo class="version">4.1.27</refmiscinfo> 21189</refmeta> 21190<refnamediv> 21191 <refname>relay_destroy_channel</refname> 21192 <refpurpose> 21193 free the channel struct 21194 </refpurpose> 21195</refnamediv> 21196<refsynopsisdiv> 21197 <title>Synopsis</title> 21198 <funcsynopsis><funcprototype> 21199 <funcdef>void <function>relay_destroy_channel </function></funcdef> 21200 <paramdef>struct kref * <parameter>kref</parameter></paramdef> 21201 </funcprototype></funcsynopsis> 21202</refsynopsisdiv> 21203<refsect1> 21204 <title>Arguments</title> 21205 <variablelist> 21206 <varlistentry> 21207 <term><parameter>kref</parameter></term> 21208 <listitem> 21209 <para> 21210 target kernel reference that contains the relay channel 21211 </para> 21212 </listitem> 21213 </varlistentry> 21214 </variablelist> 21215</refsect1> 21216<refsect1> 21217<title>Description</title> 21218<para> 21219 Should only be called from <function>kref_put</function>. 21220</para> 21221</refsect1> 21222</refentry> 21223 21224<refentry id="API-relay-destroy-buf"> 21225<refentryinfo> 21226 <title>LINUX</title> 21227 <productname>Kernel Hackers Manual</productname> 21228 <date>July 2017</date> 21229</refentryinfo> 21230<refmeta> 21231 <refentrytitle><phrase>relay_destroy_buf</phrase></refentrytitle> 21232 <manvolnum>9</manvolnum> 21233 <refmiscinfo class="version">4.1.27</refmiscinfo> 21234</refmeta> 21235<refnamediv> 21236 <refname>relay_destroy_buf</refname> 21237 <refpurpose> 21238 destroy an rchan_buf struct and associated buffer 21239 </refpurpose> 21240</refnamediv> 21241<refsynopsisdiv> 21242 <title>Synopsis</title> 21243 <funcsynopsis><funcprototype> 21244 <funcdef>void <function>relay_destroy_buf </function></funcdef> 21245 <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef> 21246 </funcprototype></funcsynopsis> 21247</refsynopsisdiv> 21248<refsect1> 21249 <title>Arguments</title> 21250 <variablelist> 21251 <varlistentry> 21252 <term><parameter>buf</parameter></term> 21253 <listitem> 21254 <para> 21255 the buffer struct 21256 </para> 21257 </listitem> 21258 </varlistentry> 21259 </variablelist> 21260</refsect1> 21261</refentry> 21262 21263<refentry id="API-relay-remove-buf"> 21264<refentryinfo> 21265 <title>LINUX</title> 21266 <productname>Kernel Hackers Manual</productname> 21267 <date>July 2017</date> 21268</refentryinfo> 21269<refmeta> 21270 <refentrytitle><phrase>relay_remove_buf</phrase></refentrytitle> 21271 <manvolnum>9</manvolnum> 21272 <refmiscinfo class="version">4.1.27</refmiscinfo> 21273</refmeta> 21274<refnamediv> 21275 <refname>relay_remove_buf</refname> 21276 <refpurpose> 21277 remove a channel buffer 21278 </refpurpose> 21279</refnamediv> 21280<refsynopsisdiv> 21281 <title>Synopsis</title> 21282 <funcsynopsis><funcprototype> 21283 <funcdef>void <function>relay_remove_buf </function></funcdef> 21284 <paramdef>struct kref * <parameter>kref</parameter></paramdef> 21285 </funcprototype></funcsynopsis> 21286</refsynopsisdiv> 21287<refsect1> 21288 <title>Arguments</title> 21289 <variablelist> 21290 <varlistentry> 21291 <term><parameter>kref</parameter></term> 21292 <listitem> 21293 <para> 21294 target kernel reference that contains the relay buffer 21295 </para> 21296 </listitem> 21297 </varlistentry> 21298 </variablelist> 21299</refsect1> 21300<refsect1> 21301<title>Description</title> 21302<para> 21303 Removes the file from the filesystem, which also frees the 21304 rchan_buf_struct and the channel buffer. Should only be called from 21305 <function>kref_put</function>. 21306</para> 21307</refsect1> 21308</refentry> 21309 21310<refentry id="API-relay-buf-empty"> 21311<refentryinfo> 21312 <title>LINUX</title> 21313 <productname>Kernel Hackers Manual</productname> 21314 <date>July 2017</date> 21315</refentryinfo> 21316<refmeta> 21317 <refentrytitle><phrase>relay_buf_empty</phrase></refentrytitle> 21318 <manvolnum>9</manvolnum> 21319 <refmiscinfo class="version">4.1.27</refmiscinfo> 21320</refmeta> 21321<refnamediv> 21322 <refname>relay_buf_empty</refname> 21323 <refpurpose> 21324 boolean, is the channel buffer empty? 21325 </refpurpose> 21326</refnamediv> 21327<refsynopsisdiv> 21328 <title>Synopsis</title> 21329 <funcsynopsis><funcprototype> 21330 <funcdef>int <function>relay_buf_empty </function></funcdef> 21331 <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef> 21332 </funcprototype></funcsynopsis> 21333</refsynopsisdiv> 21334<refsect1> 21335 <title>Arguments</title> 21336 <variablelist> 21337 <varlistentry> 21338 <term><parameter>buf</parameter></term> 21339 <listitem> 21340 <para> 21341 channel buffer 21342 </para> 21343 </listitem> 21344 </varlistentry> 21345 </variablelist> 21346</refsect1> 21347<refsect1> 21348<title>Description</title> 21349<para> 21350 Returns 1 if the buffer is empty, 0 otherwise. 21351</para> 21352</refsect1> 21353</refentry> 21354 21355<refentry id="API-wakeup-readers"> 21356<refentryinfo> 21357 <title>LINUX</title> 21358 <productname>Kernel Hackers Manual</productname> 21359 <date>July 2017</date> 21360</refentryinfo> 21361<refmeta> 21362 <refentrytitle><phrase>wakeup_readers</phrase></refentrytitle> 21363 <manvolnum>9</manvolnum> 21364 <refmiscinfo class="version">4.1.27</refmiscinfo> 21365</refmeta> 21366<refnamediv> 21367 <refname>wakeup_readers</refname> 21368 <refpurpose> 21369 wake up readers waiting on a channel 21370 </refpurpose> 21371</refnamediv> 21372<refsynopsisdiv> 21373 <title>Synopsis</title> 21374 <funcsynopsis><funcprototype> 21375 <funcdef>void <function>wakeup_readers </function></funcdef> 21376 <paramdef>unsigned long <parameter>data</parameter></paramdef> 21377 </funcprototype></funcsynopsis> 21378</refsynopsisdiv> 21379<refsect1> 21380 <title>Arguments</title> 21381 <variablelist> 21382 <varlistentry> 21383 <term><parameter>data</parameter></term> 21384 <listitem> 21385 <para> 21386 contains the channel buffer 21387 </para> 21388 </listitem> 21389 </varlistentry> 21390 </variablelist> 21391</refsect1> 21392<refsect1> 21393<title>Description</title> 21394<para> 21395 This is the timer function used to defer reader waking. 21396</para> 21397</refsect1> 21398</refentry> 21399 21400<refentry id="API---relay-reset"> 21401<refentryinfo> 21402 <title>LINUX</title> 21403 <productname>Kernel Hackers Manual</productname> 21404 <date>July 2017</date> 21405</refentryinfo> 21406<refmeta> 21407 <refentrytitle><phrase>__relay_reset</phrase></refentrytitle> 21408 <manvolnum>9</manvolnum> 21409 <refmiscinfo class="version">4.1.27</refmiscinfo> 21410</refmeta> 21411<refnamediv> 21412 <refname>__relay_reset</refname> 21413 <refpurpose> 21414 reset a channel buffer 21415 </refpurpose> 21416</refnamediv> 21417<refsynopsisdiv> 21418 <title>Synopsis</title> 21419 <funcsynopsis><funcprototype> 21420 <funcdef>void <function>__relay_reset </function></funcdef> 21421 <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef> 21422 <paramdef>unsigned int <parameter>init</parameter></paramdef> 21423 </funcprototype></funcsynopsis> 21424</refsynopsisdiv> 21425<refsect1> 21426 <title>Arguments</title> 21427 <variablelist> 21428 <varlistentry> 21429 <term><parameter>buf</parameter></term> 21430 <listitem> 21431 <para> 21432 the channel buffer 21433 </para> 21434 </listitem> 21435 </varlistentry> 21436 <varlistentry> 21437 <term><parameter>init</parameter></term> 21438 <listitem> 21439 <para> 21440 1 if this is a first-time initialization 21441 </para> 21442 </listitem> 21443 </varlistentry> 21444 </variablelist> 21445</refsect1> 21446<refsect1> 21447<title>Description</title> 21448<para> 21449 See <function>relay_reset</function> for description of effect. 21450</para> 21451</refsect1> 21452</refentry> 21453 21454<refentry id="API-relay-close-buf"> 21455<refentryinfo> 21456 <title>LINUX</title> 21457 <productname>Kernel Hackers Manual</productname> 21458 <date>July 2017</date> 21459</refentryinfo> 21460<refmeta> 21461 <refentrytitle><phrase>relay_close_buf</phrase></refentrytitle> 21462 <manvolnum>9</manvolnum> 21463 <refmiscinfo class="version">4.1.27</refmiscinfo> 21464</refmeta> 21465<refnamediv> 21466 <refname>relay_close_buf</refname> 21467 <refpurpose> 21468 close a channel buffer 21469 </refpurpose> 21470</refnamediv> 21471<refsynopsisdiv> 21472 <title>Synopsis</title> 21473 <funcsynopsis><funcprototype> 21474 <funcdef>void <function>relay_close_buf </function></funcdef> 21475 <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef> 21476 </funcprototype></funcsynopsis> 21477</refsynopsisdiv> 21478<refsect1> 21479 <title>Arguments</title> 21480 <variablelist> 21481 <varlistentry> 21482 <term><parameter>buf</parameter></term> 21483 <listitem> 21484 <para> 21485 channel buffer 21486 </para> 21487 </listitem> 21488 </varlistentry> 21489 </variablelist> 21490</refsect1> 21491<refsect1> 21492<title>Description</title> 21493<para> 21494 Marks the buffer finalized and restores the default callbacks. 21495 The channel buffer and channel buffer data structure are then freed 21496 automatically when the last reference is given up. 21497</para> 21498</refsect1> 21499</refentry> 21500 21501<refentry id="API-relay-hotcpu-callback"> 21502<refentryinfo> 21503 <title>LINUX</title> 21504 <productname>Kernel Hackers Manual</productname> 21505 <date>July 2017</date> 21506</refentryinfo> 21507<refmeta> 21508 <refentrytitle><phrase>relay_hotcpu_callback</phrase></refentrytitle> 21509 <manvolnum>9</manvolnum> 21510 <refmiscinfo class="version">4.1.27</refmiscinfo> 21511</refmeta> 21512<refnamediv> 21513 <refname>relay_hotcpu_callback</refname> 21514 <refpurpose> 21515 CPU hotplug callback 21516 </refpurpose> 21517</refnamediv> 21518<refsynopsisdiv> 21519 <title>Synopsis</title> 21520 <funcsynopsis><funcprototype> 21521 <funcdef>int <function>relay_hotcpu_callback </function></funcdef> 21522 <paramdef>struct notifier_block * <parameter>nb</parameter></paramdef> 21523 <paramdef>unsigned long <parameter>action</parameter></paramdef> 21524 <paramdef>void * <parameter>hcpu</parameter></paramdef> 21525 </funcprototype></funcsynopsis> 21526</refsynopsisdiv> 21527<refsect1> 21528 <title>Arguments</title> 21529 <variablelist> 21530 <varlistentry> 21531 <term><parameter>nb</parameter></term> 21532 <listitem> 21533 <para> 21534 notifier block 21535 </para> 21536 </listitem> 21537 </varlistentry> 21538 <varlistentry> 21539 <term><parameter>action</parameter></term> 21540 <listitem> 21541 <para> 21542 hotplug action to take 21543 </para> 21544 </listitem> 21545 </varlistentry> 21546 <varlistentry> 21547 <term><parameter>hcpu</parameter></term> 21548 <listitem> 21549 <para> 21550 CPU number 21551 </para> 21552 </listitem> 21553 </varlistentry> 21554 </variablelist> 21555</refsect1> 21556<refsect1> 21557<title>Description</title> 21558<para> 21559 Returns the success/failure of the operation. (<constant>NOTIFY_OK</constant>, <constant>NOTIFY_BAD</constant>) 21560</para> 21561</refsect1> 21562</refentry> 21563 21564<refentry id="API-relay-late-setup-files"> 21565<refentryinfo> 21566 <title>LINUX</title> 21567 <productname>Kernel Hackers Manual</productname> 21568 <date>July 2017</date> 21569</refentryinfo> 21570<refmeta> 21571 <refentrytitle><phrase>relay_late_setup_files</phrase></refentrytitle> 21572 <manvolnum>9</manvolnum> 21573 <refmiscinfo class="version">4.1.27</refmiscinfo> 21574</refmeta> 21575<refnamediv> 21576 <refname>relay_late_setup_files</refname> 21577 <refpurpose> 21578 triggers file creation 21579 </refpurpose> 21580</refnamediv> 21581<refsynopsisdiv> 21582 <title>Synopsis</title> 21583 <funcsynopsis><funcprototype> 21584 <funcdef>int <function>relay_late_setup_files </function></funcdef> 21585 <paramdef>struct rchan * <parameter>chan</parameter></paramdef> 21586 <paramdef>const char * <parameter>base_filename</parameter></paramdef> 21587 <paramdef>struct dentry * <parameter>parent</parameter></paramdef> 21588 </funcprototype></funcsynopsis> 21589</refsynopsisdiv> 21590<refsect1> 21591 <title>Arguments</title> 21592 <variablelist> 21593 <varlistentry> 21594 <term><parameter>chan</parameter></term> 21595 <listitem> 21596 <para> 21597 channel to operate on 21598 </para> 21599 </listitem> 21600 </varlistentry> 21601 <varlistentry> 21602 <term><parameter>base_filename</parameter></term> 21603 <listitem> 21604 <para> 21605 base name of files to create 21606 </para> 21607 </listitem> 21608 </varlistentry> 21609 <varlistentry> 21610 <term><parameter>parent</parameter></term> 21611 <listitem> 21612 <para> 21613 dentry of parent directory, <constant>NULL</constant> for root directory 21614 </para> 21615 </listitem> 21616 </varlistentry> 21617 </variablelist> 21618</refsect1> 21619<refsect1> 21620<title>Description</title> 21621<para> 21622 Returns 0 if successful, non-zero otherwise. 21623 </para><para> 21624 21625 Use to setup files for a previously buffer-only channel. 21626 Useful to do early tracing in kernel, before VFS is up, for example. 21627</para> 21628</refsect1> 21629</refentry> 21630 21631<refentry id="API-relay-file-open"> 21632<refentryinfo> 21633 <title>LINUX</title> 21634 <productname>Kernel Hackers Manual</productname> 21635 <date>July 2017</date> 21636</refentryinfo> 21637<refmeta> 21638 <refentrytitle><phrase>relay_file_open</phrase></refentrytitle> 21639 <manvolnum>9</manvolnum> 21640 <refmiscinfo class="version">4.1.27</refmiscinfo> 21641</refmeta> 21642<refnamediv> 21643 <refname>relay_file_open</refname> 21644 <refpurpose> 21645 open file op for relay files 21646 </refpurpose> 21647</refnamediv> 21648<refsynopsisdiv> 21649 <title>Synopsis</title> 21650 <funcsynopsis><funcprototype> 21651 <funcdef>int <function>relay_file_open </function></funcdef> 21652 <paramdef>struct inode * <parameter>inode</parameter></paramdef> 21653 <paramdef>struct file * <parameter>filp</parameter></paramdef> 21654 </funcprototype></funcsynopsis> 21655</refsynopsisdiv> 21656<refsect1> 21657 <title>Arguments</title> 21658 <variablelist> 21659 <varlistentry> 21660 <term><parameter>inode</parameter></term> 21661 <listitem> 21662 <para> 21663 the inode 21664 </para> 21665 </listitem> 21666 </varlistentry> 21667 <varlistentry> 21668 <term><parameter>filp</parameter></term> 21669 <listitem> 21670 <para> 21671 the file 21672 </para> 21673 </listitem> 21674 </varlistentry> 21675 </variablelist> 21676</refsect1> 21677<refsect1> 21678<title>Description</title> 21679<para> 21680 Increments the channel buffer refcount. 21681</para> 21682</refsect1> 21683</refentry> 21684 21685<refentry id="API-relay-file-mmap"> 21686<refentryinfo> 21687 <title>LINUX</title> 21688 <productname>Kernel Hackers Manual</productname> 21689 <date>July 2017</date> 21690</refentryinfo> 21691<refmeta> 21692 <refentrytitle><phrase>relay_file_mmap</phrase></refentrytitle> 21693 <manvolnum>9</manvolnum> 21694 <refmiscinfo class="version">4.1.27</refmiscinfo> 21695</refmeta> 21696<refnamediv> 21697 <refname>relay_file_mmap</refname> 21698 <refpurpose> 21699 mmap file op for relay files 21700 </refpurpose> 21701</refnamediv> 21702<refsynopsisdiv> 21703 <title>Synopsis</title> 21704 <funcsynopsis><funcprototype> 21705 <funcdef>int <function>relay_file_mmap </function></funcdef> 21706 <paramdef>struct file * <parameter>filp</parameter></paramdef> 21707 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 21708 </funcprototype></funcsynopsis> 21709</refsynopsisdiv> 21710<refsect1> 21711 <title>Arguments</title> 21712 <variablelist> 21713 <varlistentry> 21714 <term><parameter>filp</parameter></term> 21715 <listitem> 21716 <para> 21717 the file 21718 </para> 21719 </listitem> 21720 </varlistentry> 21721 <varlistentry> 21722 <term><parameter>vma</parameter></term> 21723 <listitem> 21724 <para> 21725 the vma describing what to map 21726 </para> 21727 </listitem> 21728 </varlistentry> 21729 </variablelist> 21730</refsect1> 21731<refsect1> 21732<title>Description</title> 21733<para> 21734 Calls upon <function>relay_mmap_buf</function> to map the file into user space. 21735</para> 21736</refsect1> 21737</refentry> 21738 21739<refentry id="API-relay-file-poll"> 21740<refentryinfo> 21741 <title>LINUX</title> 21742 <productname>Kernel Hackers Manual</productname> 21743 <date>July 2017</date> 21744</refentryinfo> 21745<refmeta> 21746 <refentrytitle><phrase>relay_file_poll</phrase></refentrytitle> 21747 <manvolnum>9</manvolnum> 21748 <refmiscinfo class="version">4.1.27</refmiscinfo> 21749</refmeta> 21750<refnamediv> 21751 <refname>relay_file_poll</refname> 21752 <refpurpose> 21753 poll file op for relay files 21754 </refpurpose> 21755</refnamediv> 21756<refsynopsisdiv> 21757 <title>Synopsis</title> 21758 <funcsynopsis><funcprototype> 21759 <funcdef>unsigned int <function>relay_file_poll </function></funcdef> 21760 <paramdef>struct file * <parameter>filp</parameter></paramdef> 21761 <paramdef>poll_table * <parameter>wait</parameter></paramdef> 21762 </funcprototype></funcsynopsis> 21763</refsynopsisdiv> 21764<refsect1> 21765 <title>Arguments</title> 21766 <variablelist> 21767 <varlistentry> 21768 <term><parameter>filp</parameter></term> 21769 <listitem> 21770 <para> 21771 the file 21772 </para> 21773 </listitem> 21774 </varlistentry> 21775 <varlistentry> 21776 <term><parameter>wait</parameter></term> 21777 <listitem> 21778 <para> 21779 poll table 21780 </para> 21781 </listitem> 21782 </varlistentry> 21783 </variablelist> 21784</refsect1> 21785<refsect1> 21786<title>Description</title> 21787<para> 21788 Poll implemention. 21789</para> 21790</refsect1> 21791</refentry> 21792 21793<refentry id="API-relay-file-release"> 21794<refentryinfo> 21795 <title>LINUX</title> 21796 <productname>Kernel Hackers Manual</productname> 21797 <date>July 2017</date> 21798</refentryinfo> 21799<refmeta> 21800 <refentrytitle><phrase>relay_file_release</phrase></refentrytitle> 21801 <manvolnum>9</manvolnum> 21802 <refmiscinfo class="version">4.1.27</refmiscinfo> 21803</refmeta> 21804<refnamediv> 21805 <refname>relay_file_release</refname> 21806 <refpurpose> 21807 release file op for relay files 21808 </refpurpose> 21809</refnamediv> 21810<refsynopsisdiv> 21811 <title>Synopsis</title> 21812 <funcsynopsis><funcprototype> 21813 <funcdef>int <function>relay_file_release </function></funcdef> 21814 <paramdef>struct inode * <parameter>inode</parameter></paramdef> 21815 <paramdef>struct file * <parameter>filp</parameter></paramdef> 21816 </funcprototype></funcsynopsis> 21817</refsynopsisdiv> 21818<refsect1> 21819 <title>Arguments</title> 21820 <variablelist> 21821 <varlistentry> 21822 <term><parameter>inode</parameter></term> 21823 <listitem> 21824 <para> 21825 the inode 21826 </para> 21827 </listitem> 21828 </varlistentry> 21829 <varlistentry> 21830 <term><parameter>filp</parameter></term> 21831 <listitem> 21832 <para> 21833 the file 21834 </para> 21835 </listitem> 21836 </varlistentry> 21837 </variablelist> 21838</refsect1> 21839<refsect1> 21840<title>Description</title> 21841<para> 21842 Decrements the channel refcount, as the filesystem is 21843 no longer using it. 21844</para> 21845</refsect1> 21846</refentry> 21847 21848<refentry id="API-relay-file-read-subbuf-avail"> 21849<refentryinfo> 21850 <title>LINUX</title> 21851 <productname>Kernel Hackers Manual</productname> 21852 <date>July 2017</date> 21853</refentryinfo> 21854<refmeta> 21855 <refentrytitle><phrase>relay_file_read_subbuf_avail</phrase></refentrytitle> 21856 <manvolnum>9</manvolnum> 21857 <refmiscinfo class="version">4.1.27</refmiscinfo> 21858</refmeta> 21859<refnamediv> 21860 <refname>relay_file_read_subbuf_avail</refname> 21861 <refpurpose> 21862 return bytes available in sub-buffer 21863 </refpurpose> 21864</refnamediv> 21865<refsynopsisdiv> 21866 <title>Synopsis</title> 21867 <funcsynopsis><funcprototype> 21868 <funcdef>size_t <function>relay_file_read_subbuf_avail </function></funcdef> 21869 <paramdef>size_t <parameter>read_pos</parameter></paramdef> 21870 <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef> 21871 </funcprototype></funcsynopsis> 21872</refsynopsisdiv> 21873<refsect1> 21874 <title>Arguments</title> 21875 <variablelist> 21876 <varlistentry> 21877 <term><parameter>read_pos</parameter></term> 21878 <listitem> 21879 <para> 21880 file read position 21881 </para> 21882 </listitem> 21883 </varlistentry> 21884 <varlistentry> 21885 <term><parameter>buf</parameter></term> 21886 <listitem> 21887 <para> 21888 relay channel buffer 21889 </para> 21890 </listitem> 21891 </varlistentry> 21892 </variablelist> 21893</refsect1> 21894</refentry> 21895 21896<refentry id="API-relay-file-read-start-pos"> 21897<refentryinfo> 21898 <title>LINUX</title> 21899 <productname>Kernel Hackers Manual</productname> 21900 <date>July 2017</date> 21901</refentryinfo> 21902<refmeta> 21903 <refentrytitle><phrase>relay_file_read_start_pos</phrase></refentrytitle> 21904 <manvolnum>9</manvolnum> 21905 <refmiscinfo class="version">4.1.27</refmiscinfo> 21906</refmeta> 21907<refnamediv> 21908 <refname>relay_file_read_start_pos</refname> 21909 <refpurpose> 21910 find the first available byte to read 21911 </refpurpose> 21912</refnamediv> 21913<refsynopsisdiv> 21914 <title>Synopsis</title> 21915 <funcsynopsis><funcprototype> 21916 <funcdef>size_t <function>relay_file_read_start_pos </function></funcdef> 21917 <paramdef>size_t <parameter>read_pos</parameter></paramdef> 21918 <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef> 21919 </funcprototype></funcsynopsis> 21920</refsynopsisdiv> 21921<refsect1> 21922 <title>Arguments</title> 21923 <variablelist> 21924 <varlistentry> 21925 <term><parameter>read_pos</parameter></term> 21926 <listitem> 21927 <para> 21928 file read position 21929 </para> 21930 </listitem> 21931 </varlistentry> 21932 <varlistentry> 21933 <term><parameter>buf</parameter></term> 21934 <listitem> 21935 <para> 21936 relay channel buffer 21937 </para> 21938 </listitem> 21939 </varlistentry> 21940 </variablelist> 21941</refsect1> 21942<refsect1> 21943<title>Description</title> 21944<para> 21945 If the <parameter>read_pos</parameter> is in the middle of padding, return the 21946 position of the first actually available byte, otherwise 21947 return the original value. 21948</para> 21949</refsect1> 21950</refentry> 21951 21952<refentry id="API-relay-file-read-end-pos"> 21953<refentryinfo> 21954 <title>LINUX</title> 21955 <productname>Kernel Hackers Manual</productname> 21956 <date>July 2017</date> 21957</refentryinfo> 21958<refmeta> 21959 <refentrytitle><phrase>relay_file_read_end_pos</phrase></refentrytitle> 21960 <manvolnum>9</manvolnum> 21961 <refmiscinfo class="version">4.1.27</refmiscinfo> 21962</refmeta> 21963<refnamediv> 21964 <refname>relay_file_read_end_pos</refname> 21965 <refpurpose> 21966 return the new read position 21967 </refpurpose> 21968</refnamediv> 21969<refsynopsisdiv> 21970 <title>Synopsis</title> 21971 <funcsynopsis><funcprototype> 21972 <funcdef>size_t <function>relay_file_read_end_pos </function></funcdef> 21973 <paramdef>struct rchan_buf * <parameter>buf</parameter></paramdef> 21974 <paramdef>size_t <parameter>read_pos</parameter></paramdef> 21975 <paramdef>size_t <parameter>count</parameter></paramdef> 21976 </funcprototype></funcsynopsis> 21977</refsynopsisdiv> 21978<refsect1> 21979 <title>Arguments</title> 21980 <variablelist> 21981 <varlistentry> 21982 <term><parameter>buf</parameter></term> 21983 <listitem> 21984 <para> 21985 relay channel buffer 21986 </para> 21987 </listitem> 21988 </varlistentry> 21989 <varlistentry> 21990 <term><parameter>read_pos</parameter></term> 21991 <listitem> 21992 <para> 21993 file read position 21994 </para> 21995 </listitem> 21996 </varlistentry> 21997 <varlistentry> 21998 <term><parameter>count</parameter></term> 21999 <listitem> 22000 <para> 22001 number of bytes to be read 22002 </para> 22003 </listitem> 22004 </varlistentry> 22005 </variablelist> 22006</refsect1> 22007</refentry> 22008 22009 </sect1> 22010 </chapter> 22011 22012 <chapter id="modload"> 22013 <title>Module Support</title> 22014 <sect1><title>Module Loading</title> 22015<!-- kernel/kmod.c --> 22016<refentry id="API---request-module"> 22017<refentryinfo> 22018 <title>LINUX</title> 22019 <productname>Kernel Hackers Manual</productname> 22020 <date>July 2017</date> 22021</refentryinfo> 22022<refmeta> 22023 <refentrytitle><phrase>__request_module</phrase></refentrytitle> 22024 <manvolnum>9</manvolnum> 22025 <refmiscinfo class="version">4.1.27</refmiscinfo> 22026</refmeta> 22027<refnamediv> 22028 <refname>__request_module</refname> 22029 <refpurpose> 22030 try to load a kernel module 22031 </refpurpose> 22032</refnamediv> 22033<refsynopsisdiv> 22034 <title>Synopsis</title> 22035 <funcsynopsis><funcprototype> 22036 <funcdef>int <function>__request_module </function></funcdef> 22037 <paramdef>bool <parameter>wait</parameter></paramdef> 22038 <paramdef>const char * <parameter>fmt</parameter></paramdef> 22039 <paramdef> <parameter>...</parameter></paramdef> 22040 </funcprototype></funcsynopsis> 22041</refsynopsisdiv> 22042<refsect1> 22043 <title>Arguments</title> 22044 <variablelist> 22045 <varlistentry> 22046 <term><parameter>wait</parameter></term> 22047 <listitem> 22048 <para> 22049 wait (or not) for the operation to complete 22050 </para> 22051 </listitem> 22052 </varlistentry> 22053 <varlistentry> 22054 <term><parameter>fmt</parameter></term> 22055 <listitem> 22056 <para> 22057 printf style format string for the name of the module 22058 @...: arguments as specified in the format string 22059 </para> 22060 </listitem> 22061 </varlistentry> 22062 <varlistentry> 22063 <term><parameter>...</parameter></term> 22064 <listitem> 22065 <para> 22066 variable arguments 22067 </para> 22068 </listitem> 22069 </varlistentry> 22070 </variablelist> 22071</refsect1> 22072<refsect1> 22073<title>Description</title> 22074<para> 22075 Load a module using the user mode module loader. The function returns 22076 zero on success or a negative errno code on failure. Note that a 22077 successful module load does not mean the module did not then unload 22078 and exit on an error of its own. Callers must check that the service 22079 they requested is now available not blindly invoke it. 22080 </para><para> 22081 22082 If module auto-loading support is disabled then this function 22083 becomes a no-operation. 22084</para> 22085</refsect1> 22086</refentry> 22087 22088<refentry id="API-call-usermodehelper-setup"> 22089<refentryinfo> 22090 <title>LINUX</title> 22091 <productname>Kernel Hackers Manual</productname> 22092 <date>July 2017</date> 22093</refentryinfo> 22094<refmeta> 22095 <refentrytitle><phrase>call_usermodehelper_setup</phrase></refentrytitle> 22096 <manvolnum>9</manvolnum> 22097 <refmiscinfo class="version">4.1.27</refmiscinfo> 22098</refmeta> 22099<refnamediv> 22100 <refname>call_usermodehelper_setup</refname> 22101 <refpurpose> 22102 prepare to call a usermode helper 22103 </refpurpose> 22104</refnamediv> 22105<refsynopsisdiv> 22106 <title>Synopsis</title> 22107 <funcsynopsis><funcprototype> 22108 <funcdef>struct subprocess_info * <function>call_usermodehelper_setup </function></funcdef> 22109 <paramdef>char * <parameter>path</parameter></paramdef> 22110 <paramdef>char ** <parameter>argv</parameter></paramdef> 22111 <paramdef>char ** <parameter>envp</parameter></paramdef> 22112 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 22113 <paramdef>int (*<parameter>init</parameter>) 22114 <funcparams>struct subprocess_info *info, struct cred *new</funcparams></paramdef> 22115 <paramdef>void (*<parameter>cleanup</parameter>) 22116 <funcparams>struct subprocess_info *info</funcparams></paramdef> 22117 <paramdef>void * <parameter>data</parameter></paramdef> 22118 </funcprototype></funcsynopsis> 22119</refsynopsisdiv> 22120<refsect1> 22121 <title>Arguments</title> 22122 <variablelist> 22123 <varlistentry> 22124 <term><parameter>path</parameter></term> 22125 <listitem> 22126 <para> 22127 path to usermode executable 22128 </para> 22129 </listitem> 22130 </varlistentry> 22131 <varlistentry> 22132 <term><parameter>argv</parameter></term> 22133 <listitem> 22134 <para> 22135 arg vector for process 22136 </para> 22137 </listitem> 22138 </varlistentry> 22139 <varlistentry> 22140 <term><parameter>envp</parameter></term> 22141 <listitem> 22142 <para> 22143 environment for process 22144 </para> 22145 </listitem> 22146 </varlistentry> 22147 <varlistentry> 22148 <term><parameter>gfp_mask</parameter></term> 22149 <listitem> 22150 <para> 22151 gfp mask for memory allocation 22152 </para> 22153 </listitem> 22154 </varlistentry> 22155 <varlistentry> 22156 <term><parameter>init</parameter></term> 22157 <listitem> 22158 <para> 22159 an init function 22160 </para> 22161 </listitem> 22162 </varlistentry> 22163 <varlistentry> 22164 <term><parameter>cleanup</parameter></term> 22165 <listitem> 22166 <para> 22167 a cleanup function 22168 </para> 22169 </listitem> 22170 </varlistentry> 22171 <varlistentry> 22172 <term><parameter>data</parameter></term> 22173 <listitem> 22174 <para> 22175 arbitrary context sensitive data 22176 </para> 22177 </listitem> 22178 </varlistentry> 22179 </variablelist> 22180</refsect1> 22181<refsect1> 22182<title>Description</title> 22183<para> 22184 Returns either <constant>NULL</constant> on allocation failure, or a subprocess_info 22185 structure. This should be passed to call_usermodehelper_exec to 22186 exec the process and free the structure. 22187 </para><para> 22188 22189 The init function is used to customize the helper process prior to 22190 exec. A non-zero return code causes the process to error out, exit, 22191 and return the failure to the calling process 22192 </para><para> 22193 22194 The cleanup function is just before ethe subprocess_info is about to 22195 be freed. This can be used for freeing the argv and envp. The 22196 Function must be runnable in either a process context or the 22197 context in which call_usermodehelper_exec is called. 22198</para> 22199</refsect1> 22200</refentry> 22201 22202<refentry id="API-call-usermodehelper-exec"> 22203<refentryinfo> 22204 <title>LINUX</title> 22205 <productname>Kernel Hackers Manual</productname> 22206 <date>July 2017</date> 22207</refentryinfo> 22208<refmeta> 22209 <refentrytitle><phrase>call_usermodehelper_exec</phrase></refentrytitle> 22210 <manvolnum>9</manvolnum> 22211 <refmiscinfo class="version">4.1.27</refmiscinfo> 22212</refmeta> 22213<refnamediv> 22214 <refname>call_usermodehelper_exec</refname> 22215 <refpurpose> 22216 start a usermode application 22217 </refpurpose> 22218</refnamediv> 22219<refsynopsisdiv> 22220 <title>Synopsis</title> 22221 <funcsynopsis><funcprototype> 22222 <funcdef>int <function>call_usermodehelper_exec </function></funcdef> 22223 <paramdef>struct subprocess_info * <parameter>sub_info</parameter></paramdef> 22224 <paramdef>int <parameter>wait</parameter></paramdef> 22225 </funcprototype></funcsynopsis> 22226</refsynopsisdiv> 22227<refsect1> 22228 <title>Arguments</title> 22229 <variablelist> 22230 <varlistentry> 22231 <term><parameter>sub_info</parameter></term> 22232 <listitem> 22233 <para> 22234 information about the subprocessa 22235 </para> 22236 </listitem> 22237 </varlistentry> 22238 <varlistentry> 22239 <term><parameter>wait</parameter></term> 22240 <listitem> 22241 <para> 22242 wait for the application to finish and return status. 22243 when UMH_NO_WAIT don't wait at all, but you get no useful error back 22244 when the program couldn't be exec'ed. This makes it safe to call 22245 from interrupt context. 22246 </para> 22247 </listitem> 22248 </varlistentry> 22249 </variablelist> 22250</refsect1> 22251<refsect1> 22252<title>Description</title> 22253<para> 22254 Runs a user-space application. The application is started 22255 asynchronously if wait is not set, and runs as a child of keventd. 22256 (ie. it runs with full root capabilities). 22257</para> 22258</refsect1> 22259</refentry> 22260 22261<refentry id="API-call-usermodehelper"> 22262<refentryinfo> 22263 <title>LINUX</title> 22264 <productname>Kernel Hackers Manual</productname> 22265 <date>July 2017</date> 22266</refentryinfo> 22267<refmeta> 22268 <refentrytitle><phrase>call_usermodehelper</phrase></refentrytitle> 22269 <manvolnum>9</manvolnum> 22270 <refmiscinfo class="version">4.1.27</refmiscinfo> 22271</refmeta> 22272<refnamediv> 22273 <refname>call_usermodehelper</refname> 22274 <refpurpose> 22275 prepare and start a usermode application 22276 </refpurpose> 22277</refnamediv> 22278<refsynopsisdiv> 22279 <title>Synopsis</title> 22280 <funcsynopsis><funcprototype> 22281 <funcdef>int <function>call_usermodehelper </function></funcdef> 22282 <paramdef>char * <parameter>path</parameter></paramdef> 22283 <paramdef>char ** <parameter>argv</parameter></paramdef> 22284 <paramdef>char ** <parameter>envp</parameter></paramdef> 22285 <paramdef>int <parameter>wait</parameter></paramdef> 22286 </funcprototype></funcsynopsis> 22287</refsynopsisdiv> 22288<refsect1> 22289 <title>Arguments</title> 22290 <variablelist> 22291 <varlistentry> 22292 <term><parameter>path</parameter></term> 22293 <listitem> 22294 <para> 22295 path to usermode executable 22296 </para> 22297 </listitem> 22298 </varlistentry> 22299 <varlistentry> 22300 <term><parameter>argv</parameter></term> 22301 <listitem> 22302 <para> 22303 arg vector for process 22304 </para> 22305 </listitem> 22306 </varlistentry> 22307 <varlistentry> 22308 <term><parameter>envp</parameter></term> 22309 <listitem> 22310 <para> 22311 environment for process 22312 </para> 22313 </listitem> 22314 </varlistentry> 22315 <varlistentry> 22316 <term><parameter>wait</parameter></term> 22317 <listitem> 22318 <para> 22319 wait for the application to finish and return status. 22320 when UMH_NO_WAIT don't wait at all, but you get no useful error back 22321 when the program couldn't be exec'ed. This makes it safe to call 22322 from interrupt context. 22323 </para> 22324 </listitem> 22325 </varlistentry> 22326 </variablelist> 22327</refsect1> 22328<refsect1> 22329<title>Description</title> 22330<para> 22331 This function is the equivalent to use <function>call_usermodehelper_setup</function> and 22332 <function>call_usermodehelper_exec</function>. 22333</para> 22334</refsect1> 22335</refentry> 22336 22337 </sect1> 22338 <sect1><title>Inter Module support</title> 22339 <para> 22340 Refer to the file kernel/module.c for more information. 22341 </para> 22342<!-- FIXME: Removed for now since no structured comments in source 22343X!Ekernel/module.c 22344--> 22345 </sect1> 22346 </chapter> 22347 22348 <chapter id="hardware"> 22349 <title>Hardware Interfaces</title> 22350 <sect1><title>Interrupt Handling</title> 22351<!-- kernel/irq/manage.c --> 22352<refentry id="API-synchronize-hardirq"> 22353<refentryinfo> 22354 <title>LINUX</title> 22355 <productname>Kernel Hackers Manual</productname> 22356 <date>July 2017</date> 22357</refentryinfo> 22358<refmeta> 22359 <refentrytitle><phrase>synchronize_hardirq</phrase></refentrytitle> 22360 <manvolnum>9</manvolnum> 22361 <refmiscinfo class="version">4.1.27</refmiscinfo> 22362</refmeta> 22363<refnamediv> 22364 <refname>synchronize_hardirq</refname> 22365 <refpurpose> 22366 wait for pending hard IRQ handlers (on other CPUs) 22367 </refpurpose> 22368</refnamediv> 22369<refsynopsisdiv> 22370 <title>Synopsis</title> 22371 <funcsynopsis><funcprototype> 22372 <funcdef>bool <function>synchronize_hardirq </function></funcdef> 22373 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 22374 </funcprototype></funcsynopsis> 22375</refsynopsisdiv> 22376<refsect1> 22377 <title>Arguments</title> 22378 <variablelist> 22379 <varlistentry> 22380 <term><parameter>irq</parameter></term> 22381 <listitem> 22382 <para> 22383 interrupt number to wait for 22384 </para> 22385 </listitem> 22386 </varlistentry> 22387 </variablelist> 22388</refsect1> 22389<refsect1> 22390<title>Description</title> 22391<para> 22392 This function waits for any pending hard IRQ handlers for this 22393 interrupt to complete before returning. If you use this 22394 function while holding a resource the IRQ handler may need you 22395 will deadlock. It does not take associated threaded handlers 22396 into account. 22397 </para><para> 22398 22399 Do not use this for shutdown scenarios where you must be sure 22400 that all parts (hardirq and threaded handler) have completed. 22401</para> 22402</refsect1> 22403<refsect1> 22404<title>Returns</title> 22405<para> 22406 false if a threaded handler is active. 22407 </para><para> 22408 22409 This function may be called - with care - from IRQ context. 22410</para> 22411</refsect1> 22412</refentry> 22413 22414<refentry id="API-synchronize-irq"> 22415<refentryinfo> 22416 <title>LINUX</title> 22417 <productname>Kernel Hackers Manual</productname> 22418 <date>July 2017</date> 22419</refentryinfo> 22420<refmeta> 22421 <refentrytitle><phrase>synchronize_irq</phrase></refentrytitle> 22422 <manvolnum>9</manvolnum> 22423 <refmiscinfo class="version">4.1.27</refmiscinfo> 22424</refmeta> 22425<refnamediv> 22426 <refname>synchronize_irq</refname> 22427 <refpurpose> 22428 wait for pending IRQ handlers (on other CPUs) 22429 </refpurpose> 22430</refnamediv> 22431<refsynopsisdiv> 22432 <title>Synopsis</title> 22433 <funcsynopsis><funcprototype> 22434 <funcdef>void <function>synchronize_irq </function></funcdef> 22435 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 22436 </funcprototype></funcsynopsis> 22437</refsynopsisdiv> 22438<refsect1> 22439 <title>Arguments</title> 22440 <variablelist> 22441 <varlistentry> 22442 <term><parameter>irq</parameter></term> 22443 <listitem> 22444 <para> 22445 interrupt number to wait for 22446 </para> 22447 </listitem> 22448 </varlistentry> 22449 </variablelist> 22450</refsect1> 22451<refsect1> 22452<title>Description</title> 22453<para> 22454 This function waits for any pending IRQ handlers for this interrupt 22455 to complete before returning. If you use this function while 22456 holding a resource the IRQ handler may need you will deadlock. 22457 </para><para> 22458 22459 This function may be called - with care - from IRQ context. 22460</para> 22461</refsect1> 22462</refentry> 22463 22464<refentry id="API-irq-set-affinity-notifier"> 22465<refentryinfo> 22466 <title>LINUX</title> 22467 <productname>Kernel Hackers Manual</productname> 22468 <date>July 2017</date> 22469</refentryinfo> 22470<refmeta> 22471 <refentrytitle><phrase>irq_set_affinity_notifier</phrase></refentrytitle> 22472 <manvolnum>9</manvolnum> 22473 <refmiscinfo class="version">4.1.27</refmiscinfo> 22474</refmeta> 22475<refnamediv> 22476 <refname>irq_set_affinity_notifier</refname> 22477 <refpurpose> 22478 control notification of IRQ affinity changes 22479 </refpurpose> 22480</refnamediv> 22481<refsynopsisdiv> 22482 <title>Synopsis</title> 22483 <funcsynopsis><funcprototype> 22484 <funcdef>int <function>irq_set_affinity_notifier </function></funcdef> 22485 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 22486 <paramdef>struct irq_affinity_notify * <parameter>notify</parameter></paramdef> 22487 </funcprototype></funcsynopsis> 22488</refsynopsisdiv> 22489<refsect1> 22490 <title>Arguments</title> 22491 <variablelist> 22492 <varlistentry> 22493 <term><parameter>irq</parameter></term> 22494 <listitem> 22495 <para> 22496 Interrupt for which to enable/disable notification 22497 </para> 22498 </listitem> 22499 </varlistentry> 22500 <varlistentry> 22501 <term><parameter>notify</parameter></term> 22502 <listitem> 22503 <para> 22504 Context for notification, or <constant>NULL</constant> to disable 22505 notification. Function pointers must be initialised; 22506 the other fields will be initialised by this function. 22507 </para> 22508 </listitem> 22509 </varlistentry> 22510 </variablelist> 22511</refsect1> 22512<refsect1> 22513<title>Description</title> 22514<para> 22515 Must be called in process context. Notification may only be enabled 22516 after the IRQ is allocated and must be disabled before the IRQ is 22517 freed using <function>free_irq</function>. 22518</para> 22519</refsect1> 22520</refentry> 22521 22522<refentry id="API-disable-irq-nosync"> 22523<refentryinfo> 22524 <title>LINUX</title> 22525 <productname>Kernel Hackers Manual</productname> 22526 <date>July 2017</date> 22527</refentryinfo> 22528<refmeta> 22529 <refentrytitle><phrase>disable_irq_nosync</phrase></refentrytitle> 22530 <manvolnum>9</manvolnum> 22531 <refmiscinfo class="version">4.1.27</refmiscinfo> 22532</refmeta> 22533<refnamediv> 22534 <refname>disable_irq_nosync</refname> 22535 <refpurpose> 22536 disable an irq without waiting 22537 </refpurpose> 22538</refnamediv> 22539<refsynopsisdiv> 22540 <title>Synopsis</title> 22541 <funcsynopsis><funcprototype> 22542 <funcdef>void <function>disable_irq_nosync </function></funcdef> 22543 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 22544 </funcprototype></funcsynopsis> 22545</refsynopsisdiv> 22546<refsect1> 22547 <title>Arguments</title> 22548 <variablelist> 22549 <varlistentry> 22550 <term><parameter>irq</parameter></term> 22551 <listitem> 22552 <para> 22553 Interrupt to disable 22554 </para> 22555 </listitem> 22556 </varlistentry> 22557 </variablelist> 22558</refsect1> 22559<refsect1> 22560<title>Description</title> 22561<para> 22562 Disable the selected interrupt line. Disables and Enables are 22563 nested. 22564 Unlike <function>disable_irq</function>, this function does not ensure existing 22565 instances of the IRQ handler have completed before returning. 22566 </para><para> 22567 22568 This function may be called from IRQ context. 22569</para> 22570</refsect1> 22571</refentry> 22572 22573<refentry id="API-disable-irq"> 22574<refentryinfo> 22575 <title>LINUX</title> 22576 <productname>Kernel Hackers Manual</productname> 22577 <date>July 2017</date> 22578</refentryinfo> 22579<refmeta> 22580 <refentrytitle><phrase>disable_irq</phrase></refentrytitle> 22581 <manvolnum>9</manvolnum> 22582 <refmiscinfo class="version">4.1.27</refmiscinfo> 22583</refmeta> 22584<refnamediv> 22585 <refname>disable_irq</refname> 22586 <refpurpose> 22587 disable an irq and wait for completion 22588 </refpurpose> 22589</refnamediv> 22590<refsynopsisdiv> 22591 <title>Synopsis</title> 22592 <funcsynopsis><funcprototype> 22593 <funcdef>void <function>disable_irq </function></funcdef> 22594 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 22595 </funcprototype></funcsynopsis> 22596</refsynopsisdiv> 22597<refsect1> 22598 <title>Arguments</title> 22599 <variablelist> 22600 <varlistentry> 22601 <term><parameter>irq</parameter></term> 22602 <listitem> 22603 <para> 22604 Interrupt to disable 22605 </para> 22606 </listitem> 22607 </varlistentry> 22608 </variablelist> 22609</refsect1> 22610<refsect1> 22611<title>Description</title> 22612<para> 22613 Disable the selected interrupt line. Enables and Disables are 22614 nested. 22615 This function waits for any pending IRQ handlers for this interrupt 22616 to complete before returning. If you use this function while 22617 holding a resource the IRQ handler may need you will deadlock. 22618 </para><para> 22619 22620 This function may be called - with care - from IRQ context. 22621</para> 22622</refsect1> 22623</refentry> 22624 22625<refentry id="API-disable-hardirq"> 22626<refentryinfo> 22627 <title>LINUX</title> 22628 <productname>Kernel Hackers Manual</productname> 22629 <date>July 2017</date> 22630</refentryinfo> 22631<refmeta> 22632 <refentrytitle><phrase>disable_hardirq</phrase></refentrytitle> 22633 <manvolnum>9</manvolnum> 22634 <refmiscinfo class="version">4.1.27</refmiscinfo> 22635</refmeta> 22636<refnamediv> 22637 <refname>disable_hardirq</refname> 22638 <refpurpose> 22639 disables an irq and waits for hardirq completion 22640 </refpurpose> 22641</refnamediv> 22642<refsynopsisdiv> 22643 <title>Synopsis</title> 22644 <funcsynopsis><funcprototype> 22645 <funcdef>bool <function>disable_hardirq </function></funcdef> 22646 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 22647 </funcprototype></funcsynopsis> 22648</refsynopsisdiv> 22649<refsect1> 22650 <title>Arguments</title> 22651 <variablelist> 22652 <varlistentry> 22653 <term><parameter>irq</parameter></term> 22654 <listitem> 22655 <para> 22656 Interrupt to disable 22657 </para> 22658 </listitem> 22659 </varlistentry> 22660 </variablelist> 22661</refsect1> 22662<refsect1> 22663<title>Description</title> 22664<para> 22665 Disable the selected interrupt line. Enables and Disables are 22666 nested. 22667 This function waits for any pending hard IRQ handlers for this 22668 interrupt to complete before returning. If you use this function while 22669 holding a resource the hard IRQ handler may need you will deadlock. 22670 </para><para> 22671 22672 When used to optimistically disable an interrupt from atomic context 22673 the return value must be checked. 22674</para> 22675</refsect1> 22676<refsect1> 22677<title>Returns</title> 22678<para> 22679 false if a threaded handler is active. 22680 </para><para> 22681 22682 This function may be called - with care - from IRQ context. 22683</para> 22684</refsect1> 22685</refentry> 22686 22687<refentry id="API-enable-irq"> 22688<refentryinfo> 22689 <title>LINUX</title> 22690 <productname>Kernel Hackers Manual</productname> 22691 <date>July 2017</date> 22692</refentryinfo> 22693<refmeta> 22694 <refentrytitle><phrase>enable_irq</phrase></refentrytitle> 22695 <manvolnum>9</manvolnum> 22696 <refmiscinfo class="version">4.1.27</refmiscinfo> 22697</refmeta> 22698<refnamediv> 22699 <refname>enable_irq</refname> 22700 <refpurpose> 22701 enable handling of an irq 22702 </refpurpose> 22703</refnamediv> 22704<refsynopsisdiv> 22705 <title>Synopsis</title> 22706 <funcsynopsis><funcprototype> 22707 <funcdef>void <function>enable_irq </function></funcdef> 22708 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 22709 </funcprototype></funcsynopsis> 22710</refsynopsisdiv> 22711<refsect1> 22712 <title>Arguments</title> 22713 <variablelist> 22714 <varlistentry> 22715 <term><parameter>irq</parameter></term> 22716 <listitem> 22717 <para> 22718 Interrupt to enable 22719 </para> 22720 </listitem> 22721 </varlistentry> 22722 </variablelist> 22723</refsect1> 22724<refsect1> 22725<title>Description</title> 22726<para> 22727 Undoes the effect of one call to <function>disable_irq</function>. If this 22728 matches the last disable, processing of interrupts on this 22729 IRQ line is re-enabled. 22730 </para><para> 22731 22732 This function may be called from IRQ context only when 22733 desc->irq_data.chip->bus_lock and desc->chip->bus_sync_unlock are NULL ! 22734</para> 22735</refsect1> 22736</refentry> 22737 22738<refentry id="API-irq-set-irq-wake"> 22739<refentryinfo> 22740 <title>LINUX</title> 22741 <productname>Kernel Hackers Manual</productname> 22742 <date>July 2017</date> 22743</refentryinfo> 22744<refmeta> 22745 <refentrytitle><phrase>irq_set_irq_wake</phrase></refentrytitle> 22746 <manvolnum>9</manvolnum> 22747 <refmiscinfo class="version">4.1.27</refmiscinfo> 22748</refmeta> 22749<refnamediv> 22750 <refname>irq_set_irq_wake</refname> 22751 <refpurpose> 22752 control irq power management wakeup 22753 </refpurpose> 22754</refnamediv> 22755<refsynopsisdiv> 22756 <title>Synopsis</title> 22757 <funcsynopsis><funcprototype> 22758 <funcdef>int <function>irq_set_irq_wake </function></funcdef> 22759 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 22760 <paramdef>unsigned int <parameter>on</parameter></paramdef> 22761 </funcprototype></funcsynopsis> 22762</refsynopsisdiv> 22763<refsect1> 22764 <title>Arguments</title> 22765 <variablelist> 22766 <varlistentry> 22767 <term><parameter>irq</parameter></term> 22768 <listitem> 22769 <para> 22770 interrupt to control 22771 </para> 22772 </listitem> 22773 </varlistentry> 22774 <varlistentry> 22775 <term><parameter>on</parameter></term> 22776 <listitem> 22777 <para> 22778 enable/disable power management wakeup 22779 </para> 22780 </listitem> 22781 </varlistentry> 22782 </variablelist> 22783</refsect1> 22784<refsect1> 22785<title>Description</title> 22786<para> 22787 Enable/disable power management wakeup mode, which is 22788 disabled by default. Enables and disables must match, 22789 just as they match for non-wakeup mode support. 22790 </para><para> 22791 22792 Wakeup mode lets this IRQ wake the system from sleep 22793 states like <quote>suspend to RAM</quote>. 22794</para> 22795</refsect1> 22796</refentry> 22797 22798<refentry id="API-irq-wake-thread"> 22799<refentryinfo> 22800 <title>LINUX</title> 22801 <productname>Kernel Hackers Manual</productname> 22802 <date>July 2017</date> 22803</refentryinfo> 22804<refmeta> 22805 <refentrytitle><phrase>irq_wake_thread</phrase></refentrytitle> 22806 <manvolnum>9</manvolnum> 22807 <refmiscinfo class="version">4.1.27</refmiscinfo> 22808</refmeta> 22809<refnamediv> 22810 <refname>irq_wake_thread</refname> 22811 <refpurpose> 22812 wake the irq thread for the action identified by dev_id 22813 </refpurpose> 22814</refnamediv> 22815<refsynopsisdiv> 22816 <title>Synopsis</title> 22817 <funcsynopsis><funcprototype> 22818 <funcdef>void <function>irq_wake_thread </function></funcdef> 22819 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 22820 <paramdef>void * <parameter>dev_id</parameter></paramdef> 22821 </funcprototype></funcsynopsis> 22822</refsynopsisdiv> 22823<refsect1> 22824 <title>Arguments</title> 22825 <variablelist> 22826 <varlistentry> 22827 <term><parameter>irq</parameter></term> 22828 <listitem> 22829 <para> 22830 Interrupt line 22831 </para> 22832 </listitem> 22833 </varlistentry> 22834 <varlistentry> 22835 <term><parameter>dev_id</parameter></term> 22836 <listitem> 22837 <para> 22838 Device identity for which the thread should be woken 22839 </para> 22840 </listitem> 22841 </varlistentry> 22842 </variablelist> 22843</refsect1> 22844</refentry> 22845 22846<refentry id="API-setup-irq"> 22847<refentryinfo> 22848 <title>LINUX</title> 22849 <productname>Kernel Hackers Manual</productname> 22850 <date>July 2017</date> 22851</refentryinfo> 22852<refmeta> 22853 <refentrytitle><phrase>setup_irq</phrase></refentrytitle> 22854 <manvolnum>9</manvolnum> 22855 <refmiscinfo class="version">4.1.27</refmiscinfo> 22856</refmeta> 22857<refnamediv> 22858 <refname>setup_irq</refname> 22859 <refpurpose> 22860 setup an interrupt 22861 </refpurpose> 22862</refnamediv> 22863<refsynopsisdiv> 22864 <title>Synopsis</title> 22865 <funcsynopsis><funcprototype> 22866 <funcdef>int <function>setup_irq </function></funcdef> 22867 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 22868 <paramdef>struct irqaction * <parameter>act</parameter></paramdef> 22869 </funcprototype></funcsynopsis> 22870</refsynopsisdiv> 22871<refsect1> 22872 <title>Arguments</title> 22873 <variablelist> 22874 <varlistentry> 22875 <term><parameter>irq</parameter></term> 22876 <listitem> 22877 <para> 22878 Interrupt line to setup 22879 </para> 22880 </listitem> 22881 </varlistentry> 22882 <varlistentry> 22883 <term><parameter>act</parameter></term> 22884 <listitem> 22885 <para> 22886 irqaction for the interrupt 22887 </para> 22888 </listitem> 22889 </varlistentry> 22890 </variablelist> 22891</refsect1> 22892<refsect1> 22893<title>Description</title> 22894<para> 22895 Used to statically setup interrupts in the early boot process. 22896</para> 22897</refsect1> 22898</refentry> 22899 22900<refentry id="API-remove-irq"> 22901<refentryinfo> 22902 <title>LINUX</title> 22903 <productname>Kernel Hackers Manual</productname> 22904 <date>July 2017</date> 22905</refentryinfo> 22906<refmeta> 22907 <refentrytitle><phrase>remove_irq</phrase></refentrytitle> 22908 <manvolnum>9</manvolnum> 22909 <refmiscinfo class="version">4.1.27</refmiscinfo> 22910</refmeta> 22911<refnamediv> 22912 <refname>remove_irq</refname> 22913 <refpurpose> 22914 free an interrupt 22915 </refpurpose> 22916</refnamediv> 22917<refsynopsisdiv> 22918 <title>Synopsis</title> 22919 <funcsynopsis><funcprototype> 22920 <funcdef>void <function>remove_irq </function></funcdef> 22921 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 22922 <paramdef>struct irqaction * <parameter>act</parameter></paramdef> 22923 </funcprototype></funcsynopsis> 22924</refsynopsisdiv> 22925<refsect1> 22926 <title>Arguments</title> 22927 <variablelist> 22928 <varlistentry> 22929 <term><parameter>irq</parameter></term> 22930 <listitem> 22931 <para> 22932 Interrupt line to free 22933 </para> 22934 </listitem> 22935 </varlistentry> 22936 <varlistentry> 22937 <term><parameter>act</parameter></term> 22938 <listitem> 22939 <para> 22940 irqaction for the interrupt 22941 </para> 22942 </listitem> 22943 </varlistentry> 22944 </variablelist> 22945</refsect1> 22946<refsect1> 22947<title>Description</title> 22948<para> 22949 Used to remove interrupts statically setup by the early boot process. 22950</para> 22951</refsect1> 22952</refentry> 22953 22954<refentry id="API-free-irq"> 22955<refentryinfo> 22956 <title>LINUX</title> 22957 <productname>Kernel Hackers Manual</productname> 22958 <date>July 2017</date> 22959</refentryinfo> 22960<refmeta> 22961 <refentrytitle><phrase>free_irq</phrase></refentrytitle> 22962 <manvolnum>9</manvolnum> 22963 <refmiscinfo class="version">4.1.27</refmiscinfo> 22964</refmeta> 22965<refnamediv> 22966 <refname>free_irq</refname> 22967 <refpurpose> 22968 free an interrupt allocated with request_irq 22969 </refpurpose> 22970</refnamediv> 22971<refsynopsisdiv> 22972 <title>Synopsis</title> 22973 <funcsynopsis><funcprototype> 22974 <funcdef>void <function>free_irq </function></funcdef> 22975 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 22976 <paramdef>void * <parameter>dev_id</parameter></paramdef> 22977 </funcprototype></funcsynopsis> 22978</refsynopsisdiv> 22979<refsect1> 22980 <title>Arguments</title> 22981 <variablelist> 22982 <varlistentry> 22983 <term><parameter>irq</parameter></term> 22984 <listitem> 22985 <para> 22986 Interrupt line to free 22987 </para> 22988 </listitem> 22989 </varlistentry> 22990 <varlistentry> 22991 <term><parameter>dev_id</parameter></term> 22992 <listitem> 22993 <para> 22994 Device identity to free 22995 </para> 22996 </listitem> 22997 </varlistentry> 22998 </variablelist> 22999</refsect1> 23000<refsect1> 23001<title>Description</title> 23002<para> 23003 Remove an interrupt handler. The handler is removed and if the 23004 interrupt line is no longer in use by any driver it is disabled. 23005 On a shared IRQ the caller must ensure the interrupt is disabled 23006 on the card it drives before calling this function. The function 23007 does not return until any executing interrupts for this IRQ 23008 have completed. 23009 </para><para> 23010 23011 This function must not be called from interrupt context. 23012</para> 23013</refsect1> 23014</refentry> 23015 23016<refentry id="API-request-threaded-irq"> 23017<refentryinfo> 23018 <title>LINUX</title> 23019 <productname>Kernel Hackers Manual</productname> 23020 <date>July 2017</date> 23021</refentryinfo> 23022<refmeta> 23023 <refentrytitle><phrase>request_threaded_irq</phrase></refentrytitle> 23024 <manvolnum>9</manvolnum> 23025 <refmiscinfo class="version">4.1.27</refmiscinfo> 23026</refmeta> 23027<refnamediv> 23028 <refname>request_threaded_irq</refname> 23029 <refpurpose> 23030 allocate an interrupt line 23031 </refpurpose> 23032</refnamediv> 23033<refsynopsisdiv> 23034 <title>Synopsis</title> 23035 <funcsynopsis><funcprototype> 23036 <funcdef>int <function>request_threaded_irq </function></funcdef> 23037 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 23038 <paramdef>irq_handler_t <parameter>handler</parameter></paramdef> 23039 <paramdef>irq_handler_t <parameter>thread_fn</parameter></paramdef> 23040 <paramdef>unsigned long <parameter>irqflags</parameter></paramdef> 23041 <paramdef>const char * <parameter>devname</parameter></paramdef> 23042 <paramdef>void * <parameter>dev_id</parameter></paramdef> 23043 </funcprototype></funcsynopsis> 23044</refsynopsisdiv> 23045<refsect1> 23046 <title>Arguments</title> 23047 <variablelist> 23048 <varlistentry> 23049 <term><parameter>irq</parameter></term> 23050 <listitem> 23051 <para> 23052 Interrupt line to allocate 23053 </para> 23054 </listitem> 23055 </varlistentry> 23056 <varlistentry> 23057 <term><parameter>handler</parameter></term> 23058 <listitem> 23059 <para> 23060 Function to be called when the IRQ occurs. 23061 Primary handler for threaded interrupts 23062 If NULL and thread_fn != NULL the default 23063 primary handler is installed 23064 </para> 23065 </listitem> 23066 </varlistentry> 23067 <varlistentry> 23068 <term><parameter>thread_fn</parameter></term> 23069 <listitem> 23070 <para> 23071 Function called from the irq handler thread 23072 If NULL, no irq thread is created 23073 </para> 23074 </listitem> 23075 </varlistentry> 23076 <varlistentry> 23077 <term><parameter>irqflags</parameter></term> 23078 <listitem> 23079 <para> 23080 Interrupt type flags 23081 </para> 23082 </listitem> 23083 </varlistentry> 23084 <varlistentry> 23085 <term><parameter>devname</parameter></term> 23086 <listitem> 23087 <para> 23088 An ascii name for the claiming device 23089 </para> 23090 </listitem> 23091 </varlistentry> 23092 <varlistentry> 23093 <term><parameter>dev_id</parameter></term> 23094 <listitem> 23095 <para> 23096 A cookie passed back to the handler function 23097 </para> 23098 </listitem> 23099 </varlistentry> 23100 </variablelist> 23101</refsect1> 23102<refsect1> 23103<title>Description</title> 23104<para> 23105 This call allocates interrupt resources and enables the 23106 interrupt line and IRQ handling. From the point this 23107 call is made your handler function may be invoked. Since 23108 your handler function must clear any interrupt the board 23109 raises, you must take care both to initialise your hardware 23110 and to set up the interrupt handler in the right order. 23111 </para><para> 23112 23113 If you want to set up a threaded irq handler for your device 23114 then you need to supply <parameter>handler</parameter> and <parameter>thread_fn</parameter>. <parameter>handler</parameter> is 23115 still called in hard interrupt context and has to check 23116 whether the interrupt originates from the device. If yes it 23117 needs to disable the interrupt on the device and return 23118 IRQ_WAKE_THREAD which will wake up the handler thread and run 23119 <parameter>thread_fn</parameter>. This split handler design is necessary to support 23120 shared interrupts. 23121 </para><para> 23122 23123 Dev_id must be globally unique. Normally the address of the 23124 device data structure is used as the cookie. Since the handler 23125 receives this value it makes sense to use it. 23126 </para><para> 23127 23128 If your interrupt is shared you must pass a non NULL dev_id 23129 as this is required when freeing the interrupt. 23130</para> 23131</refsect1> 23132<refsect1> 23133<title>Flags</title> 23134<para> 23135 </para><para> 23136 23137 IRQF_SHARED Interrupt is shared 23138 IRQF_TRIGGER_* Specify active edge(s) or level 23139</para> 23140</refsect1> 23141</refentry> 23142 23143<refentry id="API-request-any-context-irq"> 23144<refentryinfo> 23145 <title>LINUX</title> 23146 <productname>Kernel Hackers Manual</productname> 23147 <date>July 2017</date> 23148</refentryinfo> 23149<refmeta> 23150 <refentrytitle><phrase>request_any_context_irq</phrase></refentrytitle> 23151 <manvolnum>9</manvolnum> 23152 <refmiscinfo class="version">4.1.27</refmiscinfo> 23153</refmeta> 23154<refnamediv> 23155 <refname>request_any_context_irq</refname> 23156 <refpurpose> 23157 allocate an interrupt line 23158 </refpurpose> 23159</refnamediv> 23160<refsynopsisdiv> 23161 <title>Synopsis</title> 23162 <funcsynopsis><funcprototype> 23163 <funcdef>int <function>request_any_context_irq </function></funcdef> 23164 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 23165 <paramdef>irq_handler_t <parameter>handler</parameter></paramdef> 23166 <paramdef>unsigned long <parameter>flags</parameter></paramdef> 23167 <paramdef>const char * <parameter>name</parameter></paramdef> 23168 <paramdef>void * <parameter>dev_id</parameter></paramdef> 23169 </funcprototype></funcsynopsis> 23170</refsynopsisdiv> 23171<refsect1> 23172 <title>Arguments</title> 23173 <variablelist> 23174 <varlistentry> 23175 <term><parameter>irq</parameter></term> 23176 <listitem> 23177 <para> 23178 Interrupt line to allocate 23179 </para> 23180 </listitem> 23181 </varlistentry> 23182 <varlistentry> 23183 <term><parameter>handler</parameter></term> 23184 <listitem> 23185 <para> 23186 Function to be called when the IRQ occurs. 23187 Threaded handler for threaded interrupts. 23188 </para> 23189 </listitem> 23190 </varlistentry> 23191 <varlistentry> 23192 <term><parameter>flags</parameter></term> 23193 <listitem> 23194 <para> 23195 Interrupt type flags 23196 </para> 23197 </listitem> 23198 </varlistentry> 23199 <varlistentry> 23200 <term><parameter>name</parameter></term> 23201 <listitem> 23202 <para> 23203 An ascii name for the claiming device 23204 </para> 23205 </listitem> 23206 </varlistentry> 23207 <varlistentry> 23208 <term><parameter>dev_id</parameter></term> 23209 <listitem> 23210 <para> 23211 A cookie passed back to the handler function 23212 </para> 23213 </listitem> 23214 </varlistentry> 23215 </variablelist> 23216</refsect1> 23217<refsect1> 23218<title>Description</title> 23219<para> 23220 This call allocates interrupt resources and enables the 23221 interrupt line and IRQ handling. It selects either a 23222 hardirq or threaded handling method depending on the 23223 context. 23224 </para><para> 23225 23226 On failure, it returns a negative value. On success, 23227 it returns either IRQC_IS_HARDIRQ or IRQC_IS_NESTED. 23228</para> 23229</refsect1> 23230</refentry> 23231 23232 </sect1> 23233 23234 <sect1><title>DMA Channels</title> 23235<!-- kernel/dma.c --> 23236<refentry id="API-request-dma"> 23237<refentryinfo> 23238 <title>LINUX</title> 23239 <productname>Kernel Hackers Manual</productname> 23240 <date>July 2017</date> 23241</refentryinfo> 23242<refmeta> 23243 <refentrytitle><phrase>request_dma</phrase></refentrytitle> 23244 <manvolnum>9</manvolnum> 23245 <refmiscinfo class="version">4.1.27</refmiscinfo> 23246</refmeta> 23247<refnamediv> 23248 <refname>request_dma</refname> 23249 <refpurpose> 23250 request and reserve a system DMA channel 23251 </refpurpose> 23252</refnamediv> 23253<refsynopsisdiv> 23254 <title>Synopsis</title> 23255 <funcsynopsis><funcprototype> 23256 <funcdef>int <function>request_dma </function></funcdef> 23257 <paramdef>unsigned int <parameter>dmanr</parameter></paramdef> 23258 <paramdef>const char * <parameter>device_id</parameter></paramdef> 23259 </funcprototype></funcsynopsis> 23260</refsynopsisdiv> 23261<refsect1> 23262 <title>Arguments</title> 23263 <variablelist> 23264 <varlistentry> 23265 <term><parameter>dmanr</parameter></term> 23266 <listitem> 23267 <para> 23268 DMA channel number 23269 </para> 23270 </listitem> 23271 </varlistentry> 23272 <varlistentry> 23273 <term><parameter>device_id</parameter></term> 23274 <listitem> 23275 <para> 23276 reserving device ID string, used in /proc/dma 23277 </para> 23278 </listitem> 23279 </varlistentry> 23280 </variablelist> 23281</refsect1> 23282</refentry> 23283 23284<refentry id="API-free-dma"> 23285<refentryinfo> 23286 <title>LINUX</title> 23287 <productname>Kernel Hackers Manual</productname> 23288 <date>July 2017</date> 23289</refentryinfo> 23290<refmeta> 23291 <refentrytitle><phrase>free_dma</phrase></refentrytitle> 23292 <manvolnum>9</manvolnum> 23293 <refmiscinfo class="version">4.1.27</refmiscinfo> 23294</refmeta> 23295<refnamediv> 23296 <refname>free_dma</refname> 23297 <refpurpose> 23298 free a reserved system DMA channel 23299 </refpurpose> 23300</refnamediv> 23301<refsynopsisdiv> 23302 <title>Synopsis</title> 23303 <funcsynopsis><funcprototype> 23304 <funcdef>void <function>free_dma </function></funcdef> 23305 <paramdef>unsigned int <parameter>dmanr</parameter></paramdef> 23306 </funcprototype></funcsynopsis> 23307</refsynopsisdiv> 23308<refsect1> 23309 <title>Arguments</title> 23310 <variablelist> 23311 <varlistentry> 23312 <term><parameter>dmanr</parameter></term> 23313 <listitem> 23314 <para> 23315 DMA channel number 23316 </para> 23317 </listitem> 23318 </varlistentry> 23319 </variablelist> 23320</refsect1> 23321</refentry> 23322 23323 </sect1> 23324 23325 <sect1><title>Resources Management</title> 23326<!-- kernel/resource.c --> 23327<refentry id="API-request-resource-conflict"> 23328<refentryinfo> 23329 <title>LINUX</title> 23330 <productname>Kernel Hackers Manual</productname> 23331 <date>July 2017</date> 23332</refentryinfo> 23333<refmeta> 23334 <refentrytitle><phrase>request_resource_conflict</phrase></refentrytitle> 23335 <manvolnum>9</manvolnum> 23336 <refmiscinfo class="version">4.1.27</refmiscinfo> 23337</refmeta> 23338<refnamediv> 23339 <refname>request_resource_conflict</refname> 23340 <refpurpose> 23341 request and reserve an I/O or memory resource 23342 </refpurpose> 23343</refnamediv> 23344<refsynopsisdiv> 23345 <title>Synopsis</title> 23346 <funcsynopsis><funcprototype> 23347 <funcdef>struct resource * <function>request_resource_conflict </function></funcdef> 23348 <paramdef>struct resource * <parameter>root</parameter></paramdef> 23349 <paramdef>struct resource * <parameter>new</parameter></paramdef> 23350 </funcprototype></funcsynopsis> 23351</refsynopsisdiv> 23352<refsect1> 23353 <title>Arguments</title> 23354 <variablelist> 23355 <varlistentry> 23356 <term><parameter>root</parameter></term> 23357 <listitem> 23358 <para> 23359 root resource descriptor 23360 </para> 23361 </listitem> 23362 </varlistentry> 23363 <varlistentry> 23364 <term><parameter>new</parameter></term> 23365 <listitem> 23366 <para> 23367 resource descriptor desired by caller 23368 </para> 23369 </listitem> 23370 </varlistentry> 23371 </variablelist> 23372</refsect1> 23373<refsect1> 23374<title>Description</title> 23375<para> 23376 Returns 0 for success, conflict resource on error. 23377</para> 23378</refsect1> 23379</refentry> 23380 23381<refentry id="API-reallocate-resource"> 23382<refentryinfo> 23383 <title>LINUX</title> 23384 <productname>Kernel Hackers Manual</productname> 23385 <date>July 2017</date> 23386</refentryinfo> 23387<refmeta> 23388 <refentrytitle><phrase>reallocate_resource</phrase></refentrytitle> 23389 <manvolnum>9</manvolnum> 23390 <refmiscinfo class="version">4.1.27</refmiscinfo> 23391</refmeta> 23392<refnamediv> 23393 <refname>reallocate_resource</refname> 23394 <refpurpose> 23395 allocate a slot in the resource tree given range & alignment. The resource will be relocated if the new size cannot be reallocated in the current location. 23396 </refpurpose> 23397</refnamediv> 23398<refsynopsisdiv> 23399 <title>Synopsis</title> 23400 <funcsynopsis><funcprototype> 23401 <funcdef>int <function>reallocate_resource </function></funcdef> 23402 <paramdef>struct resource * <parameter>root</parameter></paramdef> 23403 <paramdef>struct resource * <parameter>old</parameter></paramdef> 23404 <paramdef>resource_size_t <parameter>newsize</parameter></paramdef> 23405 <paramdef>struct resource_constraint * <parameter>constraint</parameter></paramdef> 23406 </funcprototype></funcsynopsis> 23407</refsynopsisdiv> 23408<refsect1> 23409 <title>Arguments</title> 23410 <variablelist> 23411 <varlistentry> 23412 <term><parameter>root</parameter></term> 23413 <listitem> 23414 <para> 23415 root resource descriptor 23416 </para> 23417 </listitem> 23418 </varlistentry> 23419 <varlistentry> 23420 <term><parameter>old</parameter></term> 23421 <listitem> 23422 <para> 23423 resource descriptor desired by caller 23424 </para> 23425 </listitem> 23426 </varlistentry> 23427 <varlistentry> 23428 <term><parameter>newsize</parameter></term> 23429 <listitem> 23430 <para> 23431 new size of the resource descriptor 23432 </para> 23433 </listitem> 23434 </varlistentry> 23435 <varlistentry> 23436 <term><parameter>constraint</parameter></term> 23437 <listitem> 23438 <para> 23439 the size and alignment constraints to be met. 23440 </para> 23441 </listitem> 23442 </varlistentry> 23443 </variablelist> 23444</refsect1> 23445</refentry> 23446 23447<refentry id="API-lookup-resource"> 23448<refentryinfo> 23449 <title>LINUX</title> 23450 <productname>Kernel Hackers Manual</productname> 23451 <date>July 2017</date> 23452</refentryinfo> 23453<refmeta> 23454 <refentrytitle><phrase>lookup_resource</phrase></refentrytitle> 23455 <manvolnum>9</manvolnum> 23456 <refmiscinfo class="version">4.1.27</refmiscinfo> 23457</refmeta> 23458<refnamediv> 23459 <refname>lookup_resource</refname> 23460 <refpurpose> 23461 find an existing resource by a resource start address 23462 </refpurpose> 23463</refnamediv> 23464<refsynopsisdiv> 23465 <title>Synopsis</title> 23466 <funcsynopsis><funcprototype> 23467 <funcdef>struct resource * <function>lookup_resource </function></funcdef> 23468 <paramdef>struct resource * <parameter>root</parameter></paramdef> 23469 <paramdef>resource_size_t <parameter>start</parameter></paramdef> 23470 </funcprototype></funcsynopsis> 23471</refsynopsisdiv> 23472<refsect1> 23473 <title>Arguments</title> 23474 <variablelist> 23475 <varlistentry> 23476 <term><parameter>root</parameter></term> 23477 <listitem> 23478 <para> 23479 root resource descriptor 23480 </para> 23481 </listitem> 23482 </varlistentry> 23483 <varlistentry> 23484 <term><parameter>start</parameter></term> 23485 <listitem> 23486 <para> 23487 resource start address 23488 </para> 23489 </listitem> 23490 </varlistentry> 23491 </variablelist> 23492</refsect1> 23493<refsect1> 23494<title>Description</title> 23495<para> 23496 Returns a pointer to the resource if found, NULL otherwise 23497</para> 23498</refsect1> 23499</refentry> 23500 23501<refentry id="API-insert-resource-conflict"> 23502<refentryinfo> 23503 <title>LINUX</title> 23504 <productname>Kernel Hackers Manual</productname> 23505 <date>July 2017</date> 23506</refentryinfo> 23507<refmeta> 23508 <refentrytitle><phrase>insert_resource_conflict</phrase></refentrytitle> 23509 <manvolnum>9</manvolnum> 23510 <refmiscinfo class="version">4.1.27</refmiscinfo> 23511</refmeta> 23512<refnamediv> 23513 <refname>insert_resource_conflict</refname> 23514 <refpurpose> 23515 Inserts resource in the resource tree 23516 </refpurpose> 23517</refnamediv> 23518<refsynopsisdiv> 23519 <title>Synopsis</title> 23520 <funcsynopsis><funcprototype> 23521 <funcdef>struct resource * <function>insert_resource_conflict </function></funcdef> 23522 <paramdef>struct resource * <parameter>parent</parameter></paramdef> 23523 <paramdef>struct resource * <parameter>new</parameter></paramdef> 23524 </funcprototype></funcsynopsis> 23525</refsynopsisdiv> 23526<refsect1> 23527 <title>Arguments</title> 23528 <variablelist> 23529 <varlistentry> 23530 <term><parameter>parent</parameter></term> 23531 <listitem> 23532 <para> 23533 parent of the new resource 23534 </para> 23535 </listitem> 23536 </varlistentry> 23537 <varlistentry> 23538 <term><parameter>new</parameter></term> 23539 <listitem> 23540 <para> 23541 new resource to insert 23542 </para> 23543 </listitem> 23544 </varlistentry> 23545 </variablelist> 23546</refsect1> 23547<refsect1> 23548<title>Description</title> 23549<para> 23550 Returns 0 on success, conflict resource if the resource can't be inserted. 23551 </para><para> 23552 23553 This function is equivalent to request_resource_conflict when no conflict 23554 happens. If a conflict happens, and the conflicting resources 23555 entirely fit within the range of the new resource, then the new 23556 resource is inserted and the conflicting resources become children of 23557 the new resource. 23558</para> 23559</refsect1> 23560</refentry> 23561 23562<refentry id="API-insert-resource"> 23563<refentryinfo> 23564 <title>LINUX</title> 23565 <productname>Kernel Hackers Manual</productname> 23566 <date>July 2017</date> 23567</refentryinfo> 23568<refmeta> 23569 <refentrytitle><phrase>insert_resource</phrase></refentrytitle> 23570 <manvolnum>9</manvolnum> 23571 <refmiscinfo class="version">4.1.27</refmiscinfo> 23572</refmeta> 23573<refnamediv> 23574 <refname>insert_resource</refname> 23575 <refpurpose> 23576 Inserts a resource in the resource tree 23577 </refpurpose> 23578</refnamediv> 23579<refsynopsisdiv> 23580 <title>Synopsis</title> 23581 <funcsynopsis><funcprototype> 23582 <funcdef>int <function>insert_resource </function></funcdef> 23583 <paramdef>struct resource * <parameter>parent</parameter></paramdef> 23584 <paramdef>struct resource * <parameter>new</parameter></paramdef> 23585 </funcprototype></funcsynopsis> 23586</refsynopsisdiv> 23587<refsect1> 23588 <title>Arguments</title> 23589 <variablelist> 23590 <varlistentry> 23591 <term><parameter>parent</parameter></term> 23592 <listitem> 23593 <para> 23594 parent of the new resource 23595 </para> 23596 </listitem> 23597 </varlistentry> 23598 <varlistentry> 23599 <term><parameter>new</parameter></term> 23600 <listitem> 23601 <para> 23602 new resource to insert 23603 </para> 23604 </listitem> 23605 </varlistentry> 23606 </variablelist> 23607</refsect1> 23608<refsect1> 23609<title>Description</title> 23610<para> 23611 Returns 0 on success, -EBUSY if the resource can't be inserted. 23612</para> 23613</refsect1> 23614</refentry> 23615 23616<refentry id="API-insert-resource-expand-to-fit"> 23617<refentryinfo> 23618 <title>LINUX</title> 23619 <productname>Kernel Hackers Manual</productname> 23620 <date>July 2017</date> 23621</refentryinfo> 23622<refmeta> 23623 <refentrytitle><phrase>insert_resource_expand_to_fit</phrase></refentrytitle> 23624 <manvolnum>9</manvolnum> 23625 <refmiscinfo class="version">4.1.27</refmiscinfo> 23626</refmeta> 23627<refnamediv> 23628 <refname>insert_resource_expand_to_fit</refname> 23629 <refpurpose> 23630 Insert a resource into the resource tree 23631 </refpurpose> 23632</refnamediv> 23633<refsynopsisdiv> 23634 <title>Synopsis</title> 23635 <funcsynopsis><funcprototype> 23636 <funcdef>void <function>insert_resource_expand_to_fit </function></funcdef> 23637 <paramdef>struct resource * <parameter>root</parameter></paramdef> 23638 <paramdef>struct resource * <parameter>new</parameter></paramdef> 23639 </funcprototype></funcsynopsis> 23640</refsynopsisdiv> 23641<refsect1> 23642 <title>Arguments</title> 23643 <variablelist> 23644 <varlistentry> 23645 <term><parameter>root</parameter></term> 23646 <listitem> 23647 <para> 23648 root resource descriptor 23649 </para> 23650 </listitem> 23651 </varlistentry> 23652 <varlistentry> 23653 <term><parameter>new</parameter></term> 23654 <listitem> 23655 <para> 23656 new resource to insert 23657 </para> 23658 </listitem> 23659 </varlistentry> 23660 </variablelist> 23661</refsect1> 23662<refsect1> 23663<title>Description</title> 23664<para> 23665 Insert a resource into the resource tree, possibly expanding it in order 23666 to make it encompass any conflicting resources. 23667</para> 23668</refsect1> 23669</refentry> 23670 23671<refentry id="API-resource-alignment"> 23672<refentryinfo> 23673 <title>LINUX</title> 23674 <productname>Kernel Hackers Manual</productname> 23675 <date>July 2017</date> 23676</refentryinfo> 23677<refmeta> 23678 <refentrytitle><phrase>resource_alignment</phrase></refentrytitle> 23679 <manvolnum>9</manvolnum> 23680 <refmiscinfo class="version">4.1.27</refmiscinfo> 23681</refmeta> 23682<refnamediv> 23683 <refname>resource_alignment</refname> 23684 <refpurpose> 23685 calculate resource's alignment 23686 </refpurpose> 23687</refnamediv> 23688<refsynopsisdiv> 23689 <title>Synopsis</title> 23690 <funcsynopsis><funcprototype> 23691 <funcdef>resource_size_t <function>resource_alignment </function></funcdef> 23692 <paramdef>struct resource * <parameter>res</parameter></paramdef> 23693 </funcprototype></funcsynopsis> 23694</refsynopsisdiv> 23695<refsect1> 23696 <title>Arguments</title> 23697 <variablelist> 23698 <varlistentry> 23699 <term><parameter>res</parameter></term> 23700 <listitem> 23701 <para> 23702 resource pointer 23703 </para> 23704 </listitem> 23705 </varlistentry> 23706 </variablelist> 23707</refsect1> 23708<refsect1> 23709<title>Description</title> 23710<para> 23711 Returns alignment on success, 0 (invalid alignment) on failure. 23712</para> 23713</refsect1> 23714</refentry> 23715 23716<refentry id="API-release-mem-region-adjustable"> 23717<refentryinfo> 23718 <title>LINUX</title> 23719 <productname>Kernel Hackers Manual</productname> 23720 <date>July 2017</date> 23721</refentryinfo> 23722<refmeta> 23723 <refentrytitle><phrase>release_mem_region_adjustable</phrase></refentrytitle> 23724 <manvolnum>9</manvolnum> 23725 <refmiscinfo class="version">4.1.27</refmiscinfo> 23726</refmeta> 23727<refnamediv> 23728 <refname>release_mem_region_adjustable</refname> 23729 <refpurpose> 23730 release a previously reserved memory region 23731 </refpurpose> 23732</refnamediv> 23733<refsynopsisdiv> 23734 <title>Synopsis</title> 23735 <funcsynopsis><funcprototype> 23736 <funcdef>int <function>release_mem_region_adjustable </function></funcdef> 23737 <paramdef>struct resource * <parameter>parent</parameter></paramdef> 23738 <paramdef>resource_size_t <parameter>start</parameter></paramdef> 23739 <paramdef>resource_size_t <parameter>size</parameter></paramdef> 23740 </funcprototype></funcsynopsis> 23741</refsynopsisdiv> 23742<refsect1> 23743 <title>Arguments</title> 23744 <variablelist> 23745 <varlistentry> 23746 <term><parameter>parent</parameter></term> 23747 <listitem> 23748 <para> 23749 parent resource descriptor 23750 </para> 23751 </listitem> 23752 </varlistentry> 23753 <varlistentry> 23754 <term><parameter>start</parameter></term> 23755 <listitem> 23756 <para> 23757 resource start address 23758 </para> 23759 </listitem> 23760 </varlistentry> 23761 <varlistentry> 23762 <term><parameter>size</parameter></term> 23763 <listitem> 23764 <para> 23765 resource region size 23766 </para> 23767 </listitem> 23768 </varlistentry> 23769 </variablelist> 23770</refsect1> 23771<refsect1> 23772<title>Description</title> 23773<para> 23774 This interface is intended for memory hot-delete. The requested region 23775 is released from a currently busy memory resource. The requested region 23776 must either match exactly or fit into a single busy resource entry. In 23777 the latter case, the remaining resource is adjusted accordingly. 23778 Existing children of the busy memory resource must be immutable in the 23779 request. 23780</para> 23781</refsect1> 23782<refsect1> 23783<title>Note</title> 23784<para> 23785 - Additional release conditions, such as overlapping region, can be 23786 supported after they are confirmed as valid cases. 23787 - When a busy memory resource gets split into two entries, the code 23788 assumes that all children remain in the lower address entry for 23789 simplicity. Enhance this logic when necessary. 23790</para> 23791</refsect1> 23792</refentry> 23793 23794<!-- kernel/resource.c --> 23795<refentry id="API-request-resource"> 23796<refentryinfo> 23797 <title>LINUX</title> 23798 <productname>Kernel Hackers Manual</productname> 23799 <date>July 2017</date> 23800</refentryinfo> 23801<refmeta> 23802 <refentrytitle><phrase>request_resource</phrase></refentrytitle> 23803 <manvolnum>9</manvolnum> 23804 <refmiscinfo class="version">4.1.27</refmiscinfo> 23805</refmeta> 23806<refnamediv> 23807 <refname>request_resource</refname> 23808 <refpurpose> 23809 request and reserve an I/O or memory resource 23810 </refpurpose> 23811</refnamediv> 23812<refsynopsisdiv> 23813 <title>Synopsis</title> 23814 <funcsynopsis><funcprototype> 23815 <funcdef>int <function>request_resource </function></funcdef> 23816 <paramdef>struct resource * <parameter>root</parameter></paramdef> 23817 <paramdef>struct resource * <parameter>new</parameter></paramdef> 23818 </funcprototype></funcsynopsis> 23819</refsynopsisdiv> 23820<refsect1> 23821 <title>Arguments</title> 23822 <variablelist> 23823 <varlistentry> 23824 <term><parameter>root</parameter></term> 23825 <listitem> 23826 <para> 23827 root resource descriptor 23828 </para> 23829 </listitem> 23830 </varlistentry> 23831 <varlistentry> 23832 <term><parameter>new</parameter></term> 23833 <listitem> 23834 <para> 23835 resource descriptor desired by caller 23836 </para> 23837 </listitem> 23838 </varlistentry> 23839 </variablelist> 23840</refsect1> 23841<refsect1> 23842<title>Description</title> 23843<para> 23844 Returns 0 for success, negative error code on error. 23845</para> 23846</refsect1> 23847</refentry> 23848 23849<refentry id="API-release-resource"> 23850<refentryinfo> 23851 <title>LINUX</title> 23852 <productname>Kernel Hackers Manual</productname> 23853 <date>July 2017</date> 23854</refentryinfo> 23855<refmeta> 23856 <refentrytitle><phrase>release_resource</phrase></refentrytitle> 23857 <manvolnum>9</manvolnum> 23858 <refmiscinfo class="version">4.1.27</refmiscinfo> 23859</refmeta> 23860<refnamediv> 23861 <refname>release_resource</refname> 23862 <refpurpose> 23863 release a previously reserved resource 23864 </refpurpose> 23865</refnamediv> 23866<refsynopsisdiv> 23867 <title>Synopsis</title> 23868 <funcsynopsis><funcprototype> 23869 <funcdef>int <function>release_resource </function></funcdef> 23870 <paramdef>struct resource * <parameter>old</parameter></paramdef> 23871 </funcprototype></funcsynopsis> 23872</refsynopsisdiv> 23873<refsect1> 23874 <title>Arguments</title> 23875 <variablelist> 23876 <varlistentry> 23877 <term><parameter>old</parameter></term> 23878 <listitem> 23879 <para> 23880 resource pointer 23881 </para> 23882 </listitem> 23883 </varlistentry> 23884 </variablelist> 23885</refsect1> 23886</refentry> 23887 23888<refentry id="API-allocate-resource"> 23889<refentryinfo> 23890 <title>LINUX</title> 23891 <productname>Kernel Hackers Manual</productname> 23892 <date>July 2017</date> 23893</refentryinfo> 23894<refmeta> 23895 <refentrytitle><phrase>allocate_resource</phrase></refentrytitle> 23896 <manvolnum>9</manvolnum> 23897 <refmiscinfo class="version">4.1.27</refmiscinfo> 23898</refmeta> 23899<refnamediv> 23900 <refname>allocate_resource</refname> 23901 <refpurpose> 23902 allocate empty slot in the resource tree given range & alignment. The resource will be reallocated with a new size if it was already allocated 23903 </refpurpose> 23904</refnamediv> 23905<refsynopsisdiv> 23906 <title>Synopsis</title> 23907 <funcsynopsis><funcprototype> 23908 <funcdef>int <function>allocate_resource </function></funcdef> 23909 <paramdef>struct resource * <parameter>root</parameter></paramdef> 23910 <paramdef>struct resource * <parameter>new</parameter></paramdef> 23911 <paramdef>resource_size_t <parameter>size</parameter></paramdef> 23912 <paramdef>resource_size_t <parameter>min</parameter></paramdef> 23913 <paramdef>resource_size_t <parameter>max</parameter></paramdef> 23914 <paramdef>resource_size_t <parameter>align</parameter></paramdef> 23915 <paramdef>resource_size_t (*<parameter>alignf</parameter>) 23916 <funcparams>void *, const struct resource *, resource_size_t, resource_size_t</funcparams></paramdef> 23917 <paramdef>void * <parameter>alignf_data</parameter></paramdef> 23918 </funcprototype></funcsynopsis> 23919</refsynopsisdiv> 23920<refsect1> 23921 <title>Arguments</title> 23922 <variablelist> 23923 <varlistentry> 23924 <term><parameter>root</parameter></term> 23925 <listitem> 23926 <para> 23927 root resource descriptor 23928 </para> 23929 </listitem> 23930 </varlistentry> 23931 <varlistentry> 23932 <term><parameter>new</parameter></term> 23933 <listitem> 23934 <para> 23935 resource descriptor desired by caller 23936 </para> 23937 </listitem> 23938 </varlistentry> 23939 <varlistentry> 23940 <term><parameter>size</parameter></term> 23941 <listitem> 23942 <para> 23943 requested resource region size 23944 </para> 23945 </listitem> 23946 </varlistentry> 23947 <varlistentry> 23948 <term><parameter>min</parameter></term> 23949 <listitem> 23950 <para> 23951 minimum boundary to allocate 23952 </para> 23953 </listitem> 23954 </varlistentry> 23955 <varlistentry> 23956 <term><parameter>max</parameter></term> 23957 <listitem> 23958 <para> 23959 maximum boundary to allocate 23960 </para> 23961 </listitem> 23962 </varlistentry> 23963 <varlistentry> 23964 <term><parameter>align</parameter></term> 23965 <listitem> 23966 <para> 23967 alignment requested, in bytes 23968 </para> 23969 </listitem> 23970 </varlistentry> 23971 <varlistentry> 23972 <term><parameter>alignf</parameter></term> 23973 <listitem> 23974 <para> 23975 alignment function, optional, called if not NULL 23976 </para> 23977 </listitem> 23978 </varlistentry> 23979 <varlistentry> 23980 <term><parameter>alignf_data</parameter></term> 23981 <listitem> 23982 <para> 23983 arbitrary data to pass to the <parameter>alignf</parameter> function 23984 </para> 23985 </listitem> 23986 </varlistentry> 23987 </variablelist> 23988</refsect1> 23989</refentry> 23990 23991<refentry id="API-adjust-resource"> 23992<refentryinfo> 23993 <title>LINUX</title> 23994 <productname>Kernel Hackers Manual</productname> 23995 <date>July 2017</date> 23996</refentryinfo> 23997<refmeta> 23998 <refentrytitle><phrase>adjust_resource</phrase></refentrytitle> 23999 <manvolnum>9</manvolnum> 24000 <refmiscinfo class="version">4.1.27</refmiscinfo> 24001</refmeta> 24002<refnamediv> 24003 <refname>adjust_resource</refname> 24004 <refpurpose> 24005 modify a resource's start and size 24006 </refpurpose> 24007</refnamediv> 24008<refsynopsisdiv> 24009 <title>Synopsis</title> 24010 <funcsynopsis><funcprototype> 24011 <funcdef>int <function>adjust_resource </function></funcdef> 24012 <paramdef>struct resource * <parameter>res</parameter></paramdef> 24013 <paramdef>resource_size_t <parameter>start</parameter></paramdef> 24014 <paramdef>resource_size_t <parameter>size</parameter></paramdef> 24015 </funcprototype></funcsynopsis> 24016</refsynopsisdiv> 24017<refsect1> 24018 <title>Arguments</title> 24019 <variablelist> 24020 <varlistentry> 24021 <term><parameter>res</parameter></term> 24022 <listitem> 24023 <para> 24024 resource to modify 24025 </para> 24026 </listitem> 24027 </varlistentry> 24028 <varlistentry> 24029 <term><parameter>start</parameter></term> 24030 <listitem> 24031 <para> 24032 new start value 24033 </para> 24034 </listitem> 24035 </varlistentry> 24036 <varlistentry> 24037 <term><parameter>size</parameter></term> 24038 <listitem> 24039 <para> 24040 new size 24041 </para> 24042 </listitem> 24043 </varlistentry> 24044 </variablelist> 24045</refsect1> 24046<refsect1> 24047<title>Description</title> 24048<para> 24049 Given an existing resource, change its start and size to match the 24050 arguments. Returns 0 on success, -EBUSY if it can't fit. 24051 Existing children of the resource are assumed to be immutable. 24052</para> 24053</refsect1> 24054</refentry> 24055 24056<refentry id="API---request-region"> 24057<refentryinfo> 24058 <title>LINUX</title> 24059 <productname>Kernel Hackers Manual</productname> 24060 <date>July 2017</date> 24061</refentryinfo> 24062<refmeta> 24063 <refentrytitle><phrase>__request_region</phrase></refentrytitle> 24064 <manvolnum>9</manvolnum> 24065 <refmiscinfo class="version">4.1.27</refmiscinfo> 24066</refmeta> 24067<refnamediv> 24068 <refname>__request_region</refname> 24069 <refpurpose> 24070 create a new busy resource region 24071 </refpurpose> 24072</refnamediv> 24073<refsynopsisdiv> 24074 <title>Synopsis</title> 24075 <funcsynopsis><funcprototype> 24076 <funcdef>struct resource * <function>__request_region </function></funcdef> 24077 <paramdef>struct resource * <parameter>parent</parameter></paramdef> 24078 <paramdef>resource_size_t <parameter>start</parameter></paramdef> 24079 <paramdef>resource_size_t <parameter>n</parameter></paramdef> 24080 <paramdef>const char * <parameter>name</parameter></paramdef> 24081 <paramdef>int <parameter>flags</parameter></paramdef> 24082 </funcprototype></funcsynopsis> 24083</refsynopsisdiv> 24084<refsect1> 24085 <title>Arguments</title> 24086 <variablelist> 24087 <varlistentry> 24088 <term><parameter>parent</parameter></term> 24089 <listitem> 24090 <para> 24091 parent resource descriptor 24092 </para> 24093 </listitem> 24094 </varlistentry> 24095 <varlistentry> 24096 <term><parameter>start</parameter></term> 24097 <listitem> 24098 <para> 24099 resource start address 24100 </para> 24101 </listitem> 24102 </varlistentry> 24103 <varlistentry> 24104 <term><parameter>n</parameter></term> 24105 <listitem> 24106 <para> 24107 resource region size 24108 </para> 24109 </listitem> 24110 </varlistentry> 24111 <varlistentry> 24112 <term><parameter>name</parameter></term> 24113 <listitem> 24114 <para> 24115 reserving caller's ID string 24116 </para> 24117 </listitem> 24118 </varlistentry> 24119 <varlistentry> 24120 <term><parameter>flags</parameter></term> 24121 <listitem> 24122 <para> 24123 IO resource flags 24124 </para> 24125 </listitem> 24126 </varlistentry> 24127 </variablelist> 24128</refsect1> 24129</refentry> 24130 24131<refentry id="API---release-region"> 24132<refentryinfo> 24133 <title>LINUX</title> 24134 <productname>Kernel Hackers Manual</productname> 24135 <date>July 2017</date> 24136</refentryinfo> 24137<refmeta> 24138 <refentrytitle><phrase>__release_region</phrase></refentrytitle> 24139 <manvolnum>9</manvolnum> 24140 <refmiscinfo class="version">4.1.27</refmiscinfo> 24141</refmeta> 24142<refnamediv> 24143 <refname>__release_region</refname> 24144 <refpurpose> 24145 release a previously reserved resource region 24146 </refpurpose> 24147</refnamediv> 24148<refsynopsisdiv> 24149 <title>Synopsis</title> 24150 <funcsynopsis><funcprototype> 24151 <funcdef>void <function>__release_region </function></funcdef> 24152 <paramdef>struct resource * <parameter>parent</parameter></paramdef> 24153 <paramdef>resource_size_t <parameter>start</parameter></paramdef> 24154 <paramdef>resource_size_t <parameter>n</parameter></paramdef> 24155 </funcprototype></funcsynopsis> 24156</refsynopsisdiv> 24157<refsect1> 24158 <title>Arguments</title> 24159 <variablelist> 24160 <varlistentry> 24161 <term><parameter>parent</parameter></term> 24162 <listitem> 24163 <para> 24164 parent resource descriptor 24165 </para> 24166 </listitem> 24167 </varlistentry> 24168 <varlistentry> 24169 <term><parameter>start</parameter></term> 24170 <listitem> 24171 <para> 24172 resource start address 24173 </para> 24174 </listitem> 24175 </varlistentry> 24176 <varlistentry> 24177 <term><parameter>n</parameter></term> 24178 <listitem> 24179 <para> 24180 resource region size 24181 </para> 24182 </listitem> 24183 </varlistentry> 24184 </variablelist> 24185</refsect1> 24186<refsect1> 24187<title>Description</title> 24188<para> 24189 The described resource region must match a currently busy region. 24190</para> 24191</refsect1> 24192</refentry> 24193 24194<refentry id="API-devm-request-resource"> 24195<refentryinfo> 24196 <title>LINUX</title> 24197 <productname>Kernel Hackers Manual</productname> 24198 <date>July 2017</date> 24199</refentryinfo> 24200<refmeta> 24201 <refentrytitle><phrase>devm_request_resource</phrase></refentrytitle> 24202 <manvolnum>9</manvolnum> 24203 <refmiscinfo class="version">4.1.27</refmiscinfo> 24204</refmeta> 24205<refnamediv> 24206 <refname>devm_request_resource</refname> 24207 <refpurpose> 24208 request and reserve an I/O or memory resource 24209 </refpurpose> 24210</refnamediv> 24211<refsynopsisdiv> 24212 <title>Synopsis</title> 24213 <funcsynopsis><funcprototype> 24214 <funcdef>int <function>devm_request_resource </function></funcdef> 24215 <paramdef>struct device * <parameter>dev</parameter></paramdef> 24216 <paramdef>struct resource * <parameter>root</parameter></paramdef> 24217 <paramdef>struct resource * <parameter>new</parameter></paramdef> 24218 </funcprototype></funcsynopsis> 24219</refsynopsisdiv> 24220<refsect1> 24221 <title>Arguments</title> 24222 <variablelist> 24223 <varlistentry> 24224 <term><parameter>dev</parameter></term> 24225 <listitem> 24226 <para> 24227 device for which to request the resource 24228 </para> 24229 </listitem> 24230 </varlistentry> 24231 <varlistentry> 24232 <term><parameter>root</parameter></term> 24233 <listitem> 24234 <para> 24235 root of the resource tree from which to request the resource 24236 </para> 24237 </listitem> 24238 </varlistentry> 24239 <varlistentry> 24240 <term><parameter>new</parameter></term> 24241 <listitem> 24242 <para> 24243 descriptor of the resource to request 24244 </para> 24245 </listitem> 24246 </varlistentry> 24247 </variablelist> 24248</refsect1> 24249<refsect1> 24250<title>Description</title> 24251<para> 24252 This is a device-managed version of <function>request_resource</function>. There is usually 24253 no need to release resources requested by this function explicitly since 24254 that will be taken care of when the device is unbound from its driver. 24255 If for some reason the resource needs to be released explicitly, because 24256 of ordering issues for example, drivers must call <function>devm_release_resource</function> 24257 rather than the regular <function>release_resource</function>. 24258 </para><para> 24259 24260 When a conflict is detected between any existing resources and the newly 24261 requested resource, an error message will be printed. 24262 </para><para> 24263 24264 Returns 0 on success or a negative error code on failure. 24265</para> 24266</refsect1> 24267</refentry> 24268 24269<refentry id="API-devm-release-resource"> 24270<refentryinfo> 24271 <title>LINUX</title> 24272 <productname>Kernel Hackers Manual</productname> 24273 <date>July 2017</date> 24274</refentryinfo> 24275<refmeta> 24276 <refentrytitle><phrase>devm_release_resource</phrase></refentrytitle> 24277 <manvolnum>9</manvolnum> 24278 <refmiscinfo class="version">4.1.27</refmiscinfo> 24279</refmeta> 24280<refnamediv> 24281 <refname>devm_release_resource</refname> 24282 <refpurpose> 24283 release a previously requested resource 24284 </refpurpose> 24285</refnamediv> 24286<refsynopsisdiv> 24287 <title>Synopsis</title> 24288 <funcsynopsis><funcprototype> 24289 <funcdef>void <function>devm_release_resource </function></funcdef> 24290 <paramdef>struct device * <parameter>dev</parameter></paramdef> 24291 <paramdef>struct resource * <parameter>new</parameter></paramdef> 24292 </funcprototype></funcsynopsis> 24293</refsynopsisdiv> 24294<refsect1> 24295 <title>Arguments</title> 24296 <variablelist> 24297 <varlistentry> 24298 <term><parameter>dev</parameter></term> 24299 <listitem> 24300 <para> 24301 device for which to release the resource 24302 </para> 24303 </listitem> 24304 </varlistentry> 24305 <varlistentry> 24306 <term><parameter>new</parameter></term> 24307 <listitem> 24308 <para> 24309 descriptor of the resource to release 24310 </para> 24311 </listitem> 24312 </varlistentry> 24313 </variablelist> 24314</refsect1> 24315<refsect1> 24316<title>Description</title> 24317<para> 24318 Releases a resource previously requested using <function>devm_request_resource</function>. 24319</para> 24320</refsect1> 24321</refentry> 24322 24323 </sect1> 24324 24325 <sect1><title>MTRR Handling</title> 24326<!-- arch/x86/kernel/cpu/mtrr/main.c --> 24327<refentry id="API-mtrr-add"> 24328<refentryinfo> 24329 <title>LINUX</title> 24330 <productname>Kernel Hackers Manual</productname> 24331 <date>July 2017</date> 24332</refentryinfo> 24333<refmeta> 24334 <refentrytitle><phrase>mtrr_add</phrase></refentrytitle> 24335 <manvolnum>9</manvolnum> 24336 <refmiscinfo class="version">4.1.27</refmiscinfo> 24337</refmeta> 24338<refnamediv> 24339 <refname>mtrr_add</refname> 24340 <refpurpose> 24341 Add a memory type region 24342 </refpurpose> 24343</refnamediv> 24344<refsynopsisdiv> 24345 <title>Synopsis</title> 24346 <funcsynopsis><funcprototype> 24347 <funcdef>int <function>mtrr_add </function></funcdef> 24348 <paramdef>unsigned long <parameter>base</parameter></paramdef> 24349 <paramdef>unsigned long <parameter>size</parameter></paramdef> 24350 <paramdef>unsigned int <parameter>type</parameter></paramdef> 24351 <paramdef>bool <parameter>increment</parameter></paramdef> 24352 </funcprototype></funcsynopsis> 24353</refsynopsisdiv> 24354<refsect1> 24355 <title>Arguments</title> 24356 <variablelist> 24357 <varlistentry> 24358 <term><parameter>base</parameter></term> 24359 <listitem> 24360 <para> 24361 Physical base address of region 24362 </para> 24363 </listitem> 24364 </varlistentry> 24365 <varlistentry> 24366 <term><parameter>size</parameter></term> 24367 <listitem> 24368 <para> 24369 Physical size of region 24370 </para> 24371 </listitem> 24372 </varlistentry> 24373 <varlistentry> 24374 <term><parameter>type</parameter></term> 24375 <listitem> 24376 <para> 24377 Type of MTRR desired 24378 </para> 24379 </listitem> 24380 </varlistentry> 24381 <varlistentry> 24382 <term><parameter>increment</parameter></term> 24383 <listitem> 24384 <para> 24385 If this is true do usage counting on the region 24386 </para> 24387 </listitem> 24388 </varlistentry> 24389 </variablelist> 24390</refsect1> 24391<refsect1> 24392<title>Description</title> 24393<para> 24394 Memory type region registers control the caching on newer Intel and 24395 non Intel processors. This function allows drivers to request an 24396 MTRR is added. The details and hardware specifics of each processor's 24397 implementation are hidden from the caller, but nevertheless the 24398 caller should expect to need to provide a power of two size on an 24399 equivalent power of two boundary. 24400 </para><para> 24401 24402 If the region cannot be added either because all regions are in use 24403 or the CPU cannot support it a negative value is returned. On success 24404 the register number for this entry is returned, but should be treated 24405 as a cookie only. 24406 </para><para> 24407 24408 On a multiprocessor machine the changes are made to all processors. 24409 This is required on x86 by the Intel processors. 24410 </para><para> 24411 24412 The available types are 24413 </para><para> 24414 24415 <constant>MTRR_TYPE_UNCACHABLE</constant> - No caching 24416 </para><para> 24417 24418 <constant>MTRR_TYPE_WRBACK</constant> - Write data back in bursts whenever 24419 </para><para> 24420 24421 <constant>MTRR_TYPE_WRCOMB</constant> - Write data back soon but allow bursts 24422 </para><para> 24423 24424 <constant>MTRR_TYPE_WRTHROUGH</constant> - Cache reads but not writes 24425</para> 24426</refsect1> 24427<refsect1> 24428<title>BUGS</title> 24429<para> 24430 Needs a quiet flag for the cases where drivers do not mind 24431 failures and do not wish system log messages to be sent. 24432</para> 24433</refsect1> 24434</refentry> 24435 24436<refentry id="API-mtrr-del"> 24437<refentryinfo> 24438 <title>LINUX</title> 24439 <productname>Kernel Hackers Manual</productname> 24440 <date>July 2017</date> 24441</refentryinfo> 24442<refmeta> 24443 <refentrytitle><phrase>mtrr_del</phrase></refentrytitle> 24444 <manvolnum>9</manvolnum> 24445 <refmiscinfo class="version">4.1.27</refmiscinfo> 24446</refmeta> 24447<refnamediv> 24448 <refname>mtrr_del</refname> 24449 <refpurpose> 24450 delete a memory type region 24451 </refpurpose> 24452</refnamediv> 24453<refsynopsisdiv> 24454 <title>Synopsis</title> 24455 <funcsynopsis><funcprototype> 24456 <funcdef>int <function>mtrr_del </function></funcdef> 24457 <paramdef>int <parameter>reg</parameter></paramdef> 24458 <paramdef>unsigned long <parameter>base</parameter></paramdef> 24459 <paramdef>unsigned long <parameter>size</parameter></paramdef> 24460 </funcprototype></funcsynopsis> 24461</refsynopsisdiv> 24462<refsect1> 24463 <title>Arguments</title> 24464 <variablelist> 24465 <varlistentry> 24466 <term><parameter>reg</parameter></term> 24467 <listitem> 24468 <para> 24469 Register returned by mtrr_add 24470 </para> 24471 </listitem> 24472 </varlistentry> 24473 <varlistentry> 24474 <term><parameter>base</parameter></term> 24475 <listitem> 24476 <para> 24477 Physical base address 24478 </para> 24479 </listitem> 24480 </varlistentry> 24481 <varlistentry> 24482 <term><parameter>size</parameter></term> 24483 <listitem> 24484 <para> 24485 Size of region 24486 </para> 24487 </listitem> 24488 </varlistentry> 24489 </variablelist> 24490</refsect1> 24491<refsect1> 24492<title>Description</title> 24493<para> 24494 If register is supplied then base and size are ignored. This is 24495 how drivers should call it. 24496 </para><para> 24497 24498 Releases an MTRR region. If the usage count drops to zero the 24499 register is freed and the region returns to default state. 24500 On success the register is returned, on failure a negative error 24501 code. 24502</para> 24503</refsect1> 24504</refentry> 24505 24506<refentry id="API-arch-phys-wc-add"> 24507<refentryinfo> 24508 <title>LINUX</title> 24509 <productname>Kernel Hackers Manual</productname> 24510 <date>July 2017</date> 24511</refentryinfo> 24512<refmeta> 24513 <refentrytitle><phrase>arch_phys_wc_add</phrase></refentrytitle> 24514 <manvolnum>9</manvolnum> 24515 <refmiscinfo class="version">4.1.27</refmiscinfo> 24516</refmeta> 24517<refnamediv> 24518 <refname>arch_phys_wc_add</refname> 24519 <refpurpose> 24520 add a WC MTRR and handle errors if PAT is unavailable 24521 </refpurpose> 24522</refnamediv> 24523<refsynopsisdiv> 24524 <title>Synopsis</title> 24525 <funcsynopsis><funcprototype> 24526 <funcdef>int <function>arch_phys_wc_add </function></funcdef> 24527 <paramdef>unsigned long <parameter>base</parameter></paramdef> 24528 <paramdef>unsigned long <parameter>size</parameter></paramdef> 24529 </funcprototype></funcsynopsis> 24530</refsynopsisdiv> 24531<refsect1> 24532 <title>Arguments</title> 24533 <variablelist> 24534 <varlistentry> 24535 <term><parameter>base</parameter></term> 24536 <listitem> 24537 <para> 24538 Physical base address 24539 </para> 24540 </listitem> 24541 </varlistentry> 24542 <varlistentry> 24543 <term><parameter>size</parameter></term> 24544 <listitem> 24545 <para> 24546 Size of region 24547 </para> 24548 </listitem> 24549 </varlistentry> 24550 </variablelist> 24551</refsect1> 24552<refsect1> 24553<title>Description</title> 24554<para> 24555 If PAT is available, this does nothing. If PAT is unavailable, it 24556 attempts to add a WC MTRR covering size bytes starting at base and 24557 logs an error if this fails. 24558 </para><para> 24559 24560 Drivers must store the return value to pass to mtrr_del_wc_if_needed, 24561 but drivers should not try to interpret that return value. 24562</para> 24563</refsect1> 24564</refentry> 24565 24566 </sect1> 24567 24568 <sect1><title>PCI Support Library</title> 24569<!-- drivers/pci/pci.c --> 24570<refentry id="API-pci-bus-max-busnr"> 24571<refentryinfo> 24572 <title>LINUX</title> 24573 <productname>Kernel Hackers Manual</productname> 24574 <date>July 2017</date> 24575</refentryinfo> 24576<refmeta> 24577 <refentrytitle><phrase>pci_bus_max_busnr</phrase></refentrytitle> 24578 <manvolnum>9</manvolnum> 24579 <refmiscinfo class="version">4.1.27</refmiscinfo> 24580</refmeta> 24581<refnamediv> 24582 <refname>pci_bus_max_busnr</refname> 24583 <refpurpose> 24584 returns maximum PCI bus number of given bus' children 24585 </refpurpose> 24586</refnamediv> 24587<refsynopsisdiv> 24588 <title>Synopsis</title> 24589 <funcsynopsis><funcprototype> 24590 <funcdef>unsigned char <function>pci_bus_max_busnr </function></funcdef> 24591 <paramdef>struct pci_bus * <parameter>bus</parameter></paramdef> 24592 </funcprototype></funcsynopsis> 24593</refsynopsisdiv> 24594<refsect1> 24595 <title>Arguments</title> 24596 <variablelist> 24597 <varlistentry> 24598 <term><parameter>bus</parameter></term> 24599 <listitem> 24600 <para> 24601 pointer to PCI bus structure to search 24602 </para> 24603 </listitem> 24604 </varlistentry> 24605 </variablelist> 24606</refsect1> 24607<refsect1> 24608<title>Description</title> 24609<para> 24610 Given a PCI bus, returns the highest PCI bus number present in the set 24611 including the given PCI bus and its list of child PCI buses. 24612</para> 24613</refsect1> 24614</refentry> 24615 24616<refentry id="API-pci-find-capability"> 24617<refentryinfo> 24618 <title>LINUX</title> 24619 <productname>Kernel Hackers Manual</productname> 24620 <date>July 2017</date> 24621</refentryinfo> 24622<refmeta> 24623 <refentrytitle><phrase>pci_find_capability</phrase></refentrytitle> 24624 <manvolnum>9</manvolnum> 24625 <refmiscinfo class="version">4.1.27</refmiscinfo> 24626</refmeta> 24627<refnamediv> 24628 <refname>pci_find_capability</refname> 24629 <refpurpose> 24630 query for devices' capabilities 24631 </refpurpose> 24632</refnamediv> 24633<refsynopsisdiv> 24634 <title>Synopsis</title> 24635 <funcsynopsis><funcprototype> 24636 <funcdef>int <function>pci_find_capability </function></funcdef> 24637 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 24638 <paramdef>int <parameter>cap</parameter></paramdef> 24639 </funcprototype></funcsynopsis> 24640</refsynopsisdiv> 24641<refsect1> 24642 <title>Arguments</title> 24643 <variablelist> 24644 <varlistentry> 24645 <term><parameter>dev</parameter></term> 24646 <listitem> 24647 <para> 24648 PCI device to query 24649 </para> 24650 </listitem> 24651 </varlistentry> 24652 <varlistentry> 24653 <term><parameter>cap</parameter></term> 24654 <listitem> 24655 <para> 24656 capability code 24657 </para> 24658 </listitem> 24659 </varlistentry> 24660 </variablelist> 24661</refsect1> 24662<refsect1> 24663<title>Description</title> 24664<para> 24665 Tell if a device supports a given PCI capability. 24666 Returns the address of the requested capability structure within the 24667 device's PCI configuration space or 0 in case the device does not 24668 support it. Possible values for <parameter>cap</parameter>: 24669 </para><para> 24670 24671 <constant>PCI_CAP_ID_PM</constant> Power Management 24672 <constant>PCI_CAP_ID_AGP</constant> Accelerated Graphics Port 24673 <constant>PCI_CAP_ID_VPD</constant> Vital Product Data 24674 <constant>PCI_CAP_ID_SLOTID</constant> Slot Identification 24675 <constant>PCI_CAP_ID_MSI</constant> Message Signalled Interrupts 24676 <constant>PCI_CAP_ID_CHSWP</constant> CompactPCI HotSwap 24677 <constant>PCI_CAP_ID_PCIX</constant> PCI-X 24678 <constant>PCI_CAP_ID_EXP</constant> PCI Express 24679</para> 24680</refsect1> 24681</refentry> 24682 24683<refentry id="API-pci-bus-find-capability"> 24684<refentryinfo> 24685 <title>LINUX</title> 24686 <productname>Kernel Hackers Manual</productname> 24687 <date>July 2017</date> 24688</refentryinfo> 24689<refmeta> 24690 <refentrytitle><phrase>pci_bus_find_capability</phrase></refentrytitle> 24691 <manvolnum>9</manvolnum> 24692 <refmiscinfo class="version">4.1.27</refmiscinfo> 24693</refmeta> 24694<refnamediv> 24695 <refname>pci_bus_find_capability</refname> 24696 <refpurpose> 24697 query for devices' capabilities 24698 </refpurpose> 24699</refnamediv> 24700<refsynopsisdiv> 24701 <title>Synopsis</title> 24702 <funcsynopsis><funcprototype> 24703 <funcdef>int <function>pci_bus_find_capability </function></funcdef> 24704 <paramdef>struct pci_bus * <parameter>bus</parameter></paramdef> 24705 <paramdef>unsigned int <parameter>devfn</parameter></paramdef> 24706 <paramdef>int <parameter>cap</parameter></paramdef> 24707 </funcprototype></funcsynopsis> 24708</refsynopsisdiv> 24709<refsect1> 24710 <title>Arguments</title> 24711 <variablelist> 24712 <varlistentry> 24713 <term><parameter>bus</parameter></term> 24714 <listitem> 24715 <para> 24716 the PCI bus to query 24717 </para> 24718 </listitem> 24719 </varlistentry> 24720 <varlistentry> 24721 <term><parameter>devfn</parameter></term> 24722 <listitem> 24723 <para> 24724 PCI device to query 24725 </para> 24726 </listitem> 24727 </varlistentry> 24728 <varlistentry> 24729 <term><parameter>cap</parameter></term> 24730 <listitem> 24731 <para> 24732 capability code 24733 </para> 24734 </listitem> 24735 </varlistentry> 24736 </variablelist> 24737</refsect1> 24738<refsect1> 24739<title>Description</title> 24740<para> 24741 Like <function>pci_find_capability</function> but works for pci devices that do not have a 24742 pci_dev structure set up yet. 24743 </para><para> 24744 24745 Returns the address of the requested capability structure within the 24746 device's PCI configuration space or 0 in case the device does not 24747 support it. 24748</para> 24749</refsect1> 24750</refentry> 24751 24752<refentry id="API-pci-find-next-ext-capability"> 24753<refentryinfo> 24754 <title>LINUX</title> 24755 <productname>Kernel Hackers Manual</productname> 24756 <date>July 2017</date> 24757</refentryinfo> 24758<refmeta> 24759 <refentrytitle><phrase>pci_find_next_ext_capability</phrase></refentrytitle> 24760 <manvolnum>9</manvolnum> 24761 <refmiscinfo class="version">4.1.27</refmiscinfo> 24762</refmeta> 24763<refnamediv> 24764 <refname>pci_find_next_ext_capability</refname> 24765 <refpurpose> 24766 Find an extended capability 24767 </refpurpose> 24768</refnamediv> 24769<refsynopsisdiv> 24770 <title>Synopsis</title> 24771 <funcsynopsis><funcprototype> 24772 <funcdef>int <function>pci_find_next_ext_capability </function></funcdef> 24773 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 24774 <paramdef>int <parameter>start</parameter></paramdef> 24775 <paramdef>int <parameter>cap</parameter></paramdef> 24776 </funcprototype></funcsynopsis> 24777</refsynopsisdiv> 24778<refsect1> 24779 <title>Arguments</title> 24780 <variablelist> 24781 <varlistentry> 24782 <term><parameter>dev</parameter></term> 24783 <listitem> 24784 <para> 24785 PCI device to query 24786 </para> 24787 </listitem> 24788 </varlistentry> 24789 <varlistentry> 24790 <term><parameter>start</parameter></term> 24791 <listitem> 24792 <para> 24793 address at which to start looking (0 to start at beginning of list) 24794 </para> 24795 </listitem> 24796 </varlistentry> 24797 <varlistentry> 24798 <term><parameter>cap</parameter></term> 24799 <listitem> 24800 <para> 24801 capability code 24802 </para> 24803 </listitem> 24804 </varlistentry> 24805 </variablelist> 24806</refsect1> 24807<refsect1> 24808<title>Description</title> 24809<para> 24810 Returns the address of the next matching extended capability structure 24811 within the device's PCI configuration space or 0 if the device does 24812 not support it. Some capabilities can occur several times, e.g., the 24813 vendor-specific capability, and this provides a way to find them all. 24814</para> 24815</refsect1> 24816</refentry> 24817 24818<refentry id="API-pci-find-ext-capability"> 24819<refentryinfo> 24820 <title>LINUX</title> 24821 <productname>Kernel Hackers Manual</productname> 24822 <date>July 2017</date> 24823</refentryinfo> 24824<refmeta> 24825 <refentrytitle><phrase>pci_find_ext_capability</phrase></refentrytitle> 24826 <manvolnum>9</manvolnum> 24827 <refmiscinfo class="version">4.1.27</refmiscinfo> 24828</refmeta> 24829<refnamediv> 24830 <refname>pci_find_ext_capability</refname> 24831 <refpurpose> 24832 Find an extended capability 24833 </refpurpose> 24834</refnamediv> 24835<refsynopsisdiv> 24836 <title>Synopsis</title> 24837 <funcsynopsis><funcprototype> 24838 <funcdef>int <function>pci_find_ext_capability </function></funcdef> 24839 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 24840 <paramdef>int <parameter>cap</parameter></paramdef> 24841 </funcprototype></funcsynopsis> 24842</refsynopsisdiv> 24843<refsect1> 24844 <title>Arguments</title> 24845 <variablelist> 24846 <varlistentry> 24847 <term><parameter>dev</parameter></term> 24848 <listitem> 24849 <para> 24850 PCI device to query 24851 </para> 24852 </listitem> 24853 </varlistentry> 24854 <varlistentry> 24855 <term><parameter>cap</parameter></term> 24856 <listitem> 24857 <para> 24858 capability code 24859 </para> 24860 </listitem> 24861 </varlistentry> 24862 </variablelist> 24863</refsect1> 24864<refsect1> 24865<title>Description</title> 24866<para> 24867 Returns the address of the requested extended capability structure 24868 within the device's PCI configuration space or 0 if the device does 24869 not support it. Possible values for <parameter>cap</parameter>: 24870 </para><para> 24871 24872 <constant>PCI_EXT_CAP_ID_ERR</constant> Advanced Error Reporting 24873 <constant>PCI_EXT_CAP_ID_VC</constant> Virtual Channel 24874 <constant>PCI_EXT_CAP_ID_DSN</constant> Device Serial Number 24875 <constant>PCI_EXT_CAP_ID_PWR</constant> Power Budgeting 24876</para> 24877</refsect1> 24878</refentry> 24879 24880<refentry id="API-pci-find-next-ht-capability"> 24881<refentryinfo> 24882 <title>LINUX</title> 24883 <productname>Kernel Hackers Manual</productname> 24884 <date>July 2017</date> 24885</refentryinfo> 24886<refmeta> 24887 <refentrytitle><phrase>pci_find_next_ht_capability</phrase></refentrytitle> 24888 <manvolnum>9</manvolnum> 24889 <refmiscinfo class="version">4.1.27</refmiscinfo> 24890</refmeta> 24891<refnamediv> 24892 <refname>pci_find_next_ht_capability</refname> 24893 <refpurpose> 24894 query a device's Hypertransport capabilities 24895 </refpurpose> 24896</refnamediv> 24897<refsynopsisdiv> 24898 <title>Synopsis</title> 24899 <funcsynopsis><funcprototype> 24900 <funcdef>int <function>pci_find_next_ht_capability </function></funcdef> 24901 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 24902 <paramdef>int <parameter>pos</parameter></paramdef> 24903 <paramdef>int <parameter>ht_cap</parameter></paramdef> 24904 </funcprototype></funcsynopsis> 24905</refsynopsisdiv> 24906<refsect1> 24907 <title>Arguments</title> 24908 <variablelist> 24909 <varlistentry> 24910 <term><parameter>dev</parameter></term> 24911 <listitem> 24912 <para> 24913 PCI device to query 24914 </para> 24915 </listitem> 24916 </varlistentry> 24917 <varlistentry> 24918 <term><parameter>pos</parameter></term> 24919 <listitem> 24920 <para> 24921 Position from which to continue searching 24922 </para> 24923 </listitem> 24924 </varlistentry> 24925 <varlistentry> 24926 <term><parameter>ht_cap</parameter></term> 24927 <listitem> 24928 <para> 24929 Hypertransport capability code 24930 </para> 24931 </listitem> 24932 </varlistentry> 24933 </variablelist> 24934</refsect1> 24935<refsect1> 24936<title>Description</title> 24937<para> 24938 To be used in conjunction with <function>pci_find_ht_capability</function> to search for 24939 all capabilities matching <parameter>ht_cap</parameter>. <parameter>pos</parameter> should always be a value returned 24940 from <function>pci_find_ht_capability</function>. 24941 </para><para> 24942 24943 NB. To be 100% safe against broken PCI devices, the caller should take 24944 steps to avoid an infinite loop. 24945</para> 24946</refsect1> 24947</refentry> 24948 24949<refentry id="API-pci-find-ht-capability"> 24950<refentryinfo> 24951 <title>LINUX</title> 24952 <productname>Kernel Hackers Manual</productname> 24953 <date>July 2017</date> 24954</refentryinfo> 24955<refmeta> 24956 <refentrytitle><phrase>pci_find_ht_capability</phrase></refentrytitle> 24957 <manvolnum>9</manvolnum> 24958 <refmiscinfo class="version">4.1.27</refmiscinfo> 24959</refmeta> 24960<refnamediv> 24961 <refname>pci_find_ht_capability</refname> 24962 <refpurpose> 24963 query a device's Hypertransport capabilities 24964 </refpurpose> 24965</refnamediv> 24966<refsynopsisdiv> 24967 <title>Synopsis</title> 24968 <funcsynopsis><funcprototype> 24969 <funcdef>int <function>pci_find_ht_capability </function></funcdef> 24970 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 24971 <paramdef>int <parameter>ht_cap</parameter></paramdef> 24972 </funcprototype></funcsynopsis> 24973</refsynopsisdiv> 24974<refsect1> 24975 <title>Arguments</title> 24976 <variablelist> 24977 <varlistentry> 24978 <term><parameter>dev</parameter></term> 24979 <listitem> 24980 <para> 24981 PCI device to query 24982 </para> 24983 </listitem> 24984 </varlistentry> 24985 <varlistentry> 24986 <term><parameter>ht_cap</parameter></term> 24987 <listitem> 24988 <para> 24989 Hypertransport capability code 24990 </para> 24991 </listitem> 24992 </varlistentry> 24993 </variablelist> 24994</refsect1> 24995<refsect1> 24996<title>Description</title> 24997<para> 24998 Tell if a device supports a given Hypertransport capability. 24999 Returns an address within the device's PCI configuration space 25000 or 0 in case the device does not support the request capability. 25001 The address points to the PCI capability, of type PCI_CAP_ID_HT, 25002 which has a Hypertransport capability matching <parameter>ht_cap</parameter>. 25003</para> 25004</refsect1> 25005</refentry> 25006 25007<refentry id="API-pci-find-parent-resource"> 25008<refentryinfo> 25009 <title>LINUX</title> 25010 <productname>Kernel Hackers Manual</productname> 25011 <date>July 2017</date> 25012</refentryinfo> 25013<refmeta> 25014 <refentrytitle><phrase>pci_find_parent_resource</phrase></refentrytitle> 25015 <manvolnum>9</manvolnum> 25016 <refmiscinfo class="version">4.1.27</refmiscinfo> 25017</refmeta> 25018<refnamediv> 25019 <refname>pci_find_parent_resource</refname> 25020 <refpurpose> 25021 return resource region of parent bus of given region 25022 </refpurpose> 25023</refnamediv> 25024<refsynopsisdiv> 25025 <title>Synopsis</title> 25026 <funcsynopsis><funcprototype> 25027 <funcdef>struct resource * <function>pci_find_parent_resource </function></funcdef> 25028 <paramdef>const struct pci_dev * <parameter>dev</parameter></paramdef> 25029 <paramdef>struct resource * <parameter>res</parameter></paramdef> 25030 </funcprototype></funcsynopsis> 25031</refsynopsisdiv> 25032<refsect1> 25033 <title>Arguments</title> 25034 <variablelist> 25035 <varlistentry> 25036 <term><parameter>dev</parameter></term> 25037 <listitem> 25038 <para> 25039 PCI device structure contains resources to be searched 25040 </para> 25041 </listitem> 25042 </varlistentry> 25043 <varlistentry> 25044 <term><parameter>res</parameter></term> 25045 <listitem> 25046 <para> 25047 child resource record for which parent is sought 25048 </para> 25049 </listitem> 25050 </varlistentry> 25051 </variablelist> 25052</refsect1> 25053<refsect1> 25054<title>Description</title> 25055<para> 25056 For given resource region of given device, return the resource 25057 region of parent bus the given region is contained in. 25058</para> 25059</refsect1> 25060</refentry> 25061 25062<refentry id="API---pci-complete-power-transition"> 25063<refentryinfo> 25064 <title>LINUX</title> 25065 <productname>Kernel Hackers Manual</productname> 25066 <date>July 2017</date> 25067</refentryinfo> 25068<refmeta> 25069 <refentrytitle><phrase>__pci_complete_power_transition</phrase></refentrytitle> 25070 <manvolnum>9</manvolnum> 25071 <refmiscinfo class="version">4.1.27</refmiscinfo> 25072</refmeta> 25073<refnamediv> 25074 <refname>__pci_complete_power_transition</refname> 25075 <refpurpose> 25076 Complete power transition of a PCI device 25077 </refpurpose> 25078</refnamediv> 25079<refsynopsisdiv> 25080 <title>Synopsis</title> 25081 <funcsynopsis><funcprototype> 25082 <funcdef>int <function>__pci_complete_power_transition </function></funcdef> 25083 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25084 <paramdef>pci_power_t <parameter>state</parameter></paramdef> 25085 </funcprototype></funcsynopsis> 25086</refsynopsisdiv> 25087<refsect1> 25088 <title>Arguments</title> 25089 <variablelist> 25090 <varlistentry> 25091 <term><parameter>dev</parameter></term> 25092 <listitem> 25093 <para> 25094 PCI device to handle. 25095 </para> 25096 </listitem> 25097 </varlistentry> 25098 <varlistentry> 25099 <term><parameter>state</parameter></term> 25100 <listitem> 25101 <para> 25102 State to put the device into. 25103 </para> 25104 </listitem> 25105 </varlistentry> 25106 </variablelist> 25107</refsect1> 25108<refsect1> 25109<title>Description</title> 25110<para> 25111 This function should not be called directly by device drivers. 25112</para> 25113</refsect1> 25114</refentry> 25115 25116<refentry id="API-pci-set-power-state"> 25117<refentryinfo> 25118 <title>LINUX</title> 25119 <productname>Kernel Hackers Manual</productname> 25120 <date>July 2017</date> 25121</refentryinfo> 25122<refmeta> 25123 <refentrytitle><phrase>pci_set_power_state</phrase></refentrytitle> 25124 <manvolnum>9</manvolnum> 25125 <refmiscinfo class="version">4.1.27</refmiscinfo> 25126</refmeta> 25127<refnamediv> 25128 <refname>pci_set_power_state</refname> 25129 <refpurpose> 25130 Set the power state of a PCI device 25131 </refpurpose> 25132</refnamediv> 25133<refsynopsisdiv> 25134 <title>Synopsis</title> 25135 <funcsynopsis><funcprototype> 25136 <funcdef>int <function>pci_set_power_state </function></funcdef> 25137 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25138 <paramdef>pci_power_t <parameter>state</parameter></paramdef> 25139 </funcprototype></funcsynopsis> 25140</refsynopsisdiv> 25141<refsect1> 25142 <title>Arguments</title> 25143 <variablelist> 25144 <varlistentry> 25145 <term><parameter>dev</parameter></term> 25146 <listitem> 25147 <para> 25148 PCI device to handle. 25149 </para> 25150 </listitem> 25151 </varlistentry> 25152 <varlistentry> 25153 <term><parameter>state</parameter></term> 25154 <listitem> 25155 <para> 25156 PCI power state (D0, D1, D2, D3hot) to put the device into. 25157 </para> 25158 </listitem> 25159 </varlistentry> 25160 </variablelist> 25161</refsect1> 25162<refsect1> 25163<title>Description</title> 25164<para> 25165 Transition a device to a new power state, using the platform firmware and/or 25166 the device's PCI PM registers. 25167</para> 25168</refsect1> 25169<refsect1> 25170<title>RETURN VALUE</title> 25171<para> 25172 -EINVAL if the requested state is invalid. 25173 -EIO if device does not support PCI PM or its PM capabilities register has a 25174 wrong version, or device doesn't support the requested state. 25175 0 if device already is in the requested state. 25176 0 if device's power state has been successfully changed. 25177</para> 25178</refsect1> 25179</refentry> 25180 25181<refentry id="API-pci-choose-state"> 25182<refentryinfo> 25183 <title>LINUX</title> 25184 <productname>Kernel Hackers Manual</productname> 25185 <date>July 2017</date> 25186</refentryinfo> 25187<refmeta> 25188 <refentrytitle><phrase>pci_choose_state</phrase></refentrytitle> 25189 <manvolnum>9</manvolnum> 25190 <refmiscinfo class="version">4.1.27</refmiscinfo> 25191</refmeta> 25192<refnamediv> 25193 <refname>pci_choose_state</refname> 25194 <refpurpose> 25195 Choose the power state of a PCI device 25196 </refpurpose> 25197</refnamediv> 25198<refsynopsisdiv> 25199 <title>Synopsis</title> 25200 <funcsynopsis><funcprototype> 25201 <funcdef>pci_power_t <function>pci_choose_state </function></funcdef> 25202 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25203 <paramdef>pm_message_t <parameter>state</parameter></paramdef> 25204 </funcprototype></funcsynopsis> 25205</refsynopsisdiv> 25206<refsect1> 25207 <title>Arguments</title> 25208 <variablelist> 25209 <varlistentry> 25210 <term><parameter>dev</parameter></term> 25211 <listitem> 25212 <para> 25213 PCI device to be suspended 25214 </para> 25215 </listitem> 25216 </varlistentry> 25217 <varlistentry> 25218 <term><parameter>state</parameter></term> 25219 <listitem> 25220 <para> 25221 target sleep state for the whole system. This is the value 25222 that is passed to <function>suspend</function> function. 25223 </para> 25224 </listitem> 25225 </varlistentry> 25226 </variablelist> 25227</refsect1> 25228<refsect1> 25229<title>Description</title> 25230<para> 25231 Returns PCI power state suitable for given device and given system 25232 message. 25233</para> 25234</refsect1> 25235</refentry> 25236 25237<refentry id="API-pci-save-state"> 25238<refentryinfo> 25239 <title>LINUX</title> 25240 <productname>Kernel Hackers Manual</productname> 25241 <date>July 2017</date> 25242</refentryinfo> 25243<refmeta> 25244 <refentrytitle><phrase>pci_save_state</phrase></refentrytitle> 25245 <manvolnum>9</manvolnum> 25246 <refmiscinfo class="version">4.1.27</refmiscinfo> 25247</refmeta> 25248<refnamediv> 25249 <refname>pci_save_state</refname> 25250 <refpurpose> 25251 save the PCI configuration space of a device before suspending 25252 </refpurpose> 25253</refnamediv> 25254<refsynopsisdiv> 25255 <title>Synopsis</title> 25256 <funcsynopsis><funcprototype> 25257 <funcdef>int <function>pci_save_state </function></funcdef> 25258 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25259 </funcprototype></funcsynopsis> 25260</refsynopsisdiv> 25261<refsect1> 25262 <title>Arguments</title> 25263 <variablelist> 25264 <varlistentry> 25265 <term><parameter>dev</parameter></term> 25266 <listitem> 25267 <para> 25268 - PCI device that we're dealing with 25269 </para> 25270 </listitem> 25271 </varlistentry> 25272 </variablelist> 25273</refsect1> 25274</refentry> 25275 25276<refentry id="API-pci-restore-state"> 25277<refentryinfo> 25278 <title>LINUX</title> 25279 <productname>Kernel Hackers Manual</productname> 25280 <date>July 2017</date> 25281</refentryinfo> 25282<refmeta> 25283 <refentrytitle><phrase>pci_restore_state</phrase></refentrytitle> 25284 <manvolnum>9</manvolnum> 25285 <refmiscinfo class="version">4.1.27</refmiscinfo> 25286</refmeta> 25287<refnamediv> 25288 <refname>pci_restore_state</refname> 25289 <refpurpose> 25290 Restore the saved state of a PCI device 25291 </refpurpose> 25292</refnamediv> 25293<refsynopsisdiv> 25294 <title>Synopsis</title> 25295 <funcsynopsis><funcprototype> 25296 <funcdef>void <function>pci_restore_state </function></funcdef> 25297 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25298 </funcprototype></funcsynopsis> 25299</refsynopsisdiv> 25300<refsect1> 25301 <title>Arguments</title> 25302 <variablelist> 25303 <varlistentry> 25304 <term><parameter>dev</parameter></term> 25305 <listitem> 25306 <para> 25307 - PCI device that we're dealing with 25308 </para> 25309 </listitem> 25310 </varlistentry> 25311 </variablelist> 25312</refsect1> 25313</refentry> 25314 25315<refentry id="API-pci-store-saved-state"> 25316<refentryinfo> 25317 <title>LINUX</title> 25318 <productname>Kernel Hackers Manual</productname> 25319 <date>July 2017</date> 25320</refentryinfo> 25321<refmeta> 25322 <refentrytitle><phrase>pci_store_saved_state</phrase></refentrytitle> 25323 <manvolnum>9</manvolnum> 25324 <refmiscinfo class="version">4.1.27</refmiscinfo> 25325</refmeta> 25326<refnamediv> 25327 <refname>pci_store_saved_state</refname> 25328 <refpurpose> 25329 Allocate and return an opaque struct containing the device saved state. 25330 </refpurpose> 25331</refnamediv> 25332<refsynopsisdiv> 25333 <title>Synopsis</title> 25334 <funcsynopsis><funcprototype> 25335 <funcdef>struct pci_saved_state * <function>pci_store_saved_state </function></funcdef> 25336 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25337 </funcprototype></funcsynopsis> 25338</refsynopsisdiv> 25339<refsect1> 25340 <title>Arguments</title> 25341 <variablelist> 25342 <varlistentry> 25343 <term><parameter>dev</parameter></term> 25344 <listitem> 25345 <para> 25346 PCI device that we're dealing with 25347 </para> 25348 </listitem> 25349 </varlistentry> 25350 </variablelist> 25351</refsect1> 25352<refsect1> 25353<title>Description</title> 25354<para> 25355 Return NULL if no state or error. 25356</para> 25357</refsect1> 25358</refentry> 25359 25360<refentry id="API-pci-load-saved-state"> 25361<refentryinfo> 25362 <title>LINUX</title> 25363 <productname>Kernel Hackers Manual</productname> 25364 <date>July 2017</date> 25365</refentryinfo> 25366<refmeta> 25367 <refentrytitle><phrase>pci_load_saved_state</phrase></refentrytitle> 25368 <manvolnum>9</manvolnum> 25369 <refmiscinfo class="version">4.1.27</refmiscinfo> 25370</refmeta> 25371<refnamediv> 25372 <refname>pci_load_saved_state</refname> 25373 <refpurpose> 25374 Reload the provided save state into struct pci_dev. 25375 </refpurpose> 25376</refnamediv> 25377<refsynopsisdiv> 25378 <title>Synopsis</title> 25379 <funcsynopsis><funcprototype> 25380 <funcdef>int <function>pci_load_saved_state </function></funcdef> 25381 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25382 <paramdef>struct pci_saved_state * <parameter>state</parameter></paramdef> 25383 </funcprototype></funcsynopsis> 25384</refsynopsisdiv> 25385<refsect1> 25386 <title>Arguments</title> 25387 <variablelist> 25388 <varlistentry> 25389 <term><parameter>dev</parameter></term> 25390 <listitem> 25391 <para> 25392 PCI device that we're dealing with 25393 </para> 25394 </listitem> 25395 </varlistentry> 25396 <varlistentry> 25397 <term><parameter>state</parameter></term> 25398 <listitem> 25399 <para> 25400 Saved state returned from <function>pci_store_saved_state</function> 25401 </para> 25402 </listitem> 25403 </varlistentry> 25404 </variablelist> 25405</refsect1> 25406</refentry> 25407 25408<refentry id="API-pci-load-and-free-saved-state"> 25409<refentryinfo> 25410 <title>LINUX</title> 25411 <productname>Kernel Hackers Manual</productname> 25412 <date>July 2017</date> 25413</refentryinfo> 25414<refmeta> 25415 <refentrytitle><phrase>pci_load_and_free_saved_state</phrase></refentrytitle> 25416 <manvolnum>9</manvolnum> 25417 <refmiscinfo class="version">4.1.27</refmiscinfo> 25418</refmeta> 25419<refnamediv> 25420 <refname>pci_load_and_free_saved_state</refname> 25421 <refpurpose> 25422 Reload the save state pointed to by state, and free the memory allocated for it. 25423 </refpurpose> 25424</refnamediv> 25425<refsynopsisdiv> 25426 <title>Synopsis</title> 25427 <funcsynopsis><funcprototype> 25428 <funcdef>int <function>pci_load_and_free_saved_state </function></funcdef> 25429 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25430 <paramdef>struct pci_saved_state ** <parameter>state</parameter></paramdef> 25431 </funcprototype></funcsynopsis> 25432</refsynopsisdiv> 25433<refsect1> 25434 <title>Arguments</title> 25435 <variablelist> 25436 <varlistentry> 25437 <term><parameter>dev</parameter></term> 25438 <listitem> 25439 <para> 25440 PCI device that we're dealing with 25441 </para> 25442 </listitem> 25443 </varlistentry> 25444 <varlistentry> 25445 <term><parameter>state</parameter></term> 25446 <listitem> 25447 <para> 25448 Pointer to saved state returned from <function>pci_store_saved_state</function> 25449 </para> 25450 </listitem> 25451 </varlistentry> 25452 </variablelist> 25453</refsect1> 25454</refentry> 25455 25456<refentry id="API-pci-reenable-device"> 25457<refentryinfo> 25458 <title>LINUX</title> 25459 <productname>Kernel Hackers Manual</productname> 25460 <date>July 2017</date> 25461</refentryinfo> 25462<refmeta> 25463 <refentrytitle><phrase>pci_reenable_device</phrase></refentrytitle> 25464 <manvolnum>9</manvolnum> 25465 <refmiscinfo class="version">4.1.27</refmiscinfo> 25466</refmeta> 25467<refnamediv> 25468 <refname>pci_reenable_device</refname> 25469 <refpurpose> 25470 Resume abandoned device 25471 </refpurpose> 25472</refnamediv> 25473<refsynopsisdiv> 25474 <title>Synopsis</title> 25475 <funcsynopsis><funcprototype> 25476 <funcdef>int <function>pci_reenable_device </function></funcdef> 25477 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25478 </funcprototype></funcsynopsis> 25479</refsynopsisdiv> 25480<refsect1> 25481 <title>Arguments</title> 25482 <variablelist> 25483 <varlistentry> 25484 <term><parameter>dev</parameter></term> 25485 <listitem> 25486 <para> 25487 PCI device to be resumed 25488 </para> 25489 </listitem> 25490 </varlistentry> 25491 </variablelist> 25492</refsect1> 25493<refsect1> 25494<title>Description</title> 25495<para> 25496 Note this function is a backend of pci_default_resume and is not supposed 25497 to be called by normal code, write proper resume handler and use it instead. 25498</para> 25499</refsect1> 25500</refentry> 25501 25502<refentry id="API-pci-enable-device-io"> 25503<refentryinfo> 25504 <title>LINUX</title> 25505 <productname>Kernel Hackers Manual</productname> 25506 <date>July 2017</date> 25507</refentryinfo> 25508<refmeta> 25509 <refentrytitle><phrase>pci_enable_device_io</phrase></refentrytitle> 25510 <manvolnum>9</manvolnum> 25511 <refmiscinfo class="version">4.1.27</refmiscinfo> 25512</refmeta> 25513<refnamediv> 25514 <refname>pci_enable_device_io</refname> 25515 <refpurpose> 25516 Initialize a device for use with IO space 25517 </refpurpose> 25518</refnamediv> 25519<refsynopsisdiv> 25520 <title>Synopsis</title> 25521 <funcsynopsis><funcprototype> 25522 <funcdef>int <function>pci_enable_device_io </function></funcdef> 25523 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25524 </funcprototype></funcsynopsis> 25525</refsynopsisdiv> 25526<refsect1> 25527 <title>Arguments</title> 25528 <variablelist> 25529 <varlistentry> 25530 <term><parameter>dev</parameter></term> 25531 <listitem> 25532 <para> 25533 PCI device to be initialized 25534 </para> 25535 </listitem> 25536 </varlistentry> 25537 </variablelist> 25538</refsect1> 25539<refsect1> 25540<title>Description</title> 25541<para> 25542 Initialize device before it's used by a driver. Ask low-level code 25543 to enable I/O resources. Wake up the device if it was suspended. 25544 Beware, this function can fail. 25545</para> 25546</refsect1> 25547</refentry> 25548 25549<refentry id="API-pci-enable-device-mem"> 25550<refentryinfo> 25551 <title>LINUX</title> 25552 <productname>Kernel Hackers Manual</productname> 25553 <date>July 2017</date> 25554</refentryinfo> 25555<refmeta> 25556 <refentrytitle><phrase>pci_enable_device_mem</phrase></refentrytitle> 25557 <manvolnum>9</manvolnum> 25558 <refmiscinfo class="version">4.1.27</refmiscinfo> 25559</refmeta> 25560<refnamediv> 25561 <refname>pci_enable_device_mem</refname> 25562 <refpurpose> 25563 Initialize a device for use with Memory space 25564 </refpurpose> 25565</refnamediv> 25566<refsynopsisdiv> 25567 <title>Synopsis</title> 25568 <funcsynopsis><funcprototype> 25569 <funcdef>int <function>pci_enable_device_mem </function></funcdef> 25570 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25571 </funcprototype></funcsynopsis> 25572</refsynopsisdiv> 25573<refsect1> 25574 <title>Arguments</title> 25575 <variablelist> 25576 <varlistentry> 25577 <term><parameter>dev</parameter></term> 25578 <listitem> 25579 <para> 25580 PCI device to be initialized 25581 </para> 25582 </listitem> 25583 </varlistentry> 25584 </variablelist> 25585</refsect1> 25586<refsect1> 25587<title>Description</title> 25588<para> 25589 Initialize device before it's used by a driver. Ask low-level code 25590 to enable Memory resources. Wake up the device if it was suspended. 25591 Beware, this function can fail. 25592</para> 25593</refsect1> 25594</refentry> 25595 25596<refentry id="API-pci-enable-device"> 25597<refentryinfo> 25598 <title>LINUX</title> 25599 <productname>Kernel Hackers Manual</productname> 25600 <date>July 2017</date> 25601</refentryinfo> 25602<refmeta> 25603 <refentrytitle><phrase>pci_enable_device</phrase></refentrytitle> 25604 <manvolnum>9</manvolnum> 25605 <refmiscinfo class="version">4.1.27</refmiscinfo> 25606</refmeta> 25607<refnamediv> 25608 <refname>pci_enable_device</refname> 25609 <refpurpose> 25610 Initialize device before it's used by a driver. 25611 </refpurpose> 25612</refnamediv> 25613<refsynopsisdiv> 25614 <title>Synopsis</title> 25615 <funcsynopsis><funcprototype> 25616 <funcdef>int <function>pci_enable_device </function></funcdef> 25617 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25618 </funcprototype></funcsynopsis> 25619</refsynopsisdiv> 25620<refsect1> 25621 <title>Arguments</title> 25622 <variablelist> 25623 <varlistentry> 25624 <term><parameter>dev</parameter></term> 25625 <listitem> 25626 <para> 25627 PCI device to be initialized 25628 </para> 25629 </listitem> 25630 </varlistentry> 25631 </variablelist> 25632</refsect1> 25633<refsect1> 25634<title>Description</title> 25635<para> 25636 Initialize device before it's used by a driver. Ask low-level code 25637 to enable I/O and memory. Wake up the device if it was suspended. 25638 Beware, this function can fail. 25639 </para><para> 25640 25641 Note we don't actually enable the device many times if we call 25642 this function repeatedly (we just increment the count). 25643</para> 25644</refsect1> 25645</refentry> 25646 25647<refentry id="API-pcim-enable-device"> 25648<refentryinfo> 25649 <title>LINUX</title> 25650 <productname>Kernel Hackers Manual</productname> 25651 <date>July 2017</date> 25652</refentryinfo> 25653<refmeta> 25654 <refentrytitle><phrase>pcim_enable_device</phrase></refentrytitle> 25655 <manvolnum>9</manvolnum> 25656 <refmiscinfo class="version">4.1.27</refmiscinfo> 25657</refmeta> 25658<refnamediv> 25659 <refname>pcim_enable_device</refname> 25660 <refpurpose> 25661 Managed <function>pci_enable_device</function> 25662 </refpurpose> 25663</refnamediv> 25664<refsynopsisdiv> 25665 <title>Synopsis</title> 25666 <funcsynopsis><funcprototype> 25667 <funcdef>int <function>pcim_enable_device </function></funcdef> 25668 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 25669 </funcprototype></funcsynopsis> 25670</refsynopsisdiv> 25671<refsect1> 25672 <title>Arguments</title> 25673 <variablelist> 25674 <varlistentry> 25675 <term><parameter>pdev</parameter></term> 25676 <listitem> 25677 <para> 25678 PCI device to be initialized 25679 </para> 25680 </listitem> 25681 </varlistentry> 25682 </variablelist> 25683</refsect1> 25684<refsect1> 25685<title>Description</title> 25686<para> 25687 Managed <function>pci_enable_device</function>. 25688</para> 25689</refsect1> 25690</refentry> 25691 25692<refentry id="API-pcim-pin-device"> 25693<refentryinfo> 25694 <title>LINUX</title> 25695 <productname>Kernel Hackers Manual</productname> 25696 <date>July 2017</date> 25697</refentryinfo> 25698<refmeta> 25699 <refentrytitle><phrase>pcim_pin_device</phrase></refentrytitle> 25700 <manvolnum>9</manvolnum> 25701 <refmiscinfo class="version">4.1.27</refmiscinfo> 25702</refmeta> 25703<refnamediv> 25704 <refname>pcim_pin_device</refname> 25705 <refpurpose> 25706 Pin managed PCI device 25707 </refpurpose> 25708</refnamediv> 25709<refsynopsisdiv> 25710 <title>Synopsis</title> 25711 <funcsynopsis><funcprototype> 25712 <funcdef>void <function>pcim_pin_device </function></funcdef> 25713 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 25714 </funcprototype></funcsynopsis> 25715</refsynopsisdiv> 25716<refsect1> 25717 <title>Arguments</title> 25718 <variablelist> 25719 <varlistentry> 25720 <term><parameter>pdev</parameter></term> 25721 <listitem> 25722 <para> 25723 PCI device to pin 25724 </para> 25725 </listitem> 25726 </varlistentry> 25727 </variablelist> 25728</refsect1> 25729<refsect1> 25730<title>Description</title> 25731<para> 25732 Pin managed PCI device <parameter>pdev</parameter>. Pinned device won't be disabled on 25733 driver detach. <parameter>pdev</parameter> must have been enabled with 25734 <function>pcim_enable_device</function>. 25735</para> 25736</refsect1> 25737</refentry> 25738 25739<refentry id="API-pci-disable-device"> 25740<refentryinfo> 25741 <title>LINUX</title> 25742 <productname>Kernel Hackers Manual</productname> 25743 <date>July 2017</date> 25744</refentryinfo> 25745<refmeta> 25746 <refentrytitle><phrase>pci_disable_device</phrase></refentrytitle> 25747 <manvolnum>9</manvolnum> 25748 <refmiscinfo class="version">4.1.27</refmiscinfo> 25749</refmeta> 25750<refnamediv> 25751 <refname>pci_disable_device</refname> 25752 <refpurpose> 25753 Disable PCI device after use 25754 </refpurpose> 25755</refnamediv> 25756<refsynopsisdiv> 25757 <title>Synopsis</title> 25758 <funcsynopsis><funcprototype> 25759 <funcdef>void <function>pci_disable_device </function></funcdef> 25760 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25761 </funcprototype></funcsynopsis> 25762</refsynopsisdiv> 25763<refsect1> 25764 <title>Arguments</title> 25765 <variablelist> 25766 <varlistentry> 25767 <term><parameter>dev</parameter></term> 25768 <listitem> 25769 <para> 25770 PCI device to be disabled 25771 </para> 25772 </listitem> 25773 </varlistentry> 25774 </variablelist> 25775</refsect1> 25776<refsect1> 25777<title>Description</title> 25778<para> 25779 Signal to the system that the PCI device is not in use by the system 25780 anymore. This only involves disabling PCI bus-mastering, if active. 25781 </para><para> 25782 25783 Note we don't actually disable the device until all callers of 25784 <function>pci_enable_device</function> have called <function>pci_disable_device</function>. 25785</para> 25786</refsect1> 25787</refentry> 25788 25789<refentry id="API-pci-set-pcie-reset-state"> 25790<refentryinfo> 25791 <title>LINUX</title> 25792 <productname>Kernel Hackers Manual</productname> 25793 <date>July 2017</date> 25794</refentryinfo> 25795<refmeta> 25796 <refentrytitle><phrase>pci_set_pcie_reset_state</phrase></refentrytitle> 25797 <manvolnum>9</manvolnum> 25798 <refmiscinfo class="version">4.1.27</refmiscinfo> 25799</refmeta> 25800<refnamediv> 25801 <refname>pci_set_pcie_reset_state</refname> 25802 <refpurpose> 25803 set reset state for device dev 25804 </refpurpose> 25805</refnamediv> 25806<refsynopsisdiv> 25807 <title>Synopsis</title> 25808 <funcsynopsis><funcprototype> 25809 <funcdef>int <function>pci_set_pcie_reset_state </function></funcdef> 25810 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25811 <paramdef>enum pcie_reset_state <parameter>state</parameter></paramdef> 25812 </funcprototype></funcsynopsis> 25813</refsynopsisdiv> 25814<refsect1> 25815 <title>Arguments</title> 25816 <variablelist> 25817 <varlistentry> 25818 <term><parameter>dev</parameter></term> 25819 <listitem> 25820 <para> 25821 the PCIe device reset 25822 </para> 25823 </listitem> 25824 </varlistentry> 25825 <varlistentry> 25826 <term><parameter>state</parameter></term> 25827 <listitem> 25828 <para> 25829 Reset state to enter into 25830 </para> 25831 </listitem> 25832 </varlistentry> 25833 </variablelist> 25834</refsect1> 25835<refsect1> 25836<title>Description</title> 25837<para> 25838 </para><para> 25839 25840 Sets the PCI reset state for the device. 25841</para> 25842</refsect1> 25843</refentry> 25844 25845<refentry id="API-pci-pme-capable"> 25846<refentryinfo> 25847 <title>LINUX</title> 25848 <productname>Kernel Hackers Manual</productname> 25849 <date>July 2017</date> 25850</refentryinfo> 25851<refmeta> 25852 <refentrytitle><phrase>pci_pme_capable</phrase></refentrytitle> 25853 <manvolnum>9</manvolnum> 25854 <refmiscinfo class="version">4.1.27</refmiscinfo> 25855</refmeta> 25856<refnamediv> 25857 <refname>pci_pme_capable</refname> 25858 <refpurpose> 25859 check the capability of PCI device to generate PME# 25860 </refpurpose> 25861</refnamediv> 25862<refsynopsisdiv> 25863 <title>Synopsis</title> 25864 <funcsynopsis><funcprototype> 25865 <funcdef>bool <function>pci_pme_capable </function></funcdef> 25866 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25867 <paramdef>pci_power_t <parameter>state</parameter></paramdef> 25868 </funcprototype></funcsynopsis> 25869</refsynopsisdiv> 25870<refsect1> 25871 <title>Arguments</title> 25872 <variablelist> 25873 <varlistentry> 25874 <term><parameter>dev</parameter></term> 25875 <listitem> 25876 <para> 25877 PCI device to handle. 25878 </para> 25879 </listitem> 25880 </varlistentry> 25881 <varlistentry> 25882 <term><parameter>state</parameter></term> 25883 <listitem> 25884 <para> 25885 PCI state from which device will issue PME#. 25886 </para> 25887 </listitem> 25888 </varlistentry> 25889 </variablelist> 25890</refsect1> 25891</refentry> 25892 25893<refentry id="API-pci-pme-active"> 25894<refentryinfo> 25895 <title>LINUX</title> 25896 <productname>Kernel Hackers Manual</productname> 25897 <date>July 2017</date> 25898</refentryinfo> 25899<refmeta> 25900 <refentrytitle><phrase>pci_pme_active</phrase></refentrytitle> 25901 <manvolnum>9</manvolnum> 25902 <refmiscinfo class="version">4.1.27</refmiscinfo> 25903</refmeta> 25904<refnamediv> 25905 <refname>pci_pme_active</refname> 25906 <refpurpose> 25907 enable or disable PCI device's PME# function 25908 </refpurpose> 25909</refnamediv> 25910<refsynopsisdiv> 25911 <title>Synopsis</title> 25912 <funcsynopsis><funcprototype> 25913 <funcdef>void <function>pci_pme_active </function></funcdef> 25914 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25915 <paramdef>bool <parameter>enable</parameter></paramdef> 25916 </funcprototype></funcsynopsis> 25917</refsynopsisdiv> 25918<refsect1> 25919 <title>Arguments</title> 25920 <variablelist> 25921 <varlistentry> 25922 <term><parameter>dev</parameter></term> 25923 <listitem> 25924 <para> 25925 PCI device to handle. 25926 </para> 25927 </listitem> 25928 </varlistentry> 25929 <varlistentry> 25930 <term><parameter>enable</parameter></term> 25931 <listitem> 25932 <para> 25933 'true' to enable PME# generation; 'false' to disable it. 25934 </para> 25935 </listitem> 25936 </varlistentry> 25937 </variablelist> 25938</refsect1> 25939<refsect1> 25940<title>Description</title> 25941<para> 25942 The caller must verify that the device is capable of generating PME# before 25943 calling this function with <parameter>enable</parameter> equal to 'true'. 25944</para> 25945</refsect1> 25946</refentry> 25947 25948<refentry id="API---pci-enable-wake"> 25949<refentryinfo> 25950 <title>LINUX</title> 25951 <productname>Kernel Hackers Manual</productname> 25952 <date>July 2017</date> 25953</refentryinfo> 25954<refmeta> 25955 <refentrytitle><phrase>__pci_enable_wake</phrase></refentrytitle> 25956 <manvolnum>9</manvolnum> 25957 <refmiscinfo class="version">4.1.27</refmiscinfo> 25958</refmeta> 25959<refnamediv> 25960 <refname>__pci_enable_wake</refname> 25961 <refpurpose> 25962 enable PCI device as wakeup event source 25963 </refpurpose> 25964</refnamediv> 25965<refsynopsisdiv> 25966 <title>Synopsis</title> 25967 <funcsynopsis><funcprototype> 25968 <funcdef>int <function>__pci_enable_wake </function></funcdef> 25969 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 25970 <paramdef>pci_power_t <parameter>state</parameter></paramdef> 25971 <paramdef>bool <parameter>runtime</parameter></paramdef> 25972 <paramdef>bool <parameter>enable</parameter></paramdef> 25973 </funcprototype></funcsynopsis> 25974</refsynopsisdiv> 25975<refsect1> 25976 <title>Arguments</title> 25977 <variablelist> 25978 <varlistentry> 25979 <term><parameter>dev</parameter></term> 25980 <listitem> 25981 <para> 25982 PCI device affected 25983 </para> 25984 </listitem> 25985 </varlistentry> 25986 <varlistentry> 25987 <term><parameter>state</parameter></term> 25988 <listitem> 25989 <para> 25990 PCI state from which device will issue wakeup events 25991 </para> 25992 </listitem> 25993 </varlistentry> 25994 <varlistentry> 25995 <term><parameter>runtime</parameter></term> 25996 <listitem> 25997 <para> 25998 True if the events are to be generated at run time 25999 </para> 26000 </listitem> 26001 </varlistentry> 26002 <varlistentry> 26003 <term><parameter>enable</parameter></term> 26004 <listitem> 26005 <para> 26006 True to enable event generation; false to disable 26007 </para> 26008 </listitem> 26009 </varlistentry> 26010 </variablelist> 26011</refsect1> 26012<refsect1> 26013<title>Description</title> 26014<para> 26015 This enables the device as a wakeup event source, or disables it. 26016 When such events involves platform-specific hooks, those hooks are 26017 called automatically by this routine. 26018 </para><para> 26019 26020 Devices with legacy power management (no standard PCI PM capabilities) 26021 always require such platform hooks. 26022</para> 26023</refsect1> 26024<refsect1> 26025<title>RETURN VALUE</title> 26026<para> 26027 0 is returned on success 26028 -EINVAL is returned if device is not supposed to wake up the system 26029 Error code depending on the platform is returned if both the platform and 26030 the native mechanism fail to enable the generation of wake-up events 26031</para> 26032</refsect1> 26033</refentry> 26034 26035<refentry id="API-pci-wake-from-d3"> 26036<refentryinfo> 26037 <title>LINUX</title> 26038 <productname>Kernel Hackers Manual</productname> 26039 <date>July 2017</date> 26040</refentryinfo> 26041<refmeta> 26042 <refentrytitle><phrase>pci_wake_from_d3</phrase></refentrytitle> 26043 <manvolnum>9</manvolnum> 26044 <refmiscinfo class="version">4.1.27</refmiscinfo> 26045</refmeta> 26046<refnamediv> 26047 <refname>pci_wake_from_d3</refname> 26048 <refpurpose> 26049 enable/disable device to wake up from D3_hot or D3_cold 26050 </refpurpose> 26051</refnamediv> 26052<refsynopsisdiv> 26053 <title>Synopsis</title> 26054 <funcsynopsis><funcprototype> 26055 <funcdef>int <function>pci_wake_from_d3 </function></funcdef> 26056 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 26057 <paramdef>bool <parameter>enable</parameter></paramdef> 26058 </funcprototype></funcsynopsis> 26059</refsynopsisdiv> 26060<refsect1> 26061 <title>Arguments</title> 26062 <variablelist> 26063 <varlistentry> 26064 <term><parameter>dev</parameter></term> 26065 <listitem> 26066 <para> 26067 PCI device to prepare 26068 </para> 26069 </listitem> 26070 </varlistentry> 26071 <varlistentry> 26072 <term><parameter>enable</parameter></term> 26073 <listitem> 26074 <para> 26075 True to enable wake-up event generation; false to disable 26076 </para> 26077 </listitem> 26078 </varlistentry> 26079 </variablelist> 26080</refsect1> 26081<refsect1> 26082<title>Description</title> 26083<para> 26084 Many drivers want the device to wake up the system from D3_hot or D3_cold 26085 and this function allows them to set that up cleanly - <function>pci_enable_wake</function> 26086 should not be called twice in a row to enable wake-up due to PCI PM vs ACPI 26087 ordering constraints. 26088 </para><para> 26089 26090 This function only returns error code if the device is not capable of 26091 generating PME# from both D3_hot and D3_cold, and the platform is unable to 26092 enable wake-up power for it. 26093</para> 26094</refsect1> 26095</refentry> 26096 26097<refentry id="API-pci-prepare-to-sleep"> 26098<refentryinfo> 26099 <title>LINUX</title> 26100 <productname>Kernel Hackers Manual</productname> 26101 <date>July 2017</date> 26102</refentryinfo> 26103<refmeta> 26104 <refentrytitle><phrase>pci_prepare_to_sleep</phrase></refentrytitle> 26105 <manvolnum>9</manvolnum> 26106 <refmiscinfo class="version">4.1.27</refmiscinfo> 26107</refmeta> 26108<refnamediv> 26109 <refname>pci_prepare_to_sleep</refname> 26110 <refpurpose> 26111 prepare PCI device for system-wide transition into a sleep state 26112 </refpurpose> 26113</refnamediv> 26114<refsynopsisdiv> 26115 <title>Synopsis</title> 26116 <funcsynopsis><funcprototype> 26117 <funcdef>int <function>pci_prepare_to_sleep </function></funcdef> 26118 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 26119 </funcprototype></funcsynopsis> 26120</refsynopsisdiv> 26121<refsect1> 26122 <title>Arguments</title> 26123 <variablelist> 26124 <varlistentry> 26125 <term><parameter>dev</parameter></term> 26126 <listitem> 26127 <para> 26128 Device to handle. 26129 </para> 26130 </listitem> 26131 </varlistentry> 26132 </variablelist> 26133</refsect1> 26134<refsect1> 26135<title>Description</title> 26136<para> 26137 Choose the power state appropriate for the device depending on whether 26138 it can wake up the system and/or is power manageable by the platform 26139 (PCI_D3hot is the default) and put the device into that state. 26140</para> 26141</refsect1> 26142</refentry> 26143 26144<refentry id="API-pci-back-from-sleep"> 26145<refentryinfo> 26146 <title>LINUX</title> 26147 <productname>Kernel Hackers Manual</productname> 26148 <date>July 2017</date> 26149</refentryinfo> 26150<refmeta> 26151 <refentrytitle><phrase>pci_back_from_sleep</phrase></refentrytitle> 26152 <manvolnum>9</manvolnum> 26153 <refmiscinfo class="version">4.1.27</refmiscinfo> 26154</refmeta> 26155<refnamediv> 26156 <refname>pci_back_from_sleep</refname> 26157 <refpurpose> 26158 turn PCI device on during system-wide transition into working state 26159 </refpurpose> 26160</refnamediv> 26161<refsynopsisdiv> 26162 <title>Synopsis</title> 26163 <funcsynopsis><funcprototype> 26164 <funcdef>int <function>pci_back_from_sleep </function></funcdef> 26165 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 26166 </funcprototype></funcsynopsis> 26167</refsynopsisdiv> 26168<refsect1> 26169 <title>Arguments</title> 26170 <variablelist> 26171 <varlistentry> 26172 <term><parameter>dev</parameter></term> 26173 <listitem> 26174 <para> 26175 Device to handle. 26176 </para> 26177 </listitem> 26178 </varlistentry> 26179 </variablelist> 26180</refsect1> 26181<refsect1> 26182<title>Description</title> 26183<para> 26184 Disable device's system wake-up capability and put it into D0. 26185</para> 26186</refsect1> 26187</refentry> 26188 26189<refentry id="API-pci-dev-run-wake"> 26190<refentryinfo> 26191 <title>LINUX</title> 26192 <productname>Kernel Hackers Manual</productname> 26193 <date>July 2017</date> 26194</refentryinfo> 26195<refmeta> 26196 <refentrytitle><phrase>pci_dev_run_wake</phrase></refentrytitle> 26197 <manvolnum>9</manvolnum> 26198 <refmiscinfo class="version">4.1.27</refmiscinfo> 26199</refmeta> 26200<refnamediv> 26201 <refname>pci_dev_run_wake</refname> 26202 <refpurpose> 26203 Check if device can generate run-time wake-up events. 26204 </refpurpose> 26205</refnamediv> 26206<refsynopsisdiv> 26207 <title>Synopsis</title> 26208 <funcsynopsis><funcprototype> 26209 <funcdef>bool <function>pci_dev_run_wake </function></funcdef> 26210 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 26211 </funcprototype></funcsynopsis> 26212</refsynopsisdiv> 26213<refsect1> 26214 <title>Arguments</title> 26215 <variablelist> 26216 <varlistentry> 26217 <term><parameter>dev</parameter></term> 26218 <listitem> 26219 <para> 26220 Device to check. 26221 </para> 26222 </listitem> 26223 </varlistentry> 26224 </variablelist> 26225</refsect1> 26226<refsect1> 26227<title>Description</title> 26228<para> 26229 Return true if the device itself is capable of generating wake-up events 26230 (through the platform or using the native PCIe PME) or if the device supports 26231 PME and one of its upstream bridges can generate wake-up events. 26232</para> 26233</refsect1> 26234</refentry> 26235 26236<refentry id="API-pci-common-swizzle"> 26237<refentryinfo> 26238 <title>LINUX</title> 26239 <productname>Kernel Hackers Manual</productname> 26240 <date>July 2017</date> 26241</refentryinfo> 26242<refmeta> 26243 <refentrytitle><phrase>pci_common_swizzle</phrase></refentrytitle> 26244 <manvolnum>9</manvolnum> 26245 <refmiscinfo class="version">4.1.27</refmiscinfo> 26246</refmeta> 26247<refnamediv> 26248 <refname>pci_common_swizzle</refname> 26249 <refpurpose> 26250 swizzle INTx all the way to root bridge 26251 </refpurpose> 26252</refnamediv> 26253<refsynopsisdiv> 26254 <title>Synopsis</title> 26255 <funcsynopsis><funcprototype> 26256 <funcdef>u8 <function>pci_common_swizzle </function></funcdef> 26257 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 26258 <paramdef>u8 * <parameter>pinp</parameter></paramdef> 26259 </funcprototype></funcsynopsis> 26260</refsynopsisdiv> 26261<refsect1> 26262 <title>Arguments</title> 26263 <variablelist> 26264 <varlistentry> 26265 <term><parameter>dev</parameter></term> 26266 <listitem> 26267 <para> 26268 the PCI device 26269 </para> 26270 </listitem> 26271 </varlistentry> 26272 <varlistentry> 26273 <term><parameter>pinp</parameter></term> 26274 <listitem> 26275 <para> 26276 pointer to the INTx pin value (1=INTA, 2=INTB, 3=INTD, 4=INTD) 26277 </para> 26278 </listitem> 26279 </varlistentry> 26280 </variablelist> 26281</refsect1> 26282<refsect1> 26283<title>Description</title> 26284<para> 26285 Perform INTx swizzling for a device. This traverses through all PCI-to-PCI 26286 bridges all the way up to a PCI root bus. 26287</para> 26288</refsect1> 26289</refentry> 26290 26291<refentry id="API-pci-release-region"> 26292<refentryinfo> 26293 <title>LINUX</title> 26294 <productname>Kernel Hackers Manual</productname> 26295 <date>July 2017</date> 26296</refentryinfo> 26297<refmeta> 26298 <refentrytitle><phrase>pci_release_region</phrase></refentrytitle> 26299 <manvolnum>9</manvolnum> 26300 <refmiscinfo class="version">4.1.27</refmiscinfo> 26301</refmeta> 26302<refnamediv> 26303 <refname>pci_release_region</refname> 26304 <refpurpose> 26305 Release a PCI bar 26306 </refpurpose> 26307</refnamediv> 26308<refsynopsisdiv> 26309 <title>Synopsis</title> 26310 <funcsynopsis><funcprototype> 26311 <funcdef>void <function>pci_release_region </function></funcdef> 26312 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 26313 <paramdef>int <parameter>bar</parameter></paramdef> 26314 </funcprototype></funcsynopsis> 26315</refsynopsisdiv> 26316<refsect1> 26317 <title>Arguments</title> 26318 <variablelist> 26319 <varlistentry> 26320 <term><parameter>pdev</parameter></term> 26321 <listitem> 26322 <para> 26323 PCI device whose resources were previously reserved by pci_request_region 26324 </para> 26325 </listitem> 26326 </varlistentry> 26327 <varlistentry> 26328 <term><parameter>bar</parameter></term> 26329 <listitem> 26330 <para> 26331 BAR to release 26332 </para> 26333 </listitem> 26334 </varlistentry> 26335 </variablelist> 26336</refsect1> 26337<refsect1> 26338<title>Description</title> 26339<para> 26340 Releases the PCI I/O and memory resources previously reserved by a 26341 successful call to pci_request_region. Call this function only 26342 after all use of the PCI regions has ceased. 26343</para> 26344</refsect1> 26345</refentry> 26346 26347<refentry id="API-pci-request-region"> 26348<refentryinfo> 26349 <title>LINUX</title> 26350 <productname>Kernel Hackers Manual</productname> 26351 <date>July 2017</date> 26352</refentryinfo> 26353<refmeta> 26354 <refentrytitle><phrase>pci_request_region</phrase></refentrytitle> 26355 <manvolnum>9</manvolnum> 26356 <refmiscinfo class="version">4.1.27</refmiscinfo> 26357</refmeta> 26358<refnamediv> 26359 <refname>pci_request_region</refname> 26360 <refpurpose> 26361 Reserve PCI I/O and memory resource 26362 </refpurpose> 26363</refnamediv> 26364<refsynopsisdiv> 26365 <title>Synopsis</title> 26366 <funcsynopsis><funcprototype> 26367 <funcdef>int <function>pci_request_region </function></funcdef> 26368 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 26369 <paramdef>int <parameter>bar</parameter></paramdef> 26370 <paramdef>const char * <parameter>res_name</parameter></paramdef> 26371 </funcprototype></funcsynopsis> 26372</refsynopsisdiv> 26373<refsect1> 26374 <title>Arguments</title> 26375 <variablelist> 26376 <varlistentry> 26377 <term><parameter>pdev</parameter></term> 26378 <listitem> 26379 <para> 26380 PCI device whose resources are to be reserved 26381 </para> 26382 </listitem> 26383 </varlistentry> 26384 <varlistentry> 26385 <term><parameter>bar</parameter></term> 26386 <listitem> 26387 <para> 26388 BAR to be reserved 26389 </para> 26390 </listitem> 26391 </varlistentry> 26392 <varlistentry> 26393 <term><parameter>res_name</parameter></term> 26394 <listitem> 26395 <para> 26396 Name to be associated with resource 26397 </para> 26398 </listitem> 26399 </varlistentry> 26400 </variablelist> 26401</refsect1> 26402<refsect1> 26403<title>Description</title> 26404<para> 26405 Mark the PCI region associated with PCI device <parameter>pdev</parameter> BAR <parameter>bar</parameter> as 26406 being reserved by owner <parameter>res_name</parameter>. Do not access any 26407 address inside the PCI regions unless this call returns 26408 successfully. 26409 </para><para> 26410 26411 Returns 0 on success, or <constant>EBUSY</constant> on error. A warning 26412 message is also printed on failure. 26413</para> 26414</refsect1> 26415</refentry> 26416 26417<refentry id="API-pci-request-region-exclusive"> 26418<refentryinfo> 26419 <title>LINUX</title> 26420 <productname>Kernel Hackers Manual</productname> 26421 <date>July 2017</date> 26422</refentryinfo> 26423<refmeta> 26424 <refentrytitle><phrase>pci_request_region_exclusive</phrase></refentrytitle> 26425 <manvolnum>9</manvolnum> 26426 <refmiscinfo class="version">4.1.27</refmiscinfo> 26427</refmeta> 26428<refnamediv> 26429 <refname>pci_request_region_exclusive</refname> 26430 <refpurpose> 26431 Reserved PCI I/O and memory resource 26432 </refpurpose> 26433</refnamediv> 26434<refsynopsisdiv> 26435 <title>Synopsis</title> 26436 <funcsynopsis><funcprototype> 26437 <funcdef>int <function>pci_request_region_exclusive </function></funcdef> 26438 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 26439 <paramdef>int <parameter>bar</parameter></paramdef> 26440 <paramdef>const char * <parameter>res_name</parameter></paramdef> 26441 </funcprototype></funcsynopsis> 26442</refsynopsisdiv> 26443<refsect1> 26444 <title>Arguments</title> 26445 <variablelist> 26446 <varlistentry> 26447 <term><parameter>pdev</parameter></term> 26448 <listitem> 26449 <para> 26450 PCI device whose resources are to be reserved 26451 </para> 26452 </listitem> 26453 </varlistentry> 26454 <varlistentry> 26455 <term><parameter>bar</parameter></term> 26456 <listitem> 26457 <para> 26458 BAR to be reserved 26459 </para> 26460 </listitem> 26461 </varlistentry> 26462 <varlistentry> 26463 <term><parameter>res_name</parameter></term> 26464 <listitem> 26465 <para> 26466 Name to be associated with resource. 26467 </para> 26468 </listitem> 26469 </varlistentry> 26470 </variablelist> 26471</refsect1> 26472<refsect1> 26473<title>Description</title> 26474<para> 26475 Mark the PCI region associated with PCI device <parameter>pdev</parameter> BR <parameter>bar</parameter> as 26476 being reserved by owner <parameter>res_name</parameter>. Do not access any 26477 address inside the PCI regions unless this call returns 26478 successfully. 26479 </para><para> 26480 26481 Returns 0 on success, or <constant>EBUSY</constant> on error. A warning 26482 message is also printed on failure. 26483 </para><para> 26484 26485 The key difference that _exclusive makes it that userspace is 26486 explicitly not allowed to map the resource via /dev/mem or 26487 sysfs. 26488</para> 26489</refsect1> 26490</refentry> 26491 26492<refentry id="API-pci-release-selected-regions"> 26493<refentryinfo> 26494 <title>LINUX</title> 26495 <productname>Kernel Hackers Manual</productname> 26496 <date>July 2017</date> 26497</refentryinfo> 26498<refmeta> 26499 <refentrytitle><phrase>pci_release_selected_regions</phrase></refentrytitle> 26500 <manvolnum>9</manvolnum> 26501 <refmiscinfo class="version">4.1.27</refmiscinfo> 26502</refmeta> 26503<refnamediv> 26504 <refname>pci_release_selected_regions</refname> 26505 <refpurpose> 26506 Release selected PCI I/O and memory resources 26507 </refpurpose> 26508</refnamediv> 26509<refsynopsisdiv> 26510 <title>Synopsis</title> 26511 <funcsynopsis><funcprototype> 26512 <funcdef>void <function>pci_release_selected_regions </function></funcdef> 26513 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 26514 <paramdef>int <parameter>bars</parameter></paramdef> 26515 </funcprototype></funcsynopsis> 26516</refsynopsisdiv> 26517<refsect1> 26518 <title>Arguments</title> 26519 <variablelist> 26520 <varlistentry> 26521 <term><parameter>pdev</parameter></term> 26522 <listitem> 26523 <para> 26524 PCI device whose resources were previously reserved 26525 </para> 26526 </listitem> 26527 </varlistentry> 26528 <varlistentry> 26529 <term><parameter>bars</parameter></term> 26530 <listitem> 26531 <para> 26532 Bitmask of BARs to be released 26533 </para> 26534 </listitem> 26535 </varlistentry> 26536 </variablelist> 26537</refsect1> 26538<refsect1> 26539<title>Description</title> 26540<para> 26541 Release selected PCI I/O and memory resources previously reserved. 26542 Call this function only after all use of the PCI regions has ceased. 26543</para> 26544</refsect1> 26545</refentry> 26546 26547<refentry id="API-pci-request-selected-regions"> 26548<refentryinfo> 26549 <title>LINUX</title> 26550 <productname>Kernel Hackers Manual</productname> 26551 <date>July 2017</date> 26552</refentryinfo> 26553<refmeta> 26554 <refentrytitle><phrase>pci_request_selected_regions</phrase></refentrytitle> 26555 <manvolnum>9</manvolnum> 26556 <refmiscinfo class="version">4.1.27</refmiscinfo> 26557</refmeta> 26558<refnamediv> 26559 <refname>pci_request_selected_regions</refname> 26560 <refpurpose> 26561 Reserve selected PCI I/O and memory resources 26562 </refpurpose> 26563</refnamediv> 26564<refsynopsisdiv> 26565 <title>Synopsis</title> 26566 <funcsynopsis><funcprototype> 26567 <funcdef>int <function>pci_request_selected_regions </function></funcdef> 26568 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 26569 <paramdef>int <parameter>bars</parameter></paramdef> 26570 <paramdef>const char * <parameter>res_name</parameter></paramdef> 26571 </funcprototype></funcsynopsis> 26572</refsynopsisdiv> 26573<refsect1> 26574 <title>Arguments</title> 26575 <variablelist> 26576 <varlistentry> 26577 <term><parameter>pdev</parameter></term> 26578 <listitem> 26579 <para> 26580 PCI device whose resources are to be reserved 26581 </para> 26582 </listitem> 26583 </varlistentry> 26584 <varlistentry> 26585 <term><parameter>bars</parameter></term> 26586 <listitem> 26587 <para> 26588 Bitmask of BARs to be requested 26589 </para> 26590 </listitem> 26591 </varlistentry> 26592 <varlistentry> 26593 <term><parameter>res_name</parameter></term> 26594 <listitem> 26595 <para> 26596 Name to be associated with resource 26597 </para> 26598 </listitem> 26599 </varlistentry> 26600 </variablelist> 26601</refsect1> 26602</refentry> 26603 26604<refentry id="API-pci-release-regions"> 26605<refentryinfo> 26606 <title>LINUX</title> 26607 <productname>Kernel Hackers Manual</productname> 26608 <date>July 2017</date> 26609</refentryinfo> 26610<refmeta> 26611 <refentrytitle><phrase>pci_release_regions</phrase></refentrytitle> 26612 <manvolnum>9</manvolnum> 26613 <refmiscinfo class="version">4.1.27</refmiscinfo> 26614</refmeta> 26615<refnamediv> 26616 <refname>pci_release_regions</refname> 26617 <refpurpose> 26618 Release reserved PCI I/O and memory resources 26619 </refpurpose> 26620</refnamediv> 26621<refsynopsisdiv> 26622 <title>Synopsis</title> 26623 <funcsynopsis><funcprototype> 26624 <funcdef>void <function>pci_release_regions </function></funcdef> 26625 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 26626 </funcprototype></funcsynopsis> 26627</refsynopsisdiv> 26628<refsect1> 26629 <title>Arguments</title> 26630 <variablelist> 26631 <varlistentry> 26632 <term><parameter>pdev</parameter></term> 26633 <listitem> 26634 <para> 26635 PCI device whose resources were previously reserved by pci_request_regions 26636 </para> 26637 </listitem> 26638 </varlistentry> 26639 </variablelist> 26640</refsect1> 26641<refsect1> 26642<title>Description</title> 26643<para> 26644 Releases all PCI I/O and memory resources previously reserved by a 26645 successful call to pci_request_regions. Call this function only 26646 after all use of the PCI regions has ceased. 26647</para> 26648</refsect1> 26649</refentry> 26650 26651<refentry id="API-pci-request-regions"> 26652<refentryinfo> 26653 <title>LINUX</title> 26654 <productname>Kernel Hackers Manual</productname> 26655 <date>July 2017</date> 26656</refentryinfo> 26657<refmeta> 26658 <refentrytitle><phrase>pci_request_regions</phrase></refentrytitle> 26659 <manvolnum>9</manvolnum> 26660 <refmiscinfo class="version">4.1.27</refmiscinfo> 26661</refmeta> 26662<refnamediv> 26663 <refname>pci_request_regions</refname> 26664 <refpurpose> 26665 Reserved PCI I/O and memory resources 26666 </refpurpose> 26667</refnamediv> 26668<refsynopsisdiv> 26669 <title>Synopsis</title> 26670 <funcsynopsis><funcprototype> 26671 <funcdef>int <function>pci_request_regions </function></funcdef> 26672 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 26673 <paramdef>const char * <parameter>res_name</parameter></paramdef> 26674 </funcprototype></funcsynopsis> 26675</refsynopsisdiv> 26676<refsect1> 26677 <title>Arguments</title> 26678 <variablelist> 26679 <varlistentry> 26680 <term><parameter>pdev</parameter></term> 26681 <listitem> 26682 <para> 26683 PCI device whose resources are to be reserved 26684 </para> 26685 </listitem> 26686 </varlistentry> 26687 <varlistentry> 26688 <term><parameter>res_name</parameter></term> 26689 <listitem> 26690 <para> 26691 Name to be associated with resource. 26692 </para> 26693 </listitem> 26694 </varlistentry> 26695 </variablelist> 26696</refsect1> 26697<refsect1> 26698<title>Description</title> 26699<para> 26700 Mark all PCI regions associated with PCI device <parameter>pdev</parameter> as 26701 being reserved by owner <parameter>res_name</parameter>. Do not access any 26702 address inside the PCI regions unless this call returns 26703 successfully. 26704 </para><para> 26705 26706 Returns 0 on success, or <constant>EBUSY</constant> on error. A warning 26707 message is also printed on failure. 26708</para> 26709</refsect1> 26710</refentry> 26711 26712<refentry id="API-pci-request-regions-exclusive"> 26713<refentryinfo> 26714 <title>LINUX</title> 26715 <productname>Kernel Hackers Manual</productname> 26716 <date>July 2017</date> 26717</refentryinfo> 26718<refmeta> 26719 <refentrytitle><phrase>pci_request_regions_exclusive</phrase></refentrytitle> 26720 <manvolnum>9</manvolnum> 26721 <refmiscinfo class="version">4.1.27</refmiscinfo> 26722</refmeta> 26723<refnamediv> 26724 <refname>pci_request_regions_exclusive</refname> 26725 <refpurpose> 26726 Reserved PCI I/O and memory resources 26727 </refpurpose> 26728</refnamediv> 26729<refsynopsisdiv> 26730 <title>Synopsis</title> 26731 <funcsynopsis><funcprototype> 26732 <funcdef>int <function>pci_request_regions_exclusive </function></funcdef> 26733 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 26734 <paramdef>const char * <parameter>res_name</parameter></paramdef> 26735 </funcprototype></funcsynopsis> 26736</refsynopsisdiv> 26737<refsect1> 26738 <title>Arguments</title> 26739 <variablelist> 26740 <varlistentry> 26741 <term><parameter>pdev</parameter></term> 26742 <listitem> 26743 <para> 26744 PCI device whose resources are to be reserved 26745 </para> 26746 </listitem> 26747 </varlistentry> 26748 <varlistentry> 26749 <term><parameter>res_name</parameter></term> 26750 <listitem> 26751 <para> 26752 Name to be associated with resource. 26753 </para> 26754 </listitem> 26755 </varlistentry> 26756 </variablelist> 26757</refsect1> 26758<refsect1> 26759<title>Description</title> 26760<para> 26761 Mark all PCI regions associated with PCI device <parameter>pdev</parameter> as 26762 being reserved by owner <parameter>res_name</parameter>. Do not access any 26763 address inside the PCI regions unless this call returns 26764 successfully. 26765 </para><para> 26766 26767 <function>pci_request_regions_exclusive</function> will mark the region so that 26768 /dev/mem and the sysfs MMIO access will not be allowed. 26769 </para><para> 26770 26771 Returns 0 on success, or <constant>EBUSY</constant> on error. A warning 26772 message is also printed on failure. 26773</para> 26774</refsect1> 26775</refentry> 26776 26777<refentry id="API-pci-set-master"> 26778<refentryinfo> 26779 <title>LINUX</title> 26780 <productname>Kernel Hackers Manual</productname> 26781 <date>July 2017</date> 26782</refentryinfo> 26783<refmeta> 26784 <refentrytitle><phrase>pci_set_master</phrase></refentrytitle> 26785 <manvolnum>9</manvolnum> 26786 <refmiscinfo class="version">4.1.27</refmiscinfo> 26787</refmeta> 26788<refnamediv> 26789 <refname>pci_set_master</refname> 26790 <refpurpose> 26791 enables bus-mastering for device dev 26792 </refpurpose> 26793</refnamediv> 26794<refsynopsisdiv> 26795 <title>Synopsis</title> 26796 <funcsynopsis><funcprototype> 26797 <funcdef>void <function>pci_set_master </function></funcdef> 26798 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 26799 </funcprototype></funcsynopsis> 26800</refsynopsisdiv> 26801<refsect1> 26802 <title>Arguments</title> 26803 <variablelist> 26804 <varlistentry> 26805 <term><parameter>dev</parameter></term> 26806 <listitem> 26807 <para> 26808 the PCI device to enable 26809 </para> 26810 </listitem> 26811 </varlistentry> 26812 </variablelist> 26813</refsect1> 26814<refsect1> 26815<title>Description</title> 26816<para> 26817 Enables bus-mastering on the device and calls <function>pcibios_set_master</function> 26818 to do the needed arch specific settings. 26819</para> 26820</refsect1> 26821</refentry> 26822 26823<refentry id="API-pci-clear-master"> 26824<refentryinfo> 26825 <title>LINUX</title> 26826 <productname>Kernel Hackers Manual</productname> 26827 <date>July 2017</date> 26828</refentryinfo> 26829<refmeta> 26830 <refentrytitle><phrase>pci_clear_master</phrase></refentrytitle> 26831 <manvolnum>9</manvolnum> 26832 <refmiscinfo class="version">4.1.27</refmiscinfo> 26833</refmeta> 26834<refnamediv> 26835 <refname>pci_clear_master</refname> 26836 <refpurpose> 26837 disables bus-mastering for device dev 26838 </refpurpose> 26839</refnamediv> 26840<refsynopsisdiv> 26841 <title>Synopsis</title> 26842 <funcsynopsis><funcprototype> 26843 <funcdef>void <function>pci_clear_master </function></funcdef> 26844 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 26845 </funcprototype></funcsynopsis> 26846</refsynopsisdiv> 26847<refsect1> 26848 <title>Arguments</title> 26849 <variablelist> 26850 <varlistentry> 26851 <term><parameter>dev</parameter></term> 26852 <listitem> 26853 <para> 26854 the PCI device to disable 26855 </para> 26856 </listitem> 26857 </varlistentry> 26858 </variablelist> 26859</refsect1> 26860</refentry> 26861 26862<refentry id="API-pci-set-cacheline-size"> 26863<refentryinfo> 26864 <title>LINUX</title> 26865 <productname>Kernel Hackers Manual</productname> 26866 <date>July 2017</date> 26867</refentryinfo> 26868<refmeta> 26869 <refentrytitle><phrase>pci_set_cacheline_size</phrase></refentrytitle> 26870 <manvolnum>9</manvolnum> 26871 <refmiscinfo class="version">4.1.27</refmiscinfo> 26872</refmeta> 26873<refnamediv> 26874 <refname>pci_set_cacheline_size</refname> 26875 <refpurpose> 26876 ensure the CACHE_LINE_SIZE register is programmed 26877 </refpurpose> 26878</refnamediv> 26879<refsynopsisdiv> 26880 <title>Synopsis</title> 26881 <funcsynopsis><funcprototype> 26882 <funcdef>int <function>pci_set_cacheline_size </function></funcdef> 26883 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 26884 </funcprototype></funcsynopsis> 26885</refsynopsisdiv> 26886<refsect1> 26887 <title>Arguments</title> 26888 <variablelist> 26889 <varlistentry> 26890 <term><parameter>dev</parameter></term> 26891 <listitem> 26892 <para> 26893 the PCI device for which MWI is to be enabled 26894 </para> 26895 </listitem> 26896 </varlistentry> 26897 </variablelist> 26898</refsect1> 26899<refsect1> 26900<title>Description</title> 26901<para> 26902 Helper function for pci_set_mwi. 26903 Originally copied from drivers/net/acenic.c. 26904 Copyright 1998-2001 by Jes Sorensen, <jes<parameter>trained</parameter>-monkey.org>. 26905</para> 26906</refsect1> 26907<refsect1> 26908<title>RETURNS</title> 26909<para> 26910 An appropriate -ERRNO error value on error, or zero for success. 26911</para> 26912</refsect1> 26913</refentry> 26914 26915<refentry id="API-pci-set-mwi"> 26916<refentryinfo> 26917 <title>LINUX</title> 26918 <productname>Kernel Hackers Manual</productname> 26919 <date>July 2017</date> 26920</refentryinfo> 26921<refmeta> 26922 <refentrytitle><phrase>pci_set_mwi</phrase></refentrytitle> 26923 <manvolnum>9</manvolnum> 26924 <refmiscinfo class="version">4.1.27</refmiscinfo> 26925</refmeta> 26926<refnamediv> 26927 <refname>pci_set_mwi</refname> 26928 <refpurpose> 26929 enables memory-write-invalidate PCI transaction 26930 </refpurpose> 26931</refnamediv> 26932<refsynopsisdiv> 26933 <title>Synopsis</title> 26934 <funcsynopsis><funcprototype> 26935 <funcdef>int <function>pci_set_mwi </function></funcdef> 26936 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 26937 </funcprototype></funcsynopsis> 26938</refsynopsisdiv> 26939<refsect1> 26940 <title>Arguments</title> 26941 <variablelist> 26942 <varlistentry> 26943 <term><parameter>dev</parameter></term> 26944 <listitem> 26945 <para> 26946 the PCI device for which MWI is enabled 26947 </para> 26948 </listitem> 26949 </varlistentry> 26950 </variablelist> 26951</refsect1> 26952<refsect1> 26953<title>Description</title> 26954<para> 26955 Enables the Memory-Write-Invalidate transaction in <constant>PCI_COMMAND</constant>. 26956</para> 26957</refsect1> 26958<refsect1> 26959<title>RETURNS</title> 26960<para> 26961 An appropriate -ERRNO error value on error, or zero for success. 26962</para> 26963</refsect1> 26964</refentry> 26965 26966<refentry id="API-pci-try-set-mwi"> 26967<refentryinfo> 26968 <title>LINUX</title> 26969 <productname>Kernel Hackers Manual</productname> 26970 <date>July 2017</date> 26971</refentryinfo> 26972<refmeta> 26973 <refentrytitle><phrase>pci_try_set_mwi</phrase></refentrytitle> 26974 <manvolnum>9</manvolnum> 26975 <refmiscinfo class="version">4.1.27</refmiscinfo> 26976</refmeta> 26977<refnamediv> 26978 <refname>pci_try_set_mwi</refname> 26979 <refpurpose> 26980 enables memory-write-invalidate PCI transaction 26981 </refpurpose> 26982</refnamediv> 26983<refsynopsisdiv> 26984 <title>Synopsis</title> 26985 <funcsynopsis><funcprototype> 26986 <funcdef>int <function>pci_try_set_mwi </function></funcdef> 26987 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 26988 </funcprototype></funcsynopsis> 26989</refsynopsisdiv> 26990<refsect1> 26991 <title>Arguments</title> 26992 <variablelist> 26993 <varlistentry> 26994 <term><parameter>dev</parameter></term> 26995 <listitem> 26996 <para> 26997 the PCI device for which MWI is enabled 26998 </para> 26999 </listitem> 27000 </varlistentry> 27001 </variablelist> 27002</refsect1> 27003<refsect1> 27004<title>Description</title> 27005<para> 27006 Enables the Memory-Write-Invalidate transaction in <constant>PCI_COMMAND</constant>. 27007 Callers are not required to check the return value. 27008</para> 27009</refsect1> 27010<refsect1> 27011<title>RETURNS</title> 27012<para> 27013 An appropriate -ERRNO error value on error, or zero for success. 27014</para> 27015</refsect1> 27016</refentry> 27017 27018<refentry id="API-pci-clear-mwi"> 27019<refentryinfo> 27020 <title>LINUX</title> 27021 <productname>Kernel Hackers Manual</productname> 27022 <date>July 2017</date> 27023</refentryinfo> 27024<refmeta> 27025 <refentrytitle><phrase>pci_clear_mwi</phrase></refentrytitle> 27026 <manvolnum>9</manvolnum> 27027 <refmiscinfo class="version">4.1.27</refmiscinfo> 27028</refmeta> 27029<refnamediv> 27030 <refname>pci_clear_mwi</refname> 27031 <refpurpose> 27032 disables Memory-Write-Invalidate for device dev 27033 </refpurpose> 27034</refnamediv> 27035<refsynopsisdiv> 27036 <title>Synopsis</title> 27037 <funcsynopsis><funcprototype> 27038 <funcdef>void <function>pci_clear_mwi </function></funcdef> 27039 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 27040 </funcprototype></funcsynopsis> 27041</refsynopsisdiv> 27042<refsect1> 27043 <title>Arguments</title> 27044 <variablelist> 27045 <varlistentry> 27046 <term><parameter>dev</parameter></term> 27047 <listitem> 27048 <para> 27049 the PCI device to disable 27050 </para> 27051 </listitem> 27052 </varlistentry> 27053 </variablelist> 27054</refsect1> 27055<refsect1> 27056<title>Description</title> 27057<para> 27058 Disables PCI Memory-Write-Invalidate transaction on the device 27059</para> 27060</refsect1> 27061</refentry> 27062 27063<refentry id="API-pci-intx"> 27064<refentryinfo> 27065 <title>LINUX</title> 27066 <productname>Kernel Hackers Manual</productname> 27067 <date>July 2017</date> 27068</refentryinfo> 27069<refmeta> 27070 <refentrytitle><phrase>pci_intx</phrase></refentrytitle> 27071 <manvolnum>9</manvolnum> 27072 <refmiscinfo class="version">4.1.27</refmiscinfo> 27073</refmeta> 27074<refnamediv> 27075 <refname>pci_intx</refname> 27076 <refpurpose> 27077 enables/disables PCI INTx for device dev 27078 </refpurpose> 27079</refnamediv> 27080<refsynopsisdiv> 27081 <title>Synopsis</title> 27082 <funcsynopsis><funcprototype> 27083 <funcdef>void <function>pci_intx </function></funcdef> 27084 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 27085 <paramdef>int <parameter>enable</parameter></paramdef> 27086 </funcprototype></funcsynopsis> 27087</refsynopsisdiv> 27088<refsect1> 27089 <title>Arguments</title> 27090 <variablelist> 27091 <varlistentry> 27092 <term><parameter>pdev</parameter></term> 27093 <listitem> 27094 <para> 27095 the PCI device to operate on 27096 </para> 27097 </listitem> 27098 </varlistentry> 27099 <varlistentry> 27100 <term><parameter>enable</parameter></term> 27101 <listitem> 27102 <para> 27103 boolean: whether to enable or disable PCI INTx 27104 </para> 27105 </listitem> 27106 </varlistentry> 27107 </variablelist> 27108</refsect1> 27109<refsect1> 27110<title>Description</title> 27111<para> 27112 Enables/disables PCI INTx for device dev 27113</para> 27114</refsect1> 27115</refentry> 27116 27117<refentry id="API-pci-intx-mask-supported"> 27118<refentryinfo> 27119 <title>LINUX</title> 27120 <productname>Kernel Hackers Manual</productname> 27121 <date>July 2017</date> 27122</refentryinfo> 27123<refmeta> 27124 <refentrytitle><phrase>pci_intx_mask_supported</phrase></refentrytitle> 27125 <manvolnum>9</manvolnum> 27126 <refmiscinfo class="version">4.1.27</refmiscinfo> 27127</refmeta> 27128<refnamediv> 27129 <refname>pci_intx_mask_supported</refname> 27130 <refpurpose> 27131 probe for INTx masking support 27132 </refpurpose> 27133</refnamediv> 27134<refsynopsisdiv> 27135 <title>Synopsis</title> 27136 <funcsynopsis><funcprototype> 27137 <funcdef>bool <function>pci_intx_mask_supported </function></funcdef> 27138 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 27139 </funcprototype></funcsynopsis> 27140</refsynopsisdiv> 27141<refsect1> 27142 <title>Arguments</title> 27143 <variablelist> 27144 <varlistentry> 27145 <term><parameter>dev</parameter></term> 27146 <listitem> 27147 <para> 27148 the PCI device to operate on 27149 </para> 27150 </listitem> 27151 </varlistentry> 27152 </variablelist> 27153</refsect1> 27154<refsect1> 27155<title>Description</title> 27156<para> 27157 Check if the device dev support INTx masking via the config space 27158 command word. 27159</para> 27160</refsect1> 27161</refentry> 27162 27163<refentry id="API-pci-check-and-mask-intx"> 27164<refentryinfo> 27165 <title>LINUX</title> 27166 <productname>Kernel Hackers Manual</productname> 27167 <date>July 2017</date> 27168</refentryinfo> 27169<refmeta> 27170 <refentrytitle><phrase>pci_check_and_mask_intx</phrase></refentrytitle> 27171 <manvolnum>9</manvolnum> 27172 <refmiscinfo class="version">4.1.27</refmiscinfo> 27173</refmeta> 27174<refnamediv> 27175 <refname>pci_check_and_mask_intx</refname> 27176 <refpurpose> 27177 mask INTx on pending interrupt 27178 </refpurpose> 27179</refnamediv> 27180<refsynopsisdiv> 27181 <title>Synopsis</title> 27182 <funcsynopsis><funcprototype> 27183 <funcdef>bool <function>pci_check_and_mask_intx </function></funcdef> 27184 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 27185 </funcprototype></funcsynopsis> 27186</refsynopsisdiv> 27187<refsect1> 27188 <title>Arguments</title> 27189 <variablelist> 27190 <varlistentry> 27191 <term><parameter>dev</parameter></term> 27192 <listitem> 27193 <para> 27194 the PCI device to operate on 27195 </para> 27196 </listitem> 27197 </varlistentry> 27198 </variablelist> 27199</refsect1> 27200<refsect1> 27201<title>Description</title> 27202<para> 27203 Check if the device dev has its INTx line asserted, mask it and 27204 return true in that case. False is returned if not interrupt was 27205 pending. 27206</para> 27207</refsect1> 27208</refentry> 27209 27210<refentry id="API-pci-check-and-unmask-intx"> 27211<refentryinfo> 27212 <title>LINUX</title> 27213 <productname>Kernel Hackers Manual</productname> 27214 <date>July 2017</date> 27215</refentryinfo> 27216<refmeta> 27217 <refentrytitle><phrase>pci_check_and_unmask_intx</phrase></refentrytitle> 27218 <manvolnum>9</manvolnum> 27219 <refmiscinfo class="version">4.1.27</refmiscinfo> 27220</refmeta> 27221<refnamediv> 27222 <refname>pci_check_and_unmask_intx</refname> 27223 <refpurpose> 27224 unmask INTx if no interrupt is pending 27225 </refpurpose> 27226</refnamediv> 27227<refsynopsisdiv> 27228 <title>Synopsis</title> 27229 <funcsynopsis><funcprototype> 27230 <funcdef>bool <function>pci_check_and_unmask_intx </function></funcdef> 27231 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 27232 </funcprototype></funcsynopsis> 27233</refsynopsisdiv> 27234<refsect1> 27235 <title>Arguments</title> 27236 <variablelist> 27237 <varlistentry> 27238 <term><parameter>dev</parameter></term> 27239 <listitem> 27240 <para> 27241 the PCI device to operate on 27242 </para> 27243 </listitem> 27244 </varlistentry> 27245 </variablelist> 27246</refsect1> 27247<refsect1> 27248<title>Description</title> 27249<para> 27250 Check if the device dev has its INTx line asserted, unmask it if not 27251 and return true. False is returned and the mask remains active if 27252 there was still an interrupt pending. 27253</para> 27254</refsect1> 27255</refentry> 27256 27257<refentry id="API-pci-msi-off"> 27258<refentryinfo> 27259 <title>LINUX</title> 27260 <productname>Kernel Hackers Manual</productname> 27261 <date>July 2017</date> 27262</refentryinfo> 27263<refmeta> 27264 <refentrytitle><phrase>pci_msi_off</phrase></refentrytitle> 27265 <manvolnum>9</manvolnum> 27266 <refmiscinfo class="version">4.1.27</refmiscinfo> 27267</refmeta> 27268<refnamediv> 27269 <refname>pci_msi_off</refname> 27270 <refpurpose> 27271 disables any MSI or MSI-X capabilities 27272 </refpurpose> 27273</refnamediv> 27274<refsynopsisdiv> 27275 <title>Synopsis</title> 27276 <funcsynopsis><funcprototype> 27277 <funcdef>void <function>pci_msi_off </function></funcdef> 27278 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 27279 </funcprototype></funcsynopsis> 27280</refsynopsisdiv> 27281<refsect1> 27282 <title>Arguments</title> 27283 <variablelist> 27284 <varlistentry> 27285 <term><parameter>dev</parameter></term> 27286 <listitem> 27287 <para> 27288 the PCI device to operate on 27289 </para> 27290 </listitem> 27291 </varlistentry> 27292 </variablelist> 27293</refsect1> 27294<refsect1> 27295<title>Description</title> 27296<para> 27297 If you want to use MSI, see <function>pci_enable_msi</function> and friends. 27298 This is a lower-level primitive that allows us to disable 27299 MSI operation at the device level. 27300</para> 27301</refsect1> 27302</refentry> 27303 27304<refentry id="API-pci-wait-for-pending-transaction"> 27305<refentryinfo> 27306 <title>LINUX</title> 27307 <productname>Kernel Hackers Manual</productname> 27308 <date>July 2017</date> 27309</refentryinfo> 27310<refmeta> 27311 <refentrytitle><phrase>pci_wait_for_pending_transaction</phrase></refentrytitle> 27312 <manvolnum>9</manvolnum> 27313 <refmiscinfo class="version">4.1.27</refmiscinfo> 27314</refmeta> 27315<refnamediv> 27316 <refname>pci_wait_for_pending_transaction</refname> 27317 <refpurpose> 27318 waits for pending transaction 27319 </refpurpose> 27320</refnamediv> 27321<refsynopsisdiv> 27322 <title>Synopsis</title> 27323 <funcsynopsis><funcprototype> 27324 <funcdef>int <function>pci_wait_for_pending_transaction </function></funcdef> 27325 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 27326 </funcprototype></funcsynopsis> 27327</refsynopsisdiv> 27328<refsect1> 27329 <title>Arguments</title> 27330 <variablelist> 27331 <varlistentry> 27332 <term><parameter>dev</parameter></term> 27333 <listitem> 27334 <para> 27335 the PCI device to operate on 27336 </para> 27337 </listitem> 27338 </varlistentry> 27339 </variablelist> 27340</refsect1> 27341<refsect1> 27342<title>Description</title> 27343<para> 27344 Return 0 if transaction is pending 1 otherwise. 27345</para> 27346</refsect1> 27347</refentry> 27348 27349<refentry id="API-pci-reset-bridge-secondary-bus"> 27350<refentryinfo> 27351 <title>LINUX</title> 27352 <productname>Kernel Hackers Manual</productname> 27353 <date>July 2017</date> 27354</refentryinfo> 27355<refmeta> 27356 <refentrytitle><phrase>pci_reset_bridge_secondary_bus</phrase></refentrytitle> 27357 <manvolnum>9</manvolnum> 27358 <refmiscinfo class="version">4.1.27</refmiscinfo> 27359</refmeta> 27360<refnamediv> 27361 <refname>pci_reset_bridge_secondary_bus</refname> 27362 <refpurpose> 27363 Reset the secondary bus on a PCI bridge. 27364 </refpurpose> 27365</refnamediv> 27366<refsynopsisdiv> 27367 <title>Synopsis</title> 27368 <funcsynopsis><funcprototype> 27369 <funcdef>void <function>pci_reset_bridge_secondary_bus </function></funcdef> 27370 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 27371 </funcprototype></funcsynopsis> 27372</refsynopsisdiv> 27373<refsect1> 27374 <title>Arguments</title> 27375 <variablelist> 27376 <varlistentry> 27377 <term><parameter>dev</parameter></term> 27378 <listitem> 27379 <para> 27380 Bridge device 27381 </para> 27382 </listitem> 27383 </varlistentry> 27384 </variablelist> 27385</refsect1> 27386<refsect1> 27387<title>Description</title> 27388<para> 27389 Use the bridge control register to assert reset on the secondary bus. 27390 Devices on the secondary bus are left in power-on state. 27391</para> 27392</refsect1> 27393</refentry> 27394 27395<refentry id="API---pci-reset-function"> 27396<refentryinfo> 27397 <title>LINUX</title> 27398 <productname>Kernel Hackers Manual</productname> 27399 <date>July 2017</date> 27400</refentryinfo> 27401<refmeta> 27402 <refentrytitle><phrase>__pci_reset_function</phrase></refentrytitle> 27403 <manvolnum>9</manvolnum> 27404 <refmiscinfo class="version">4.1.27</refmiscinfo> 27405</refmeta> 27406<refnamediv> 27407 <refname>__pci_reset_function</refname> 27408 <refpurpose> 27409 reset a PCI device function 27410 </refpurpose> 27411</refnamediv> 27412<refsynopsisdiv> 27413 <title>Synopsis</title> 27414 <funcsynopsis><funcprototype> 27415 <funcdef>int <function>__pci_reset_function </function></funcdef> 27416 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 27417 </funcprototype></funcsynopsis> 27418</refsynopsisdiv> 27419<refsect1> 27420 <title>Arguments</title> 27421 <variablelist> 27422 <varlistentry> 27423 <term><parameter>dev</parameter></term> 27424 <listitem> 27425 <para> 27426 PCI device to reset 27427 </para> 27428 </listitem> 27429 </varlistentry> 27430 </variablelist> 27431</refsect1> 27432<refsect1> 27433<title>Description</title> 27434<para> 27435 Some devices allow an individual function to be reset without affecting 27436 other functions in the same device. The PCI device must be responsive 27437 to PCI config space in order to use this function. 27438 </para><para> 27439 27440 The device function is presumed to be unused when this function is called. 27441 Resetting the device will make the contents of PCI configuration space 27442 random, so any caller of this must be prepared to reinitialise the 27443 device including MSI, bus mastering, BARs, decoding IO and memory spaces, 27444 etc. 27445 </para><para> 27446 27447 Returns 0 if the device function was successfully reset or negative if the 27448 device doesn't support resetting a single function. 27449</para> 27450</refsect1> 27451</refentry> 27452 27453<refentry id="API---pci-reset-function-locked"> 27454<refentryinfo> 27455 <title>LINUX</title> 27456 <productname>Kernel Hackers Manual</productname> 27457 <date>July 2017</date> 27458</refentryinfo> 27459<refmeta> 27460 <refentrytitle><phrase>__pci_reset_function_locked</phrase></refentrytitle> 27461 <manvolnum>9</manvolnum> 27462 <refmiscinfo class="version">4.1.27</refmiscinfo> 27463</refmeta> 27464<refnamediv> 27465 <refname>__pci_reset_function_locked</refname> 27466 <refpurpose> 27467 reset a PCI device function while holding the <parameter>dev</parameter> mutex lock. 27468 </refpurpose> 27469</refnamediv> 27470<refsynopsisdiv> 27471 <title>Synopsis</title> 27472 <funcsynopsis><funcprototype> 27473 <funcdef>int <function>__pci_reset_function_locked </function></funcdef> 27474 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 27475 </funcprototype></funcsynopsis> 27476</refsynopsisdiv> 27477<refsect1> 27478 <title>Arguments</title> 27479 <variablelist> 27480 <varlistentry> 27481 <term><parameter>dev</parameter></term> 27482 <listitem> 27483 <para> 27484 PCI device to reset 27485 </para> 27486 </listitem> 27487 </varlistentry> 27488 </variablelist> 27489</refsect1> 27490<refsect1> 27491<title>Description</title> 27492<para> 27493 Some devices allow an individual function to be reset without affecting 27494 other functions in the same device. The PCI device must be responsive 27495 to PCI config space in order to use this function. 27496 </para><para> 27497 27498 The device function is presumed to be unused and the caller is holding 27499 the device mutex lock when this function is called. 27500 Resetting the device will make the contents of PCI configuration space 27501 random, so any caller of this must be prepared to reinitialise the 27502 device including MSI, bus mastering, BARs, decoding IO and memory spaces, 27503 etc. 27504 </para><para> 27505 27506 Returns 0 if the device function was successfully reset or negative if the 27507 device doesn't support resetting a single function. 27508</para> 27509</refsect1> 27510</refentry> 27511 27512<refentry id="API-pci-reset-function"> 27513<refentryinfo> 27514 <title>LINUX</title> 27515 <productname>Kernel Hackers Manual</productname> 27516 <date>July 2017</date> 27517</refentryinfo> 27518<refmeta> 27519 <refentrytitle><phrase>pci_reset_function</phrase></refentrytitle> 27520 <manvolnum>9</manvolnum> 27521 <refmiscinfo class="version">4.1.27</refmiscinfo> 27522</refmeta> 27523<refnamediv> 27524 <refname>pci_reset_function</refname> 27525 <refpurpose> 27526 quiesce and reset a PCI device function 27527 </refpurpose> 27528</refnamediv> 27529<refsynopsisdiv> 27530 <title>Synopsis</title> 27531 <funcsynopsis><funcprototype> 27532 <funcdef>int <function>pci_reset_function </function></funcdef> 27533 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 27534 </funcprototype></funcsynopsis> 27535</refsynopsisdiv> 27536<refsect1> 27537 <title>Arguments</title> 27538 <variablelist> 27539 <varlistentry> 27540 <term><parameter>dev</parameter></term> 27541 <listitem> 27542 <para> 27543 PCI device to reset 27544 </para> 27545 </listitem> 27546 </varlistentry> 27547 </variablelist> 27548</refsect1> 27549<refsect1> 27550<title>Description</title> 27551<para> 27552 Some devices allow an individual function to be reset without affecting 27553 other functions in the same device. The PCI device must be responsive 27554 to PCI config space in order to use this function. 27555 </para><para> 27556 27557 This function does not just reset the PCI portion of a device, but 27558 clears all the state associated with the device. This function differs 27559 from __pci_reset_function in that it saves and restores device state 27560 over the reset. 27561 </para><para> 27562 27563 Returns 0 if the device function was successfully reset or negative if the 27564 device doesn't support resetting a single function. 27565</para> 27566</refsect1> 27567</refentry> 27568 27569<refentry id="API-pci-try-reset-function"> 27570<refentryinfo> 27571 <title>LINUX</title> 27572 <productname>Kernel Hackers Manual</productname> 27573 <date>July 2017</date> 27574</refentryinfo> 27575<refmeta> 27576 <refentrytitle><phrase>pci_try_reset_function</phrase></refentrytitle> 27577 <manvolnum>9</manvolnum> 27578 <refmiscinfo class="version">4.1.27</refmiscinfo> 27579</refmeta> 27580<refnamediv> 27581 <refname>pci_try_reset_function</refname> 27582 <refpurpose> 27583 quiesce and reset a PCI device function 27584 </refpurpose> 27585</refnamediv> 27586<refsynopsisdiv> 27587 <title>Synopsis</title> 27588 <funcsynopsis><funcprototype> 27589 <funcdef>int <function>pci_try_reset_function </function></funcdef> 27590 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 27591 </funcprototype></funcsynopsis> 27592</refsynopsisdiv> 27593<refsect1> 27594 <title>Arguments</title> 27595 <variablelist> 27596 <varlistentry> 27597 <term><parameter>dev</parameter></term> 27598 <listitem> 27599 <para> 27600 PCI device to reset 27601 </para> 27602 </listitem> 27603 </varlistentry> 27604 </variablelist> 27605</refsect1> 27606<refsect1> 27607<title>Description</title> 27608<para> 27609 Same as above, except return -EAGAIN if unable to lock device. 27610</para> 27611</refsect1> 27612</refentry> 27613 27614<refentry id="API-pci-probe-reset-slot"> 27615<refentryinfo> 27616 <title>LINUX</title> 27617 <productname>Kernel Hackers Manual</productname> 27618 <date>July 2017</date> 27619</refentryinfo> 27620<refmeta> 27621 <refentrytitle><phrase>pci_probe_reset_slot</phrase></refentrytitle> 27622 <manvolnum>9</manvolnum> 27623 <refmiscinfo class="version">4.1.27</refmiscinfo> 27624</refmeta> 27625<refnamediv> 27626 <refname>pci_probe_reset_slot</refname> 27627 <refpurpose> 27628 probe whether a PCI slot can be reset 27629 </refpurpose> 27630</refnamediv> 27631<refsynopsisdiv> 27632 <title>Synopsis</title> 27633 <funcsynopsis><funcprototype> 27634 <funcdef>int <function>pci_probe_reset_slot </function></funcdef> 27635 <paramdef>struct pci_slot * <parameter>slot</parameter></paramdef> 27636 </funcprototype></funcsynopsis> 27637</refsynopsisdiv> 27638<refsect1> 27639 <title>Arguments</title> 27640 <variablelist> 27641 <varlistentry> 27642 <term><parameter>slot</parameter></term> 27643 <listitem> 27644 <para> 27645 PCI slot to probe 27646 </para> 27647 </listitem> 27648 </varlistentry> 27649 </variablelist> 27650</refsect1> 27651<refsect1> 27652<title>Description</title> 27653<para> 27654 Return 0 if slot can be reset, negative if a slot reset is not supported. 27655</para> 27656</refsect1> 27657</refentry> 27658 27659<refentry id="API-pci-reset-slot"> 27660<refentryinfo> 27661 <title>LINUX</title> 27662 <productname>Kernel Hackers Manual</productname> 27663 <date>July 2017</date> 27664</refentryinfo> 27665<refmeta> 27666 <refentrytitle><phrase>pci_reset_slot</phrase></refentrytitle> 27667 <manvolnum>9</manvolnum> 27668 <refmiscinfo class="version">4.1.27</refmiscinfo> 27669</refmeta> 27670<refnamediv> 27671 <refname>pci_reset_slot</refname> 27672 <refpurpose> 27673 reset a PCI slot 27674 </refpurpose> 27675</refnamediv> 27676<refsynopsisdiv> 27677 <title>Synopsis</title> 27678 <funcsynopsis><funcprototype> 27679 <funcdef>int <function>pci_reset_slot </function></funcdef> 27680 <paramdef>struct pci_slot * <parameter>slot</parameter></paramdef> 27681 </funcprototype></funcsynopsis> 27682</refsynopsisdiv> 27683<refsect1> 27684 <title>Arguments</title> 27685 <variablelist> 27686 <varlistentry> 27687 <term><parameter>slot</parameter></term> 27688 <listitem> 27689 <para> 27690 PCI slot to reset 27691 </para> 27692 </listitem> 27693 </varlistentry> 27694 </variablelist> 27695</refsect1> 27696<refsect1> 27697<title>Description</title> 27698<para> 27699 A PCI bus may host multiple slots, each slot may support a reset mechanism 27700 independent of other slots. For instance, some slots may support slot power 27701 control. In the case of a 1:1 bus to slot architecture, this function may 27702 wrap the bus reset to avoid spurious slot related events such as hotplug. 27703 Generally a slot reset should be attempted before a bus reset. All of the 27704 function of the slot and any subordinate buses behind the slot are reset 27705 through this function. PCI config space of all devices in the slot and 27706 behind the slot is saved before and restored after reset. 27707 </para><para> 27708 27709 Return 0 on success, non-zero on error. 27710</para> 27711</refsect1> 27712</refentry> 27713 27714<refentry id="API-pci-try-reset-slot"> 27715<refentryinfo> 27716 <title>LINUX</title> 27717 <productname>Kernel Hackers Manual</productname> 27718 <date>July 2017</date> 27719</refentryinfo> 27720<refmeta> 27721 <refentrytitle><phrase>pci_try_reset_slot</phrase></refentrytitle> 27722 <manvolnum>9</manvolnum> 27723 <refmiscinfo class="version">4.1.27</refmiscinfo> 27724</refmeta> 27725<refnamediv> 27726 <refname>pci_try_reset_slot</refname> 27727 <refpurpose> 27728 Try to reset a PCI slot 27729 </refpurpose> 27730</refnamediv> 27731<refsynopsisdiv> 27732 <title>Synopsis</title> 27733 <funcsynopsis><funcprototype> 27734 <funcdef>int <function>pci_try_reset_slot </function></funcdef> 27735 <paramdef>struct pci_slot * <parameter>slot</parameter></paramdef> 27736 </funcprototype></funcsynopsis> 27737</refsynopsisdiv> 27738<refsect1> 27739 <title>Arguments</title> 27740 <variablelist> 27741 <varlistentry> 27742 <term><parameter>slot</parameter></term> 27743 <listitem> 27744 <para> 27745 PCI slot to reset 27746 </para> 27747 </listitem> 27748 </varlistentry> 27749 </variablelist> 27750</refsect1> 27751<refsect1> 27752<title>Description</title> 27753<para> 27754 Same as above except return -EAGAIN if the slot cannot be locked 27755</para> 27756</refsect1> 27757</refentry> 27758 27759<refentry id="API-pci-probe-reset-bus"> 27760<refentryinfo> 27761 <title>LINUX</title> 27762 <productname>Kernel Hackers Manual</productname> 27763 <date>July 2017</date> 27764</refentryinfo> 27765<refmeta> 27766 <refentrytitle><phrase>pci_probe_reset_bus</phrase></refentrytitle> 27767 <manvolnum>9</manvolnum> 27768 <refmiscinfo class="version">4.1.27</refmiscinfo> 27769</refmeta> 27770<refnamediv> 27771 <refname>pci_probe_reset_bus</refname> 27772 <refpurpose> 27773 probe whether a PCI bus can be reset 27774 </refpurpose> 27775</refnamediv> 27776<refsynopsisdiv> 27777 <title>Synopsis</title> 27778 <funcsynopsis><funcprototype> 27779 <funcdef>int <function>pci_probe_reset_bus </function></funcdef> 27780 <paramdef>struct pci_bus * <parameter>bus</parameter></paramdef> 27781 </funcprototype></funcsynopsis> 27782</refsynopsisdiv> 27783<refsect1> 27784 <title>Arguments</title> 27785 <variablelist> 27786 <varlistentry> 27787 <term><parameter>bus</parameter></term> 27788 <listitem> 27789 <para> 27790 PCI bus to probe 27791 </para> 27792 </listitem> 27793 </varlistentry> 27794 </variablelist> 27795</refsect1> 27796<refsect1> 27797<title>Description</title> 27798<para> 27799 Return 0 if bus can be reset, negative if a bus reset is not supported. 27800</para> 27801</refsect1> 27802</refentry> 27803 27804<refentry id="API-pci-reset-bus"> 27805<refentryinfo> 27806 <title>LINUX</title> 27807 <productname>Kernel Hackers Manual</productname> 27808 <date>July 2017</date> 27809</refentryinfo> 27810<refmeta> 27811 <refentrytitle><phrase>pci_reset_bus</phrase></refentrytitle> 27812 <manvolnum>9</manvolnum> 27813 <refmiscinfo class="version">4.1.27</refmiscinfo> 27814</refmeta> 27815<refnamediv> 27816 <refname>pci_reset_bus</refname> 27817 <refpurpose> 27818 reset a PCI bus 27819 </refpurpose> 27820</refnamediv> 27821<refsynopsisdiv> 27822 <title>Synopsis</title> 27823 <funcsynopsis><funcprototype> 27824 <funcdef>int <function>pci_reset_bus </function></funcdef> 27825 <paramdef>struct pci_bus * <parameter>bus</parameter></paramdef> 27826 </funcprototype></funcsynopsis> 27827</refsynopsisdiv> 27828<refsect1> 27829 <title>Arguments</title> 27830 <variablelist> 27831 <varlistentry> 27832 <term><parameter>bus</parameter></term> 27833 <listitem> 27834 <para> 27835 top level PCI bus to reset 27836 </para> 27837 </listitem> 27838 </varlistentry> 27839 </variablelist> 27840</refsect1> 27841<refsect1> 27842<title>Description</title> 27843<para> 27844 Do a bus reset on the given bus and any subordinate buses, saving 27845 and restoring state of all devices. 27846 </para><para> 27847 27848 Return 0 on success, non-zero on error. 27849</para> 27850</refsect1> 27851</refentry> 27852 27853<refentry id="API-pci-try-reset-bus"> 27854<refentryinfo> 27855 <title>LINUX</title> 27856 <productname>Kernel Hackers Manual</productname> 27857 <date>July 2017</date> 27858</refentryinfo> 27859<refmeta> 27860 <refentrytitle><phrase>pci_try_reset_bus</phrase></refentrytitle> 27861 <manvolnum>9</manvolnum> 27862 <refmiscinfo class="version">4.1.27</refmiscinfo> 27863</refmeta> 27864<refnamediv> 27865 <refname>pci_try_reset_bus</refname> 27866 <refpurpose> 27867 Try to reset a PCI bus 27868 </refpurpose> 27869</refnamediv> 27870<refsynopsisdiv> 27871 <title>Synopsis</title> 27872 <funcsynopsis><funcprototype> 27873 <funcdef>int <function>pci_try_reset_bus </function></funcdef> 27874 <paramdef>struct pci_bus * <parameter>bus</parameter></paramdef> 27875 </funcprototype></funcsynopsis> 27876</refsynopsisdiv> 27877<refsect1> 27878 <title>Arguments</title> 27879 <variablelist> 27880 <varlistentry> 27881 <term><parameter>bus</parameter></term> 27882 <listitem> 27883 <para> 27884 top level PCI bus to reset 27885 </para> 27886 </listitem> 27887 </varlistentry> 27888 </variablelist> 27889</refsect1> 27890<refsect1> 27891<title>Description</title> 27892<para> 27893 Same as above except return -EAGAIN if the bus cannot be locked 27894</para> 27895</refsect1> 27896</refentry> 27897 27898<refentry id="API-pcix-get-max-mmrbc"> 27899<refentryinfo> 27900 <title>LINUX</title> 27901 <productname>Kernel Hackers Manual</productname> 27902 <date>July 2017</date> 27903</refentryinfo> 27904<refmeta> 27905 <refentrytitle><phrase>pcix_get_max_mmrbc</phrase></refentrytitle> 27906 <manvolnum>9</manvolnum> 27907 <refmiscinfo class="version">4.1.27</refmiscinfo> 27908</refmeta> 27909<refnamediv> 27910 <refname>pcix_get_max_mmrbc</refname> 27911 <refpurpose> 27912 get PCI-X maximum designed memory read byte count 27913 </refpurpose> 27914</refnamediv> 27915<refsynopsisdiv> 27916 <title>Synopsis</title> 27917 <funcsynopsis><funcprototype> 27918 <funcdef>int <function>pcix_get_max_mmrbc </function></funcdef> 27919 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 27920 </funcprototype></funcsynopsis> 27921</refsynopsisdiv> 27922<refsect1> 27923 <title>Arguments</title> 27924 <variablelist> 27925 <varlistentry> 27926 <term><parameter>dev</parameter></term> 27927 <listitem> 27928 <para> 27929 PCI device to query 27930 </para> 27931 </listitem> 27932 </varlistentry> 27933 </variablelist> 27934</refsect1> 27935<refsect1> 27936<title>Returns mmrbc</title> 27937<para> 27938 maximum designed memory read count in bytes 27939 or appropriate error value. 27940</para> 27941</refsect1> 27942</refentry> 27943 27944<refentry id="API-pcix-get-mmrbc"> 27945<refentryinfo> 27946 <title>LINUX</title> 27947 <productname>Kernel Hackers Manual</productname> 27948 <date>July 2017</date> 27949</refentryinfo> 27950<refmeta> 27951 <refentrytitle><phrase>pcix_get_mmrbc</phrase></refentrytitle> 27952 <manvolnum>9</manvolnum> 27953 <refmiscinfo class="version">4.1.27</refmiscinfo> 27954</refmeta> 27955<refnamediv> 27956 <refname>pcix_get_mmrbc</refname> 27957 <refpurpose> 27958 get PCI-X maximum memory read byte count 27959 </refpurpose> 27960</refnamediv> 27961<refsynopsisdiv> 27962 <title>Synopsis</title> 27963 <funcsynopsis><funcprototype> 27964 <funcdef>int <function>pcix_get_mmrbc </function></funcdef> 27965 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 27966 </funcprototype></funcsynopsis> 27967</refsynopsisdiv> 27968<refsect1> 27969 <title>Arguments</title> 27970 <variablelist> 27971 <varlistentry> 27972 <term><parameter>dev</parameter></term> 27973 <listitem> 27974 <para> 27975 PCI device to query 27976 </para> 27977 </listitem> 27978 </varlistentry> 27979 </variablelist> 27980</refsect1> 27981<refsect1> 27982<title>Returns mmrbc</title> 27983<para> 27984 maximum memory read count in bytes 27985 or appropriate error value. 27986</para> 27987</refsect1> 27988</refentry> 27989 27990<refentry id="API-pcix-set-mmrbc"> 27991<refentryinfo> 27992 <title>LINUX</title> 27993 <productname>Kernel Hackers Manual</productname> 27994 <date>July 2017</date> 27995</refentryinfo> 27996<refmeta> 27997 <refentrytitle><phrase>pcix_set_mmrbc</phrase></refentrytitle> 27998 <manvolnum>9</manvolnum> 27999 <refmiscinfo class="version">4.1.27</refmiscinfo> 28000</refmeta> 28001<refnamediv> 28002 <refname>pcix_set_mmrbc</refname> 28003 <refpurpose> 28004 set PCI-X maximum memory read byte count 28005 </refpurpose> 28006</refnamediv> 28007<refsynopsisdiv> 28008 <title>Synopsis</title> 28009 <funcsynopsis><funcprototype> 28010 <funcdef>int <function>pcix_set_mmrbc </function></funcdef> 28011 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 28012 <paramdef>int <parameter>mmrbc</parameter></paramdef> 28013 </funcprototype></funcsynopsis> 28014</refsynopsisdiv> 28015<refsect1> 28016 <title>Arguments</title> 28017 <variablelist> 28018 <varlistentry> 28019 <term><parameter>dev</parameter></term> 28020 <listitem> 28021 <para> 28022 PCI device to query 28023 </para> 28024 </listitem> 28025 </varlistentry> 28026 <varlistentry> 28027 <term><parameter>mmrbc</parameter></term> 28028 <listitem> 28029 <para> 28030 maximum memory read count in bytes 28031 valid values are 512, 1024, 2048, 4096 28032 </para> 28033 </listitem> 28034 </varlistentry> 28035 </variablelist> 28036</refsect1> 28037<refsect1> 28038<title>Description</title> 28039<para> 28040 If possible sets maximum memory read byte count, some bridges have erratas 28041 that prevent this. 28042</para> 28043</refsect1> 28044</refentry> 28045 28046<refentry id="API-pcie-get-readrq"> 28047<refentryinfo> 28048 <title>LINUX</title> 28049 <productname>Kernel Hackers Manual</productname> 28050 <date>July 2017</date> 28051</refentryinfo> 28052<refmeta> 28053 <refentrytitle><phrase>pcie_get_readrq</phrase></refentrytitle> 28054 <manvolnum>9</manvolnum> 28055 <refmiscinfo class="version">4.1.27</refmiscinfo> 28056</refmeta> 28057<refnamediv> 28058 <refname>pcie_get_readrq</refname> 28059 <refpurpose> 28060 get PCI Express read request size 28061 </refpurpose> 28062</refnamediv> 28063<refsynopsisdiv> 28064 <title>Synopsis</title> 28065 <funcsynopsis><funcprototype> 28066 <funcdef>int <function>pcie_get_readrq </function></funcdef> 28067 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 28068 </funcprototype></funcsynopsis> 28069</refsynopsisdiv> 28070<refsect1> 28071 <title>Arguments</title> 28072 <variablelist> 28073 <varlistentry> 28074 <term><parameter>dev</parameter></term> 28075 <listitem> 28076 <para> 28077 PCI device to query 28078 </para> 28079 </listitem> 28080 </varlistentry> 28081 </variablelist> 28082</refsect1> 28083<refsect1> 28084<title>Description</title> 28085<para> 28086 Returns maximum memory read request in bytes 28087 or appropriate error value. 28088</para> 28089</refsect1> 28090</refentry> 28091 28092<refentry id="API-pcie-set-readrq"> 28093<refentryinfo> 28094 <title>LINUX</title> 28095 <productname>Kernel Hackers Manual</productname> 28096 <date>July 2017</date> 28097</refentryinfo> 28098<refmeta> 28099 <refentrytitle><phrase>pcie_set_readrq</phrase></refentrytitle> 28100 <manvolnum>9</manvolnum> 28101 <refmiscinfo class="version">4.1.27</refmiscinfo> 28102</refmeta> 28103<refnamediv> 28104 <refname>pcie_set_readrq</refname> 28105 <refpurpose> 28106 set PCI Express maximum memory read request 28107 </refpurpose> 28108</refnamediv> 28109<refsynopsisdiv> 28110 <title>Synopsis</title> 28111 <funcsynopsis><funcprototype> 28112 <funcdef>int <function>pcie_set_readrq </function></funcdef> 28113 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 28114 <paramdef>int <parameter>rq</parameter></paramdef> 28115 </funcprototype></funcsynopsis> 28116</refsynopsisdiv> 28117<refsect1> 28118 <title>Arguments</title> 28119 <variablelist> 28120 <varlistentry> 28121 <term><parameter>dev</parameter></term> 28122 <listitem> 28123 <para> 28124 PCI device to query 28125 </para> 28126 </listitem> 28127 </varlistentry> 28128 <varlistentry> 28129 <term><parameter>rq</parameter></term> 28130 <listitem> 28131 <para> 28132 maximum memory read count in bytes 28133 valid values are 128, 256, 512, 1024, 2048, 4096 28134 </para> 28135 </listitem> 28136 </varlistentry> 28137 </variablelist> 28138</refsect1> 28139<refsect1> 28140<title>Description</title> 28141<para> 28142 If possible sets maximum memory read request in bytes 28143</para> 28144</refsect1> 28145</refentry> 28146 28147<refentry id="API-pcie-get-mps"> 28148<refentryinfo> 28149 <title>LINUX</title> 28150 <productname>Kernel Hackers Manual</productname> 28151 <date>July 2017</date> 28152</refentryinfo> 28153<refmeta> 28154 <refentrytitle><phrase>pcie_get_mps</phrase></refentrytitle> 28155 <manvolnum>9</manvolnum> 28156 <refmiscinfo class="version">4.1.27</refmiscinfo> 28157</refmeta> 28158<refnamediv> 28159 <refname>pcie_get_mps</refname> 28160 <refpurpose> 28161 get PCI Express maximum payload size 28162 </refpurpose> 28163</refnamediv> 28164<refsynopsisdiv> 28165 <title>Synopsis</title> 28166 <funcsynopsis><funcprototype> 28167 <funcdef>int <function>pcie_get_mps </function></funcdef> 28168 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 28169 </funcprototype></funcsynopsis> 28170</refsynopsisdiv> 28171<refsect1> 28172 <title>Arguments</title> 28173 <variablelist> 28174 <varlistentry> 28175 <term><parameter>dev</parameter></term> 28176 <listitem> 28177 <para> 28178 PCI device to query 28179 </para> 28180 </listitem> 28181 </varlistentry> 28182 </variablelist> 28183</refsect1> 28184<refsect1> 28185<title>Description</title> 28186<para> 28187 Returns maximum payload size in bytes 28188</para> 28189</refsect1> 28190</refentry> 28191 28192<refentry id="API-pcie-set-mps"> 28193<refentryinfo> 28194 <title>LINUX</title> 28195 <productname>Kernel Hackers Manual</productname> 28196 <date>July 2017</date> 28197</refentryinfo> 28198<refmeta> 28199 <refentrytitle><phrase>pcie_set_mps</phrase></refentrytitle> 28200 <manvolnum>9</manvolnum> 28201 <refmiscinfo class="version">4.1.27</refmiscinfo> 28202</refmeta> 28203<refnamediv> 28204 <refname>pcie_set_mps</refname> 28205 <refpurpose> 28206 set PCI Express maximum payload size 28207 </refpurpose> 28208</refnamediv> 28209<refsynopsisdiv> 28210 <title>Synopsis</title> 28211 <funcsynopsis><funcprototype> 28212 <funcdef>int <function>pcie_set_mps </function></funcdef> 28213 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 28214 <paramdef>int <parameter>mps</parameter></paramdef> 28215 </funcprototype></funcsynopsis> 28216</refsynopsisdiv> 28217<refsect1> 28218 <title>Arguments</title> 28219 <variablelist> 28220 <varlistentry> 28221 <term><parameter>dev</parameter></term> 28222 <listitem> 28223 <para> 28224 PCI device to query 28225 </para> 28226 </listitem> 28227 </varlistentry> 28228 <varlistentry> 28229 <term><parameter>mps</parameter></term> 28230 <listitem> 28231 <para> 28232 maximum payload size in bytes 28233 valid values are 128, 256, 512, 1024, 2048, 4096 28234 </para> 28235 </listitem> 28236 </varlistentry> 28237 </variablelist> 28238</refsect1> 28239<refsect1> 28240<title>Description</title> 28241<para> 28242 If possible sets maximum payload size 28243</para> 28244</refsect1> 28245</refentry> 28246 28247<refentry id="API-pcie-get-minimum-link"> 28248<refentryinfo> 28249 <title>LINUX</title> 28250 <productname>Kernel Hackers Manual</productname> 28251 <date>July 2017</date> 28252</refentryinfo> 28253<refmeta> 28254 <refentrytitle><phrase>pcie_get_minimum_link</phrase></refentrytitle> 28255 <manvolnum>9</manvolnum> 28256 <refmiscinfo class="version">4.1.27</refmiscinfo> 28257</refmeta> 28258<refnamediv> 28259 <refname>pcie_get_minimum_link</refname> 28260 <refpurpose> 28261 determine minimum link settings of a PCI device 28262 </refpurpose> 28263</refnamediv> 28264<refsynopsisdiv> 28265 <title>Synopsis</title> 28266 <funcsynopsis><funcprototype> 28267 <funcdef>int <function>pcie_get_minimum_link </function></funcdef> 28268 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 28269 <paramdef>enum pci_bus_speed * <parameter>speed</parameter></paramdef> 28270 <paramdef>enum pcie_link_width * <parameter>width</parameter></paramdef> 28271 </funcprototype></funcsynopsis> 28272</refsynopsisdiv> 28273<refsect1> 28274 <title>Arguments</title> 28275 <variablelist> 28276 <varlistentry> 28277 <term><parameter>dev</parameter></term> 28278 <listitem> 28279 <para> 28280 PCI device to query 28281 </para> 28282 </listitem> 28283 </varlistentry> 28284 <varlistentry> 28285 <term><parameter>speed</parameter></term> 28286 <listitem> 28287 <para> 28288 storage for minimum speed 28289 </para> 28290 </listitem> 28291 </varlistentry> 28292 <varlistentry> 28293 <term><parameter>width</parameter></term> 28294 <listitem> 28295 <para> 28296 storage for minimum width 28297 </para> 28298 </listitem> 28299 </varlistentry> 28300 </variablelist> 28301</refsect1> 28302<refsect1> 28303<title>Description</title> 28304<para> 28305 This function will walk up the PCI device chain and determine the minimum 28306 link width and speed of the device. 28307</para> 28308</refsect1> 28309</refentry> 28310 28311<refentry id="API-pci-select-bars"> 28312<refentryinfo> 28313 <title>LINUX</title> 28314 <productname>Kernel Hackers Manual</productname> 28315 <date>July 2017</date> 28316</refentryinfo> 28317<refmeta> 28318 <refentrytitle><phrase>pci_select_bars</phrase></refentrytitle> 28319 <manvolnum>9</manvolnum> 28320 <refmiscinfo class="version">4.1.27</refmiscinfo> 28321</refmeta> 28322<refnamediv> 28323 <refname>pci_select_bars</refname> 28324 <refpurpose> 28325 Make BAR mask from the type of resource 28326 </refpurpose> 28327</refnamediv> 28328<refsynopsisdiv> 28329 <title>Synopsis</title> 28330 <funcsynopsis><funcprototype> 28331 <funcdef>int <function>pci_select_bars </function></funcdef> 28332 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 28333 <paramdef>unsigned long <parameter>flags</parameter></paramdef> 28334 </funcprototype></funcsynopsis> 28335</refsynopsisdiv> 28336<refsect1> 28337 <title>Arguments</title> 28338 <variablelist> 28339 <varlistentry> 28340 <term><parameter>dev</parameter></term> 28341 <listitem> 28342 <para> 28343 the PCI device for which BAR mask is made 28344 </para> 28345 </listitem> 28346 </varlistentry> 28347 <varlistentry> 28348 <term><parameter>flags</parameter></term> 28349 <listitem> 28350 <para> 28351 resource type mask to be selected 28352 </para> 28353 </listitem> 28354 </varlistentry> 28355 </variablelist> 28356</refsect1> 28357<refsect1> 28358<title>Description</title> 28359<para> 28360 This helper routine makes bar mask from the type of resource. 28361</para> 28362</refsect1> 28363</refentry> 28364 28365<!-- drivers/pci/pci-driver.c --> 28366<refentry id="API-pci-add-dynid"> 28367<refentryinfo> 28368 <title>LINUX</title> 28369 <productname>Kernel Hackers Manual</productname> 28370 <date>July 2017</date> 28371</refentryinfo> 28372<refmeta> 28373 <refentrytitle><phrase>pci_add_dynid</phrase></refentrytitle> 28374 <manvolnum>9</manvolnum> 28375 <refmiscinfo class="version">4.1.27</refmiscinfo> 28376</refmeta> 28377<refnamediv> 28378 <refname>pci_add_dynid</refname> 28379 <refpurpose> 28380 add a new PCI device ID to this driver and re-probe devices 28381 </refpurpose> 28382</refnamediv> 28383<refsynopsisdiv> 28384 <title>Synopsis</title> 28385 <funcsynopsis><funcprototype> 28386 <funcdef>int <function>pci_add_dynid </function></funcdef> 28387 <paramdef>struct pci_driver * <parameter>drv</parameter></paramdef> 28388 <paramdef>unsigned int <parameter>vendor</parameter></paramdef> 28389 <paramdef>unsigned int <parameter>device</parameter></paramdef> 28390 <paramdef>unsigned int <parameter>subvendor</parameter></paramdef> 28391 <paramdef>unsigned int <parameter>subdevice</parameter></paramdef> 28392 <paramdef>unsigned int <parameter>class</parameter></paramdef> 28393 <paramdef>unsigned int <parameter>class_mask</parameter></paramdef> 28394 <paramdef>unsigned long <parameter>driver_data</parameter></paramdef> 28395 </funcprototype></funcsynopsis> 28396</refsynopsisdiv> 28397<refsect1> 28398 <title>Arguments</title> 28399 <variablelist> 28400 <varlistentry> 28401 <term><parameter>drv</parameter></term> 28402 <listitem> 28403 <para> 28404 target pci driver 28405 </para> 28406 </listitem> 28407 </varlistentry> 28408 <varlistentry> 28409 <term><parameter>vendor</parameter></term> 28410 <listitem> 28411 <para> 28412 PCI vendor ID 28413 </para> 28414 </listitem> 28415 </varlistentry> 28416 <varlistentry> 28417 <term><parameter>device</parameter></term> 28418 <listitem> 28419 <para> 28420 PCI device ID 28421 </para> 28422 </listitem> 28423 </varlistentry> 28424 <varlistentry> 28425 <term><parameter>subvendor</parameter></term> 28426 <listitem> 28427 <para> 28428 PCI subvendor ID 28429 </para> 28430 </listitem> 28431 </varlistentry> 28432 <varlistentry> 28433 <term><parameter>subdevice</parameter></term> 28434 <listitem> 28435 <para> 28436 PCI subdevice ID 28437 </para> 28438 </listitem> 28439 </varlistentry> 28440 <varlistentry> 28441 <term><parameter>class</parameter></term> 28442 <listitem> 28443 <para> 28444 PCI class 28445 </para> 28446 </listitem> 28447 </varlistentry> 28448 <varlistentry> 28449 <term><parameter>class_mask</parameter></term> 28450 <listitem> 28451 <para> 28452 PCI class mask 28453 </para> 28454 </listitem> 28455 </varlistentry> 28456 <varlistentry> 28457 <term><parameter>driver_data</parameter></term> 28458 <listitem> 28459 <para> 28460 private driver data 28461 </para> 28462 </listitem> 28463 </varlistentry> 28464 </variablelist> 28465</refsect1> 28466<refsect1> 28467<title>Description</title> 28468<para> 28469 Adds a new dynamic pci device ID to this driver and causes the 28470 driver to probe for all devices again. <parameter>drv</parameter> must have been 28471 registered prior to calling this function. 28472</para> 28473</refsect1> 28474<refsect1> 28475<title>CONTEXT</title> 28476<para> 28477 Does GFP_KERNEL allocation. 28478</para> 28479</refsect1> 28480<refsect1> 28481<title>RETURNS</title> 28482<para> 28483 0 on success, -errno on failure. 28484</para> 28485</refsect1> 28486</refentry> 28487 28488<refentry id="API-pci-match-id"> 28489<refentryinfo> 28490 <title>LINUX</title> 28491 <productname>Kernel Hackers Manual</productname> 28492 <date>July 2017</date> 28493</refentryinfo> 28494<refmeta> 28495 <refentrytitle><phrase>pci_match_id</phrase></refentrytitle> 28496 <manvolnum>9</manvolnum> 28497 <refmiscinfo class="version">4.1.27</refmiscinfo> 28498</refmeta> 28499<refnamediv> 28500 <refname>pci_match_id</refname> 28501 <refpurpose> 28502 See if a pci device matches a given pci_id table 28503 </refpurpose> 28504</refnamediv> 28505<refsynopsisdiv> 28506 <title>Synopsis</title> 28507 <funcsynopsis><funcprototype> 28508 <funcdef>const struct pci_device_id * <function>pci_match_id </function></funcdef> 28509 <paramdef>const struct pci_device_id * <parameter>ids</parameter></paramdef> 28510 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 28511 </funcprototype></funcsynopsis> 28512</refsynopsisdiv> 28513<refsect1> 28514 <title>Arguments</title> 28515 <variablelist> 28516 <varlistentry> 28517 <term><parameter>ids</parameter></term> 28518 <listitem> 28519 <para> 28520 array of PCI device id structures to search in 28521 </para> 28522 </listitem> 28523 </varlistentry> 28524 <varlistentry> 28525 <term><parameter>dev</parameter></term> 28526 <listitem> 28527 <para> 28528 the PCI device structure to match against. 28529 </para> 28530 </listitem> 28531 </varlistentry> 28532 </variablelist> 28533</refsect1> 28534<refsect1> 28535<title>Description</title> 28536<para> 28537 Used by a driver to check whether a PCI device present in the 28538 system is in its list of supported devices. Returns the matching 28539 pci_device_id structure or <constant>NULL</constant> if there is no match. 28540 </para><para> 28541 28542 Deprecated, don't use this as it will not catch any dynamic ids 28543 that a driver might want to check for. 28544</para> 28545</refsect1> 28546</refentry> 28547 28548<refentry id="API---pci-register-driver"> 28549<refentryinfo> 28550 <title>LINUX</title> 28551 <productname>Kernel Hackers Manual</productname> 28552 <date>July 2017</date> 28553</refentryinfo> 28554<refmeta> 28555 <refentrytitle><phrase>__pci_register_driver</phrase></refentrytitle> 28556 <manvolnum>9</manvolnum> 28557 <refmiscinfo class="version">4.1.27</refmiscinfo> 28558</refmeta> 28559<refnamediv> 28560 <refname>__pci_register_driver</refname> 28561 <refpurpose> 28562 register a new pci driver 28563 </refpurpose> 28564</refnamediv> 28565<refsynopsisdiv> 28566 <title>Synopsis</title> 28567 <funcsynopsis><funcprototype> 28568 <funcdef>int <function>__pci_register_driver </function></funcdef> 28569 <paramdef>struct pci_driver * <parameter>drv</parameter></paramdef> 28570 <paramdef>struct module * <parameter>owner</parameter></paramdef> 28571 <paramdef>const char * <parameter>mod_name</parameter></paramdef> 28572 </funcprototype></funcsynopsis> 28573</refsynopsisdiv> 28574<refsect1> 28575 <title>Arguments</title> 28576 <variablelist> 28577 <varlistentry> 28578 <term><parameter>drv</parameter></term> 28579 <listitem> 28580 <para> 28581 the driver structure to register 28582 </para> 28583 </listitem> 28584 </varlistentry> 28585 <varlistentry> 28586 <term><parameter>owner</parameter></term> 28587 <listitem> 28588 <para> 28589 owner module of drv 28590 </para> 28591 </listitem> 28592 </varlistentry> 28593 <varlistentry> 28594 <term><parameter>mod_name</parameter></term> 28595 <listitem> 28596 <para> 28597 module name string 28598 </para> 28599 </listitem> 28600 </varlistentry> 28601 </variablelist> 28602</refsect1> 28603<refsect1> 28604<title>Description</title> 28605<para> 28606 Adds the driver structure to the list of registered drivers. 28607 Returns a negative value on error, otherwise 0. 28608 If no error occurred, the driver remains registered even if 28609 no device was claimed during registration. 28610</para> 28611</refsect1> 28612</refentry> 28613 28614<refentry id="API-pci-unregister-driver"> 28615<refentryinfo> 28616 <title>LINUX</title> 28617 <productname>Kernel Hackers Manual</productname> 28618 <date>July 2017</date> 28619</refentryinfo> 28620<refmeta> 28621 <refentrytitle><phrase>pci_unregister_driver</phrase></refentrytitle> 28622 <manvolnum>9</manvolnum> 28623 <refmiscinfo class="version">4.1.27</refmiscinfo> 28624</refmeta> 28625<refnamediv> 28626 <refname>pci_unregister_driver</refname> 28627 <refpurpose> 28628 unregister a pci driver 28629 </refpurpose> 28630</refnamediv> 28631<refsynopsisdiv> 28632 <title>Synopsis</title> 28633 <funcsynopsis><funcprototype> 28634 <funcdef>void <function>pci_unregister_driver </function></funcdef> 28635 <paramdef>struct pci_driver * <parameter>drv</parameter></paramdef> 28636 </funcprototype></funcsynopsis> 28637</refsynopsisdiv> 28638<refsect1> 28639 <title>Arguments</title> 28640 <variablelist> 28641 <varlistentry> 28642 <term><parameter>drv</parameter></term> 28643 <listitem> 28644 <para> 28645 the driver structure to unregister 28646 </para> 28647 </listitem> 28648 </varlistentry> 28649 </variablelist> 28650</refsect1> 28651<refsect1> 28652<title>Description</title> 28653<para> 28654 Deletes the driver structure from the list of registered PCI drivers, 28655 gives it a chance to clean up by calling its <function>remove</function> function for 28656 each device it was responsible for, and marks those devices as 28657 driverless. 28658</para> 28659</refsect1> 28660</refentry> 28661 28662<refentry id="API-pci-dev-driver"> 28663<refentryinfo> 28664 <title>LINUX</title> 28665 <productname>Kernel Hackers Manual</productname> 28666 <date>July 2017</date> 28667</refentryinfo> 28668<refmeta> 28669 <refentrytitle><phrase>pci_dev_driver</phrase></refentrytitle> 28670 <manvolnum>9</manvolnum> 28671 <refmiscinfo class="version">4.1.27</refmiscinfo> 28672</refmeta> 28673<refnamediv> 28674 <refname>pci_dev_driver</refname> 28675 <refpurpose> 28676 get the pci_driver of a device 28677 </refpurpose> 28678</refnamediv> 28679<refsynopsisdiv> 28680 <title>Synopsis</title> 28681 <funcsynopsis><funcprototype> 28682 <funcdef>struct pci_driver * <function>pci_dev_driver </function></funcdef> 28683 <paramdef>const struct pci_dev * <parameter>dev</parameter></paramdef> 28684 </funcprototype></funcsynopsis> 28685</refsynopsisdiv> 28686<refsect1> 28687 <title>Arguments</title> 28688 <variablelist> 28689 <varlistentry> 28690 <term><parameter>dev</parameter></term> 28691 <listitem> 28692 <para> 28693 the device to query 28694 </para> 28695 </listitem> 28696 </varlistentry> 28697 </variablelist> 28698</refsect1> 28699<refsect1> 28700<title>Description</title> 28701<para> 28702 Returns the appropriate pci_driver structure or <constant>NULL</constant> if there is no 28703 registered driver for the device. 28704</para> 28705</refsect1> 28706</refentry> 28707 28708<refentry id="API-pci-dev-get"> 28709<refentryinfo> 28710 <title>LINUX</title> 28711 <productname>Kernel Hackers Manual</productname> 28712 <date>July 2017</date> 28713</refentryinfo> 28714<refmeta> 28715 <refentrytitle><phrase>pci_dev_get</phrase></refentrytitle> 28716 <manvolnum>9</manvolnum> 28717 <refmiscinfo class="version">4.1.27</refmiscinfo> 28718</refmeta> 28719<refnamediv> 28720 <refname>pci_dev_get</refname> 28721 <refpurpose> 28722 increments the reference count of the pci device structure 28723 </refpurpose> 28724</refnamediv> 28725<refsynopsisdiv> 28726 <title>Synopsis</title> 28727 <funcsynopsis><funcprototype> 28728 <funcdef>struct pci_dev * <function>pci_dev_get </function></funcdef> 28729 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 28730 </funcprototype></funcsynopsis> 28731</refsynopsisdiv> 28732<refsect1> 28733 <title>Arguments</title> 28734 <variablelist> 28735 <varlistentry> 28736 <term><parameter>dev</parameter></term> 28737 <listitem> 28738 <para> 28739 the device being referenced 28740 </para> 28741 </listitem> 28742 </varlistentry> 28743 </variablelist> 28744</refsect1> 28745<refsect1> 28746<title>Description</title> 28747<para> 28748 Each live reference to a device should be refcounted. 28749 </para><para> 28750 28751 Drivers for PCI devices should normally record such references in 28752 their <function>probe</function> methods, when they bind to a device, and release 28753 them by calling <function>pci_dev_put</function>, in their <function>disconnect</function> methods. 28754 </para><para> 28755 28756 A pointer to the device with the incremented reference counter is returned. 28757</para> 28758</refsect1> 28759</refentry> 28760 28761<refentry id="API-pci-dev-put"> 28762<refentryinfo> 28763 <title>LINUX</title> 28764 <productname>Kernel Hackers Manual</productname> 28765 <date>July 2017</date> 28766</refentryinfo> 28767<refmeta> 28768 <refentrytitle><phrase>pci_dev_put</phrase></refentrytitle> 28769 <manvolnum>9</manvolnum> 28770 <refmiscinfo class="version">4.1.27</refmiscinfo> 28771</refmeta> 28772<refnamediv> 28773 <refname>pci_dev_put</refname> 28774 <refpurpose> 28775 release a use of the pci device structure 28776 </refpurpose> 28777</refnamediv> 28778<refsynopsisdiv> 28779 <title>Synopsis</title> 28780 <funcsynopsis><funcprototype> 28781 <funcdef>void <function>pci_dev_put </function></funcdef> 28782 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 28783 </funcprototype></funcsynopsis> 28784</refsynopsisdiv> 28785<refsect1> 28786 <title>Arguments</title> 28787 <variablelist> 28788 <varlistentry> 28789 <term><parameter>dev</parameter></term> 28790 <listitem> 28791 <para> 28792 device that's been disconnected 28793 </para> 28794 </listitem> 28795 </varlistentry> 28796 </variablelist> 28797</refsect1> 28798<refsect1> 28799<title>Description</title> 28800<para> 28801 Must be called when a user of a device is finished with it. When the last 28802 user of the device calls this function, the memory of the device is freed. 28803</para> 28804</refsect1> 28805</refentry> 28806 28807<!-- drivers/pci/remove.c --> 28808<refentry id="API-pci-stop-and-remove-bus-device"> 28809<refentryinfo> 28810 <title>LINUX</title> 28811 <productname>Kernel Hackers Manual</productname> 28812 <date>July 2017</date> 28813</refentryinfo> 28814<refmeta> 28815 <refentrytitle><phrase>pci_stop_and_remove_bus_device</phrase></refentrytitle> 28816 <manvolnum>9</manvolnum> 28817 <refmiscinfo class="version">4.1.27</refmiscinfo> 28818</refmeta> 28819<refnamediv> 28820 <refname>pci_stop_and_remove_bus_device</refname> 28821 <refpurpose> 28822 remove a PCI device and any children 28823 </refpurpose> 28824</refnamediv> 28825<refsynopsisdiv> 28826 <title>Synopsis</title> 28827 <funcsynopsis><funcprototype> 28828 <funcdef>void <function>pci_stop_and_remove_bus_device </function></funcdef> 28829 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 28830 </funcprototype></funcsynopsis> 28831</refsynopsisdiv> 28832<refsect1> 28833 <title>Arguments</title> 28834 <variablelist> 28835 <varlistentry> 28836 <term><parameter>dev</parameter></term> 28837 <listitem> 28838 <para> 28839 the device to remove 28840 </para> 28841 </listitem> 28842 </varlistentry> 28843 </variablelist> 28844</refsect1> 28845<refsect1> 28846<title>Description</title> 28847<para> 28848 Remove a PCI device from the device lists, informing the drivers 28849 that the device has been removed. We also remove any subordinate 28850 buses and children in a depth-first manner. 28851 </para><para> 28852 28853 For each device we remove, delete the device structure from the 28854 device lists, remove the /proc entry, and notify userspace 28855 (/sbin/hotplug). 28856</para> 28857</refsect1> 28858</refentry> 28859 28860<!-- drivers/pci/search.c --> 28861<refentry id="API-pci-find-bus"> 28862<refentryinfo> 28863 <title>LINUX</title> 28864 <productname>Kernel Hackers Manual</productname> 28865 <date>July 2017</date> 28866</refentryinfo> 28867<refmeta> 28868 <refentrytitle><phrase>pci_find_bus</phrase></refentrytitle> 28869 <manvolnum>9</manvolnum> 28870 <refmiscinfo class="version">4.1.27</refmiscinfo> 28871</refmeta> 28872<refnamediv> 28873 <refname>pci_find_bus</refname> 28874 <refpurpose> 28875 locate PCI bus from a given domain and bus number 28876 </refpurpose> 28877</refnamediv> 28878<refsynopsisdiv> 28879 <title>Synopsis</title> 28880 <funcsynopsis><funcprototype> 28881 <funcdef>struct pci_bus * <function>pci_find_bus </function></funcdef> 28882 <paramdef>int <parameter>domain</parameter></paramdef> 28883 <paramdef>int <parameter>busnr</parameter></paramdef> 28884 </funcprototype></funcsynopsis> 28885</refsynopsisdiv> 28886<refsect1> 28887 <title>Arguments</title> 28888 <variablelist> 28889 <varlistentry> 28890 <term><parameter>domain</parameter></term> 28891 <listitem> 28892 <para> 28893 number of PCI domain to search 28894 </para> 28895 </listitem> 28896 </varlistentry> 28897 <varlistentry> 28898 <term><parameter>busnr</parameter></term> 28899 <listitem> 28900 <para> 28901 number of desired PCI bus 28902 </para> 28903 </listitem> 28904 </varlistentry> 28905 </variablelist> 28906</refsect1> 28907<refsect1> 28908<title>Description</title> 28909<para> 28910 Given a PCI bus number and domain number, the desired PCI bus is located 28911 in the global list of PCI buses. If the bus is found, a pointer to its 28912 data structure is returned. If no bus is found, <constant>NULL</constant> is returned. 28913</para> 28914</refsect1> 28915</refentry> 28916 28917<refentry id="API-pci-find-next-bus"> 28918<refentryinfo> 28919 <title>LINUX</title> 28920 <productname>Kernel Hackers Manual</productname> 28921 <date>July 2017</date> 28922</refentryinfo> 28923<refmeta> 28924 <refentrytitle><phrase>pci_find_next_bus</phrase></refentrytitle> 28925 <manvolnum>9</manvolnum> 28926 <refmiscinfo class="version">4.1.27</refmiscinfo> 28927</refmeta> 28928<refnamediv> 28929 <refname>pci_find_next_bus</refname> 28930 <refpurpose> 28931 begin or continue searching for a PCI bus 28932 </refpurpose> 28933</refnamediv> 28934<refsynopsisdiv> 28935 <title>Synopsis</title> 28936 <funcsynopsis><funcprototype> 28937 <funcdef>struct pci_bus * <function>pci_find_next_bus </function></funcdef> 28938 <paramdef>const struct pci_bus * <parameter>from</parameter></paramdef> 28939 </funcprototype></funcsynopsis> 28940</refsynopsisdiv> 28941<refsect1> 28942 <title>Arguments</title> 28943 <variablelist> 28944 <varlistentry> 28945 <term><parameter>from</parameter></term> 28946 <listitem> 28947 <para> 28948 Previous PCI bus found, or <constant>NULL</constant> for new search. 28949 </para> 28950 </listitem> 28951 </varlistentry> 28952 </variablelist> 28953</refsect1> 28954<refsect1> 28955<title>Description</title> 28956<para> 28957 Iterates through the list of known PCI buses. A new search is 28958 initiated by passing <constant>NULL</constant> as the <parameter>from</parameter> argument. Otherwise if 28959 <parameter>from</parameter> is not <constant>NULL</constant>, searches continue from next device on the 28960 global list. 28961</para> 28962</refsect1> 28963</refentry> 28964 28965<refentry id="API-pci-get-slot"> 28966<refentryinfo> 28967 <title>LINUX</title> 28968 <productname>Kernel Hackers Manual</productname> 28969 <date>July 2017</date> 28970</refentryinfo> 28971<refmeta> 28972 <refentrytitle><phrase>pci_get_slot</phrase></refentrytitle> 28973 <manvolnum>9</manvolnum> 28974 <refmiscinfo class="version">4.1.27</refmiscinfo> 28975</refmeta> 28976<refnamediv> 28977 <refname>pci_get_slot</refname> 28978 <refpurpose> 28979 locate PCI device for a given PCI slot 28980 </refpurpose> 28981</refnamediv> 28982<refsynopsisdiv> 28983 <title>Synopsis</title> 28984 <funcsynopsis><funcprototype> 28985 <funcdef>struct pci_dev * <function>pci_get_slot </function></funcdef> 28986 <paramdef>struct pci_bus * <parameter>bus</parameter></paramdef> 28987 <paramdef>unsigned int <parameter>devfn</parameter></paramdef> 28988 </funcprototype></funcsynopsis> 28989</refsynopsisdiv> 28990<refsect1> 28991 <title>Arguments</title> 28992 <variablelist> 28993 <varlistentry> 28994 <term><parameter>bus</parameter></term> 28995 <listitem> 28996 <para> 28997 PCI bus on which desired PCI device resides 28998 </para> 28999 </listitem> 29000 </varlistentry> 29001 <varlistentry> 29002 <term><parameter>devfn</parameter></term> 29003 <listitem> 29004 <para> 29005 encodes number of PCI slot in which the desired PCI 29006 device resides and the logical device number within that slot 29007 in case of multi-function devices. 29008 </para> 29009 </listitem> 29010 </varlistentry> 29011 </variablelist> 29012</refsect1> 29013<refsect1> 29014<title>Description</title> 29015<para> 29016 Given a PCI bus and slot/function number, the desired PCI device 29017 is located in the list of PCI devices. 29018 If the device is found, its reference count is increased and this 29019 function returns a pointer to its data structure. The caller must 29020 decrement the reference count by calling <function>pci_dev_put</function>. 29021 If no device is found, <constant>NULL</constant> is returned. 29022</para> 29023</refsect1> 29024</refentry> 29025 29026<refentry id="API-pci-get-domain-bus-and-slot"> 29027<refentryinfo> 29028 <title>LINUX</title> 29029 <productname>Kernel Hackers Manual</productname> 29030 <date>July 2017</date> 29031</refentryinfo> 29032<refmeta> 29033 <refentrytitle><phrase>pci_get_domain_bus_and_slot</phrase></refentrytitle> 29034 <manvolnum>9</manvolnum> 29035 <refmiscinfo class="version">4.1.27</refmiscinfo> 29036</refmeta> 29037<refnamediv> 29038 <refname>pci_get_domain_bus_and_slot</refname> 29039 <refpurpose> 29040 locate PCI device for a given PCI domain (segment), bus, and slot 29041 </refpurpose> 29042</refnamediv> 29043<refsynopsisdiv> 29044 <title>Synopsis</title> 29045 <funcsynopsis><funcprototype> 29046 <funcdef>struct pci_dev * <function>pci_get_domain_bus_and_slot </function></funcdef> 29047 <paramdef>int <parameter>domain</parameter></paramdef> 29048 <paramdef>unsigned int <parameter>bus</parameter></paramdef> 29049 <paramdef>unsigned int <parameter>devfn</parameter></paramdef> 29050 </funcprototype></funcsynopsis> 29051</refsynopsisdiv> 29052<refsect1> 29053 <title>Arguments</title> 29054 <variablelist> 29055 <varlistentry> 29056 <term><parameter>domain</parameter></term> 29057 <listitem> 29058 <para> 29059 PCI domain/segment on which the PCI device resides. 29060 </para> 29061 </listitem> 29062 </varlistentry> 29063 <varlistentry> 29064 <term><parameter>bus</parameter></term> 29065 <listitem> 29066 <para> 29067 PCI bus on which desired PCI device resides 29068 </para> 29069 </listitem> 29070 </varlistentry> 29071 <varlistentry> 29072 <term><parameter>devfn</parameter></term> 29073 <listitem> 29074 <para> 29075 encodes number of PCI slot in which the desired PCI device 29076 resides and the logical device number within that slot in case of 29077 multi-function devices. 29078 </para> 29079 </listitem> 29080 </varlistentry> 29081 </variablelist> 29082</refsect1> 29083<refsect1> 29084<title>Description</title> 29085<para> 29086 Given a PCI domain, bus, and slot/function number, the desired PCI 29087 device is located in the list of PCI devices. If the device is 29088 found, its reference count is increased and this function returns a 29089 pointer to its data structure. The caller must decrement the 29090 reference count by calling <function>pci_dev_put</function>. If no device is found, 29091 <constant>NULL</constant> is returned. 29092</para> 29093</refsect1> 29094</refentry> 29095 29096<refentry id="API-pci-get-subsys"> 29097<refentryinfo> 29098 <title>LINUX</title> 29099 <productname>Kernel Hackers Manual</productname> 29100 <date>July 2017</date> 29101</refentryinfo> 29102<refmeta> 29103 <refentrytitle><phrase>pci_get_subsys</phrase></refentrytitle> 29104 <manvolnum>9</manvolnum> 29105 <refmiscinfo class="version">4.1.27</refmiscinfo> 29106</refmeta> 29107<refnamediv> 29108 <refname>pci_get_subsys</refname> 29109 <refpurpose> 29110 begin or continue searching for a PCI device by vendor/subvendor/device/subdevice id 29111 </refpurpose> 29112</refnamediv> 29113<refsynopsisdiv> 29114 <title>Synopsis</title> 29115 <funcsynopsis><funcprototype> 29116 <funcdef>struct pci_dev * <function>pci_get_subsys </function></funcdef> 29117 <paramdef>unsigned int <parameter>vendor</parameter></paramdef> 29118 <paramdef>unsigned int <parameter>device</parameter></paramdef> 29119 <paramdef>unsigned int <parameter>ss_vendor</parameter></paramdef> 29120 <paramdef>unsigned int <parameter>ss_device</parameter></paramdef> 29121 <paramdef>struct pci_dev * <parameter>from</parameter></paramdef> 29122 </funcprototype></funcsynopsis> 29123</refsynopsisdiv> 29124<refsect1> 29125 <title>Arguments</title> 29126 <variablelist> 29127 <varlistentry> 29128 <term><parameter>vendor</parameter></term> 29129 <listitem> 29130 <para> 29131 PCI vendor id to match, or <constant>PCI_ANY_ID</constant> to match all vendor ids 29132 </para> 29133 </listitem> 29134 </varlistentry> 29135 <varlistentry> 29136 <term><parameter>device</parameter></term> 29137 <listitem> 29138 <para> 29139 PCI device id to match, or <constant>PCI_ANY_ID</constant> to match all device ids 29140 </para> 29141 </listitem> 29142 </varlistentry> 29143 <varlistentry> 29144 <term><parameter>ss_vendor</parameter></term> 29145 <listitem> 29146 <para> 29147 PCI subsystem vendor id to match, or <constant>PCI_ANY_ID</constant> to match all vendor ids 29148 </para> 29149 </listitem> 29150 </varlistentry> 29151 <varlistentry> 29152 <term><parameter>ss_device</parameter></term> 29153 <listitem> 29154 <para> 29155 PCI subsystem device id to match, or <constant>PCI_ANY_ID</constant> to match all device ids 29156 </para> 29157 </listitem> 29158 </varlistentry> 29159 <varlistentry> 29160 <term><parameter>from</parameter></term> 29161 <listitem> 29162 <para> 29163 Previous PCI device found in search, or <constant>NULL</constant> for new search. 29164 </para> 29165 </listitem> 29166 </varlistentry> 29167 </variablelist> 29168</refsect1> 29169<refsect1> 29170<title>Description</title> 29171<para> 29172 Iterates through the list of known PCI devices. If a PCI device is found 29173 with a matching <parameter>vendor</parameter>, <parameter>device</parameter>, <parameter>ss_vendor</parameter> and <parameter>ss_device</parameter>, a pointer to its 29174 device structure is returned, and the reference count to the device is 29175 incremented. Otherwise, <constant>NULL</constant> is returned. A new search is initiated by 29176 passing <constant>NULL</constant> as the <parameter>from</parameter> argument. Otherwise if <parameter>from</parameter> is not <constant>NULL</constant>, 29177 searches continue from next device on the global list. 29178 The reference count for <parameter>from</parameter> is always decremented if it is not <constant>NULL</constant>. 29179</para> 29180</refsect1> 29181</refentry> 29182 29183<refentry id="API-pci-get-device"> 29184<refentryinfo> 29185 <title>LINUX</title> 29186 <productname>Kernel Hackers Manual</productname> 29187 <date>July 2017</date> 29188</refentryinfo> 29189<refmeta> 29190 <refentrytitle><phrase>pci_get_device</phrase></refentrytitle> 29191 <manvolnum>9</manvolnum> 29192 <refmiscinfo class="version">4.1.27</refmiscinfo> 29193</refmeta> 29194<refnamediv> 29195 <refname>pci_get_device</refname> 29196 <refpurpose> 29197 begin or continue searching for a PCI device by vendor/device id 29198 </refpurpose> 29199</refnamediv> 29200<refsynopsisdiv> 29201 <title>Synopsis</title> 29202 <funcsynopsis><funcprototype> 29203 <funcdef>struct pci_dev * <function>pci_get_device </function></funcdef> 29204 <paramdef>unsigned int <parameter>vendor</parameter></paramdef> 29205 <paramdef>unsigned int <parameter>device</parameter></paramdef> 29206 <paramdef>struct pci_dev * <parameter>from</parameter></paramdef> 29207 </funcprototype></funcsynopsis> 29208</refsynopsisdiv> 29209<refsect1> 29210 <title>Arguments</title> 29211 <variablelist> 29212 <varlistentry> 29213 <term><parameter>vendor</parameter></term> 29214 <listitem> 29215 <para> 29216 PCI vendor id to match, or <constant>PCI_ANY_ID</constant> to match all vendor ids 29217 </para> 29218 </listitem> 29219 </varlistentry> 29220 <varlistentry> 29221 <term><parameter>device</parameter></term> 29222 <listitem> 29223 <para> 29224 PCI device id to match, or <constant>PCI_ANY_ID</constant> to match all device ids 29225 </para> 29226 </listitem> 29227 </varlistentry> 29228 <varlistentry> 29229 <term><parameter>from</parameter></term> 29230 <listitem> 29231 <para> 29232 Previous PCI device found in search, or <constant>NULL</constant> for new search. 29233 </para> 29234 </listitem> 29235 </varlistentry> 29236 </variablelist> 29237</refsect1> 29238<refsect1> 29239<title>Description</title> 29240<para> 29241 Iterates through the list of known PCI devices. If a PCI device is 29242 found with a matching <parameter>vendor</parameter> and <parameter>device</parameter>, the reference count to the 29243 device is incremented and a pointer to its device structure is returned. 29244 Otherwise, <constant>NULL</constant> is returned. A new search is initiated by passing <constant>NULL</constant> 29245 as the <parameter>from</parameter> argument. Otherwise if <parameter>from</parameter> is not <constant>NULL</constant>, searches continue 29246 from next device on the global list. The reference count for <parameter>from</parameter> is 29247 always decremented if it is not <constant>NULL</constant>. 29248</para> 29249</refsect1> 29250</refentry> 29251 29252<refentry id="API-pci-get-class"> 29253<refentryinfo> 29254 <title>LINUX</title> 29255 <productname>Kernel Hackers Manual</productname> 29256 <date>July 2017</date> 29257</refentryinfo> 29258<refmeta> 29259 <refentrytitle><phrase>pci_get_class</phrase></refentrytitle> 29260 <manvolnum>9</manvolnum> 29261 <refmiscinfo class="version">4.1.27</refmiscinfo> 29262</refmeta> 29263<refnamediv> 29264 <refname>pci_get_class</refname> 29265 <refpurpose> 29266 begin or continue searching for a PCI device by class 29267 </refpurpose> 29268</refnamediv> 29269<refsynopsisdiv> 29270 <title>Synopsis</title> 29271 <funcsynopsis><funcprototype> 29272 <funcdef>struct pci_dev * <function>pci_get_class </function></funcdef> 29273 <paramdef>unsigned int <parameter>class</parameter></paramdef> 29274 <paramdef>struct pci_dev * <parameter>from</parameter></paramdef> 29275 </funcprototype></funcsynopsis> 29276</refsynopsisdiv> 29277<refsect1> 29278 <title>Arguments</title> 29279 <variablelist> 29280 <varlistentry> 29281 <term><parameter>class</parameter></term> 29282 <listitem> 29283 <para> 29284 search for a PCI device with this class designation 29285 </para> 29286 </listitem> 29287 </varlistentry> 29288 <varlistentry> 29289 <term><parameter>from</parameter></term> 29290 <listitem> 29291 <para> 29292 Previous PCI device found in search, or <constant>NULL</constant> for new search. 29293 </para> 29294 </listitem> 29295 </varlistentry> 29296 </variablelist> 29297</refsect1> 29298<refsect1> 29299<title>Description</title> 29300<para> 29301 Iterates through the list of known PCI devices. If a PCI device is 29302 found with a matching <parameter>class</parameter>, the reference count to the device is 29303 incremented and a pointer to its device structure is returned. 29304 Otherwise, <constant>NULL</constant> is returned. 29305 A new search is initiated by passing <constant>NULL</constant> as the <parameter>from</parameter> argument. 29306 Otherwise if <parameter>from</parameter> is not <constant>NULL</constant>, searches continue from next device 29307 on the global list. The reference count for <parameter>from</parameter> is always decremented 29308 if it is not <constant>NULL</constant>. 29309</para> 29310</refsect1> 29311</refentry> 29312 29313<refentry id="API-pci-dev-present"> 29314<refentryinfo> 29315 <title>LINUX</title> 29316 <productname>Kernel Hackers Manual</productname> 29317 <date>July 2017</date> 29318</refentryinfo> 29319<refmeta> 29320 <refentrytitle><phrase>pci_dev_present</phrase></refentrytitle> 29321 <manvolnum>9</manvolnum> 29322 <refmiscinfo class="version">4.1.27</refmiscinfo> 29323</refmeta> 29324<refnamediv> 29325 <refname>pci_dev_present</refname> 29326 <refpurpose> 29327 Returns 1 if device matching the device list is present, 0 if not. 29328 </refpurpose> 29329</refnamediv> 29330<refsynopsisdiv> 29331 <title>Synopsis</title> 29332 <funcsynopsis><funcprototype> 29333 <funcdef>int <function>pci_dev_present </function></funcdef> 29334 <paramdef>const struct pci_device_id * <parameter>ids</parameter></paramdef> 29335 </funcprototype></funcsynopsis> 29336</refsynopsisdiv> 29337<refsect1> 29338 <title>Arguments</title> 29339 <variablelist> 29340 <varlistentry> 29341 <term><parameter>ids</parameter></term> 29342 <listitem> 29343 <para> 29344 A pointer to a null terminated list of struct pci_device_id structures 29345 that describe the type of PCI device the caller is trying to find. 29346 </para> 29347 </listitem> 29348 </varlistentry> 29349 </variablelist> 29350</refsect1> 29351<refsect1> 29352<title>Obvious fact</title> 29353<para> 29354 You do not have a reference to any device that might be found 29355 by this function, so if that device is removed from the system right after 29356 this function is finished, the value will be stale. Use this function to 29357 find devices that are usually built into a system, or for a general hint as 29358 to if another device happens to be present at this specific moment in time. 29359</para> 29360</refsect1> 29361</refentry> 29362 29363<!-- drivers/pci/msi.c --> 29364<refentry id="API-pci-msi-vec-count"> 29365<refentryinfo> 29366 <title>LINUX</title> 29367 <productname>Kernel Hackers Manual</productname> 29368 <date>July 2017</date> 29369</refentryinfo> 29370<refmeta> 29371 <refentrytitle><phrase>pci_msi_vec_count</phrase></refentrytitle> 29372 <manvolnum>9</manvolnum> 29373 <refmiscinfo class="version">4.1.27</refmiscinfo> 29374</refmeta> 29375<refnamediv> 29376 <refname>pci_msi_vec_count</refname> 29377 <refpurpose> 29378 Return the number of MSI vectors a device can send 29379 </refpurpose> 29380</refnamediv> 29381<refsynopsisdiv> 29382 <title>Synopsis</title> 29383 <funcsynopsis><funcprototype> 29384 <funcdef>int <function>pci_msi_vec_count </function></funcdef> 29385 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 29386 </funcprototype></funcsynopsis> 29387</refsynopsisdiv> 29388<refsect1> 29389 <title>Arguments</title> 29390 <variablelist> 29391 <varlistentry> 29392 <term><parameter>dev</parameter></term> 29393 <listitem> 29394 <para> 29395 device to report about 29396 </para> 29397 </listitem> 29398 </varlistentry> 29399 </variablelist> 29400</refsect1> 29401<refsect1> 29402<title>Description</title> 29403<para> 29404 This function returns the number of MSI vectors a device requested via 29405 Multiple Message Capable register. It returns a negative errno if the 29406 device is not capable sending MSI interrupts. Otherwise, the call succeeds 29407 and returns a power of two, up to a maximum of 2^5 (32), according to the 29408 MSI specification. 29409</para> 29410</refsect1> 29411</refentry> 29412 29413<refentry id="API-pci-msix-vec-count"> 29414<refentryinfo> 29415 <title>LINUX</title> 29416 <productname>Kernel Hackers Manual</productname> 29417 <date>July 2017</date> 29418</refentryinfo> 29419<refmeta> 29420 <refentrytitle><phrase>pci_msix_vec_count</phrase></refentrytitle> 29421 <manvolnum>9</manvolnum> 29422 <refmiscinfo class="version">4.1.27</refmiscinfo> 29423</refmeta> 29424<refnamediv> 29425 <refname>pci_msix_vec_count</refname> 29426 <refpurpose> 29427 return the number of device's MSI-X table entries 29428 </refpurpose> 29429</refnamediv> 29430<refsynopsisdiv> 29431 <title>Synopsis</title> 29432 <funcsynopsis><funcprototype> 29433 <funcdef>int <function>pci_msix_vec_count </function></funcdef> 29434 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 29435 </funcprototype></funcsynopsis> 29436</refsynopsisdiv> 29437<refsect1> 29438 <title>Arguments</title> 29439 <variablelist> 29440 <varlistentry> 29441 <term><parameter>dev</parameter></term> 29442 <listitem> 29443 <para> 29444 pointer to the pci_dev data structure of MSI-X device function 29445 This function returns the number of device's MSI-X table entries and 29446 therefore the number of MSI-X vectors device is capable of sending. 29447 It returns a negative errno if the device is not capable of sending MSI-X 29448 interrupts. 29449 </para> 29450 </listitem> 29451 </varlistentry> 29452 </variablelist> 29453</refsect1> 29454</refentry> 29455 29456<refentry id="API-pci-enable-msix"> 29457<refentryinfo> 29458 <title>LINUX</title> 29459 <productname>Kernel Hackers Manual</productname> 29460 <date>July 2017</date> 29461</refentryinfo> 29462<refmeta> 29463 <refentrytitle><phrase>pci_enable_msix</phrase></refentrytitle> 29464 <manvolnum>9</manvolnum> 29465 <refmiscinfo class="version">4.1.27</refmiscinfo> 29466</refmeta> 29467<refnamediv> 29468 <refname>pci_enable_msix</refname> 29469 <refpurpose> 29470 configure device's MSI-X capability structure 29471 </refpurpose> 29472</refnamediv> 29473<refsynopsisdiv> 29474 <title>Synopsis</title> 29475 <funcsynopsis><funcprototype> 29476 <funcdef>int <function>pci_enable_msix </function></funcdef> 29477 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 29478 <paramdef>struct msix_entry * <parameter>entries</parameter></paramdef> 29479 <paramdef>int <parameter>nvec</parameter></paramdef> 29480 </funcprototype></funcsynopsis> 29481</refsynopsisdiv> 29482<refsect1> 29483 <title>Arguments</title> 29484 <variablelist> 29485 <varlistentry> 29486 <term><parameter>dev</parameter></term> 29487 <listitem> 29488 <para> 29489 pointer to the pci_dev data structure of MSI-X device function 29490 </para> 29491 </listitem> 29492 </varlistentry> 29493 <varlistentry> 29494 <term><parameter>entries</parameter></term> 29495 <listitem> 29496 <para> 29497 pointer to an array of MSI-X entries 29498 </para> 29499 </listitem> 29500 </varlistentry> 29501 <varlistentry> 29502 <term><parameter>nvec</parameter></term> 29503 <listitem> 29504 <para> 29505 number of MSI-X irqs requested for allocation by device driver 29506 </para> 29507 </listitem> 29508 </varlistentry> 29509 </variablelist> 29510</refsect1> 29511<refsect1> 29512<title>Description</title> 29513<para> 29514 Setup the MSI-X capability structure of device function with the number 29515 of requested irqs upon its software driver call to request for 29516 MSI-X mode enabled on its hardware device function. A return of zero 29517 indicates the successful configuration of MSI-X capability structure 29518 with new allocated MSI-X irqs. A return of < 0 indicates a failure. 29519 Or a return of > 0 indicates that driver request is exceeding the number 29520 of irqs or MSI-X vectors available. Driver should use the returned value to 29521 re-send its request. 29522</para> 29523</refsect1> 29524</refentry> 29525 29526<refentry id="API-pci-msi-enabled"> 29527<refentryinfo> 29528 <title>LINUX</title> 29529 <productname>Kernel Hackers Manual</productname> 29530 <date>July 2017</date> 29531</refentryinfo> 29532<refmeta> 29533 <refentrytitle><phrase>pci_msi_enabled</phrase></refentrytitle> 29534 <manvolnum>9</manvolnum> 29535 <refmiscinfo class="version">4.1.27</refmiscinfo> 29536</refmeta> 29537<refnamediv> 29538 <refname>pci_msi_enabled</refname> 29539 <refpurpose> 29540 is MSI enabled? 29541 </refpurpose> 29542</refnamediv> 29543<refsynopsisdiv> 29544 <title>Synopsis</title> 29545 <funcsynopsis><funcprototype> 29546 <funcdef>int <function>pci_msi_enabled </function></funcdef> 29547 <paramdef> <parameter>void</parameter></paramdef> 29548 </funcprototype></funcsynopsis> 29549</refsynopsisdiv> 29550<refsect1> 29551 <title>Arguments</title> 29552 <variablelist> 29553 <varlistentry> 29554 <term><parameter>void</parameter></term> 29555 <listitem> 29556 <para> 29557 no arguments 29558 </para> 29559 </listitem> 29560 </varlistentry> 29561 </variablelist> 29562</refsect1> 29563<refsect1> 29564<title>Description</title> 29565<para> 29566 </para><para> 29567 29568 Returns true if MSI has not been disabled by the command-line option 29569 pci=nomsi. 29570</para> 29571</refsect1> 29572</refentry> 29573 29574<refentry id="API-pci-enable-msi-range"> 29575<refentryinfo> 29576 <title>LINUX</title> 29577 <productname>Kernel Hackers Manual</productname> 29578 <date>July 2017</date> 29579</refentryinfo> 29580<refmeta> 29581 <refentrytitle><phrase>pci_enable_msi_range</phrase></refentrytitle> 29582 <manvolnum>9</manvolnum> 29583 <refmiscinfo class="version">4.1.27</refmiscinfo> 29584</refmeta> 29585<refnamediv> 29586 <refname>pci_enable_msi_range</refname> 29587 <refpurpose> 29588 configure device's MSI capability structure 29589 </refpurpose> 29590</refnamediv> 29591<refsynopsisdiv> 29592 <title>Synopsis</title> 29593 <funcsynopsis><funcprototype> 29594 <funcdef>int <function>pci_enable_msi_range </function></funcdef> 29595 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 29596 <paramdef>int <parameter>minvec</parameter></paramdef> 29597 <paramdef>int <parameter>maxvec</parameter></paramdef> 29598 </funcprototype></funcsynopsis> 29599</refsynopsisdiv> 29600<refsect1> 29601 <title>Arguments</title> 29602 <variablelist> 29603 <varlistentry> 29604 <term><parameter>dev</parameter></term> 29605 <listitem> 29606 <para> 29607 device to configure 29608 </para> 29609 </listitem> 29610 </varlistentry> 29611 <varlistentry> 29612 <term><parameter>minvec</parameter></term> 29613 <listitem> 29614 <para> 29615 minimal number of interrupts to configure 29616 </para> 29617 </listitem> 29618 </varlistentry> 29619 <varlistentry> 29620 <term><parameter>maxvec</parameter></term> 29621 <listitem> 29622 <para> 29623 maximum number of interrupts to configure 29624 </para> 29625 </listitem> 29626 </varlistentry> 29627 </variablelist> 29628</refsect1> 29629<refsect1> 29630<title>Description</title> 29631<para> 29632 This function tries to allocate a maximum possible number of interrupts in a 29633 range between <parameter>minvec</parameter> and <parameter>maxvec</parameter>. It returns a negative errno if an error 29634 occurs. If it succeeds, it returns the actual number of interrupts allocated 29635 and updates the <parameter>dev</parameter>'s irq member to the lowest new interrupt number; 29636 the other interrupt numbers allocated to this device are consecutive. 29637</para> 29638</refsect1> 29639</refentry> 29640 29641<refentry id="API-pci-enable-msix-range"> 29642<refentryinfo> 29643 <title>LINUX</title> 29644 <productname>Kernel Hackers Manual</productname> 29645 <date>July 2017</date> 29646</refentryinfo> 29647<refmeta> 29648 <refentrytitle><phrase>pci_enable_msix_range</phrase></refentrytitle> 29649 <manvolnum>9</manvolnum> 29650 <refmiscinfo class="version">4.1.27</refmiscinfo> 29651</refmeta> 29652<refnamediv> 29653 <refname>pci_enable_msix_range</refname> 29654 <refpurpose> 29655 configure device's MSI-X capability structure 29656 </refpurpose> 29657</refnamediv> 29658<refsynopsisdiv> 29659 <title>Synopsis</title> 29660 <funcsynopsis><funcprototype> 29661 <funcdef>int <function>pci_enable_msix_range </function></funcdef> 29662 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 29663 <paramdef>struct msix_entry * <parameter>entries</parameter></paramdef> 29664 <paramdef>int <parameter>minvec</parameter></paramdef> 29665 <paramdef>int <parameter>maxvec</parameter></paramdef> 29666 </funcprototype></funcsynopsis> 29667</refsynopsisdiv> 29668<refsect1> 29669 <title>Arguments</title> 29670 <variablelist> 29671 <varlistentry> 29672 <term><parameter>dev</parameter></term> 29673 <listitem> 29674 <para> 29675 pointer to the pci_dev data structure of MSI-X device function 29676 </para> 29677 </listitem> 29678 </varlistentry> 29679 <varlistentry> 29680 <term><parameter>entries</parameter></term> 29681 <listitem> 29682 <para> 29683 pointer to an array of MSI-X entries 29684 </para> 29685 </listitem> 29686 </varlistentry> 29687 <varlistentry> 29688 <term><parameter>minvec</parameter></term> 29689 <listitem> 29690 <para> 29691 minimum number of MSI-X irqs requested 29692 </para> 29693 </listitem> 29694 </varlistentry> 29695 <varlistentry> 29696 <term><parameter>maxvec</parameter></term> 29697 <listitem> 29698 <para> 29699 maximum number of MSI-X irqs requested 29700 </para> 29701 </listitem> 29702 </varlistentry> 29703 </variablelist> 29704</refsect1> 29705<refsect1> 29706<title>Description</title> 29707<para> 29708 Setup the MSI-X capability structure of device function with a maximum 29709 possible number of interrupts in the range between <parameter>minvec</parameter> and <parameter>maxvec</parameter> 29710 upon its software driver call to request for MSI-X mode enabled on its 29711 hardware device function. It returns a negative errno if an error occurs. 29712 If it succeeds, it returns the actual number of interrupts allocated and 29713 indicates the successful configuration of MSI-X capability structure 29714 with new allocated MSI-X interrupts. 29715</para> 29716</refsect1> 29717</refentry> 29718 29719<!-- drivers/pci/bus.c --> 29720<refentry id="API-pci-bus-alloc-resource"> 29721<refentryinfo> 29722 <title>LINUX</title> 29723 <productname>Kernel Hackers Manual</productname> 29724 <date>July 2017</date> 29725</refentryinfo> 29726<refmeta> 29727 <refentrytitle><phrase>pci_bus_alloc_resource</phrase></refentrytitle> 29728 <manvolnum>9</manvolnum> 29729 <refmiscinfo class="version">4.1.27</refmiscinfo> 29730</refmeta> 29731<refnamediv> 29732 <refname>pci_bus_alloc_resource</refname> 29733 <refpurpose> 29734 allocate a resource from a parent bus 29735 </refpurpose> 29736</refnamediv> 29737<refsynopsisdiv> 29738 <title>Synopsis</title> 29739 <funcsynopsis><funcprototype> 29740 <funcdef>int <function>pci_bus_alloc_resource </function></funcdef> 29741 <paramdef>struct pci_bus * <parameter>bus</parameter></paramdef> 29742 <paramdef>struct resource * <parameter>res</parameter></paramdef> 29743 <paramdef>resource_size_t <parameter>size</parameter></paramdef> 29744 <paramdef>resource_size_t <parameter>align</parameter></paramdef> 29745 <paramdef>resource_size_t <parameter>min</parameter></paramdef> 29746 <paramdef>unsigned long <parameter>type_mask</parameter></paramdef> 29747 <paramdef>resource_size_t (*<parameter>alignf</parameter>) 29748 <funcparams>void *, const struct resource *, resource_size_t, resource_size_t</funcparams></paramdef> 29749 <paramdef>void * <parameter>alignf_data</parameter></paramdef> 29750 </funcprototype></funcsynopsis> 29751</refsynopsisdiv> 29752<refsect1> 29753 <title>Arguments</title> 29754 <variablelist> 29755 <varlistentry> 29756 <term><parameter>bus</parameter></term> 29757 <listitem> 29758 <para> 29759 PCI bus 29760 </para> 29761 </listitem> 29762 </varlistentry> 29763 <varlistentry> 29764 <term><parameter>res</parameter></term> 29765 <listitem> 29766 <para> 29767 resource to allocate 29768 </para> 29769 </listitem> 29770 </varlistentry> 29771 <varlistentry> 29772 <term><parameter>size</parameter></term> 29773 <listitem> 29774 <para> 29775 size of resource to allocate 29776 </para> 29777 </listitem> 29778 </varlistentry> 29779 <varlistentry> 29780 <term><parameter>align</parameter></term> 29781 <listitem> 29782 <para> 29783 alignment of resource to allocate 29784 </para> 29785 </listitem> 29786 </varlistentry> 29787 <varlistentry> 29788 <term><parameter>min</parameter></term> 29789 <listitem> 29790 <para> 29791 minimum /proc/iomem address to allocate 29792 </para> 29793 </listitem> 29794 </varlistentry> 29795 <varlistentry> 29796 <term><parameter>type_mask</parameter></term> 29797 <listitem> 29798 <para> 29799 IORESOURCE_* type flags 29800 </para> 29801 </listitem> 29802 </varlistentry> 29803 <varlistentry> 29804 <term><parameter>alignf</parameter></term> 29805 <listitem> 29806 <para> 29807 resource alignment function 29808 </para> 29809 </listitem> 29810 </varlistentry> 29811 <varlistentry> 29812 <term><parameter>alignf_data</parameter></term> 29813 <listitem> 29814 <para> 29815 data argument for resource alignment function 29816 </para> 29817 </listitem> 29818 </varlistentry> 29819 </variablelist> 29820</refsect1> 29821<refsect1> 29822<title>Description</title> 29823<para> 29824 Given the PCI bus a device resides on, the size, minimum address, 29825 alignment and type, try to find an acceptable resource allocation 29826 for a specific device resource. 29827</para> 29828</refsect1> 29829</refentry> 29830 29831<refentry id="API-pci-bus-add-device"> 29832<refentryinfo> 29833 <title>LINUX</title> 29834 <productname>Kernel Hackers Manual</productname> 29835 <date>July 2017</date> 29836</refentryinfo> 29837<refmeta> 29838 <refentrytitle><phrase>pci_bus_add_device</phrase></refentrytitle> 29839 <manvolnum>9</manvolnum> 29840 <refmiscinfo class="version">4.1.27</refmiscinfo> 29841</refmeta> 29842<refnamediv> 29843 <refname>pci_bus_add_device</refname> 29844 <refpurpose> 29845 start driver for a single device 29846 </refpurpose> 29847</refnamediv> 29848<refsynopsisdiv> 29849 <title>Synopsis</title> 29850 <funcsynopsis><funcprototype> 29851 <funcdef>void <function>pci_bus_add_device </function></funcdef> 29852 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 29853 </funcprototype></funcsynopsis> 29854</refsynopsisdiv> 29855<refsect1> 29856 <title>Arguments</title> 29857 <variablelist> 29858 <varlistentry> 29859 <term><parameter>dev</parameter></term> 29860 <listitem> 29861 <para> 29862 device to add 29863 </para> 29864 </listitem> 29865 </varlistentry> 29866 </variablelist> 29867</refsect1> 29868<refsect1> 29869<title>Description</title> 29870<para> 29871 This adds add sysfs entries and start device drivers 29872</para> 29873</refsect1> 29874</refentry> 29875 29876<refentry id="API-pci-bus-add-devices"> 29877<refentryinfo> 29878 <title>LINUX</title> 29879 <productname>Kernel Hackers Manual</productname> 29880 <date>July 2017</date> 29881</refentryinfo> 29882<refmeta> 29883 <refentrytitle><phrase>pci_bus_add_devices</phrase></refentrytitle> 29884 <manvolnum>9</manvolnum> 29885 <refmiscinfo class="version">4.1.27</refmiscinfo> 29886</refmeta> 29887<refnamediv> 29888 <refname>pci_bus_add_devices</refname> 29889 <refpurpose> 29890 start driver for PCI devices 29891 </refpurpose> 29892</refnamediv> 29893<refsynopsisdiv> 29894 <title>Synopsis</title> 29895 <funcsynopsis><funcprototype> 29896 <funcdef>void <function>pci_bus_add_devices </function></funcdef> 29897 <paramdef>const struct pci_bus * <parameter>bus</parameter></paramdef> 29898 </funcprototype></funcsynopsis> 29899</refsynopsisdiv> 29900<refsect1> 29901 <title>Arguments</title> 29902 <variablelist> 29903 <varlistentry> 29904 <term><parameter>bus</parameter></term> 29905 <listitem> 29906 <para> 29907 bus to check for new devices 29908 </para> 29909 </listitem> 29910 </varlistentry> 29911 </variablelist> 29912</refsect1> 29913<refsect1> 29914<title>Description</title> 29915<para> 29916 Start driver for PCI devices and add some sysfs entries. 29917</para> 29918</refsect1> 29919</refentry> 29920 29921<!-- drivers/pci/access.c --> 29922<refentry id="API-pci-bus-set-ops"> 29923<refentryinfo> 29924 <title>LINUX</title> 29925 <productname>Kernel Hackers Manual</productname> 29926 <date>July 2017</date> 29927</refentryinfo> 29928<refmeta> 29929 <refentrytitle><phrase>pci_bus_set_ops</phrase></refentrytitle> 29930 <manvolnum>9</manvolnum> 29931 <refmiscinfo class="version">4.1.27</refmiscinfo> 29932</refmeta> 29933<refnamediv> 29934 <refname>pci_bus_set_ops</refname> 29935 <refpurpose> 29936 Set raw operations of pci bus 29937 </refpurpose> 29938</refnamediv> 29939<refsynopsisdiv> 29940 <title>Synopsis</title> 29941 <funcsynopsis><funcprototype> 29942 <funcdef>struct pci_ops * <function>pci_bus_set_ops </function></funcdef> 29943 <paramdef>struct pci_bus * <parameter>bus</parameter></paramdef> 29944 <paramdef>struct pci_ops * <parameter>ops</parameter></paramdef> 29945 </funcprototype></funcsynopsis> 29946</refsynopsisdiv> 29947<refsect1> 29948 <title>Arguments</title> 29949 <variablelist> 29950 <varlistentry> 29951 <term><parameter>bus</parameter></term> 29952 <listitem> 29953 <para> 29954 pci bus struct 29955 </para> 29956 </listitem> 29957 </varlistentry> 29958 <varlistentry> 29959 <term><parameter>ops</parameter></term> 29960 <listitem> 29961 <para> 29962 new raw operations 29963 </para> 29964 </listitem> 29965 </varlistentry> 29966 </variablelist> 29967</refsect1> 29968<refsect1> 29969<title>Description</title> 29970<para> 29971 Return previous raw operations 29972</para> 29973</refsect1> 29974</refentry> 29975 29976<refentry id="API-pci-read-vpd"> 29977<refentryinfo> 29978 <title>LINUX</title> 29979 <productname>Kernel Hackers Manual</productname> 29980 <date>July 2017</date> 29981</refentryinfo> 29982<refmeta> 29983 <refentrytitle><phrase>pci_read_vpd</phrase></refentrytitle> 29984 <manvolnum>9</manvolnum> 29985 <refmiscinfo class="version">4.1.27</refmiscinfo> 29986</refmeta> 29987<refnamediv> 29988 <refname>pci_read_vpd</refname> 29989 <refpurpose> 29990 Read one entry from Vital Product Data 29991 </refpurpose> 29992</refnamediv> 29993<refsynopsisdiv> 29994 <title>Synopsis</title> 29995 <funcsynopsis><funcprototype> 29996 <funcdef>ssize_t <function>pci_read_vpd </function></funcdef> 29997 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 29998 <paramdef>loff_t <parameter>pos</parameter></paramdef> 29999 <paramdef>size_t <parameter>count</parameter></paramdef> 30000 <paramdef>void * <parameter>buf</parameter></paramdef> 30001 </funcprototype></funcsynopsis> 30002</refsynopsisdiv> 30003<refsect1> 30004 <title>Arguments</title> 30005 <variablelist> 30006 <varlistentry> 30007 <term><parameter>dev</parameter></term> 30008 <listitem> 30009 <para> 30010 pci device struct 30011 </para> 30012 </listitem> 30013 </varlistentry> 30014 <varlistentry> 30015 <term><parameter>pos</parameter></term> 30016 <listitem> 30017 <para> 30018 offset in vpd space 30019 </para> 30020 </listitem> 30021 </varlistentry> 30022 <varlistentry> 30023 <term><parameter>count</parameter></term> 30024 <listitem> 30025 <para> 30026 number of bytes to read 30027 </para> 30028 </listitem> 30029 </varlistentry> 30030 <varlistentry> 30031 <term><parameter>buf</parameter></term> 30032 <listitem> 30033 <para> 30034 pointer to where to store result 30035 </para> 30036 </listitem> 30037 </varlistentry> 30038 </variablelist> 30039</refsect1> 30040</refentry> 30041 30042<refentry id="API-pci-write-vpd"> 30043<refentryinfo> 30044 <title>LINUX</title> 30045 <productname>Kernel Hackers Manual</productname> 30046 <date>July 2017</date> 30047</refentryinfo> 30048<refmeta> 30049 <refentrytitle><phrase>pci_write_vpd</phrase></refentrytitle> 30050 <manvolnum>9</manvolnum> 30051 <refmiscinfo class="version">4.1.27</refmiscinfo> 30052</refmeta> 30053<refnamediv> 30054 <refname>pci_write_vpd</refname> 30055 <refpurpose> 30056 Write entry to Vital Product Data 30057 </refpurpose> 30058</refnamediv> 30059<refsynopsisdiv> 30060 <title>Synopsis</title> 30061 <funcsynopsis><funcprototype> 30062 <funcdef>ssize_t <function>pci_write_vpd </function></funcdef> 30063 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 30064 <paramdef>loff_t <parameter>pos</parameter></paramdef> 30065 <paramdef>size_t <parameter>count</parameter></paramdef> 30066 <paramdef>const void * <parameter>buf</parameter></paramdef> 30067 </funcprototype></funcsynopsis> 30068</refsynopsisdiv> 30069<refsect1> 30070 <title>Arguments</title> 30071 <variablelist> 30072 <varlistentry> 30073 <term><parameter>dev</parameter></term> 30074 <listitem> 30075 <para> 30076 pci device struct 30077 </para> 30078 </listitem> 30079 </varlistentry> 30080 <varlistentry> 30081 <term><parameter>pos</parameter></term> 30082 <listitem> 30083 <para> 30084 offset in vpd space 30085 </para> 30086 </listitem> 30087 </varlistentry> 30088 <varlistentry> 30089 <term><parameter>count</parameter></term> 30090 <listitem> 30091 <para> 30092 number of bytes to write 30093 </para> 30094 </listitem> 30095 </varlistentry> 30096 <varlistentry> 30097 <term><parameter>buf</parameter></term> 30098 <listitem> 30099 <para> 30100 buffer containing write data 30101 </para> 30102 </listitem> 30103 </varlistentry> 30104 </variablelist> 30105</refsect1> 30106</refentry> 30107 30108<refentry id="API-pci-cfg-access-lock"> 30109<refentryinfo> 30110 <title>LINUX</title> 30111 <productname>Kernel Hackers Manual</productname> 30112 <date>July 2017</date> 30113</refentryinfo> 30114<refmeta> 30115 <refentrytitle><phrase>pci_cfg_access_lock</phrase></refentrytitle> 30116 <manvolnum>9</manvolnum> 30117 <refmiscinfo class="version">4.1.27</refmiscinfo> 30118</refmeta> 30119<refnamediv> 30120 <refname>pci_cfg_access_lock</refname> 30121 <refpurpose> 30122 Lock PCI config reads/writes 30123 </refpurpose> 30124</refnamediv> 30125<refsynopsisdiv> 30126 <title>Synopsis</title> 30127 <funcsynopsis><funcprototype> 30128 <funcdef>void <function>pci_cfg_access_lock </function></funcdef> 30129 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 30130 </funcprototype></funcsynopsis> 30131</refsynopsisdiv> 30132<refsect1> 30133 <title>Arguments</title> 30134 <variablelist> 30135 <varlistentry> 30136 <term><parameter>dev</parameter></term> 30137 <listitem> 30138 <para> 30139 pci device struct 30140 </para> 30141 </listitem> 30142 </varlistentry> 30143 </variablelist> 30144</refsect1> 30145<refsect1> 30146<title>Description</title> 30147<para> 30148 When access is locked, any userspace reads or writes to config 30149 space and concurrent lock requests will sleep until access is 30150 allowed via pci_cfg_access_unlocked again. 30151</para> 30152</refsect1> 30153</refentry> 30154 30155<refentry id="API-pci-cfg-access-trylock"> 30156<refentryinfo> 30157 <title>LINUX</title> 30158 <productname>Kernel Hackers Manual</productname> 30159 <date>July 2017</date> 30160</refentryinfo> 30161<refmeta> 30162 <refentrytitle><phrase>pci_cfg_access_trylock</phrase></refentrytitle> 30163 <manvolnum>9</manvolnum> 30164 <refmiscinfo class="version">4.1.27</refmiscinfo> 30165</refmeta> 30166<refnamediv> 30167 <refname>pci_cfg_access_trylock</refname> 30168 <refpurpose> 30169 try to lock PCI config reads/writes 30170 </refpurpose> 30171</refnamediv> 30172<refsynopsisdiv> 30173 <title>Synopsis</title> 30174 <funcsynopsis><funcprototype> 30175 <funcdef>bool <function>pci_cfg_access_trylock </function></funcdef> 30176 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 30177 </funcprototype></funcsynopsis> 30178</refsynopsisdiv> 30179<refsect1> 30180 <title>Arguments</title> 30181 <variablelist> 30182 <varlistentry> 30183 <term><parameter>dev</parameter></term> 30184 <listitem> 30185 <para> 30186 pci device struct 30187 </para> 30188 </listitem> 30189 </varlistentry> 30190 </variablelist> 30191</refsect1> 30192<refsect1> 30193<title>Description</title> 30194<para> 30195 Same as pci_cfg_access_lock, but will return 0 if access is 30196 already locked, 1 otherwise. This function can be used from 30197 atomic contexts. 30198</para> 30199</refsect1> 30200</refentry> 30201 30202<refentry id="API-pci-cfg-access-unlock"> 30203<refentryinfo> 30204 <title>LINUX</title> 30205 <productname>Kernel Hackers Manual</productname> 30206 <date>July 2017</date> 30207</refentryinfo> 30208<refmeta> 30209 <refentrytitle><phrase>pci_cfg_access_unlock</phrase></refentrytitle> 30210 <manvolnum>9</manvolnum> 30211 <refmiscinfo class="version">4.1.27</refmiscinfo> 30212</refmeta> 30213<refnamediv> 30214 <refname>pci_cfg_access_unlock</refname> 30215 <refpurpose> 30216 Unlock PCI config reads/writes 30217 </refpurpose> 30218</refnamediv> 30219<refsynopsisdiv> 30220 <title>Synopsis</title> 30221 <funcsynopsis><funcprototype> 30222 <funcdef>void <function>pci_cfg_access_unlock </function></funcdef> 30223 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 30224 </funcprototype></funcsynopsis> 30225</refsynopsisdiv> 30226<refsect1> 30227 <title>Arguments</title> 30228 <variablelist> 30229 <varlistentry> 30230 <term><parameter>dev</parameter></term> 30231 <listitem> 30232 <para> 30233 pci device struct 30234 </para> 30235 </listitem> 30236 </varlistentry> 30237 </variablelist> 30238</refsect1> 30239<refsect1> 30240<title>Description</title> 30241<para> 30242 This function allows PCI config accesses to resume. 30243</para> 30244</refsect1> 30245</refentry> 30246 30247<!-- drivers/pci/irq.c --> 30248<refentry id="API-pci-lost-interrupt"> 30249<refentryinfo> 30250 <title>LINUX</title> 30251 <productname>Kernel Hackers Manual</productname> 30252 <date>July 2017</date> 30253</refentryinfo> 30254<refmeta> 30255 <refentrytitle><phrase>pci_lost_interrupt</phrase></refentrytitle> 30256 <manvolnum>9</manvolnum> 30257 <refmiscinfo class="version">4.1.27</refmiscinfo> 30258</refmeta> 30259<refnamediv> 30260 <refname>pci_lost_interrupt</refname> 30261 <refpurpose> 30262 reports a lost PCI interrupt 30263 </refpurpose> 30264</refnamediv> 30265<refsynopsisdiv> 30266 <title>Synopsis</title> 30267 <funcsynopsis><funcprototype> 30268 <funcdef>enum pci_lost_interrupt_reason <function>pci_lost_interrupt </function></funcdef> 30269 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 30270 </funcprototype></funcsynopsis> 30271</refsynopsisdiv> 30272<refsect1> 30273 <title>Arguments</title> 30274 <variablelist> 30275 <varlistentry> 30276 <term><parameter>pdev</parameter></term> 30277 <listitem> 30278 <para> 30279 device whose interrupt is lost 30280 </para> 30281 </listitem> 30282 </varlistentry> 30283 </variablelist> 30284</refsect1> 30285<refsect1> 30286<title>Description</title> 30287<para> 30288 The primary function of this routine is to report a lost interrupt 30289 in a standard way which users can recognise (instead of blaming the 30290 driver). 30291</para> 30292</refsect1> 30293<refsect1> 30294<title>Returns</title> 30295<para> 30296 a suggestion for fixing it (although the driver is not required to 30297 act on this). 30298</para> 30299</refsect1> 30300</refentry> 30301 30302<!-- drivers/pci/htirq.c --> 30303<refentry id="API---ht-create-irq"> 30304<refentryinfo> 30305 <title>LINUX</title> 30306 <productname>Kernel Hackers Manual</productname> 30307 <date>July 2017</date> 30308</refentryinfo> 30309<refmeta> 30310 <refentrytitle><phrase>__ht_create_irq</phrase></refentrytitle> 30311 <manvolnum>9</manvolnum> 30312 <refmiscinfo class="version">4.1.27</refmiscinfo> 30313</refmeta> 30314<refnamediv> 30315 <refname>__ht_create_irq</refname> 30316 <refpurpose> 30317 create an irq and attach it to a device. 30318 </refpurpose> 30319</refnamediv> 30320<refsynopsisdiv> 30321 <title>Synopsis</title> 30322 <funcsynopsis><funcprototype> 30323 <funcdef>int <function>__ht_create_irq </function></funcdef> 30324 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 30325 <paramdef>int <parameter>idx</parameter></paramdef> 30326 <paramdef>ht_irq_update_t * <parameter>update</parameter></paramdef> 30327 </funcprototype></funcsynopsis> 30328</refsynopsisdiv> 30329<refsect1> 30330 <title>Arguments</title> 30331 <variablelist> 30332 <varlistentry> 30333 <term><parameter>dev</parameter></term> 30334 <listitem> 30335 <para> 30336 The hypertransport device to find the irq capability on. 30337 </para> 30338 </listitem> 30339 </varlistentry> 30340 <varlistentry> 30341 <term><parameter>idx</parameter></term> 30342 <listitem> 30343 <para> 30344 Which of the possible irqs to attach to. 30345 </para> 30346 </listitem> 30347 </varlistentry> 30348 <varlistentry> 30349 <term><parameter>update</parameter></term> 30350 <listitem> 30351 <para> 30352 Function to be called when changing the htirq message 30353 </para> 30354 </listitem> 30355 </varlistentry> 30356 </variablelist> 30357</refsect1> 30358<refsect1> 30359<title>Description</title> 30360<para> 30361 The irq number of the new irq or a negative error value is returned. 30362</para> 30363</refsect1> 30364</refentry> 30365 30366<refentry id="API-ht-create-irq"> 30367<refentryinfo> 30368 <title>LINUX</title> 30369 <productname>Kernel Hackers Manual</productname> 30370 <date>July 2017</date> 30371</refentryinfo> 30372<refmeta> 30373 <refentrytitle><phrase>ht_create_irq</phrase></refentrytitle> 30374 <manvolnum>9</manvolnum> 30375 <refmiscinfo class="version">4.1.27</refmiscinfo> 30376</refmeta> 30377<refnamediv> 30378 <refname>ht_create_irq</refname> 30379 <refpurpose> 30380 create an irq and attach it to a device. 30381 </refpurpose> 30382</refnamediv> 30383<refsynopsisdiv> 30384 <title>Synopsis</title> 30385 <funcsynopsis><funcprototype> 30386 <funcdef>int <function>ht_create_irq </function></funcdef> 30387 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 30388 <paramdef>int <parameter>idx</parameter></paramdef> 30389 </funcprototype></funcsynopsis> 30390</refsynopsisdiv> 30391<refsect1> 30392 <title>Arguments</title> 30393 <variablelist> 30394 <varlistentry> 30395 <term><parameter>dev</parameter></term> 30396 <listitem> 30397 <para> 30398 The hypertransport device to find the irq capability on. 30399 </para> 30400 </listitem> 30401 </varlistentry> 30402 <varlistentry> 30403 <term><parameter>idx</parameter></term> 30404 <listitem> 30405 <para> 30406 Which of the possible irqs to attach to. 30407 </para> 30408 </listitem> 30409 </varlistentry> 30410 </variablelist> 30411</refsect1> 30412<refsect1> 30413<title>Description</title> 30414<para> 30415 ht_create_irq needs to be called for all hypertransport devices 30416 that generate irqs. 30417 </para><para> 30418 30419 The irq number of the new irq or a negative error value is returned. 30420</para> 30421</refsect1> 30422</refentry> 30423 30424<refentry id="API-ht-destroy-irq"> 30425<refentryinfo> 30426 <title>LINUX</title> 30427 <productname>Kernel Hackers Manual</productname> 30428 <date>July 2017</date> 30429</refentryinfo> 30430<refmeta> 30431 <refentrytitle><phrase>ht_destroy_irq</phrase></refentrytitle> 30432 <manvolnum>9</manvolnum> 30433 <refmiscinfo class="version">4.1.27</refmiscinfo> 30434</refmeta> 30435<refnamediv> 30436 <refname>ht_destroy_irq</refname> 30437 <refpurpose> 30438 destroy an irq created with ht_create_irq 30439 </refpurpose> 30440</refnamediv> 30441<refsynopsisdiv> 30442 <title>Synopsis</title> 30443 <funcsynopsis><funcprototype> 30444 <funcdef>void <function>ht_destroy_irq </function></funcdef> 30445 <paramdef>unsigned int <parameter>irq</parameter></paramdef> 30446 </funcprototype></funcsynopsis> 30447</refsynopsisdiv> 30448<refsect1> 30449 <title>Arguments</title> 30450 <variablelist> 30451 <varlistentry> 30452 <term><parameter>irq</parameter></term> 30453 <listitem> 30454 <para> 30455 irq to be destroyed 30456 </para> 30457 </listitem> 30458 </varlistentry> 30459 </variablelist> 30460</refsect1> 30461<refsect1> 30462<title>Description</title> 30463<para> 30464 This reverses ht_create_irq removing the specified irq from 30465 existence. The irq should be free before this happens. 30466</para> 30467</refsect1> 30468</refentry> 30469 30470<!-- FIXME: Removed for now since no structured comments in source 30471X!Edrivers/pci/hotplug.c 30472--> 30473<!-- drivers/pci/probe.c --> 30474<refentry id="API-pci-scan-slot"> 30475<refentryinfo> 30476 <title>LINUX</title> 30477 <productname>Kernel Hackers Manual</productname> 30478 <date>July 2017</date> 30479</refentryinfo> 30480<refmeta> 30481 <refentrytitle><phrase>pci_scan_slot</phrase></refentrytitle> 30482 <manvolnum>9</manvolnum> 30483 <refmiscinfo class="version">4.1.27</refmiscinfo> 30484</refmeta> 30485<refnamediv> 30486 <refname>pci_scan_slot</refname> 30487 <refpurpose> 30488 scan a PCI slot on a bus for devices. 30489 </refpurpose> 30490</refnamediv> 30491<refsynopsisdiv> 30492 <title>Synopsis</title> 30493 <funcsynopsis><funcprototype> 30494 <funcdef>int <function>pci_scan_slot </function></funcdef> 30495 <paramdef>struct pci_bus * <parameter>bus</parameter></paramdef> 30496 <paramdef>int <parameter>devfn</parameter></paramdef> 30497 </funcprototype></funcsynopsis> 30498</refsynopsisdiv> 30499<refsect1> 30500 <title>Arguments</title> 30501 <variablelist> 30502 <varlistentry> 30503 <term><parameter>bus</parameter></term> 30504 <listitem> 30505 <para> 30506 PCI bus to scan 30507 </para> 30508 </listitem> 30509 </varlistentry> 30510 <varlistentry> 30511 <term><parameter>devfn</parameter></term> 30512 <listitem> 30513 <para> 30514 slot number to scan (must have zero function.) 30515 </para> 30516 </listitem> 30517 </varlistentry> 30518 </variablelist> 30519</refsect1> 30520<refsect1> 30521<title>Description</title> 30522<para> 30523 Scan a PCI slot on the specified PCI bus for devices, adding 30524 discovered devices to the <parameter>bus</parameter>->devices list. New devices 30525 will not have is_added set. 30526 </para><para> 30527 30528 Returns the number of new devices found. 30529</para> 30530</refsect1> 30531</refentry> 30532 30533<refentry id="API-pci-rescan-bus"> 30534<refentryinfo> 30535 <title>LINUX</title> 30536 <productname>Kernel Hackers Manual</productname> 30537 <date>July 2017</date> 30538</refentryinfo> 30539<refmeta> 30540 <refentrytitle><phrase>pci_rescan_bus</phrase></refentrytitle> 30541 <manvolnum>9</manvolnum> 30542 <refmiscinfo class="version">4.1.27</refmiscinfo> 30543</refmeta> 30544<refnamediv> 30545 <refname>pci_rescan_bus</refname> 30546 <refpurpose> 30547 scan a PCI bus for devices. 30548 </refpurpose> 30549</refnamediv> 30550<refsynopsisdiv> 30551 <title>Synopsis</title> 30552 <funcsynopsis><funcprototype> 30553 <funcdef>unsigned int <function>pci_rescan_bus </function></funcdef> 30554 <paramdef>struct pci_bus * <parameter>bus</parameter></paramdef> 30555 </funcprototype></funcsynopsis> 30556</refsynopsisdiv> 30557<refsect1> 30558 <title>Arguments</title> 30559 <variablelist> 30560 <varlistentry> 30561 <term><parameter>bus</parameter></term> 30562 <listitem> 30563 <para> 30564 PCI bus to scan 30565 </para> 30566 </listitem> 30567 </varlistentry> 30568 </variablelist> 30569</refsect1> 30570<refsect1> 30571<title>Description</title> 30572<para> 30573 Scan a PCI bus and child buses for new devices, adds them, 30574 and enables them. 30575 </para><para> 30576 30577 Returns the max number of subordinate bus discovered. 30578</para> 30579</refsect1> 30580</refentry> 30581 30582<!-- drivers/pci/slot.c --> 30583<refentry id="API-pci-create-slot"> 30584<refentryinfo> 30585 <title>LINUX</title> 30586 <productname>Kernel Hackers Manual</productname> 30587 <date>July 2017</date> 30588</refentryinfo> 30589<refmeta> 30590 <refentrytitle><phrase>pci_create_slot</phrase></refentrytitle> 30591 <manvolnum>9</manvolnum> 30592 <refmiscinfo class="version">4.1.27</refmiscinfo> 30593</refmeta> 30594<refnamediv> 30595 <refname>pci_create_slot</refname> 30596 <refpurpose> 30597 create or increment refcount for physical PCI slot 30598 </refpurpose> 30599</refnamediv> 30600<refsynopsisdiv> 30601 <title>Synopsis</title> 30602 <funcsynopsis><funcprototype> 30603 <funcdef>struct pci_slot * <function>pci_create_slot </function></funcdef> 30604 <paramdef>struct pci_bus * <parameter>parent</parameter></paramdef> 30605 <paramdef>int <parameter>slot_nr</parameter></paramdef> 30606 <paramdef>const char * <parameter>name</parameter></paramdef> 30607 <paramdef>struct hotplug_slot * <parameter>hotplug</parameter></paramdef> 30608 </funcprototype></funcsynopsis> 30609</refsynopsisdiv> 30610<refsect1> 30611 <title>Arguments</title> 30612 <variablelist> 30613 <varlistentry> 30614 <term><parameter>parent</parameter></term> 30615 <listitem> 30616 <para> 30617 struct pci_bus of parent bridge 30618 </para> 30619 </listitem> 30620 </varlistentry> 30621 <varlistentry> 30622 <term><parameter>slot_nr</parameter></term> 30623 <listitem> 30624 <para> 30625 PCI_SLOT(pci_dev->devfn) or -1 for placeholder 30626 </para> 30627 </listitem> 30628 </varlistentry> 30629 <varlistentry> 30630 <term><parameter>name</parameter></term> 30631 <listitem> 30632 <para> 30633 user visible string presented in /sys/bus/pci/slots/<name> 30634 </para> 30635 </listitem> 30636 </varlistentry> 30637 <varlistentry> 30638 <term><parameter>hotplug</parameter></term> 30639 <listitem> 30640 <para> 30641 set if caller is hotplug driver, NULL otherwise 30642 </para> 30643 </listitem> 30644 </varlistentry> 30645 </variablelist> 30646</refsect1> 30647<refsect1> 30648<title>Description</title> 30649<para> 30650 PCI slots have first class attributes such as address, speed, width, 30651 and a <structname>struct pci_slot</structname> is used to manage them. This interface will 30652 either return a new <structname>struct pci_slot</structname> to the caller, or if the pci_slot 30653 already exists, its refcount will be incremented. 30654 </para><para> 30655 30656 Slots are uniquely identified by a <parameter>pci_bus</parameter>, <parameter>slot_nr</parameter> tuple. 30657 </para><para> 30658 30659 There are known platforms with broken firmware that assign the same 30660 name to multiple slots. Workaround these broken platforms by renaming 30661 the slots on behalf of the caller. If firmware assigns name N to 30662</para> 30663</refsect1> 30664<refsect1> 30665<title>multiple slots</title> 30666<para> 30667 </para><para> 30668 30669 The first slot is assigned N 30670 The second slot is assigned N-1 30671 The third slot is assigned N-2 30672 etc. 30673</para> 30674</refsect1> 30675<refsect1> 30676<title>Placeholder slots</title> 30677<para> 30678 In most cases, <parameter>pci_bus</parameter>, <parameter>slot_nr</parameter> will be sufficient to uniquely identify 30679 a slot. There is one notable exception - pSeries (rpaphp), where the 30680 <parameter>slot_nr</parameter> cannot be determined until a device is actually inserted into 30681 the slot. In this scenario, the caller may pass -1 for <parameter>slot_nr</parameter>. 30682 </para><para> 30683 30684 The following semantics are imposed when the caller passes <parameter>slot_nr</parameter> == 30685 -1. First, we no longer check for an existing <constant>struct</constant> pci_slot, as there 30686 may be many slots with <parameter>slot_nr</parameter> of -1. The other change in semantics is 30687 user-visible, which is the 'address' parameter presented in sysfs will 30688</para> 30689</refsect1> 30690<refsect1> 30691<title>consist solely of a dddd</title> 30692<para> 30693 bb tuple, where dddd is the PCI domain of the 30694 <constant>struct</constant> pci_bus and bb is the bus number. In other words, the devfn of 30695 the 'placeholder' slot will not be displayed. 30696</para> 30697</refsect1> 30698</refentry> 30699 30700<refentry id="API-pci-destroy-slot"> 30701<refentryinfo> 30702 <title>LINUX</title> 30703 <productname>Kernel Hackers Manual</productname> 30704 <date>July 2017</date> 30705</refentryinfo> 30706<refmeta> 30707 <refentrytitle><phrase>pci_destroy_slot</phrase></refentrytitle> 30708 <manvolnum>9</manvolnum> 30709 <refmiscinfo class="version">4.1.27</refmiscinfo> 30710</refmeta> 30711<refnamediv> 30712 <refname>pci_destroy_slot</refname> 30713 <refpurpose> 30714 decrement refcount for physical PCI slot 30715 </refpurpose> 30716</refnamediv> 30717<refsynopsisdiv> 30718 <title>Synopsis</title> 30719 <funcsynopsis><funcprototype> 30720 <funcdef>void <function>pci_destroy_slot </function></funcdef> 30721 <paramdef>struct pci_slot * <parameter>slot</parameter></paramdef> 30722 </funcprototype></funcsynopsis> 30723</refsynopsisdiv> 30724<refsect1> 30725 <title>Arguments</title> 30726 <variablelist> 30727 <varlistentry> 30728 <term><parameter>slot</parameter></term> 30729 <listitem> 30730 <para> 30731 struct pci_slot to decrement 30732 </para> 30733 </listitem> 30734 </varlistentry> 30735 </variablelist> 30736</refsect1> 30737<refsect1> 30738<title>Description</title> 30739<para> 30740 <constant>struct</constant> pci_slot is refcounted, so destroying them is really easy; we 30741 just call kobject_put on its kobj and let our release methods do the 30742 rest. 30743</para> 30744</refsect1> 30745</refentry> 30746 30747<refentry id="API-pci-hp-create-module-link"> 30748<refentryinfo> 30749 <title>LINUX</title> 30750 <productname>Kernel Hackers Manual</productname> 30751 <date>July 2017</date> 30752</refentryinfo> 30753<refmeta> 30754 <refentrytitle><phrase>pci_hp_create_module_link</phrase></refentrytitle> 30755 <manvolnum>9</manvolnum> 30756 <refmiscinfo class="version">4.1.27</refmiscinfo> 30757</refmeta> 30758<refnamediv> 30759 <refname>pci_hp_create_module_link</refname> 30760 <refpurpose> 30761 create symbolic link to the hotplug driver module. 30762 </refpurpose> 30763</refnamediv> 30764<refsynopsisdiv> 30765 <title>Synopsis</title> 30766 <funcsynopsis><funcprototype> 30767 <funcdef>void <function>pci_hp_create_module_link </function></funcdef> 30768 <paramdef>struct pci_slot * <parameter>pci_slot</parameter></paramdef> 30769 </funcprototype></funcsynopsis> 30770</refsynopsisdiv> 30771<refsect1> 30772 <title>Arguments</title> 30773 <variablelist> 30774 <varlistentry> 30775 <term><parameter>pci_slot</parameter></term> 30776 <listitem> 30777 <para> 30778 struct pci_slot 30779 </para> 30780 </listitem> 30781 </varlistentry> 30782 </variablelist> 30783</refsect1> 30784<refsect1> 30785<title>Description</title> 30786<para> 30787 Helper function for pci_hotplug_core.c to create symbolic link to 30788 the hotplug driver module. 30789</para> 30790</refsect1> 30791</refentry> 30792 30793<refentry id="API-pci-hp-remove-module-link"> 30794<refentryinfo> 30795 <title>LINUX</title> 30796 <productname>Kernel Hackers Manual</productname> 30797 <date>July 2017</date> 30798</refentryinfo> 30799<refmeta> 30800 <refentrytitle><phrase>pci_hp_remove_module_link</phrase></refentrytitle> 30801 <manvolnum>9</manvolnum> 30802 <refmiscinfo class="version">4.1.27</refmiscinfo> 30803</refmeta> 30804<refnamediv> 30805 <refname>pci_hp_remove_module_link</refname> 30806 <refpurpose> 30807 remove symbolic link to the hotplug driver module. 30808 </refpurpose> 30809</refnamediv> 30810<refsynopsisdiv> 30811 <title>Synopsis</title> 30812 <funcsynopsis><funcprototype> 30813 <funcdef>void <function>pci_hp_remove_module_link </function></funcdef> 30814 <paramdef>struct pci_slot * <parameter>pci_slot</parameter></paramdef> 30815 </funcprototype></funcsynopsis> 30816</refsynopsisdiv> 30817<refsect1> 30818 <title>Arguments</title> 30819 <variablelist> 30820 <varlistentry> 30821 <term><parameter>pci_slot</parameter></term> 30822 <listitem> 30823 <para> 30824 struct pci_slot 30825 </para> 30826 </listitem> 30827 </varlistentry> 30828 </variablelist> 30829</refsect1> 30830<refsect1> 30831<title>Description</title> 30832<para> 30833 Helper function for pci_hotplug_core.c to remove symbolic link to 30834 the hotplug driver module. 30835</para> 30836</refsect1> 30837</refentry> 30838 30839<!-- drivers/pci/rom.c --> 30840<refentry id="API-pci-enable-rom"> 30841<refentryinfo> 30842 <title>LINUX</title> 30843 <productname>Kernel Hackers Manual</productname> 30844 <date>July 2017</date> 30845</refentryinfo> 30846<refmeta> 30847 <refentrytitle><phrase>pci_enable_rom</phrase></refentrytitle> 30848 <manvolnum>9</manvolnum> 30849 <refmiscinfo class="version">4.1.27</refmiscinfo> 30850</refmeta> 30851<refnamediv> 30852 <refname>pci_enable_rom</refname> 30853 <refpurpose> 30854 enable ROM decoding for a PCI device 30855 </refpurpose> 30856</refnamediv> 30857<refsynopsisdiv> 30858 <title>Synopsis</title> 30859 <funcsynopsis><funcprototype> 30860 <funcdef>int <function>pci_enable_rom </function></funcdef> 30861 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 30862 </funcprototype></funcsynopsis> 30863</refsynopsisdiv> 30864<refsect1> 30865 <title>Arguments</title> 30866 <variablelist> 30867 <varlistentry> 30868 <term><parameter>pdev</parameter></term> 30869 <listitem> 30870 <para> 30871 PCI device to enable 30872 </para> 30873 </listitem> 30874 </varlistentry> 30875 </variablelist> 30876</refsect1> 30877<refsect1> 30878<title>Description</title> 30879<para> 30880 Enable ROM decoding on <parameter>dev</parameter>. This involves simply turning on the last 30881 bit of the PCI ROM BAR. Note that some cards may share address decoders 30882 between the ROM and other resources, so enabling it may disable access 30883 to MMIO registers or other card memory. 30884</para> 30885</refsect1> 30886</refentry> 30887 30888<refentry id="API-pci-disable-rom"> 30889<refentryinfo> 30890 <title>LINUX</title> 30891 <productname>Kernel Hackers Manual</productname> 30892 <date>July 2017</date> 30893</refentryinfo> 30894<refmeta> 30895 <refentrytitle><phrase>pci_disable_rom</phrase></refentrytitle> 30896 <manvolnum>9</manvolnum> 30897 <refmiscinfo class="version">4.1.27</refmiscinfo> 30898</refmeta> 30899<refnamediv> 30900 <refname>pci_disable_rom</refname> 30901 <refpurpose> 30902 disable ROM decoding for a PCI device 30903 </refpurpose> 30904</refnamediv> 30905<refsynopsisdiv> 30906 <title>Synopsis</title> 30907 <funcsynopsis><funcprototype> 30908 <funcdef>void <function>pci_disable_rom </function></funcdef> 30909 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 30910 </funcprototype></funcsynopsis> 30911</refsynopsisdiv> 30912<refsect1> 30913 <title>Arguments</title> 30914 <variablelist> 30915 <varlistentry> 30916 <term><parameter>pdev</parameter></term> 30917 <listitem> 30918 <para> 30919 PCI device to disable 30920 </para> 30921 </listitem> 30922 </varlistentry> 30923 </variablelist> 30924</refsect1> 30925<refsect1> 30926<title>Description</title> 30927<para> 30928 Disable ROM decoding on a PCI device by turning off the last bit in the 30929 ROM BAR. 30930</para> 30931</refsect1> 30932</refentry> 30933 30934<refentry id="API-pci-map-rom"> 30935<refentryinfo> 30936 <title>LINUX</title> 30937 <productname>Kernel Hackers Manual</productname> 30938 <date>July 2017</date> 30939</refentryinfo> 30940<refmeta> 30941 <refentrytitle><phrase>pci_map_rom</phrase></refentrytitle> 30942 <manvolnum>9</manvolnum> 30943 <refmiscinfo class="version">4.1.27</refmiscinfo> 30944</refmeta> 30945<refnamediv> 30946 <refname>pci_map_rom</refname> 30947 <refpurpose> 30948 map a PCI ROM to kernel space 30949 </refpurpose> 30950</refnamediv> 30951<refsynopsisdiv> 30952 <title>Synopsis</title> 30953 <funcsynopsis><funcprototype> 30954 <funcdef>void __iomem * <function>pci_map_rom </function></funcdef> 30955 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 30956 <paramdef>size_t * <parameter>size</parameter></paramdef> 30957 </funcprototype></funcsynopsis> 30958</refsynopsisdiv> 30959<refsect1> 30960 <title>Arguments</title> 30961 <variablelist> 30962 <varlistentry> 30963 <term><parameter>pdev</parameter></term> 30964 <listitem> 30965 <para> 30966 pointer to pci device struct 30967 </para> 30968 </listitem> 30969 </varlistentry> 30970 <varlistentry> 30971 <term><parameter>size</parameter></term> 30972 <listitem> 30973 <para> 30974 pointer to receive size of pci window over ROM 30975 </para> 30976 </listitem> 30977 </varlistentry> 30978 </variablelist> 30979</refsect1> 30980<refsect1> 30981<title>Return</title> 30982<para> 30983 kernel virtual pointer to image of ROM 30984 </para><para> 30985 30986 Map a PCI ROM into kernel space. If ROM is boot video ROM, 30987 the shadow BIOS copy will be returned instead of the 30988 actual ROM. 30989</para> 30990</refsect1> 30991</refentry> 30992 30993<refentry id="API-pci-unmap-rom"> 30994<refentryinfo> 30995 <title>LINUX</title> 30996 <productname>Kernel Hackers Manual</productname> 30997 <date>July 2017</date> 30998</refentryinfo> 30999<refmeta> 31000 <refentrytitle><phrase>pci_unmap_rom</phrase></refentrytitle> 31001 <manvolnum>9</manvolnum> 31002 <refmiscinfo class="version">4.1.27</refmiscinfo> 31003</refmeta> 31004<refnamediv> 31005 <refname>pci_unmap_rom</refname> 31006 <refpurpose> 31007 unmap the ROM from kernel space 31008 </refpurpose> 31009</refnamediv> 31010<refsynopsisdiv> 31011 <title>Synopsis</title> 31012 <funcsynopsis><funcprototype> 31013 <funcdef>void <function>pci_unmap_rom </function></funcdef> 31014 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 31015 <paramdef>void __iomem * <parameter>rom</parameter></paramdef> 31016 </funcprototype></funcsynopsis> 31017</refsynopsisdiv> 31018<refsect1> 31019 <title>Arguments</title> 31020 <variablelist> 31021 <varlistentry> 31022 <term><parameter>pdev</parameter></term> 31023 <listitem> 31024 <para> 31025 pointer to pci device struct 31026 </para> 31027 </listitem> 31028 </varlistentry> 31029 <varlistentry> 31030 <term><parameter>rom</parameter></term> 31031 <listitem> 31032 <para> 31033 virtual address of the previous mapping 31034 </para> 31035 </listitem> 31036 </varlistentry> 31037 </variablelist> 31038</refsect1> 31039<refsect1> 31040<title>Description</title> 31041<para> 31042 Remove a mapping of a previously mapped ROM 31043</para> 31044</refsect1> 31045</refentry> 31046 31047<refentry id="API-pci-platform-rom"> 31048<refentryinfo> 31049 <title>LINUX</title> 31050 <productname>Kernel Hackers Manual</productname> 31051 <date>July 2017</date> 31052</refentryinfo> 31053<refmeta> 31054 <refentrytitle><phrase>pci_platform_rom</phrase></refentrytitle> 31055 <manvolnum>9</manvolnum> 31056 <refmiscinfo class="version">4.1.27</refmiscinfo> 31057</refmeta> 31058<refnamediv> 31059 <refname>pci_platform_rom</refname> 31060 <refpurpose> 31061 provides a pointer to any ROM image provided by the platform 31062 </refpurpose> 31063</refnamediv> 31064<refsynopsisdiv> 31065 <title>Synopsis</title> 31066 <funcsynopsis><funcprototype> 31067 <funcdef>void __iomem * <function>pci_platform_rom </function></funcdef> 31068 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 31069 <paramdef>size_t * <parameter>size</parameter></paramdef> 31070 </funcprototype></funcsynopsis> 31071</refsynopsisdiv> 31072<refsect1> 31073 <title>Arguments</title> 31074 <variablelist> 31075 <varlistentry> 31076 <term><parameter>pdev</parameter></term> 31077 <listitem> 31078 <para> 31079 pointer to pci device struct 31080 </para> 31081 </listitem> 31082 </varlistentry> 31083 <varlistentry> 31084 <term><parameter>size</parameter></term> 31085 <listitem> 31086 <para> 31087 pointer to receive size of pci window over ROM 31088 </para> 31089 </listitem> 31090 </varlistentry> 31091 </variablelist> 31092</refsect1> 31093</refentry> 31094 31095<!-- drivers/pci/iov.c --> 31096<refentry id="API-pci-enable-sriov"> 31097<refentryinfo> 31098 <title>LINUX</title> 31099 <productname>Kernel Hackers Manual</productname> 31100 <date>July 2017</date> 31101</refentryinfo> 31102<refmeta> 31103 <refentrytitle><phrase>pci_enable_sriov</phrase></refentrytitle> 31104 <manvolnum>9</manvolnum> 31105 <refmiscinfo class="version">4.1.27</refmiscinfo> 31106</refmeta> 31107<refnamediv> 31108 <refname>pci_enable_sriov</refname> 31109 <refpurpose> 31110 enable the SR-IOV capability 31111 </refpurpose> 31112</refnamediv> 31113<refsynopsisdiv> 31114 <title>Synopsis</title> 31115 <funcsynopsis><funcprototype> 31116 <funcdef>int <function>pci_enable_sriov </function></funcdef> 31117 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 31118 <paramdef>int <parameter>nr_virtfn</parameter></paramdef> 31119 </funcprototype></funcsynopsis> 31120</refsynopsisdiv> 31121<refsect1> 31122 <title>Arguments</title> 31123 <variablelist> 31124 <varlistentry> 31125 <term><parameter>dev</parameter></term> 31126 <listitem> 31127 <para> 31128 the PCI device 31129 </para> 31130 </listitem> 31131 </varlistentry> 31132 <varlistentry> 31133 <term><parameter>nr_virtfn</parameter></term> 31134 <listitem> 31135 <para> 31136 number of virtual functions to enable 31137 </para> 31138 </listitem> 31139 </varlistentry> 31140 </variablelist> 31141</refsect1> 31142<refsect1> 31143<title>Description</title> 31144<para> 31145 Returns 0 on success, or negative on failure. 31146</para> 31147</refsect1> 31148</refentry> 31149 31150<refentry id="API-pci-disable-sriov"> 31151<refentryinfo> 31152 <title>LINUX</title> 31153 <productname>Kernel Hackers Manual</productname> 31154 <date>July 2017</date> 31155</refentryinfo> 31156<refmeta> 31157 <refentrytitle><phrase>pci_disable_sriov</phrase></refentrytitle> 31158 <manvolnum>9</manvolnum> 31159 <refmiscinfo class="version">4.1.27</refmiscinfo> 31160</refmeta> 31161<refnamediv> 31162 <refname>pci_disable_sriov</refname> 31163 <refpurpose> 31164 disable the SR-IOV capability 31165 </refpurpose> 31166</refnamediv> 31167<refsynopsisdiv> 31168 <title>Synopsis</title> 31169 <funcsynopsis><funcprototype> 31170 <funcdef>void <function>pci_disable_sriov </function></funcdef> 31171 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 31172 </funcprototype></funcsynopsis> 31173</refsynopsisdiv> 31174<refsect1> 31175 <title>Arguments</title> 31176 <variablelist> 31177 <varlistentry> 31178 <term><parameter>dev</parameter></term> 31179 <listitem> 31180 <para> 31181 the PCI device 31182 </para> 31183 </listitem> 31184 </varlistentry> 31185 </variablelist> 31186</refsect1> 31187</refentry> 31188 31189<refentry id="API-pci-num-vf"> 31190<refentryinfo> 31191 <title>LINUX</title> 31192 <productname>Kernel Hackers Manual</productname> 31193 <date>July 2017</date> 31194</refentryinfo> 31195<refmeta> 31196 <refentrytitle><phrase>pci_num_vf</phrase></refentrytitle> 31197 <manvolnum>9</manvolnum> 31198 <refmiscinfo class="version">4.1.27</refmiscinfo> 31199</refmeta> 31200<refnamediv> 31201 <refname>pci_num_vf</refname> 31202 <refpurpose> 31203 return number of VFs associated with a PF device_release_driver 31204 </refpurpose> 31205</refnamediv> 31206<refsynopsisdiv> 31207 <title>Synopsis</title> 31208 <funcsynopsis><funcprototype> 31209 <funcdef>int <function>pci_num_vf </function></funcdef> 31210 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 31211 </funcprototype></funcsynopsis> 31212</refsynopsisdiv> 31213<refsect1> 31214 <title>Arguments</title> 31215 <variablelist> 31216 <varlistentry> 31217 <term><parameter>dev</parameter></term> 31218 <listitem> 31219 <para> 31220 the PCI device 31221 </para> 31222 </listitem> 31223 </varlistentry> 31224 </variablelist> 31225</refsect1> 31226<refsect1> 31227<title>Description</title> 31228<para> 31229 Returns number of VFs, or 0 if SR-IOV is not enabled. 31230</para> 31231</refsect1> 31232</refentry> 31233 31234<refentry id="API-pci-vfs-assigned"> 31235<refentryinfo> 31236 <title>LINUX</title> 31237 <productname>Kernel Hackers Manual</productname> 31238 <date>July 2017</date> 31239</refentryinfo> 31240<refmeta> 31241 <refentrytitle><phrase>pci_vfs_assigned</phrase></refentrytitle> 31242 <manvolnum>9</manvolnum> 31243 <refmiscinfo class="version">4.1.27</refmiscinfo> 31244</refmeta> 31245<refnamediv> 31246 <refname>pci_vfs_assigned</refname> 31247 <refpurpose> 31248 returns number of VFs are assigned to a guest 31249 </refpurpose> 31250</refnamediv> 31251<refsynopsisdiv> 31252 <title>Synopsis</title> 31253 <funcsynopsis><funcprototype> 31254 <funcdef>int <function>pci_vfs_assigned </function></funcdef> 31255 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 31256 </funcprototype></funcsynopsis> 31257</refsynopsisdiv> 31258<refsect1> 31259 <title>Arguments</title> 31260 <variablelist> 31261 <varlistentry> 31262 <term><parameter>dev</parameter></term> 31263 <listitem> 31264 <para> 31265 the PCI device 31266 </para> 31267 </listitem> 31268 </varlistentry> 31269 </variablelist> 31270</refsect1> 31271<refsect1> 31272<title>Description</title> 31273<para> 31274 Returns number of VFs belonging to this device that are assigned to a guest. 31275 If device is not a physical function returns 0. 31276</para> 31277</refsect1> 31278</refentry> 31279 31280<refentry id="API-pci-sriov-set-totalvfs"> 31281<refentryinfo> 31282 <title>LINUX</title> 31283 <productname>Kernel Hackers Manual</productname> 31284 <date>July 2017</date> 31285</refentryinfo> 31286<refmeta> 31287 <refentrytitle><phrase>pci_sriov_set_totalvfs</phrase></refentrytitle> 31288 <manvolnum>9</manvolnum> 31289 <refmiscinfo class="version">4.1.27</refmiscinfo> 31290</refmeta> 31291<refnamediv> 31292 <refname>pci_sriov_set_totalvfs</refname> 31293 <refpurpose> 31294 - reduce the TotalVFs available 31295 </refpurpose> 31296</refnamediv> 31297<refsynopsisdiv> 31298 <title>Synopsis</title> 31299 <funcsynopsis><funcprototype> 31300 <funcdef>int <function>pci_sriov_set_totalvfs </function></funcdef> 31301 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 31302 <paramdef>u16 <parameter>numvfs</parameter></paramdef> 31303 </funcprototype></funcsynopsis> 31304</refsynopsisdiv> 31305<refsect1> 31306 <title>Arguments</title> 31307 <variablelist> 31308 <varlistentry> 31309 <term><parameter>dev</parameter></term> 31310 <listitem> 31311 <para> 31312 the PCI PF device 31313 </para> 31314 </listitem> 31315 </varlistentry> 31316 <varlistentry> 31317 <term><parameter>numvfs</parameter></term> 31318 <listitem> 31319 <para> 31320 number that should be used for TotalVFs supported 31321 </para> 31322 </listitem> 31323 </varlistentry> 31324 </variablelist> 31325</refsect1> 31326<refsect1> 31327<title>Description</title> 31328<para> 31329 Should be called from PF driver's probe routine with 31330 device's mutex held. 31331 </para><para> 31332 31333 Returns 0 if PF is an SRIOV-capable device and 31334 value of numvfs valid. If not a PF return -ENOSYS; 31335 if numvfs is invalid return -EINVAL; 31336 if VFs already enabled, return -EBUSY. 31337</para> 31338</refsect1> 31339</refentry> 31340 31341<refentry id="API-pci-sriov-get-totalvfs"> 31342<refentryinfo> 31343 <title>LINUX</title> 31344 <productname>Kernel Hackers Manual</productname> 31345 <date>July 2017</date> 31346</refentryinfo> 31347<refmeta> 31348 <refentrytitle><phrase>pci_sriov_get_totalvfs</phrase></refentrytitle> 31349 <manvolnum>9</manvolnum> 31350 <refmiscinfo class="version">4.1.27</refmiscinfo> 31351</refmeta> 31352<refnamediv> 31353 <refname>pci_sriov_get_totalvfs</refname> 31354 <refpurpose> 31355 - get total VFs supported on this device 31356 </refpurpose> 31357</refnamediv> 31358<refsynopsisdiv> 31359 <title>Synopsis</title> 31360 <funcsynopsis><funcprototype> 31361 <funcdef>int <function>pci_sriov_get_totalvfs </function></funcdef> 31362 <paramdef>struct pci_dev * <parameter>dev</parameter></paramdef> 31363 </funcprototype></funcsynopsis> 31364</refsynopsisdiv> 31365<refsect1> 31366 <title>Arguments</title> 31367 <variablelist> 31368 <varlistentry> 31369 <term><parameter>dev</parameter></term> 31370 <listitem> 31371 <para> 31372 the PCI PF device 31373 </para> 31374 </listitem> 31375 </varlistentry> 31376 </variablelist> 31377</refsect1> 31378<refsect1> 31379<title>Description</title> 31380<para> 31381 For a PCIe device with SRIOV support, return the PCIe 31382 SRIOV capability value of TotalVFs or the value of driver_max_VFs 31383 if the driver reduced it. Otherwise 0. 31384</para> 31385</refsect1> 31386</refentry> 31387 31388<!-- drivers/pci/pci-sysfs.c --> 31389<refentry id="API-pci-read-legacy-io"> 31390<refentryinfo> 31391 <title>LINUX</title> 31392 <productname>Kernel Hackers Manual</productname> 31393 <date>July 2017</date> 31394</refentryinfo> 31395<refmeta> 31396 <refentrytitle><phrase>pci_read_legacy_io</phrase></refentrytitle> 31397 <manvolnum>9</manvolnum> 31398 <refmiscinfo class="version">4.1.27</refmiscinfo> 31399</refmeta> 31400<refnamediv> 31401 <refname>pci_read_legacy_io</refname> 31402 <refpurpose> 31403 read byte(s) from legacy I/O port space 31404 </refpurpose> 31405</refnamediv> 31406<refsynopsisdiv> 31407 <title>Synopsis</title> 31408 <funcsynopsis><funcprototype> 31409 <funcdef>ssize_t <function>pci_read_legacy_io </function></funcdef> 31410 <paramdef>struct file * <parameter>filp</parameter></paramdef> 31411 <paramdef>struct kobject * <parameter>kobj</parameter></paramdef> 31412 <paramdef>struct bin_attribute * <parameter>bin_attr</parameter></paramdef> 31413 <paramdef>char * <parameter>buf</parameter></paramdef> 31414 <paramdef>loff_t <parameter>off</parameter></paramdef> 31415 <paramdef>size_t <parameter>count</parameter></paramdef> 31416 </funcprototype></funcsynopsis> 31417</refsynopsisdiv> 31418<refsect1> 31419 <title>Arguments</title> 31420 <variablelist> 31421 <varlistentry> 31422 <term><parameter>filp</parameter></term> 31423 <listitem> 31424 <para> 31425 open sysfs file 31426 </para> 31427 </listitem> 31428 </varlistentry> 31429 <varlistentry> 31430 <term><parameter>kobj</parameter></term> 31431 <listitem> 31432 <para> 31433 kobject corresponding to file to read from 31434 </para> 31435 </listitem> 31436 </varlistentry> 31437 <varlistentry> 31438 <term><parameter>bin_attr</parameter></term> 31439 <listitem> 31440 <para> 31441 struct bin_attribute for this file 31442 </para> 31443 </listitem> 31444 </varlistentry> 31445 <varlistentry> 31446 <term><parameter>buf</parameter></term> 31447 <listitem> 31448 <para> 31449 buffer to store results 31450 </para> 31451 </listitem> 31452 </varlistentry> 31453 <varlistentry> 31454 <term><parameter>off</parameter></term> 31455 <listitem> 31456 <para> 31457 offset into legacy I/O port space 31458 </para> 31459 </listitem> 31460 </varlistentry> 31461 <varlistentry> 31462 <term><parameter>count</parameter></term> 31463 <listitem> 31464 <para> 31465 number of bytes to read 31466 </para> 31467 </listitem> 31468 </varlistentry> 31469 </variablelist> 31470</refsect1> 31471<refsect1> 31472<title>Description</title> 31473<para> 31474 Reads 1, 2, or 4 bytes from legacy I/O port space using an arch specific 31475 callback routine (pci_legacy_read). 31476</para> 31477</refsect1> 31478</refentry> 31479 31480<refentry id="API-pci-write-legacy-io"> 31481<refentryinfo> 31482 <title>LINUX</title> 31483 <productname>Kernel Hackers Manual</productname> 31484 <date>July 2017</date> 31485</refentryinfo> 31486<refmeta> 31487 <refentrytitle><phrase>pci_write_legacy_io</phrase></refentrytitle> 31488 <manvolnum>9</manvolnum> 31489 <refmiscinfo class="version">4.1.27</refmiscinfo> 31490</refmeta> 31491<refnamediv> 31492 <refname>pci_write_legacy_io</refname> 31493 <refpurpose> 31494 write byte(s) to legacy I/O port space 31495 </refpurpose> 31496</refnamediv> 31497<refsynopsisdiv> 31498 <title>Synopsis</title> 31499 <funcsynopsis><funcprototype> 31500 <funcdef>ssize_t <function>pci_write_legacy_io </function></funcdef> 31501 <paramdef>struct file * <parameter>filp</parameter></paramdef> 31502 <paramdef>struct kobject * <parameter>kobj</parameter></paramdef> 31503 <paramdef>struct bin_attribute * <parameter>bin_attr</parameter></paramdef> 31504 <paramdef>char * <parameter>buf</parameter></paramdef> 31505 <paramdef>loff_t <parameter>off</parameter></paramdef> 31506 <paramdef>size_t <parameter>count</parameter></paramdef> 31507 </funcprototype></funcsynopsis> 31508</refsynopsisdiv> 31509<refsect1> 31510 <title>Arguments</title> 31511 <variablelist> 31512 <varlistentry> 31513 <term><parameter>filp</parameter></term> 31514 <listitem> 31515 <para> 31516 open sysfs file 31517 </para> 31518 </listitem> 31519 </varlistentry> 31520 <varlistentry> 31521 <term><parameter>kobj</parameter></term> 31522 <listitem> 31523 <para> 31524 kobject corresponding to file to read from 31525 </para> 31526 </listitem> 31527 </varlistentry> 31528 <varlistentry> 31529 <term><parameter>bin_attr</parameter></term> 31530 <listitem> 31531 <para> 31532 struct bin_attribute for this file 31533 </para> 31534 </listitem> 31535 </varlistentry> 31536 <varlistentry> 31537 <term><parameter>buf</parameter></term> 31538 <listitem> 31539 <para> 31540 buffer containing value to be written 31541 </para> 31542 </listitem> 31543 </varlistentry> 31544 <varlistentry> 31545 <term><parameter>off</parameter></term> 31546 <listitem> 31547 <para> 31548 offset into legacy I/O port space 31549 </para> 31550 </listitem> 31551 </varlistentry> 31552 <varlistentry> 31553 <term><parameter>count</parameter></term> 31554 <listitem> 31555 <para> 31556 number of bytes to write 31557 </para> 31558 </listitem> 31559 </varlistentry> 31560 </variablelist> 31561</refsect1> 31562<refsect1> 31563<title>Description</title> 31564<para> 31565 Writes 1, 2, or 4 bytes from legacy I/O port space using an arch specific 31566 callback routine (pci_legacy_write). 31567</para> 31568</refsect1> 31569</refentry> 31570 31571<refentry id="API-pci-mmap-legacy-mem"> 31572<refentryinfo> 31573 <title>LINUX</title> 31574 <productname>Kernel Hackers Manual</productname> 31575 <date>July 2017</date> 31576</refentryinfo> 31577<refmeta> 31578 <refentrytitle><phrase>pci_mmap_legacy_mem</phrase></refentrytitle> 31579 <manvolnum>9</manvolnum> 31580 <refmiscinfo class="version">4.1.27</refmiscinfo> 31581</refmeta> 31582<refnamediv> 31583 <refname>pci_mmap_legacy_mem</refname> 31584 <refpurpose> 31585 map legacy PCI memory into user memory space 31586 </refpurpose> 31587</refnamediv> 31588<refsynopsisdiv> 31589 <title>Synopsis</title> 31590 <funcsynopsis><funcprototype> 31591 <funcdef>int <function>pci_mmap_legacy_mem </function></funcdef> 31592 <paramdef>struct file * <parameter>filp</parameter></paramdef> 31593 <paramdef>struct kobject * <parameter>kobj</parameter></paramdef> 31594 <paramdef>struct bin_attribute * <parameter>attr</parameter></paramdef> 31595 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 31596 </funcprototype></funcsynopsis> 31597</refsynopsisdiv> 31598<refsect1> 31599 <title>Arguments</title> 31600 <variablelist> 31601 <varlistentry> 31602 <term><parameter>filp</parameter></term> 31603 <listitem> 31604 <para> 31605 open sysfs file 31606 </para> 31607 </listitem> 31608 </varlistentry> 31609 <varlistentry> 31610 <term><parameter>kobj</parameter></term> 31611 <listitem> 31612 <para> 31613 kobject corresponding to device to be mapped 31614 </para> 31615 </listitem> 31616 </varlistentry> 31617 <varlistentry> 31618 <term><parameter>attr</parameter></term> 31619 <listitem> 31620 <para> 31621 struct bin_attribute for this file 31622 </para> 31623 </listitem> 31624 </varlistentry> 31625 <varlistentry> 31626 <term><parameter>vma</parameter></term> 31627 <listitem> 31628 <para> 31629 struct vm_area_struct passed to mmap 31630 </para> 31631 </listitem> 31632 </varlistentry> 31633 </variablelist> 31634</refsect1> 31635<refsect1> 31636<title>Description</title> 31637<para> 31638 Uses an arch specific callback, pci_mmap_legacy_mem_page_range, to mmap 31639 legacy memory space (first meg of bus space) into application virtual 31640 memory space. 31641</para> 31642</refsect1> 31643</refentry> 31644 31645<refentry id="API-pci-mmap-legacy-io"> 31646<refentryinfo> 31647 <title>LINUX</title> 31648 <productname>Kernel Hackers Manual</productname> 31649 <date>July 2017</date> 31650</refentryinfo> 31651<refmeta> 31652 <refentrytitle><phrase>pci_mmap_legacy_io</phrase></refentrytitle> 31653 <manvolnum>9</manvolnum> 31654 <refmiscinfo class="version">4.1.27</refmiscinfo> 31655</refmeta> 31656<refnamediv> 31657 <refname>pci_mmap_legacy_io</refname> 31658 <refpurpose> 31659 map legacy PCI IO into user memory space 31660 </refpurpose> 31661</refnamediv> 31662<refsynopsisdiv> 31663 <title>Synopsis</title> 31664 <funcsynopsis><funcprototype> 31665 <funcdef>int <function>pci_mmap_legacy_io </function></funcdef> 31666 <paramdef>struct file * <parameter>filp</parameter></paramdef> 31667 <paramdef>struct kobject * <parameter>kobj</parameter></paramdef> 31668 <paramdef>struct bin_attribute * <parameter>attr</parameter></paramdef> 31669 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 31670 </funcprototype></funcsynopsis> 31671</refsynopsisdiv> 31672<refsect1> 31673 <title>Arguments</title> 31674 <variablelist> 31675 <varlistentry> 31676 <term><parameter>filp</parameter></term> 31677 <listitem> 31678 <para> 31679 open sysfs file 31680 </para> 31681 </listitem> 31682 </varlistentry> 31683 <varlistentry> 31684 <term><parameter>kobj</parameter></term> 31685 <listitem> 31686 <para> 31687 kobject corresponding to device to be mapped 31688 </para> 31689 </listitem> 31690 </varlistentry> 31691 <varlistentry> 31692 <term><parameter>attr</parameter></term> 31693 <listitem> 31694 <para> 31695 struct bin_attribute for this file 31696 </para> 31697 </listitem> 31698 </varlistentry> 31699 <varlistentry> 31700 <term><parameter>vma</parameter></term> 31701 <listitem> 31702 <para> 31703 struct vm_area_struct passed to mmap 31704 </para> 31705 </listitem> 31706 </varlistentry> 31707 </variablelist> 31708</refsect1> 31709<refsect1> 31710<title>Description</title> 31711<para> 31712 Uses an arch specific callback, pci_mmap_legacy_io_page_range, to mmap 31713 legacy IO space (first meg of bus space) into application virtual 31714 memory space. Returns -ENOSYS if the operation isn't supported 31715</para> 31716</refsect1> 31717</refentry> 31718 31719<refentry id="API-pci-adjust-legacy-attr"> 31720<refentryinfo> 31721 <title>LINUX</title> 31722 <productname>Kernel Hackers Manual</productname> 31723 <date>July 2017</date> 31724</refentryinfo> 31725<refmeta> 31726 <refentrytitle><phrase>pci_adjust_legacy_attr</phrase></refentrytitle> 31727 <manvolnum>9</manvolnum> 31728 <refmiscinfo class="version">4.1.27</refmiscinfo> 31729</refmeta> 31730<refnamediv> 31731 <refname>pci_adjust_legacy_attr</refname> 31732 <refpurpose> 31733 adjustment of legacy file attributes 31734 </refpurpose> 31735</refnamediv> 31736<refsynopsisdiv> 31737 <title>Synopsis</title> 31738 <funcsynopsis><funcprototype> 31739 <funcdef>void <function>pci_adjust_legacy_attr </function></funcdef> 31740 <paramdef>struct pci_bus * <parameter>b</parameter></paramdef> 31741 <paramdef>enum pci_mmap_state <parameter>mmap_type</parameter></paramdef> 31742 </funcprototype></funcsynopsis> 31743</refsynopsisdiv> 31744<refsect1> 31745 <title>Arguments</title> 31746 <variablelist> 31747 <varlistentry> 31748 <term><parameter>b</parameter></term> 31749 <listitem> 31750 <para> 31751 bus to create files under 31752 </para> 31753 </listitem> 31754 </varlistentry> 31755 <varlistentry> 31756 <term><parameter>mmap_type</parameter></term> 31757 <listitem> 31758 <para> 31759 I/O port or memory 31760 </para> 31761 </listitem> 31762 </varlistentry> 31763 </variablelist> 31764</refsect1> 31765<refsect1> 31766<title>Description</title> 31767<para> 31768 Stub implementation. Can be overridden by arch if necessary. 31769</para> 31770</refsect1> 31771</refentry> 31772 31773<refentry id="API-pci-create-legacy-files"> 31774<refentryinfo> 31775 <title>LINUX</title> 31776 <productname>Kernel Hackers Manual</productname> 31777 <date>July 2017</date> 31778</refentryinfo> 31779<refmeta> 31780 <refentrytitle><phrase>pci_create_legacy_files</phrase></refentrytitle> 31781 <manvolnum>9</manvolnum> 31782 <refmiscinfo class="version">4.1.27</refmiscinfo> 31783</refmeta> 31784<refnamediv> 31785 <refname>pci_create_legacy_files</refname> 31786 <refpurpose> 31787 create legacy I/O port and memory files 31788 </refpurpose> 31789</refnamediv> 31790<refsynopsisdiv> 31791 <title>Synopsis</title> 31792 <funcsynopsis><funcprototype> 31793 <funcdef>void <function>pci_create_legacy_files </function></funcdef> 31794 <paramdef>struct pci_bus * <parameter>b</parameter></paramdef> 31795 </funcprototype></funcsynopsis> 31796</refsynopsisdiv> 31797<refsect1> 31798 <title>Arguments</title> 31799 <variablelist> 31800 <varlistentry> 31801 <term><parameter>b</parameter></term> 31802 <listitem> 31803 <para> 31804 bus to create files under 31805 </para> 31806 </listitem> 31807 </varlistentry> 31808 </variablelist> 31809</refsect1> 31810<refsect1> 31811<title>Description</title> 31812<para> 31813 Some platforms allow access to legacy I/O port and ISA memory space on 31814 a per-bus basis. This routine creates the files and ties them into 31815 their associated read, write and mmap files from pci-sysfs.c 31816 </para><para> 31817 31818 On error unwind, but don't propagate the error to the caller 31819 as it is ok to set up the PCI bus without these files. 31820</para> 31821</refsect1> 31822</refentry> 31823 31824<refentry id="API-pci-mmap-resource"> 31825<refentryinfo> 31826 <title>LINUX</title> 31827 <productname>Kernel Hackers Manual</productname> 31828 <date>July 2017</date> 31829</refentryinfo> 31830<refmeta> 31831 <refentrytitle><phrase>pci_mmap_resource</phrase></refentrytitle> 31832 <manvolnum>9</manvolnum> 31833 <refmiscinfo class="version">4.1.27</refmiscinfo> 31834</refmeta> 31835<refnamediv> 31836 <refname>pci_mmap_resource</refname> 31837 <refpurpose> 31838 map a PCI resource into user memory space 31839 </refpurpose> 31840</refnamediv> 31841<refsynopsisdiv> 31842 <title>Synopsis</title> 31843 <funcsynopsis><funcprototype> 31844 <funcdef>int <function>pci_mmap_resource </function></funcdef> 31845 <paramdef>struct kobject * <parameter>kobj</parameter></paramdef> 31846 <paramdef>struct bin_attribute * <parameter>attr</parameter></paramdef> 31847 <paramdef>struct vm_area_struct * <parameter>vma</parameter></paramdef> 31848 <paramdef>int <parameter>write_combine</parameter></paramdef> 31849 </funcprototype></funcsynopsis> 31850</refsynopsisdiv> 31851<refsect1> 31852 <title>Arguments</title> 31853 <variablelist> 31854 <varlistentry> 31855 <term><parameter>kobj</parameter></term> 31856 <listitem> 31857 <para> 31858 kobject for mapping 31859 </para> 31860 </listitem> 31861 </varlistentry> 31862 <varlistentry> 31863 <term><parameter>attr</parameter></term> 31864 <listitem> 31865 <para> 31866 struct bin_attribute for the file being mapped 31867 </para> 31868 </listitem> 31869 </varlistentry> 31870 <varlistentry> 31871 <term><parameter>vma</parameter></term> 31872 <listitem> 31873 <para> 31874 struct vm_area_struct passed into the mmap 31875 </para> 31876 </listitem> 31877 </varlistentry> 31878 <varlistentry> 31879 <term><parameter>write_combine</parameter></term> 31880 <listitem> 31881 <para> 31882 1 for write_combine mapping 31883 </para> 31884 </listitem> 31885 </varlistentry> 31886 </variablelist> 31887</refsect1> 31888<refsect1> 31889<title>Description</title> 31890<para> 31891 Use the regular PCI mapping routines to map a PCI resource into userspace. 31892</para> 31893</refsect1> 31894</refentry> 31895 31896<refentry id="API-pci-remove-resource-files"> 31897<refentryinfo> 31898 <title>LINUX</title> 31899 <productname>Kernel Hackers Manual</productname> 31900 <date>July 2017</date> 31901</refentryinfo> 31902<refmeta> 31903 <refentrytitle><phrase>pci_remove_resource_files</phrase></refentrytitle> 31904 <manvolnum>9</manvolnum> 31905 <refmiscinfo class="version">4.1.27</refmiscinfo> 31906</refmeta> 31907<refnamediv> 31908 <refname>pci_remove_resource_files</refname> 31909 <refpurpose> 31910 cleanup resource files 31911 </refpurpose> 31912</refnamediv> 31913<refsynopsisdiv> 31914 <title>Synopsis</title> 31915 <funcsynopsis><funcprototype> 31916 <funcdef>void <function>pci_remove_resource_files </function></funcdef> 31917 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 31918 </funcprototype></funcsynopsis> 31919</refsynopsisdiv> 31920<refsect1> 31921 <title>Arguments</title> 31922 <variablelist> 31923 <varlistentry> 31924 <term><parameter>pdev</parameter></term> 31925 <listitem> 31926 <para> 31927 dev to cleanup 31928 </para> 31929 </listitem> 31930 </varlistentry> 31931 </variablelist> 31932</refsect1> 31933<refsect1> 31934<title>Description</title> 31935<para> 31936 If we created resource files for <parameter>pdev</parameter>, remove them from sysfs and 31937 free their resources. 31938</para> 31939</refsect1> 31940</refentry> 31941 31942<refentry id="API-pci-create-resource-files"> 31943<refentryinfo> 31944 <title>LINUX</title> 31945 <productname>Kernel Hackers Manual</productname> 31946 <date>July 2017</date> 31947</refentryinfo> 31948<refmeta> 31949 <refentrytitle><phrase>pci_create_resource_files</phrase></refentrytitle> 31950 <manvolnum>9</manvolnum> 31951 <refmiscinfo class="version">4.1.27</refmiscinfo> 31952</refmeta> 31953<refnamediv> 31954 <refname>pci_create_resource_files</refname> 31955 <refpurpose> 31956 create resource files in sysfs for <parameter>dev</parameter> 31957 </refpurpose> 31958</refnamediv> 31959<refsynopsisdiv> 31960 <title>Synopsis</title> 31961 <funcsynopsis><funcprototype> 31962 <funcdef>int <function>pci_create_resource_files </function></funcdef> 31963 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 31964 </funcprototype></funcsynopsis> 31965</refsynopsisdiv> 31966<refsect1> 31967 <title>Arguments</title> 31968 <variablelist> 31969 <varlistentry> 31970 <term><parameter>pdev</parameter></term> 31971 <listitem> 31972 <para> 31973 dev in question 31974 </para> 31975 </listitem> 31976 </varlistentry> 31977 </variablelist> 31978</refsect1> 31979<refsect1> 31980<title>Description</title> 31981<para> 31982 Walk the resources in <parameter>pdev</parameter> creating files for each resource available. 31983</para> 31984</refsect1> 31985</refentry> 31986 31987<refentry id="API-pci-write-rom"> 31988<refentryinfo> 31989 <title>LINUX</title> 31990 <productname>Kernel Hackers Manual</productname> 31991 <date>July 2017</date> 31992</refentryinfo> 31993<refmeta> 31994 <refentrytitle><phrase>pci_write_rom</phrase></refentrytitle> 31995 <manvolnum>9</manvolnum> 31996 <refmiscinfo class="version">4.1.27</refmiscinfo> 31997</refmeta> 31998<refnamediv> 31999 <refname>pci_write_rom</refname> 32000 <refpurpose> 32001 used to enable access to the PCI ROM display 32002 </refpurpose> 32003</refnamediv> 32004<refsynopsisdiv> 32005 <title>Synopsis</title> 32006 <funcsynopsis><funcprototype> 32007 <funcdef>ssize_t <function>pci_write_rom </function></funcdef> 32008 <paramdef>struct file * <parameter>filp</parameter></paramdef> 32009 <paramdef>struct kobject * <parameter>kobj</parameter></paramdef> 32010 <paramdef>struct bin_attribute * <parameter>bin_attr</parameter></paramdef> 32011 <paramdef>char * <parameter>buf</parameter></paramdef> 32012 <paramdef>loff_t <parameter>off</parameter></paramdef> 32013 <paramdef>size_t <parameter>count</parameter></paramdef> 32014 </funcprototype></funcsynopsis> 32015</refsynopsisdiv> 32016<refsect1> 32017 <title>Arguments</title> 32018 <variablelist> 32019 <varlistentry> 32020 <term><parameter>filp</parameter></term> 32021 <listitem> 32022 <para> 32023 sysfs file 32024 </para> 32025 </listitem> 32026 </varlistentry> 32027 <varlistentry> 32028 <term><parameter>kobj</parameter></term> 32029 <listitem> 32030 <para> 32031 kernel object handle 32032 </para> 32033 </listitem> 32034 </varlistentry> 32035 <varlistentry> 32036 <term><parameter>bin_attr</parameter></term> 32037 <listitem> 32038 <para> 32039 struct bin_attribute for this file 32040 </para> 32041 </listitem> 32042 </varlistentry> 32043 <varlistentry> 32044 <term><parameter>buf</parameter></term> 32045 <listitem> 32046 <para> 32047 user input 32048 </para> 32049 </listitem> 32050 </varlistentry> 32051 <varlistentry> 32052 <term><parameter>off</parameter></term> 32053 <listitem> 32054 <para> 32055 file offset 32056 </para> 32057 </listitem> 32058 </varlistentry> 32059 <varlistentry> 32060 <term><parameter>count</parameter></term> 32061 <listitem> 32062 <para> 32063 number of byte in input 32064 </para> 32065 </listitem> 32066 </varlistentry> 32067 </variablelist> 32068</refsect1> 32069<refsect1> 32070<title>Description</title> 32071<para> 32072 writing anything except 0 enables it 32073</para> 32074</refsect1> 32075</refentry> 32076 32077<refentry id="API-pci-read-rom"> 32078<refentryinfo> 32079 <title>LINUX</title> 32080 <productname>Kernel Hackers Manual</productname> 32081 <date>July 2017</date> 32082</refentryinfo> 32083<refmeta> 32084 <refentrytitle><phrase>pci_read_rom</phrase></refentrytitle> 32085 <manvolnum>9</manvolnum> 32086 <refmiscinfo class="version">4.1.27</refmiscinfo> 32087</refmeta> 32088<refnamediv> 32089 <refname>pci_read_rom</refname> 32090 <refpurpose> 32091 read a PCI ROM 32092 </refpurpose> 32093</refnamediv> 32094<refsynopsisdiv> 32095 <title>Synopsis</title> 32096 <funcsynopsis><funcprototype> 32097 <funcdef>ssize_t <function>pci_read_rom </function></funcdef> 32098 <paramdef>struct file * <parameter>filp</parameter></paramdef> 32099 <paramdef>struct kobject * <parameter>kobj</parameter></paramdef> 32100 <paramdef>struct bin_attribute * <parameter>bin_attr</parameter></paramdef> 32101 <paramdef>char * <parameter>buf</parameter></paramdef> 32102 <paramdef>loff_t <parameter>off</parameter></paramdef> 32103 <paramdef>size_t <parameter>count</parameter></paramdef> 32104 </funcprototype></funcsynopsis> 32105</refsynopsisdiv> 32106<refsect1> 32107 <title>Arguments</title> 32108 <variablelist> 32109 <varlistentry> 32110 <term><parameter>filp</parameter></term> 32111 <listitem> 32112 <para> 32113 sysfs file 32114 </para> 32115 </listitem> 32116 </varlistentry> 32117 <varlistentry> 32118 <term><parameter>kobj</parameter></term> 32119 <listitem> 32120 <para> 32121 kernel object handle 32122 </para> 32123 </listitem> 32124 </varlistentry> 32125 <varlistentry> 32126 <term><parameter>bin_attr</parameter></term> 32127 <listitem> 32128 <para> 32129 struct bin_attribute for this file 32130 </para> 32131 </listitem> 32132 </varlistentry> 32133 <varlistentry> 32134 <term><parameter>buf</parameter></term> 32135 <listitem> 32136 <para> 32137 where to put the data we read from the ROM 32138 </para> 32139 </listitem> 32140 </varlistentry> 32141 <varlistentry> 32142 <term><parameter>off</parameter></term> 32143 <listitem> 32144 <para> 32145 file offset 32146 </para> 32147 </listitem> 32148 </varlistentry> 32149 <varlistentry> 32150 <term><parameter>count</parameter></term> 32151 <listitem> 32152 <para> 32153 number of bytes to read 32154 </para> 32155 </listitem> 32156 </varlistentry> 32157 </variablelist> 32158</refsect1> 32159<refsect1> 32160<title>Description</title> 32161<para> 32162 Put <parameter>count</parameter> bytes starting at <parameter>off</parameter> into <parameter>buf</parameter> from the ROM in the PCI 32163 device corresponding to <parameter>kobj</parameter>. 32164</para> 32165</refsect1> 32166</refentry> 32167 32168<refentry id="API-pci-remove-sysfs-dev-files"> 32169<refentryinfo> 32170 <title>LINUX</title> 32171 <productname>Kernel Hackers Manual</productname> 32172 <date>July 2017</date> 32173</refentryinfo> 32174<refmeta> 32175 <refentrytitle><phrase>pci_remove_sysfs_dev_files</phrase></refentrytitle> 32176 <manvolnum>9</manvolnum> 32177 <refmiscinfo class="version">4.1.27</refmiscinfo> 32178</refmeta> 32179<refnamediv> 32180 <refname>pci_remove_sysfs_dev_files</refname> 32181 <refpurpose> 32182 cleanup PCI specific sysfs files 32183 </refpurpose> 32184</refnamediv> 32185<refsynopsisdiv> 32186 <title>Synopsis</title> 32187 <funcsynopsis><funcprototype> 32188 <funcdef>void <function>pci_remove_sysfs_dev_files </function></funcdef> 32189 <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef> 32190 </funcprototype></funcsynopsis> 32191</refsynopsisdiv> 32192<refsect1> 32193 <title>Arguments</title> 32194 <variablelist> 32195 <varlistentry> 32196 <term><parameter>pdev</parameter></term> 32197 <listitem> 32198 <para> 32199 device whose entries we should free 32200 </para> 32201 </listitem> 32202 </varlistentry> 32203 </variablelist> 32204</refsect1> 32205<refsect1> 32206<title>Description</title> 32207<para> 32208 Cleanup when <parameter>pdev</parameter> is removed from sysfs. 32209</para> 32210</refsect1> 32211</refentry> 32212 32213 </sect1> 32214 <sect1><title>PCI Hotplug Support Library</title> 32215<!-- drivers/pci/hotplug/pci_hotplug_core.c --> 32216<refentry id="API---pci-hp-register"> 32217<refentryinfo> 32218 <title>LINUX</title> 32219 <productname>Kernel Hackers Manual</productname> 32220 <date>July 2017</date> 32221</refentryinfo> 32222<refmeta> 32223 <refentrytitle><phrase>__pci_hp_register</phrase></refentrytitle> 32224 <manvolnum>9</manvolnum> 32225 <refmiscinfo class="version">4.1.27</refmiscinfo> 32226</refmeta> 32227<refnamediv> 32228 <refname>__pci_hp_register</refname> 32229 <refpurpose> 32230 register a hotplug_slot with the PCI hotplug subsystem 32231 </refpurpose> 32232</refnamediv> 32233<refsynopsisdiv> 32234 <title>Synopsis</title> 32235 <funcsynopsis><funcprototype> 32236 <funcdef>int <function>__pci_hp_register </function></funcdef> 32237 <paramdef>struct hotplug_slot * <parameter>slot</parameter></paramdef> 32238 <paramdef>struct pci_bus * <parameter>bus</parameter></paramdef> 32239 <paramdef>int <parameter>devnr</parameter></paramdef> 32240 <paramdef>const char * <parameter>name</parameter></paramdef> 32241 <paramdef>struct module * <parameter>owner</parameter></paramdef> 32242 <paramdef>const char * <parameter>mod_name</parameter></paramdef> 32243 </funcprototype></funcsynopsis> 32244</refsynopsisdiv> 32245<refsect1> 32246 <title>Arguments</title> 32247 <variablelist> 32248 <varlistentry> 32249 <term><parameter>slot</parameter></term> 32250 <listitem> 32251 <para> 32252 pointer to the <structname>struct hotplug_slot</structname> to register 32253 </para> 32254 </listitem> 32255 </varlistentry> 32256 <varlistentry> 32257 <term><parameter>bus</parameter></term> 32258 <listitem> 32259 <para> 32260 bus this slot is on 32261 </para> 32262 </listitem> 32263 </varlistentry> 32264 <varlistentry> 32265 <term><parameter>devnr</parameter></term> 32266 <listitem> 32267 <para> 32268 device number 32269 </para> 32270 </listitem> 32271 </varlistentry> 32272 <varlistentry> 32273 <term><parameter>name</parameter></term> 32274 <listitem> 32275 <para> 32276 name registered with kobject core 32277 </para> 32278 </listitem> 32279 </varlistentry> 32280 <varlistentry> 32281 <term><parameter>owner</parameter></term> 32282 <listitem> 32283 <para> 32284 caller module owner 32285 </para> 32286 </listitem> 32287 </varlistentry> 32288 <varlistentry> 32289 <term><parameter>mod_name</parameter></term> 32290 <listitem> 32291 <para> 32292 caller module name 32293 </para> 32294 </listitem> 32295 </varlistentry> 32296 </variablelist> 32297</refsect1> 32298<refsect1> 32299<title>Description</title> 32300<para> 32301 Registers a hotplug slot with the pci hotplug subsystem, which will allow 32302 userspace interaction to the slot. 32303 </para><para> 32304 32305 Returns 0 if successful, anything else for an error. 32306</para> 32307</refsect1> 32308</refentry> 32309 32310<refentry id="API-pci-hp-deregister"> 32311<refentryinfo> 32312 <title>LINUX</title> 32313 <productname>Kernel Hackers Manual</productname> 32314 <date>July 2017</date> 32315</refentryinfo> 32316<refmeta> 32317 <refentrytitle><phrase>pci_hp_deregister</phrase></refentrytitle> 32318 <manvolnum>9</manvolnum> 32319 <refmiscinfo class="version">4.1.27</refmiscinfo> 32320</refmeta> 32321<refnamediv> 32322 <refname>pci_hp_deregister</refname> 32323 <refpurpose> 32324 deregister a hotplug_slot with the PCI hotplug subsystem 32325 </refpurpose> 32326</refnamediv> 32327<refsynopsisdiv> 32328 <title>Synopsis</title> 32329 <funcsynopsis><funcprototype> 32330 <funcdef>int <function>pci_hp_deregister </function></funcdef> 32331 <paramdef>struct hotplug_slot * <parameter>hotplug</parameter></paramdef> 32332 </funcprototype></funcsynopsis> 32333</refsynopsisdiv> 32334<refsect1> 32335 <title>Arguments</title> 32336 <variablelist> 32337 <varlistentry> 32338 <term><parameter>hotplug</parameter></term> 32339 <listitem> 32340 <para> 32341 pointer to the <structname>struct hotplug_slot</structname> to deregister 32342 </para> 32343 </listitem> 32344 </varlistentry> 32345 </variablelist> 32346</refsect1> 32347<refsect1> 32348<title>Description</title> 32349<para> 32350 The <parameter>slot</parameter> must have been registered with the pci hotplug subsystem 32351 previously with a call to <function>pci_hp_register</function>. 32352 </para><para> 32353 32354 Returns 0 if successful, anything else for an error. 32355</para> 32356</refsect1> 32357</refentry> 32358 32359<refentry id="API-pci-hp-change-slot-info"> 32360<refentryinfo> 32361 <title>LINUX</title> 32362 <productname>Kernel Hackers Manual</productname> 32363 <date>July 2017</date> 32364</refentryinfo> 32365<refmeta> 32366 <refentrytitle><phrase>pci_hp_change_slot_info</phrase></refentrytitle> 32367 <manvolnum>9</manvolnum> 32368 <refmiscinfo class="version">4.1.27</refmiscinfo> 32369</refmeta> 32370<refnamediv> 32371 <refname>pci_hp_change_slot_info</refname> 32372 <refpurpose> 32373 changes the slot's information structure in the core 32374 </refpurpose> 32375</refnamediv> 32376<refsynopsisdiv> 32377 <title>Synopsis</title> 32378 <funcsynopsis><funcprototype> 32379 <funcdef>int <function>pci_hp_change_slot_info </function></funcdef> 32380 <paramdef>struct hotplug_slot * <parameter>hotplug</parameter></paramdef> 32381 <paramdef>struct hotplug_slot_info * <parameter>info</parameter></paramdef> 32382 </funcprototype></funcsynopsis> 32383</refsynopsisdiv> 32384<refsect1> 32385 <title>Arguments</title> 32386 <variablelist> 32387 <varlistentry> 32388 <term><parameter>hotplug</parameter></term> 32389 <listitem> 32390 <para> 32391 pointer to the slot whose info has changed 32392 </para> 32393 </listitem> 32394 </varlistentry> 32395 <varlistentry> 32396 <term><parameter>info</parameter></term> 32397 <listitem> 32398 <para> 32399 pointer to the info copy into the slot's info structure 32400 </para> 32401 </listitem> 32402 </varlistentry> 32403 </variablelist> 32404</refsect1> 32405<refsect1> 32406<title>Description</title> 32407<para> 32408 <parameter>slot</parameter> must have been registered with the pci 32409 hotplug subsystem previously with a call to <function>pci_hp_register</function>. 32410 </para><para> 32411 32412 Returns 0 if successful, anything else for an error. 32413</para> 32414</refsect1> 32415</refentry> 32416 32417 </sect1> 32418 </chapter> 32419 32420 <chapter id="firmware"> 32421 <title>Firmware Interfaces</title> 32422 <sect1><title>DMI Interfaces</title> 32423<!-- drivers/firmware/dmi_scan.c --> 32424<refentry id="API-dmi-check-system"> 32425<refentryinfo> 32426 <title>LINUX</title> 32427 <productname>Kernel Hackers Manual</productname> 32428 <date>July 2017</date> 32429</refentryinfo> 32430<refmeta> 32431 <refentrytitle><phrase>dmi_check_system</phrase></refentrytitle> 32432 <manvolnum>9</manvolnum> 32433 <refmiscinfo class="version">4.1.27</refmiscinfo> 32434</refmeta> 32435<refnamediv> 32436 <refname>dmi_check_system</refname> 32437 <refpurpose> 32438 check system DMI data 32439 </refpurpose> 32440</refnamediv> 32441<refsynopsisdiv> 32442 <title>Synopsis</title> 32443 <funcsynopsis><funcprototype> 32444 <funcdef>int <function>dmi_check_system </function></funcdef> 32445 <paramdef>const struct dmi_system_id * <parameter>list</parameter></paramdef> 32446 </funcprototype></funcsynopsis> 32447</refsynopsisdiv> 32448<refsect1> 32449 <title>Arguments</title> 32450 <variablelist> 32451 <varlistentry> 32452 <term><parameter>list</parameter></term> 32453 <listitem> 32454 <para> 32455 array of dmi_system_id structures to match against 32456 All non-null elements of the list must match 32457 their slot's (field index's) data (i.e., each 32458 list string must be a substring of the specified 32459 DMI slot's string data) to be considered a 32460 successful match. 32461 </para> 32462 </listitem> 32463 </varlistentry> 32464 </variablelist> 32465</refsect1> 32466<refsect1> 32467<title>Description</title> 32468<para> 32469 Walk the blacklist table running matching functions until someone 32470 returns non zero or we hit the end. Callback function is called for 32471 each successful match. Returns the number of matches. 32472</para> 32473</refsect1> 32474</refentry> 32475 32476<refentry id="API-dmi-first-match"> 32477<refentryinfo> 32478 <title>LINUX</title> 32479 <productname>Kernel Hackers Manual</productname> 32480 <date>July 2017</date> 32481</refentryinfo> 32482<refmeta> 32483 <refentrytitle><phrase>dmi_first_match</phrase></refentrytitle> 32484 <manvolnum>9</manvolnum> 32485 <refmiscinfo class="version">4.1.27</refmiscinfo> 32486</refmeta> 32487<refnamediv> 32488 <refname>dmi_first_match</refname> 32489 <refpurpose> 32490 find dmi_system_id structure matching system DMI data 32491 </refpurpose> 32492</refnamediv> 32493<refsynopsisdiv> 32494 <title>Synopsis</title> 32495 <funcsynopsis><funcprototype> 32496 <funcdef>const struct dmi_system_id * <function>dmi_first_match </function></funcdef> 32497 <paramdef>const struct dmi_system_id * <parameter>list</parameter></paramdef> 32498 </funcprototype></funcsynopsis> 32499</refsynopsisdiv> 32500<refsect1> 32501 <title>Arguments</title> 32502 <variablelist> 32503 <varlistentry> 32504 <term><parameter>list</parameter></term> 32505 <listitem> 32506 <para> 32507 array of dmi_system_id structures to match against 32508 All non-null elements of the list must match 32509 their slot's (field index's) data (i.e., each 32510 list string must be a substring of the specified 32511 DMI slot's string data) to be considered a 32512 successful match. 32513 </para> 32514 </listitem> 32515 </varlistentry> 32516 </variablelist> 32517</refsect1> 32518<refsect1> 32519<title>Description</title> 32520<para> 32521 Walk the blacklist table until the first match is found. Return the 32522 pointer to the matching entry or NULL if there's no match. 32523</para> 32524</refsect1> 32525</refentry> 32526 32527<refentry id="API-dmi-get-system-info"> 32528<refentryinfo> 32529 <title>LINUX</title> 32530 <productname>Kernel Hackers Manual</productname> 32531 <date>July 2017</date> 32532</refentryinfo> 32533<refmeta> 32534 <refentrytitle><phrase>dmi_get_system_info</phrase></refentrytitle> 32535 <manvolnum>9</manvolnum> 32536 <refmiscinfo class="version">4.1.27</refmiscinfo> 32537</refmeta> 32538<refnamediv> 32539 <refname>dmi_get_system_info</refname> 32540 <refpurpose> 32541 return DMI data value 32542 </refpurpose> 32543</refnamediv> 32544<refsynopsisdiv> 32545 <title>Synopsis</title> 32546 <funcsynopsis><funcprototype> 32547 <funcdef>const char * <function>dmi_get_system_info </function></funcdef> 32548 <paramdef>int <parameter>field</parameter></paramdef> 32549 </funcprototype></funcsynopsis> 32550</refsynopsisdiv> 32551<refsect1> 32552 <title>Arguments</title> 32553 <variablelist> 32554 <varlistentry> 32555 <term><parameter>field</parameter></term> 32556 <listitem> 32557 <para> 32558 data index (see enum dmi_field) 32559 </para> 32560 </listitem> 32561 </varlistentry> 32562 </variablelist> 32563</refsect1> 32564<refsect1> 32565<title>Description</title> 32566<para> 32567 Returns one DMI data value, can be used to perform 32568 complex DMI data checks. 32569</para> 32570</refsect1> 32571</refentry> 32572 32573<refentry id="API-dmi-name-in-vendors"> 32574<refentryinfo> 32575 <title>LINUX</title> 32576 <productname>Kernel Hackers Manual</productname> 32577 <date>July 2017</date> 32578</refentryinfo> 32579<refmeta> 32580 <refentrytitle><phrase>dmi_name_in_vendors</phrase></refentrytitle> 32581 <manvolnum>9</manvolnum> 32582 <refmiscinfo class="version">4.1.27</refmiscinfo> 32583</refmeta> 32584<refnamediv> 32585 <refname>dmi_name_in_vendors</refname> 32586 <refpurpose> 32587 Check if string is in the DMI system or board vendor name 32588 </refpurpose> 32589</refnamediv> 32590<refsynopsisdiv> 32591 <title>Synopsis</title> 32592 <funcsynopsis><funcprototype> 32593 <funcdef>int <function>dmi_name_in_vendors </function></funcdef> 32594 <paramdef>const char * <parameter>str</parameter></paramdef> 32595 </funcprototype></funcsynopsis> 32596</refsynopsisdiv> 32597<refsect1> 32598 <title>Arguments</title> 32599 <variablelist> 32600 <varlistentry> 32601 <term><parameter>str</parameter></term> 32602 <listitem> 32603 <para> 32604 Case sensitive Name 32605 </para> 32606 </listitem> 32607 </varlistentry> 32608 </variablelist> 32609</refsect1> 32610</refentry> 32611 32612<refentry id="API-dmi-find-device"> 32613<refentryinfo> 32614 <title>LINUX</title> 32615 <productname>Kernel Hackers Manual</productname> 32616 <date>July 2017</date> 32617</refentryinfo> 32618<refmeta> 32619 <refentrytitle><phrase>dmi_find_device</phrase></refentrytitle> 32620 <manvolnum>9</manvolnum> 32621 <refmiscinfo class="version">4.1.27</refmiscinfo> 32622</refmeta> 32623<refnamediv> 32624 <refname>dmi_find_device</refname> 32625 <refpurpose> 32626 find onboard device by type/name 32627 </refpurpose> 32628</refnamediv> 32629<refsynopsisdiv> 32630 <title>Synopsis</title> 32631 <funcsynopsis><funcprototype> 32632 <funcdef>const struct dmi_device * <function>dmi_find_device </function></funcdef> 32633 <paramdef>int <parameter>type</parameter></paramdef> 32634 <paramdef>const char * <parameter>name</parameter></paramdef> 32635 <paramdef>const struct dmi_device * <parameter>from</parameter></paramdef> 32636 </funcprototype></funcsynopsis> 32637</refsynopsisdiv> 32638<refsect1> 32639 <title>Arguments</title> 32640 <variablelist> 32641 <varlistentry> 32642 <term><parameter>type</parameter></term> 32643 <listitem> 32644 <para> 32645 device type or <constant>DMI_DEV_TYPE_ANY</constant> to match all device types 32646 </para> 32647 </listitem> 32648 </varlistentry> 32649 <varlistentry> 32650 <term><parameter>name</parameter></term> 32651 <listitem> 32652 <para> 32653 device name string or <constant>NULL</constant> to match all 32654 </para> 32655 </listitem> 32656 </varlistentry> 32657 <varlistentry> 32658 <term><parameter>from</parameter></term> 32659 <listitem> 32660 <para> 32661 previous device found in search, or <constant>NULL</constant> for new search. 32662 </para> 32663 </listitem> 32664 </varlistentry> 32665 </variablelist> 32666</refsect1> 32667<refsect1> 32668<title>Description</title> 32669<para> 32670 Iterates through the list of known onboard devices. If a device is 32671 found with a matching <parameter>vendor</parameter> and <parameter>device</parameter>, a pointer to its device 32672 structure is returned. Otherwise, <constant>NULL</constant> is returned. 32673 A new search is initiated by passing <constant>NULL</constant> as the <parameter>from</parameter> argument. 32674 If <parameter>from</parameter> is not <constant>NULL</constant>, searches continue from next device. 32675</para> 32676</refsect1> 32677</refentry> 32678 32679<refentry id="API-dmi-get-date"> 32680<refentryinfo> 32681 <title>LINUX</title> 32682 <productname>Kernel Hackers Manual</productname> 32683 <date>July 2017</date> 32684</refentryinfo> 32685<refmeta> 32686 <refentrytitle><phrase>dmi_get_date</phrase></refentrytitle> 32687 <manvolnum>9</manvolnum> 32688 <refmiscinfo class="version">4.1.27</refmiscinfo> 32689</refmeta> 32690<refnamediv> 32691 <refname>dmi_get_date</refname> 32692 <refpurpose> 32693 parse a DMI date 32694 </refpurpose> 32695</refnamediv> 32696<refsynopsisdiv> 32697 <title>Synopsis</title> 32698 <funcsynopsis><funcprototype> 32699 <funcdef>bool <function>dmi_get_date </function></funcdef> 32700 <paramdef>int <parameter>field</parameter></paramdef> 32701 <paramdef>int * <parameter>yearp</parameter></paramdef> 32702 <paramdef>int * <parameter>monthp</parameter></paramdef> 32703 <paramdef>int * <parameter>dayp</parameter></paramdef> 32704 </funcprototype></funcsynopsis> 32705</refsynopsisdiv> 32706<refsect1> 32707 <title>Arguments</title> 32708 <variablelist> 32709 <varlistentry> 32710 <term><parameter>field</parameter></term> 32711 <listitem> 32712 <para> 32713 data index (see enum dmi_field) 32714 </para> 32715 </listitem> 32716 </varlistentry> 32717 <varlistentry> 32718 <term><parameter>yearp</parameter></term> 32719 <listitem> 32720 <para> 32721 optional out parameter for the year 32722 </para> 32723 </listitem> 32724 </varlistentry> 32725 <varlistentry> 32726 <term><parameter>monthp</parameter></term> 32727 <listitem> 32728 <para> 32729 optional out parameter for the month 32730 </para> 32731 </listitem> 32732 </varlistentry> 32733 <varlistentry> 32734 <term><parameter>dayp</parameter></term> 32735 <listitem> 32736 <para> 32737 optional out parameter for the day 32738 </para> 32739 </listitem> 32740 </varlistentry> 32741 </variablelist> 32742</refsect1> 32743<refsect1> 32744<title>Description</title> 32745<para> 32746 The date field is assumed to be in the form resembling 32747 [mm[/dd]]/yy[yy] and the result is stored in the out 32748 parameters any or all of which can be omitted. 32749 </para><para> 32750 32751 If the field doesn't exist, all out parameters are set to zero 32752 and false is returned. Otherwise, true is returned with any 32753 invalid part of date set to zero. 32754 </para><para> 32755 32756 On return, year, month and day are guaranteed to be in the 32757 range of [0,9999], [0,12] and [0,31] respectively. 32758</para> 32759</refsect1> 32760</refentry> 32761 32762<refentry id="API-dmi-walk"> 32763<refentryinfo> 32764 <title>LINUX</title> 32765 <productname>Kernel Hackers Manual</productname> 32766 <date>July 2017</date> 32767</refentryinfo> 32768<refmeta> 32769 <refentrytitle><phrase>dmi_walk</phrase></refentrytitle> 32770 <manvolnum>9</manvolnum> 32771 <refmiscinfo class="version">4.1.27</refmiscinfo> 32772</refmeta> 32773<refnamediv> 32774 <refname>dmi_walk</refname> 32775 <refpurpose> 32776 Walk the DMI table and get called back for every record 32777 </refpurpose> 32778</refnamediv> 32779<refsynopsisdiv> 32780 <title>Synopsis</title> 32781 <funcsynopsis><funcprototype> 32782 <funcdef>int <function>dmi_walk </function></funcdef> 32783 <paramdef>void (*<parameter>decode</parameter>) 32784 <funcparams>const struct dmi_header *, void *</funcparams></paramdef> 32785 <paramdef>void * <parameter>private_data</parameter></paramdef> 32786 </funcprototype></funcsynopsis> 32787</refsynopsisdiv> 32788<refsect1> 32789 <title>Arguments</title> 32790 <variablelist> 32791 <varlistentry> 32792 <term><parameter>decode</parameter></term> 32793 <listitem> 32794 <para> 32795 Callback function 32796 </para> 32797 </listitem> 32798 </varlistentry> 32799 <varlistentry> 32800 <term><parameter>private_data</parameter></term> 32801 <listitem> 32802 <para> 32803 Private data to be passed to the callback function 32804 </para> 32805 </listitem> 32806 </varlistentry> 32807 </variablelist> 32808</refsect1> 32809<refsect1> 32810<title>Description</title> 32811<para> 32812 Returns -1 when the DMI table can't be reached, 0 on success. 32813</para> 32814</refsect1> 32815</refentry> 32816 32817<refentry id="API-dmi-match"> 32818<refentryinfo> 32819 <title>LINUX</title> 32820 <productname>Kernel Hackers Manual</productname> 32821 <date>July 2017</date> 32822</refentryinfo> 32823<refmeta> 32824 <refentrytitle><phrase>dmi_match</phrase></refentrytitle> 32825 <manvolnum>9</manvolnum> 32826 <refmiscinfo class="version">4.1.27</refmiscinfo> 32827</refmeta> 32828<refnamediv> 32829 <refname>dmi_match</refname> 32830 <refpurpose> 32831 compare a string to the dmi field (if exists) 32832 </refpurpose> 32833</refnamediv> 32834<refsynopsisdiv> 32835 <title>Synopsis</title> 32836 <funcsynopsis><funcprototype> 32837 <funcdef>bool <function>dmi_match </function></funcdef> 32838 <paramdef>enum dmi_field <parameter>f</parameter></paramdef> 32839 <paramdef>const char * <parameter>str</parameter></paramdef> 32840 </funcprototype></funcsynopsis> 32841</refsynopsisdiv> 32842<refsect1> 32843 <title>Arguments</title> 32844 <variablelist> 32845 <varlistentry> 32846 <term><parameter>f</parameter></term> 32847 <listitem> 32848 <para> 32849 DMI field identifier 32850 </para> 32851 </listitem> 32852 </varlistentry> 32853 <varlistentry> 32854 <term><parameter>str</parameter></term> 32855 <listitem> 32856 <para> 32857 string to compare the DMI field to 32858 </para> 32859 </listitem> 32860 </varlistentry> 32861 </variablelist> 32862</refsect1> 32863<refsect1> 32864<title>Description</title> 32865<para> 32866 Returns true if the requested field equals to the str (including NULL). 32867</para> 32868</refsect1> 32869</refentry> 32870 32871 </sect1> 32872 <sect1><title>EDD Interfaces</title> 32873<!-- drivers/firmware/edd.c --> 32874<refentry id="API-edd-show-raw-data"> 32875<refentryinfo> 32876 <title>LINUX</title> 32877 <productname>Kernel Hackers Manual</productname> 32878 <date>July 2017</date> 32879</refentryinfo> 32880<refmeta> 32881 <refentrytitle><phrase>edd_show_raw_data</phrase></refentrytitle> 32882 <manvolnum>9</manvolnum> 32883 <refmiscinfo class="version">4.1.27</refmiscinfo> 32884</refmeta> 32885<refnamediv> 32886 <refname>edd_show_raw_data</refname> 32887 <refpurpose> 32888 copies raw data to buffer for userspace to parse 32889 </refpurpose> 32890</refnamediv> 32891<refsynopsisdiv> 32892 <title>Synopsis</title> 32893 <funcsynopsis><funcprototype> 32894 <funcdef>ssize_t <function>edd_show_raw_data </function></funcdef> 32895 <paramdef>struct edd_device * <parameter>edev</parameter></paramdef> 32896 <paramdef>char * <parameter>buf</parameter></paramdef> 32897 </funcprototype></funcsynopsis> 32898</refsynopsisdiv> 32899<refsect1> 32900 <title>Arguments</title> 32901 <variablelist> 32902 <varlistentry> 32903 <term><parameter>edev</parameter></term> 32904 <listitem> 32905 <para> 32906 target edd_device 32907 </para> 32908 </listitem> 32909 </varlistentry> 32910 <varlistentry> 32911 <term><parameter>buf</parameter></term> 32912 <listitem> 32913 <para> 32914 output buffer 32915 </para> 32916 </listitem> 32917 </varlistentry> 32918 </variablelist> 32919</refsect1> 32920<refsect1> 32921<title>Returns</title> 32922<para> 32923 number of bytes written, or -EINVAL on failure 32924</para> 32925</refsect1> 32926</refentry> 32927 32928<refentry id="API-edd-release"> 32929<refentryinfo> 32930 <title>LINUX</title> 32931 <productname>Kernel Hackers Manual</productname> 32932 <date>July 2017</date> 32933</refentryinfo> 32934<refmeta> 32935 <refentrytitle><phrase>edd_release</phrase></refentrytitle> 32936 <manvolnum>9</manvolnum> 32937 <refmiscinfo class="version">4.1.27</refmiscinfo> 32938</refmeta> 32939<refnamediv> 32940 <refname>edd_release</refname> 32941 <refpurpose> 32942 free edd structure 32943 </refpurpose> 32944</refnamediv> 32945<refsynopsisdiv> 32946 <title>Synopsis</title> 32947 <funcsynopsis><funcprototype> 32948 <funcdef>void <function>edd_release </function></funcdef> 32949 <paramdef>struct kobject * <parameter>kobj</parameter></paramdef> 32950 </funcprototype></funcsynopsis> 32951</refsynopsisdiv> 32952<refsect1> 32953 <title>Arguments</title> 32954 <variablelist> 32955 <varlistentry> 32956 <term><parameter>kobj</parameter></term> 32957 <listitem> 32958 <para> 32959 kobject of edd structure 32960 </para> 32961 </listitem> 32962 </varlistentry> 32963 </variablelist> 32964</refsect1> 32965<refsect1> 32966<title>Description</title> 32967<para> 32968 This is called when the refcount of the edd structure 32969 reaches 0. This should happen right after we unregister, 32970 but just in case, we use the release callback anyway. 32971</para> 32972</refsect1> 32973</refentry> 32974 32975<refentry id="API-edd-dev-is-type"> 32976<refentryinfo> 32977 <title>LINUX</title> 32978 <productname>Kernel Hackers Manual</productname> 32979 <date>July 2017</date> 32980</refentryinfo> 32981<refmeta> 32982 <refentrytitle><phrase>edd_dev_is_type</phrase></refentrytitle> 32983 <manvolnum>9</manvolnum> 32984 <refmiscinfo class="version">4.1.27</refmiscinfo> 32985</refmeta> 32986<refnamediv> 32987 <refname>edd_dev_is_type</refname> 32988 <refpurpose> 32989 is this EDD device a 'type' device? 32990 </refpurpose> 32991</refnamediv> 32992<refsynopsisdiv> 32993 <title>Synopsis</title> 32994 <funcsynopsis><funcprototype> 32995 <funcdef>int <function>edd_dev_is_type </function></funcdef> 32996 <paramdef>struct edd_device * <parameter>edev</parameter></paramdef> 32997 <paramdef>const char * <parameter>type</parameter></paramdef> 32998 </funcprototype></funcsynopsis> 32999</refsynopsisdiv> 33000<refsect1> 33001 <title>Arguments</title> 33002 <variablelist> 33003 <varlistentry> 33004 <term><parameter>edev</parameter></term> 33005 <listitem> 33006 <para> 33007 target edd_device 33008 </para> 33009 </listitem> 33010 </varlistentry> 33011 <varlistentry> 33012 <term><parameter>type</parameter></term> 33013 <listitem> 33014 <para> 33015 a host bus or interface identifier string per the EDD spec 33016 </para> 33017 </listitem> 33018 </varlistentry> 33019 </variablelist> 33020</refsect1> 33021<refsect1> 33022<title>Description</title> 33023<para> 33024 Returns 1 (TRUE) if it is a 'type' device, 0 otherwise. 33025</para> 33026</refsect1> 33027</refentry> 33028 33029<refentry id="API-edd-get-pci-dev"> 33030<refentryinfo> 33031 <title>LINUX</title> 33032 <productname>Kernel Hackers Manual</productname> 33033 <date>July 2017</date> 33034</refentryinfo> 33035<refmeta> 33036 <refentrytitle><phrase>edd_get_pci_dev</phrase></refentrytitle> 33037 <manvolnum>9</manvolnum> 33038 <refmiscinfo class="version">4.1.27</refmiscinfo> 33039</refmeta> 33040<refnamediv> 33041 <refname>edd_get_pci_dev</refname> 33042 <refpurpose> 33043 finds pci_dev that matches edev 33044 </refpurpose> 33045</refnamediv> 33046<refsynopsisdiv> 33047 <title>Synopsis</title> 33048 <funcsynopsis><funcprototype> 33049 <funcdef>struct pci_dev * <function>edd_get_pci_dev </function></funcdef> 33050 <paramdef>struct edd_device * <parameter>edev</parameter></paramdef> 33051 </funcprototype></funcsynopsis> 33052</refsynopsisdiv> 33053<refsect1> 33054 <title>Arguments</title> 33055 <variablelist> 33056 <varlistentry> 33057 <term><parameter>edev</parameter></term> 33058 <listitem> 33059 <para> 33060 edd_device 33061 </para> 33062 </listitem> 33063 </varlistentry> 33064 </variablelist> 33065</refsect1> 33066<refsect1> 33067<title>Description</title> 33068<para> 33069 Returns pci_dev if found, or NULL 33070</para> 33071</refsect1> 33072</refentry> 33073 33074<refentry id="API-edd-init"> 33075<refentryinfo> 33076 <title>LINUX</title> 33077 <productname>Kernel Hackers Manual</productname> 33078 <date>July 2017</date> 33079</refentryinfo> 33080<refmeta> 33081 <refentrytitle><phrase>edd_init</phrase></refentrytitle> 33082 <manvolnum>9</manvolnum> 33083 <refmiscinfo class="version">4.1.27</refmiscinfo> 33084</refmeta> 33085<refnamediv> 33086 <refname>edd_init</refname> 33087 <refpurpose> 33088 creates sysfs tree of EDD data 33089 </refpurpose> 33090</refnamediv> 33091<refsynopsisdiv> 33092 <title>Synopsis</title> 33093 <funcsynopsis><funcprototype> 33094 <funcdef>int <function>edd_init </function></funcdef> 33095 <paramdef> <parameter>void</parameter></paramdef> 33096 </funcprototype></funcsynopsis> 33097</refsynopsisdiv> 33098<refsect1> 33099 <title>Arguments</title> 33100 <variablelist> 33101 <varlistentry> 33102 <term><parameter>void</parameter></term> 33103 <listitem> 33104 <para> 33105 no arguments 33106 </para> 33107 </listitem> 33108 </varlistentry> 33109 </variablelist> 33110</refsect1> 33111</refentry> 33112 33113 </sect1> 33114 </chapter> 33115 33116 <chapter id="security"> 33117 <title>Security Framework</title> 33118<!-- security/security.c --> 33119<refentry id="API-security-init"> 33120<refentryinfo> 33121 <title>LINUX</title> 33122 <productname>Kernel Hackers Manual</productname> 33123 <date>July 2017</date> 33124</refentryinfo> 33125<refmeta> 33126 <refentrytitle><phrase>security_init</phrase></refentrytitle> 33127 <manvolnum>9</manvolnum> 33128 <refmiscinfo class="version">4.1.27</refmiscinfo> 33129</refmeta> 33130<refnamediv> 33131 <refname>security_init</refname> 33132 <refpurpose> 33133 initializes the security framework 33134 </refpurpose> 33135</refnamediv> 33136<refsynopsisdiv> 33137 <title>Synopsis</title> 33138 <funcsynopsis><funcprototype> 33139 <funcdef>int <function>security_init </function></funcdef> 33140 <paramdef> <parameter>void</parameter></paramdef> 33141 </funcprototype></funcsynopsis> 33142</refsynopsisdiv> 33143<refsect1> 33144 <title>Arguments</title> 33145 <variablelist> 33146 <varlistentry> 33147 <term><parameter>void</parameter></term> 33148 <listitem> 33149 <para> 33150 no arguments 33151 </para> 33152 </listitem> 33153 </varlistentry> 33154 </variablelist> 33155</refsect1> 33156<refsect1> 33157<title>Description</title> 33158<para> 33159 </para><para> 33160 33161 This should be called early in the kernel initialization sequence. 33162</para> 33163</refsect1> 33164</refentry> 33165 33166<refentry id="API-security-module-enable"> 33167<refentryinfo> 33168 <title>LINUX</title> 33169 <productname>Kernel Hackers Manual</productname> 33170 <date>July 2017</date> 33171</refentryinfo> 33172<refmeta> 33173 <refentrytitle><phrase>security_module_enable</phrase></refentrytitle> 33174 <manvolnum>9</manvolnum> 33175 <refmiscinfo class="version">4.1.27</refmiscinfo> 33176</refmeta> 33177<refnamediv> 33178 <refname>security_module_enable</refname> 33179 <refpurpose> 33180 Load given security module on boot ? 33181 </refpurpose> 33182</refnamediv> 33183<refsynopsisdiv> 33184 <title>Synopsis</title> 33185 <funcsynopsis><funcprototype> 33186 <funcdef>int <function>security_module_enable </function></funcdef> 33187 <paramdef>struct security_operations * <parameter>ops</parameter></paramdef> 33188 </funcprototype></funcsynopsis> 33189</refsynopsisdiv> 33190<refsect1> 33191 <title>Arguments</title> 33192 <variablelist> 33193 <varlistentry> 33194 <term><parameter>ops</parameter></term> 33195 <listitem> 33196 <para> 33197 a pointer to the struct security_operations that is to be checked. 33198 </para> 33199 </listitem> 33200 </varlistentry> 33201 </variablelist> 33202</refsect1> 33203<refsect1> 33204<title>Description</title> 33205<para> 33206 Each LSM must pass this method before registering its own operations 33207 to avoid security registration races. This method may also be used 33208 to check if your LSM is currently loaded during kernel initialization. 33209</para> 33210</refsect1> 33211<refsect1> 33212<title>Return true if</title> 33213<para> 33214 -The passed LSM is the one chosen by user at boot time, 33215 -or the passed LSM is configured as the default and the user did not 33216 choose an alternate LSM at boot time. 33217 Otherwise, return false. 33218</para> 33219</refsect1> 33220</refentry> 33221 33222<refentry id="API-register-security"> 33223<refentryinfo> 33224 <title>LINUX</title> 33225 <productname>Kernel Hackers Manual</productname> 33226 <date>July 2017</date> 33227</refentryinfo> 33228<refmeta> 33229 <refentrytitle><phrase>register_security</phrase></refentrytitle> 33230 <manvolnum>9</manvolnum> 33231 <refmiscinfo class="version">4.1.27</refmiscinfo> 33232</refmeta> 33233<refnamediv> 33234 <refname>register_security</refname> 33235 <refpurpose> 33236 registers a security framework with the kernel 33237 </refpurpose> 33238</refnamediv> 33239<refsynopsisdiv> 33240 <title>Synopsis</title> 33241 <funcsynopsis><funcprototype> 33242 <funcdef>int <function>register_security </function></funcdef> 33243 <paramdef>struct security_operations * <parameter>ops</parameter></paramdef> 33244 </funcprototype></funcsynopsis> 33245</refsynopsisdiv> 33246<refsect1> 33247 <title>Arguments</title> 33248 <variablelist> 33249 <varlistentry> 33250 <term><parameter>ops</parameter></term> 33251 <listitem> 33252 <para> 33253 a pointer to the struct security_options that is to be registered 33254 </para> 33255 </listitem> 33256 </varlistentry> 33257 </variablelist> 33258</refsect1> 33259<refsect1> 33260<title>Description</title> 33261<para> 33262 This function allows a security module to register itself with the 33263 kernel security subsystem. Some rudimentary checking is done on the <parameter>ops</parameter> 33264 value passed to this function. You'll need to check first if your LSM 33265 is allowed to register its <parameter>ops</parameter> by calling security_module_enable(<parameter>ops</parameter>). 33266 </para><para> 33267 33268 If there is already a security module registered with the kernel, 33269 an error will be returned. Otherwise <constant>0</constant> is returned on success. 33270</para> 33271</refsect1> 33272</refentry> 33273 33274<!-- security/inode.c --> 33275<refentry id="API-securityfs-create-file"> 33276<refentryinfo> 33277 <title>LINUX</title> 33278 <productname>Kernel Hackers Manual</productname> 33279 <date>July 2017</date> 33280</refentryinfo> 33281<refmeta> 33282 <refentrytitle><phrase>securityfs_create_file</phrase></refentrytitle> 33283 <manvolnum>9</manvolnum> 33284 <refmiscinfo class="version">4.1.27</refmiscinfo> 33285</refmeta> 33286<refnamediv> 33287 <refname>securityfs_create_file</refname> 33288 <refpurpose> 33289 create a file in the securityfs filesystem 33290 </refpurpose> 33291</refnamediv> 33292<refsynopsisdiv> 33293 <title>Synopsis</title> 33294 <funcsynopsis><funcprototype> 33295 <funcdef>struct dentry * <function>securityfs_create_file </function></funcdef> 33296 <paramdef>const char * <parameter>name</parameter></paramdef> 33297 <paramdef>umode_t <parameter>mode</parameter></paramdef> 33298 <paramdef>struct dentry * <parameter>parent</parameter></paramdef> 33299 <paramdef>void * <parameter>data</parameter></paramdef> 33300 <paramdef>const struct file_operations * <parameter>fops</parameter></paramdef> 33301 </funcprototype></funcsynopsis> 33302</refsynopsisdiv> 33303<refsect1> 33304 <title>Arguments</title> 33305 <variablelist> 33306 <varlistentry> 33307 <term><parameter>name</parameter></term> 33308 <listitem> 33309 <para> 33310 a pointer to a string containing the name of the file to create. 33311 </para> 33312 </listitem> 33313 </varlistentry> 33314 <varlistentry> 33315 <term><parameter>mode</parameter></term> 33316 <listitem> 33317 <para> 33318 the permission that the file should have 33319 </para> 33320 </listitem> 33321 </varlistentry> 33322 <varlistentry> 33323 <term><parameter>parent</parameter></term> 33324 <listitem> 33325 <para> 33326 a pointer to the parent dentry for this file. This should be a 33327 directory dentry if set. If this parameter is <constant>NULL</constant>, then the 33328 file will be created in the root of the securityfs filesystem. 33329 </para> 33330 </listitem> 33331 </varlistentry> 33332 <varlistentry> 33333 <term><parameter>data</parameter></term> 33334 <listitem> 33335 <para> 33336 a pointer to something that the caller will want to get to later 33337 on. The inode.i_private pointer will point to this value on 33338 the <function>open</function> call. 33339 </para> 33340 </listitem> 33341 </varlistentry> 33342 <varlistentry> 33343 <term><parameter>fops</parameter></term> 33344 <listitem> 33345 <para> 33346 a pointer to a struct file_operations that should be used for 33347 this file. 33348 </para> 33349 </listitem> 33350 </varlistentry> 33351 </variablelist> 33352</refsect1> 33353<refsect1> 33354<title>Description</title> 33355<para> 33356 This is the basic <quote>create a file</quote> function for securityfs. It allows for a 33357 wide range of flexibility in creating a file, or a directory (if you 33358 want to create a directory, the <function>securityfs_create_dir</function> function is 33359 recommended to be used instead). 33360 </para><para> 33361 33362 This function returns a pointer to a dentry if it succeeds. This 33363 pointer must be passed to the <function>securityfs_remove</function> function when the file is 33364 to be removed (no automatic cleanup happens if your module is unloaded, 33365 you are responsible here). If an error occurs, the function will return 33366 the error value (via ERR_PTR). 33367 </para><para> 33368 33369 If securityfs is not enabled in the kernel, the value <constant>-ENODEV</constant> is 33370 returned. 33371</para> 33372</refsect1> 33373</refentry> 33374 33375<refentry id="API-securityfs-create-dir"> 33376<refentryinfo> 33377 <title>LINUX</title> 33378 <productname>Kernel Hackers Manual</productname> 33379 <date>July 2017</date> 33380</refentryinfo> 33381<refmeta> 33382 <refentrytitle><phrase>securityfs_create_dir</phrase></refentrytitle> 33383 <manvolnum>9</manvolnum> 33384 <refmiscinfo class="version">4.1.27</refmiscinfo> 33385</refmeta> 33386<refnamediv> 33387 <refname>securityfs_create_dir</refname> 33388 <refpurpose> 33389 create a directory in the securityfs filesystem 33390 </refpurpose> 33391</refnamediv> 33392<refsynopsisdiv> 33393 <title>Synopsis</title> 33394 <funcsynopsis><funcprototype> 33395 <funcdef>struct dentry * <function>securityfs_create_dir </function></funcdef> 33396 <paramdef>const char * <parameter>name</parameter></paramdef> 33397 <paramdef>struct dentry * <parameter>parent</parameter></paramdef> 33398 </funcprototype></funcsynopsis> 33399</refsynopsisdiv> 33400<refsect1> 33401 <title>Arguments</title> 33402 <variablelist> 33403 <varlistentry> 33404 <term><parameter>name</parameter></term> 33405 <listitem> 33406 <para> 33407 a pointer to a string containing the name of the directory to 33408 create. 33409 </para> 33410 </listitem> 33411 </varlistentry> 33412 <varlistentry> 33413 <term><parameter>parent</parameter></term> 33414 <listitem> 33415 <para> 33416 a pointer to the parent dentry for this file. This should be a 33417 directory dentry if set. If this parameter is <constant>NULL</constant>, then the 33418 directory will be created in the root of the securityfs filesystem. 33419 </para> 33420 </listitem> 33421 </varlistentry> 33422 </variablelist> 33423</refsect1> 33424<refsect1> 33425<title>Description</title> 33426<para> 33427 This function creates a directory in securityfs with the given <parameter>name</parameter>. 33428 </para><para> 33429 33430 This function returns a pointer to a dentry if it succeeds. This 33431 pointer must be passed to the <function>securityfs_remove</function> function when the file is 33432 to be removed (no automatic cleanup happens if your module is unloaded, 33433 you are responsible here). If an error occurs, <constant>NULL</constant> will be returned. 33434 </para><para> 33435 33436 If securityfs is not enabled in the kernel, the value <constant>-ENODEV</constant> is 33437 returned. It is not wise to check for this value, but rather, check for 33438 <constant>NULL</constant> or !<constant>NULL</constant> instead as to eliminate the need for #ifdef in the calling 33439 code. 33440</para> 33441</refsect1> 33442</refentry> 33443 33444<refentry id="API-securityfs-remove"> 33445<refentryinfo> 33446 <title>LINUX</title> 33447 <productname>Kernel Hackers Manual</productname> 33448 <date>July 2017</date> 33449</refentryinfo> 33450<refmeta> 33451 <refentrytitle><phrase>securityfs_remove</phrase></refentrytitle> 33452 <manvolnum>9</manvolnum> 33453 <refmiscinfo class="version">4.1.27</refmiscinfo> 33454</refmeta> 33455<refnamediv> 33456 <refname>securityfs_remove</refname> 33457 <refpurpose> 33458 removes a file or directory from the securityfs filesystem 33459 </refpurpose> 33460</refnamediv> 33461<refsynopsisdiv> 33462 <title>Synopsis</title> 33463 <funcsynopsis><funcprototype> 33464 <funcdef>void <function>securityfs_remove </function></funcdef> 33465 <paramdef>struct dentry * <parameter>dentry</parameter></paramdef> 33466 </funcprototype></funcsynopsis> 33467</refsynopsisdiv> 33468<refsect1> 33469 <title>Arguments</title> 33470 <variablelist> 33471 <varlistentry> 33472 <term><parameter>dentry</parameter></term> 33473 <listitem> 33474 <para> 33475 a pointer to a the dentry of the file or directory to be removed. 33476 </para> 33477 </listitem> 33478 </varlistentry> 33479 </variablelist> 33480</refsect1> 33481<refsect1> 33482<title>Description</title> 33483<para> 33484 This function removes a file or directory in securityfs that was previously 33485 created with a call to another securityfs function (like 33486 <function>securityfs_create_file</function> or variants thereof.) 33487 </para><para> 33488 33489 This function is required to be called in order for the file to be 33490 removed. No automatic cleanup of files will happen when a module is 33491 removed; you are responsible here. 33492</para> 33493</refsect1> 33494</refentry> 33495 33496 </chapter> 33497 33498 <chapter id="audit"> 33499 <title>Audit Interfaces</title> 33500<!-- kernel/audit.c --> 33501<refentry id="API-audit-log-start"> 33502<refentryinfo> 33503 <title>LINUX</title> 33504 <productname>Kernel Hackers Manual</productname> 33505 <date>July 2017</date> 33506</refentryinfo> 33507<refmeta> 33508 <refentrytitle><phrase>audit_log_start</phrase></refentrytitle> 33509 <manvolnum>9</manvolnum> 33510 <refmiscinfo class="version">4.1.27</refmiscinfo> 33511</refmeta> 33512<refnamediv> 33513 <refname>audit_log_start</refname> 33514 <refpurpose> 33515 obtain an audit buffer 33516 </refpurpose> 33517</refnamediv> 33518<refsynopsisdiv> 33519 <title>Synopsis</title> 33520 <funcsynopsis><funcprototype> 33521 <funcdef>struct audit_buffer * <function>audit_log_start </function></funcdef> 33522 <paramdef>struct audit_context * <parameter>ctx</parameter></paramdef> 33523 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 33524 <paramdef>int <parameter>type</parameter></paramdef> 33525 </funcprototype></funcsynopsis> 33526</refsynopsisdiv> 33527<refsect1> 33528 <title>Arguments</title> 33529 <variablelist> 33530 <varlistentry> 33531 <term><parameter>ctx</parameter></term> 33532 <listitem> 33533 <para> 33534 audit_context (may be NULL) 33535 </para> 33536 </listitem> 33537 </varlistentry> 33538 <varlistentry> 33539 <term><parameter>gfp_mask</parameter></term> 33540 <listitem> 33541 <para> 33542 type of allocation 33543 </para> 33544 </listitem> 33545 </varlistentry> 33546 <varlistentry> 33547 <term><parameter>type</parameter></term> 33548 <listitem> 33549 <para> 33550 audit message type 33551 </para> 33552 </listitem> 33553 </varlistentry> 33554 </variablelist> 33555</refsect1> 33556<refsect1> 33557<title>Description</title> 33558<para> 33559 Returns audit_buffer pointer on success or NULL on error. 33560 </para><para> 33561 33562 Obtain an audit buffer. This routine does locking to obtain the 33563 audit buffer, but then no locking is required for calls to 33564 audit_log_*format. If the task (ctx) is a task that is currently in a 33565 syscall, then the syscall is marked as auditable and an audit record 33566 will be written at syscall exit. If there is no associated task, then 33567 task context (ctx) should be NULL. 33568</para> 33569</refsect1> 33570</refentry> 33571 33572<refentry id="API-audit-log-format"> 33573<refentryinfo> 33574 <title>LINUX</title> 33575 <productname>Kernel Hackers Manual</productname> 33576 <date>July 2017</date> 33577</refentryinfo> 33578<refmeta> 33579 <refentrytitle><phrase>audit_log_format</phrase></refentrytitle> 33580 <manvolnum>9</manvolnum> 33581 <refmiscinfo class="version">4.1.27</refmiscinfo> 33582</refmeta> 33583<refnamediv> 33584 <refname>audit_log_format</refname> 33585 <refpurpose> 33586 format a message into the audit buffer. 33587 </refpurpose> 33588</refnamediv> 33589<refsynopsisdiv> 33590 <title>Synopsis</title> 33591 <funcsynopsis><funcprototype> 33592 <funcdef>void <function>audit_log_format </function></funcdef> 33593 <paramdef>struct audit_buffer * <parameter>ab</parameter></paramdef> 33594 <paramdef>const char * <parameter>fmt</parameter></paramdef> 33595 <paramdef> <parameter>...</parameter></paramdef> 33596 </funcprototype></funcsynopsis> 33597</refsynopsisdiv> 33598<refsect1> 33599 <title>Arguments</title> 33600 <variablelist> 33601 <varlistentry> 33602 <term><parameter>ab</parameter></term> 33603 <listitem> 33604 <para> 33605 audit_buffer 33606 </para> 33607 </listitem> 33608 </varlistentry> 33609 <varlistentry> 33610 <term><parameter>fmt</parameter></term> 33611 <listitem> 33612 <para> 33613 format string 33614 @...: optional parameters matching <parameter>fmt</parameter> string 33615 </para> 33616 </listitem> 33617 </varlistentry> 33618 <varlistentry> 33619 <term><parameter>...</parameter></term> 33620 <listitem> 33621 <para> 33622 variable arguments 33623 </para> 33624 </listitem> 33625 </varlistentry> 33626 </variablelist> 33627</refsect1> 33628<refsect1> 33629<title>Description</title> 33630<para> 33631 All the work is done in audit_log_vformat. 33632</para> 33633</refsect1> 33634</refentry> 33635 33636<refentry id="API-audit-log-end"> 33637<refentryinfo> 33638 <title>LINUX</title> 33639 <productname>Kernel Hackers Manual</productname> 33640 <date>July 2017</date> 33641</refentryinfo> 33642<refmeta> 33643 <refentrytitle><phrase>audit_log_end</phrase></refentrytitle> 33644 <manvolnum>9</manvolnum> 33645 <refmiscinfo class="version">4.1.27</refmiscinfo> 33646</refmeta> 33647<refnamediv> 33648 <refname>audit_log_end</refname> 33649 <refpurpose> 33650 end one audit record 33651 </refpurpose> 33652</refnamediv> 33653<refsynopsisdiv> 33654 <title>Synopsis</title> 33655 <funcsynopsis><funcprototype> 33656 <funcdef>void <function>audit_log_end </function></funcdef> 33657 <paramdef>struct audit_buffer * <parameter>ab</parameter></paramdef> 33658 </funcprototype></funcsynopsis> 33659</refsynopsisdiv> 33660<refsect1> 33661 <title>Arguments</title> 33662 <variablelist> 33663 <varlistentry> 33664 <term><parameter>ab</parameter></term> 33665 <listitem> 33666 <para> 33667 the audit_buffer 33668 </para> 33669 </listitem> 33670 </varlistentry> 33671 </variablelist> 33672</refsect1> 33673<refsect1> 33674<title>Description</title> 33675<para> 33676 <function>netlink_unicast</function> cannot be called inside an irq context because it blocks 33677 (last arg, flags, is not set to MSG_DONTWAIT), so the audit buffer is placed 33678 on a queue and a tasklet is scheduled to remove them from the queue outside 33679 the irq context. May be called in any context. 33680</para> 33681</refsect1> 33682</refentry> 33683 33684<refentry id="API-audit-log"> 33685<refentryinfo> 33686 <title>LINUX</title> 33687 <productname>Kernel Hackers Manual</productname> 33688 <date>July 2017</date> 33689</refentryinfo> 33690<refmeta> 33691 <refentrytitle><phrase>audit_log</phrase></refentrytitle> 33692 <manvolnum>9</manvolnum> 33693 <refmiscinfo class="version">4.1.27</refmiscinfo> 33694</refmeta> 33695<refnamediv> 33696 <refname>audit_log</refname> 33697 <refpurpose> 33698 Log an audit record 33699 </refpurpose> 33700</refnamediv> 33701<refsynopsisdiv> 33702 <title>Synopsis</title> 33703 <funcsynopsis><funcprototype> 33704 <funcdef>void <function>audit_log </function></funcdef> 33705 <paramdef>struct audit_context * <parameter>ctx</parameter></paramdef> 33706 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 33707 <paramdef>int <parameter>type</parameter></paramdef> 33708 <paramdef>const char * <parameter>fmt</parameter></paramdef> 33709 <paramdef> <parameter>...</parameter></paramdef> 33710 </funcprototype></funcsynopsis> 33711</refsynopsisdiv> 33712<refsect1> 33713 <title>Arguments</title> 33714 <variablelist> 33715 <varlistentry> 33716 <term><parameter>ctx</parameter></term> 33717 <listitem> 33718 <para> 33719 audit context 33720 </para> 33721 </listitem> 33722 </varlistentry> 33723 <varlistentry> 33724 <term><parameter>gfp_mask</parameter></term> 33725 <listitem> 33726 <para> 33727 type of allocation 33728 </para> 33729 </listitem> 33730 </varlistentry> 33731 <varlistentry> 33732 <term><parameter>type</parameter></term> 33733 <listitem> 33734 <para> 33735 audit message type 33736 </para> 33737 </listitem> 33738 </varlistentry> 33739 <varlistentry> 33740 <term><parameter>fmt</parameter></term> 33741 <listitem> 33742 <para> 33743 format string to use 33744 @...: variable parameters matching the format string 33745 </para> 33746 </listitem> 33747 </varlistentry> 33748 <varlistentry> 33749 <term><parameter>...</parameter></term> 33750 <listitem> 33751 <para> 33752 variable arguments 33753 </para> 33754 </listitem> 33755 </varlistentry> 33756 </variablelist> 33757</refsect1> 33758<refsect1> 33759<title>Description</title> 33760<para> 33761 This is a convenience function that calls audit_log_start, 33762 audit_log_vformat, and audit_log_end. It may be called 33763 in any context. 33764</para> 33765</refsect1> 33766</refentry> 33767 33768<refentry id="API-audit-log-secctx"> 33769<refentryinfo> 33770 <title>LINUX</title> 33771 <productname>Kernel Hackers Manual</productname> 33772 <date>July 2017</date> 33773</refentryinfo> 33774<refmeta> 33775 <refentrytitle><phrase>audit_log_secctx</phrase></refentrytitle> 33776 <manvolnum>9</manvolnum> 33777 <refmiscinfo class="version">4.1.27</refmiscinfo> 33778</refmeta> 33779<refnamediv> 33780 <refname>audit_log_secctx</refname> 33781 <refpurpose> 33782 Converts and logs SELinux context 33783 </refpurpose> 33784</refnamediv> 33785<refsynopsisdiv> 33786 <title>Synopsis</title> 33787 <funcsynopsis><funcprototype> 33788 <funcdef>void <function>audit_log_secctx </function></funcdef> 33789 <paramdef>struct audit_buffer * <parameter>ab</parameter></paramdef> 33790 <paramdef>u32 <parameter>secid</parameter></paramdef> 33791 </funcprototype></funcsynopsis> 33792</refsynopsisdiv> 33793<refsect1> 33794 <title>Arguments</title> 33795 <variablelist> 33796 <varlistentry> 33797 <term><parameter>ab</parameter></term> 33798 <listitem> 33799 <para> 33800 audit_buffer 33801 </para> 33802 </listitem> 33803 </varlistentry> 33804 <varlistentry> 33805 <term><parameter>secid</parameter></term> 33806 <listitem> 33807 <para> 33808 security number 33809 </para> 33810 </listitem> 33811 </varlistentry> 33812 </variablelist> 33813</refsect1> 33814<refsect1> 33815<title>Description</title> 33816<para> 33817 This is a helper function that calls security_secid_to_secctx to convert 33818 secid to secctx and then adds the (converted) SELinux context to the audit 33819 log by calling audit_log_format, thus also preventing leak of internal secid 33820 to userspace. If secid cannot be converted audit_panic is called. 33821</para> 33822</refsect1> 33823</refentry> 33824 33825<!-- kernel/auditsc.c --> 33826<refentry id="API-audit-alloc"> 33827<refentryinfo> 33828 <title>LINUX</title> 33829 <productname>Kernel Hackers Manual</productname> 33830 <date>July 2017</date> 33831</refentryinfo> 33832<refmeta> 33833 <refentrytitle><phrase>audit_alloc</phrase></refentrytitle> 33834 <manvolnum>9</manvolnum> 33835 <refmiscinfo class="version">4.1.27</refmiscinfo> 33836</refmeta> 33837<refnamediv> 33838 <refname>audit_alloc</refname> 33839 <refpurpose> 33840 allocate an audit context block for a task 33841 </refpurpose> 33842</refnamediv> 33843<refsynopsisdiv> 33844 <title>Synopsis</title> 33845 <funcsynopsis><funcprototype> 33846 <funcdef>int <function>audit_alloc </function></funcdef> 33847 <paramdef>struct task_struct * <parameter>tsk</parameter></paramdef> 33848 </funcprototype></funcsynopsis> 33849</refsynopsisdiv> 33850<refsect1> 33851 <title>Arguments</title> 33852 <variablelist> 33853 <varlistentry> 33854 <term><parameter>tsk</parameter></term> 33855 <listitem> 33856 <para> 33857 task 33858 </para> 33859 </listitem> 33860 </varlistentry> 33861 </variablelist> 33862</refsect1> 33863<refsect1> 33864<title>Description</title> 33865<para> 33866 Filter on the task information and allocate a per-task audit context 33867 if necessary. Doing so turns on system call auditing for the 33868 specified task. This is called from copy_process, so no lock is 33869 needed. 33870</para> 33871</refsect1> 33872</refentry> 33873 33874<refentry id="API---audit-free"> 33875<refentryinfo> 33876 <title>LINUX</title> 33877 <productname>Kernel Hackers Manual</productname> 33878 <date>July 2017</date> 33879</refentryinfo> 33880<refmeta> 33881 <refentrytitle><phrase>__audit_free</phrase></refentrytitle> 33882 <manvolnum>9</manvolnum> 33883 <refmiscinfo class="version">4.1.27</refmiscinfo> 33884</refmeta> 33885<refnamediv> 33886 <refname>__audit_free</refname> 33887 <refpurpose> 33888 free a per-task audit context 33889 </refpurpose> 33890</refnamediv> 33891<refsynopsisdiv> 33892 <title>Synopsis</title> 33893 <funcsynopsis><funcprototype> 33894 <funcdef>void <function>__audit_free </function></funcdef> 33895 <paramdef>struct task_struct * <parameter>tsk</parameter></paramdef> 33896 </funcprototype></funcsynopsis> 33897</refsynopsisdiv> 33898<refsect1> 33899 <title>Arguments</title> 33900 <variablelist> 33901 <varlistentry> 33902 <term><parameter>tsk</parameter></term> 33903 <listitem> 33904 <para> 33905 task whose audit context block to free 33906 </para> 33907 </listitem> 33908 </varlistentry> 33909 </variablelist> 33910</refsect1> 33911<refsect1> 33912<title>Description</title> 33913<para> 33914 Called from copy_process and do_exit 33915</para> 33916</refsect1> 33917</refentry> 33918 33919<refentry id="API---audit-syscall-entry"> 33920<refentryinfo> 33921 <title>LINUX</title> 33922 <productname>Kernel Hackers Manual</productname> 33923 <date>July 2017</date> 33924</refentryinfo> 33925<refmeta> 33926 <refentrytitle><phrase>__audit_syscall_entry</phrase></refentrytitle> 33927 <manvolnum>9</manvolnum> 33928 <refmiscinfo class="version">4.1.27</refmiscinfo> 33929</refmeta> 33930<refnamediv> 33931 <refname>__audit_syscall_entry</refname> 33932 <refpurpose> 33933 fill in an audit record at syscall entry 33934 </refpurpose> 33935</refnamediv> 33936<refsynopsisdiv> 33937 <title>Synopsis</title> 33938 <funcsynopsis><funcprototype> 33939 <funcdef>void <function>__audit_syscall_entry </function></funcdef> 33940 <paramdef>int <parameter>major</parameter></paramdef> 33941 <paramdef>unsigned long <parameter>a1</parameter></paramdef> 33942 <paramdef>unsigned long <parameter>a2</parameter></paramdef> 33943 <paramdef>unsigned long <parameter>a3</parameter></paramdef> 33944 <paramdef>unsigned long <parameter>a4</parameter></paramdef> 33945 </funcprototype></funcsynopsis> 33946</refsynopsisdiv> 33947<refsect1> 33948 <title>Arguments</title> 33949 <variablelist> 33950 <varlistentry> 33951 <term><parameter>major</parameter></term> 33952 <listitem> 33953 <para> 33954 major syscall type (function) 33955 </para> 33956 </listitem> 33957 </varlistentry> 33958 <varlistentry> 33959 <term><parameter>a1</parameter></term> 33960 <listitem> 33961 <para> 33962 additional syscall register 1 33963 </para> 33964 </listitem> 33965 </varlistentry> 33966 <varlistentry> 33967 <term><parameter>a2</parameter></term> 33968 <listitem> 33969 <para> 33970 additional syscall register 2 33971 </para> 33972 </listitem> 33973 </varlistentry> 33974 <varlistentry> 33975 <term><parameter>a3</parameter></term> 33976 <listitem> 33977 <para> 33978 additional syscall register 3 33979 </para> 33980 </listitem> 33981 </varlistentry> 33982 <varlistentry> 33983 <term><parameter>a4</parameter></term> 33984 <listitem> 33985 <para> 33986 additional syscall register 4 33987 </para> 33988 </listitem> 33989 </varlistentry> 33990 </variablelist> 33991</refsect1> 33992<refsect1> 33993<title>Description</title> 33994<para> 33995 Fill in audit context at syscall entry. This only happens if the 33996 audit context was created when the task was created and the state or 33997 filters demand the audit context be built. If the state from the 33998 per-task filter or from the per-syscall filter is AUDIT_RECORD_CONTEXT, 33999 then the record will be written at syscall exit time (otherwise, it 34000 will only be written if another part of the kernel requests that it 34001 be written). 34002</para> 34003</refsect1> 34004</refentry> 34005 34006<refentry id="API---audit-syscall-exit"> 34007<refentryinfo> 34008 <title>LINUX</title> 34009 <productname>Kernel Hackers Manual</productname> 34010 <date>July 2017</date> 34011</refentryinfo> 34012<refmeta> 34013 <refentrytitle><phrase>__audit_syscall_exit</phrase></refentrytitle> 34014 <manvolnum>9</manvolnum> 34015 <refmiscinfo class="version">4.1.27</refmiscinfo> 34016</refmeta> 34017<refnamediv> 34018 <refname>__audit_syscall_exit</refname> 34019 <refpurpose> 34020 deallocate audit context after a system call 34021 </refpurpose> 34022</refnamediv> 34023<refsynopsisdiv> 34024 <title>Synopsis</title> 34025 <funcsynopsis><funcprototype> 34026 <funcdef>void <function>__audit_syscall_exit </function></funcdef> 34027 <paramdef>int <parameter>success</parameter></paramdef> 34028 <paramdef>long <parameter>return_code</parameter></paramdef> 34029 </funcprototype></funcsynopsis> 34030</refsynopsisdiv> 34031<refsect1> 34032 <title>Arguments</title> 34033 <variablelist> 34034 <varlistentry> 34035 <term><parameter>success</parameter></term> 34036 <listitem> 34037 <para> 34038 success value of the syscall 34039 </para> 34040 </listitem> 34041 </varlistentry> 34042 <varlistentry> 34043 <term><parameter>return_code</parameter></term> 34044 <listitem> 34045 <para> 34046 return value of the syscall 34047 </para> 34048 </listitem> 34049 </varlistentry> 34050 </variablelist> 34051</refsect1> 34052<refsect1> 34053<title>Description</title> 34054<para> 34055 Tear down after system call. If the audit context has been marked as 34056 auditable (either because of the AUDIT_RECORD_CONTEXT state from 34057 filtering, or because some other part of the kernel wrote an audit 34058 message), then write out the syscall information. In call cases, 34059 free the names stored from <function>getname</function>. 34060</para> 34061</refsect1> 34062</refentry> 34063 34064<refentry id="API---audit-reusename"> 34065<refentryinfo> 34066 <title>LINUX</title> 34067 <productname>Kernel Hackers Manual</productname> 34068 <date>July 2017</date> 34069</refentryinfo> 34070<refmeta> 34071 <refentrytitle><phrase>__audit_reusename</phrase></refentrytitle> 34072 <manvolnum>9</manvolnum> 34073 <refmiscinfo class="version">4.1.27</refmiscinfo> 34074</refmeta> 34075<refnamediv> 34076 <refname>__audit_reusename</refname> 34077 <refpurpose> 34078 fill out filename with info from existing entry 34079 </refpurpose> 34080</refnamediv> 34081<refsynopsisdiv> 34082 <title>Synopsis</title> 34083 <funcsynopsis><funcprototype> 34084 <funcdef>struct filename * <function>__audit_reusename </function></funcdef> 34085 <paramdef>const __user char * <parameter>uptr</parameter></paramdef> 34086 </funcprototype></funcsynopsis> 34087</refsynopsisdiv> 34088<refsect1> 34089 <title>Arguments</title> 34090 <variablelist> 34091 <varlistentry> 34092 <term><parameter>uptr</parameter></term> 34093 <listitem> 34094 <para> 34095 userland ptr to pathname 34096 </para> 34097 </listitem> 34098 </varlistentry> 34099 </variablelist> 34100</refsect1> 34101<refsect1> 34102<title>Description</title> 34103<para> 34104 Search the audit_names list for the current audit context. If there is an 34105 existing entry with a matching <quote>uptr</quote> then return the filename 34106 associated with that audit_name. If not, return NULL. 34107</para> 34108</refsect1> 34109</refentry> 34110 34111<refentry id="API---audit-getname"> 34112<refentryinfo> 34113 <title>LINUX</title> 34114 <productname>Kernel Hackers Manual</productname> 34115 <date>July 2017</date> 34116</refentryinfo> 34117<refmeta> 34118 <refentrytitle><phrase>__audit_getname</phrase></refentrytitle> 34119 <manvolnum>9</manvolnum> 34120 <refmiscinfo class="version">4.1.27</refmiscinfo> 34121</refmeta> 34122<refnamediv> 34123 <refname>__audit_getname</refname> 34124 <refpurpose> 34125 add a name to the list 34126 </refpurpose> 34127</refnamediv> 34128<refsynopsisdiv> 34129 <title>Synopsis</title> 34130 <funcsynopsis><funcprototype> 34131 <funcdef>void <function>__audit_getname </function></funcdef> 34132 <paramdef>struct filename * <parameter>name</parameter></paramdef> 34133 </funcprototype></funcsynopsis> 34134</refsynopsisdiv> 34135<refsect1> 34136 <title>Arguments</title> 34137 <variablelist> 34138 <varlistentry> 34139 <term><parameter>name</parameter></term> 34140 <listitem> 34141 <para> 34142 name to add 34143 </para> 34144 </listitem> 34145 </varlistentry> 34146 </variablelist> 34147</refsect1> 34148<refsect1> 34149<title>Description</title> 34150<para> 34151 Add a name to the list of audit names for this context. 34152 Called from fs/namei.c:<function>getname</function>. 34153</para> 34154</refsect1> 34155</refentry> 34156 34157<refentry id="API---audit-inode"> 34158<refentryinfo> 34159 <title>LINUX</title> 34160 <productname>Kernel Hackers Manual</productname> 34161 <date>July 2017</date> 34162</refentryinfo> 34163<refmeta> 34164 <refentrytitle><phrase>__audit_inode</phrase></refentrytitle> 34165 <manvolnum>9</manvolnum> 34166 <refmiscinfo class="version">4.1.27</refmiscinfo> 34167</refmeta> 34168<refnamediv> 34169 <refname>__audit_inode</refname> 34170 <refpurpose> 34171 store the inode and device from a lookup 34172 </refpurpose> 34173</refnamediv> 34174<refsynopsisdiv> 34175 <title>Synopsis</title> 34176 <funcsynopsis><funcprototype> 34177 <funcdef>void <function>__audit_inode </function></funcdef> 34178 <paramdef>struct filename * <parameter>name</parameter></paramdef> 34179 <paramdef>const struct dentry * <parameter>dentry</parameter></paramdef> 34180 <paramdef>unsigned int <parameter>flags</parameter></paramdef> 34181 </funcprototype></funcsynopsis> 34182</refsynopsisdiv> 34183<refsect1> 34184 <title>Arguments</title> 34185 <variablelist> 34186 <varlistentry> 34187 <term><parameter>name</parameter></term> 34188 <listitem> 34189 <para> 34190 name being audited 34191 </para> 34192 </listitem> 34193 </varlistentry> 34194 <varlistentry> 34195 <term><parameter>dentry</parameter></term> 34196 <listitem> 34197 <para> 34198 dentry being audited 34199 </para> 34200 </listitem> 34201 </varlistentry> 34202 <varlistentry> 34203 <term><parameter>flags</parameter></term> 34204 <listitem> 34205 <para> 34206 attributes for this particular entry 34207 </para> 34208 </listitem> 34209 </varlistentry> 34210 </variablelist> 34211</refsect1> 34212</refentry> 34213 34214<refentry id="API-auditsc-get-stamp"> 34215<refentryinfo> 34216 <title>LINUX</title> 34217 <productname>Kernel Hackers Manual</productname> 34218 <date>July 2017</date> 34219</refentryinfo> 34220<refmeta> 34221 <refentrytitle><phrase>auditsc_get_stamp</phrase></refentrytitle> 34222 <manvolnum>9</manvolnum> 34223 <refmiscinfo class="version">4.1.27</refmiscinfo> 34224</refmeta> 34225<refnamediv> 34226 <refname>auditsc_get_stamp</refname> 34227 <refpurpose> 34228 get local copies of audit_context values 34229 </refpurpose> 34230</refnamediv> 34231<refsynopsisdiv> 34232 <title>Synopsis</title> 34233 <funcsynopsis><funcprototype> 34234 <funcdef>int <function>auditsc_get_stamp </function></funcdef> 34235 <paramdef>struct audit_context * <parameter>ctx</parameter></paramdef> 34236 <paramdef>struct timespec * <parameter>t</parameter></paramdef> 34237 <paramdef>unsigned int * <parameter>serial</parameter></paramdef> 34238 </funcprototype></funcsynopsis> 34239</refsynopsisdiv> 34240<refsect1> 34241 <title>Arguments</title> 34242 <variablelist> 34243 <varlistentry> 34244 <term><parameter>ctx</parameter></term> 34245 <listitem> 34246 <para> 34247 audit_context for the task 34248 </para> 34249 </listitem> 34250 </varlistentry> 34251 <varlistentry> 34252 <term><parameter>t</parameter></term> 34253 <listitem> 34254 <para> 34255 timespec to store time recorded in the audit_context 34256 </para> 34257 </listitem> 34258 </varlistentry> 34259 <varlistentry> 34260 <term><parameter>serial</parameter></term> 34261 <listitem> 34262 <para> 34263 serial value that is recorded in the audit_context 34264 </para> 34265 </listitem> 34266 </varlistentry> 34267 </variablelist> 34268</refsect1> 34269<refsect1> 34270<title>Description</title> 34271<para> 34272 Also sets the context as auditable. 34273</para> 34274</refsect1> 34275</refentry> 34276 34277<refentry id="API-audit-set-loginuid"> 34278<refentryinfo> 34279 <title>LINUX</title> 34280 <productname>Kernel Hackers Manual</productname> 34281 <date>July 2017</date> 34282</refentryinfo> 34283<refmeta> 34284 <refentrytitle><phrase>audit_set_loginuid</phrase></refentrytitle> 34285 <manvolnum>9</manvolnum> 34286 <refmiscinfo class="version">4.1.27</refmiscinfo> 34287</refmeta> 34288<refnamediv> 34289 <refname>audit_set_loginuid</refname> 34290 <refpurpose> 34291 set current task's audit_context loginuid 34292 </refpurpose> 34293</refnamediv> 34294<refsynopsisdiv> 34295 <title>Synopsis</title> 34296 <funcsynopsis><funcprototype> 34297 <funcdef>int <function>audit_set_loginuid </function></funcdef> 34298 <paramdef>kuid_t <parameter>loginuid</parameter></paramdef> 34299 </funcprototype></funcsynopsis> 34300</refsynopsisdiv> 34301<refsect1> 34302 <title>Arguments</title> 34303 <variablelist> 34304 <varlistentry> 34305 <term><parameter>loginuid</parameter></term> 34306 <listitem> 34307 <para> 34308 loginuid value 34309 </para> 34310 </listitem> 34311 </varlistentry> 34312 </variablelist> 34313</refsect1> 34314<refsect1> 34315<title>Description</title> 34316<para> 34317 Returns 0. 34318 </para><para> 34319 34320 Called (set) from fs/proc/base.c::<function>proc_loginuid_write</function>. 34321</para> 34322</refsect1> 34323</refentry> 34324 34325<refentry id="API---audit-mq-open"> 34326<refentryinfo> 34327 <title>LINUX</title> 34328 <productname>Kernel Hackers Manual</productname> 34329 <date>July 2017</date> 34330</refentryinfo> 34331<refmeta> 34332 <refentrytitle><phrase>__audit_mq_open</phrase></refentrytitle> 34333 <manvolnum>9</manvolnum> 34334 <refmiscinfo class="version">4.1.27</refmiscinfo> 34335</refmeta> 34336<refnamediv> 34337 <refname>__audit_mq_open</refname> 34338 <refpurpose> 34339 record audit data for a POSIX MQ open 34340 </refpurpose> 34341</refnamediv> 34342<refsynopsisdiv> 34343 <title>Synopsis</title> 34344 <funcsynopsis><funcprototype> 34345 <funcdef>void <function>__audit_mq_open </function></funcdef> 34346 <paramdef>int <parameter>oflag</parameter></paramdef> 34347 <paramdef>umode_t <parameter>mode</parameter></paramdef> 34348 <paramdef>struct mq_attr * <parameter>attr</parameter></paramdef> 34349 </funcprototype></funcsynopsis> 34350</refsynopsisdiv> 34351<refsect1> 34352 <title>Arguments</title> 34353 <variablelist> 34354 <varlistentry> 34355 <term><parameter>oflag</parameter></term> 34356 <listitem> 34357 <para> 34358 open flag 34359 </para> 34360 </listitem> 34361 </varlistentry> 34362 <varlistentry> 34363 <term><parameter>mode</parameter></term> 34364 <listitem> 34365 <para> 34366 mode bits 34367 </para> 34368 </listitem> 34369 </varlistentry> 34370 <varlistentry> 34371 <term><parameter>attr</parameter></term> 34372 <listitem> 34373 <para> 34374 queue attributes 34375 </para> 34376 </listitem> 34377 </varlistentry> 34378 </variablelist> 34379</refsect1> 34380</refentry> 34381 34382<refentry id="API---audit-mq-sendrecv"> 34383<refentryinfo> 34384 <title>LINUX</title> 34385 <productname>Kernel Hackers Manual</productname> 34386 <date>July 2017</date> 34387</refentryinfo> 34388<refmeta> 34389 <refentrytitle><phrase>__audit_mq_sendrecv</phrase></refentrytitle> 34390 <manvolnum>9</manvolnum> 34391 <refmiscinfo class="version">4.1.27</refmiscinfo> 34392</refmeta> 34393<refnamediv> 34394 <refname>__audit_mq_sendrecv</refname> 34395 <refpurpose> 34396 record audit data for a POSIX MQ timed send/receive 34397 </refpurpose> 34398</refnamediv> 34399<refsynopsisdiv> 34400 <title>Synopsis</title> 34401 <funcsynopsis><funcprototype> 34402 <funcdef>void <function>__audit_mq_sendrecv </function></funcdef> 34403 <paramdef>mqd_t <parameter>mqdes</parameter></paramdef> 34404 <paramdef>size_t <parameter>msg_len</parameter></paramdef> 34405 <paramdef>unsigned int <parameter>msg_prio</parameter></paramdef> 34406 <paramdef>const struct timespec * <parameter>abs_timeout</parameter></paramdef> 34407 </funcprototype></funcsynopsis> 34408</refsynopsisdiv> 34409<refsect1> 34410 <title>Arguments</title> 34411 <variablelist> 34412 <varlistentry> 34413 <term><parameter>mqdes</parameter></term> 34414 <listitem> 34415 <para> 34416 MQ descriptor 34417 </para> 34418 </listitem> 34419 </varlistentry> 34420 <varlistentry> 34421 <term><parameter>msg_len</parameter></term> 34422 <listitem> 34423 <para> 34424 Message length 34425 </para> 34426 </listitem> 34427 </varlistentry> 34428 <varlistentry> 34429 <term><parameter>msg_prio</parameter></term> 34430 <listitem> 34431 <para> 34432 Message priority 34433 </para> 34434 </listitem> 34435 </varlistentry> 34436 <varlistentry> 34437 <term><parameter>abs_timeout</parameter></term> 34438 <listitem> 34439 <para> 34440 Message timeout in absolute time 34441 </para> 34442 </listitem> 34443 </varlistentry> 34444 </variablelist> 34445</refsect1> 34446</refentry> 34447 34448<refentry id="API---audit-mq-notify"> 34449<refentryinfo> 34450 <title>LINUX</title> 34451 <productname>Kernel Hackers Manual</productname> 34452 <date>July 2017</date> 34453</refentryinfo> 34454<refmeta> 34455 <refentrytitle><phrase>__audit_mq_notify</phrase></refentrytitle> 34456 <manvolnum>9</manvolnum> 34457 <refmiscinfo class="version">4.1.27</refmiscinfo> 34458</refmeta> 34459<refnamediv> 34460 <refname>__audit_mq_notify</refname> 34461 <refpurpose> 34462 record audit data for a POSIX MQ notify 34463 </refpurpose> 34464</refnamediv> 34465<refsynopsisdiv> 34466 <title>Synopsis</title> 34467 <funcsynopsis><funcprototype> 34468 <funcdef>void <function>__audit_mq_notify </function></funcdef> 34469 <paramdef>mqd_t <parameter>mqdes</parameter></paramdef> 34470 <paramdef>const struct sigevent * <parameter>notification</parameter></paramdef> 34471 </funcprototype></funcsynopsis> 34472</refsynopsisdiv> 34473<refsect1> 34474 <title>Arguments</title> 34475 <variablelist> 34476 <varlistentry> 34477 <term><parameter>mqdes</parameter></term> 34478 <listitem> 34479 <para> 34480 MQ descriptor 34481 </para> 34482 </listitem> 34483 </varlistentry> 34484 <varlistentry> 34485 <term><parameter>notification</parameter></term> 34486 <listitem> 34487 <para> 34488 Notification event 34489 </para> 34490 </listitem> 34491 </varlistentry> 34492 </variablelist> 34493</refsect1> 34494</refentry> 34495 34496<refentry id="API---audit-mq-getsetattr"> 34497<refentryinfo> 34498 <title>LINUX</title> 34499 <productname>Kernel Hackers Manual</productname> 34500 <date>July 2017</date> 34501</refentryinfo> 34502<refmeta> 34503 <refentrytitle><phrase>__audit_mq_getsetattr</phrase></refentrytitle> 34504 <manvolnum>9</manvolnum> 34505 <refmiscinfo class="version">4.1.27</refmiscinfo> 34506</refmeta> 34507<refnamediv> 34508 <refname>__audit_mq_getsetattr</refname> 34509 <refpurpose> 34510 record audit data for a POSIX MQ get/set attribute 34511 </refpurpose> 34512</refnamediv> 34513<refsynopsisdiv> 34514 <title>Synopsis</title> 34515 <funcsynopsis><funcprototype> 34516 <funcdef>void <function>__audit_mq_getsetattr </function></funcdef> 34517 <paramdef>mqd_t <parameter>mqdes</parameter></paramdef> 34518 <paramdef>struct mq_attr * <parameter>mqstat</parameter></paramdef> 34519 </funcprototype></funcsynopsis> 34520</refsynopsisdiv> 34521<refsect1> 34522 <title>Arguments</title> 34523 <variablelist> 34524 <varlistentry> 34525 <term><parameter>mqdes</parameter></term> 34526 <listitem> 34527 <para> 34528 MQ descriptor 34529 </para> 34530 </listitem> 34531 </varlistentry> 34532 <varlistentry> 34533 <term><parameter>mqstat</parameter></term> 34534 <listitem> 34535 <para> 34536 MQ flags 34537 </para> 34538 </listitem> 34539 </varlistentry> 34540 </variablelist> 34541</refsect1> 34542</refentry> 34543 34544<refentry id="API---audit-ipc-obj"> 34545<refentryinfo> 34546 <title>LINUX</title> 34547 <productname>Kernel Hackers Manual</productname> 34548 <date>July 2017</date> 34549</refentryinfo> 34550<refmeta> 34551 <refentrytitle><phrase>__audit_ipc_obj</phrase></refentrytitle> 34552 <manvolnum>9</manvolnum> 34553 <refmiscinfo class="version">4.1.27</refmiscinfo> 34554</refmeta> 34555<refnamediv> 34556 <refname>__audit_ipc_obj</refname> 34557 <refpurpose> 34558 record audit data for ipc object 34559 </refpurpose> 34560</refnamediv> 34561<refsynopsisdiv> 34562 <title>Synopsis</title> 34563 <funcsynopsis><funcprototype> 34564 <funcdef>void <function>__audit_ipc_obj </function></funcdef> 34565 <paramdef>struct kern_ipc_perm * <parameter>ipcp</parameter></paramdef> 34566 </funcprototype></funcsynopsis> 34567</refsynopsisdiv> 34568<refsect1> 34569 <title>Arguments</title> 34570 <variablelist> 34571 <varlistentry> 34572 <term><parameter>ipcp</parameter></term> 34573 <listitem> 34574 <para> 34575 ipc permissions 34576 </para> 34577 </listitem> 34578 </varlistentry> 34579 </variablelist> 34580</refsect1> 34581</refentry> 34582 34583<refentry id="API---audit-ipc-set-perm"> 34584<refentryinfo> 34585 <title>LINUX</title> 34586 <productname>Kernel Hackers Manual</productname> 34587 <date>July 2017</date> 34588</refentryinfo> 34589<refmeta> 34590 <refentrytitle><phrase>__audit_ipc_set_perm</phrase></refentrytitle> 34591 <manvolnum>9</manvolnum> 34592 <refmiscinfo class="version">4.1.27</refmiscinfo> 34593</refmeta> 34594<refnamediv> 34595 <refname>__audit_ipc_set_perm</refname> 34596 <refpurpose> 34597 record audit data for new ipc permissions 34598 </refpurpose> 34599</refnamediv> 34600<refsynopsisdiv> 34601 <title>Synopsis</title> 34602 <funcsynopsis><funcprototype> 34603 <funcdef>void <function>__audit_ipc_set_perm </function></funcdef> 34604 <paramdef>unsigned long <parameter>qbytes</parameter></paramdef> 34605 <paramdef>uid_t <parameter>uid</parameter></paramdef> 34606 <paramdef>gid_t <parameter>gid</parameter></paramdef> 34607 <paramdef>umode_t <parameter>mode</parameter></paramdef> 34608 </funcprototype></funcsynopsis> 34609</refsynopsisdiv> 34610<refsect1> 34611 <title>Arguments</title> 34612 <variablelist> 34613 <varlistentry> 34614 <term><parameter>qbytes</parameter></term> 34615 <listitem> 34616 <para> 34617 msgq bytes 34618 </para> 34619 </listitem> 34620 </varlistentry> 34621 <varlistentry> 34622 <term><parameter>uid</parameter></term> 34623 <listitem> 34624 <para> 34625 msgq user id 34626 </para> 34627 </listitem> 34628 </varlistentry> 34629 <varlistentry> 34630 <term><parameter>gid</parameter></term> 34631 <listitem> 34632 <para> 34633 msgq group id 34634 </para> 34635 </listitem> 34636 </varlistentry> 34637 <varlistentry> 34638 <term><parameter>mode</parameter></term> 34639 <listitem> 34640 <para> 34641 msgq mode (permissions) 34642 </para> 34643 </listitem> 34644 </varlistentry> 34645 </variablelist> 34646</refsect1> 34647<refsect1> 34648<title>Description</title> 34649<para> 34650 Called only after <function>audit_ipc_obj</function>. 34651</para> 34652</refsect1> 34653</refentry> 34654 34655<refentry id="API---audit-socketcall"> 34656<refentryinfo> 34657 <title>LINUX</title> 34658 <productname>Kernel Hackers Manual</productname> 34659 <date>July 2017</date> 34660</refentryinfo> 34661<refmeta> 34662 <refentrytitle><phrase>__audit_socketcall</phrase></refentrytitle> 34663 <manvolnum>9</manvolnum> 34664 <refmiscinfo class="version">4.1.27</refmiscinfo> 34665</refmeta> 34666<refnamediv> 34667 <refname>__audit_socketcall</refname> 34668 <refpurpose> 34669 record audit data for sys_socketcall 34670 </refpurpose> 34671</refnamediv> 34672<refsynopsisdiv> 34673 <title>Synopsis</title> 34674 <funcsynopsis><funcprototype> 34675 <funcdef>int <function>__audit_socketcall </function></funcdef> 34676 <paramdef>int <parameter>nargs</parameter></paramdef> 34677 <paramdef>unsigned long * <parameter>args</parameter></paramdef> 34678 </funcprototype></funcsynopsis> 34679</refsynopsisdiv> 34680<refsect1> 34681 <title>Arguments</title> 34682 <variablelist> 34683 <varlistentry> 34684 <term><parameter>nargs</parameter></term> 34685 <listitem> 34686 <para> 34687 number of args, which should not be more than AUDITSC_ARGS. 34688 </para> 34689 </listitem> 34690 </varlistentry> 34691 <varlistentry> 34692 <term><parameter>args</parameter></term> 34693 <listitem> 34694 <para> 34695 args array 34696 </para> 34697 </listitem> 34698 </varlistentry> 34699 </variablelist> 34700</refsect1> 34701</refentry> 34702 34703<refentry id="API---audit-fd-pair"> 34704<refentryinfo> 34705 <title>LINUX</title> 34706 <productname>Kernel Hackers Manual</productname> 34707 <date>July 2017</date> 34708</refentryinfo> 34709<refmeta> 34710 <refentrytitle><phrase>__audit_fd_pair</phrase></refentrytitle> 34711 <manvolnum>9</manvolnum> 34712 <refmiscinfo class="version">4.1.27</refmiscinfo> 34713</refmeta> 34714<refnamediv> 34715 <refname>__audit_fd_pair</refname> 34716 <refpurpose> 34717 record audit data for pipe and socketpair 34718 </refpurpose> 34719</refnamediv> 34720<refsynopsisdiv> 34721 <title>Synopsis</title> 34722 <funcsynopsis><funcprototype> 34723 <funcdef>void <function>__audit_fd_pair </function></funcdef> 34724 <paramdef>int <parameter>fd1</parameter></paramdef> 34725 <paramdef>int <parameter>fd2</parameter></paramdef> 34726 </funcprototype></funcsynopsis> 34727</refsynopsisdiv> 34728<refsect1> 34729 <title>Arguments</title> 34730 <variablelist> 34731 <varlistentry> 34732 <term><parameter>fd1</parameter></term> 34733 <listitem> 34734 <para> 34735 the first file descriptor 34736 </para> 34737 </listitem> 34738 </varlistentry> 34739 <varlistentry> 34740 <term><parameter>fd2</parameter></term> 34741 <listitem> 34742 <para> 34743 the second file descriptor 34744 </para> 34745 </listitem> 34746 </varlistentry> 34747 </variablelist> 34748</refsect1> 34749</refentry> 34750 34751<refentry id="API---audit-sockaddr"> 34752<refentryinfo> 34753 <title>LINUX</title> 34754 <productname>Kernel Hackers Manual</productname> 34755 <date>July 2017</date> 34756</refentryinfo> 34757<refmeta> 34758 <refentrytitle><phrase>__audit_sockaddr</phrase></refentrytitle> 34759 <manvolnum>9</manvolnum> 34760 <refmiscinfo class="version">4.1.27</refmiscinfo> 34761</refmeta> 34762<refnamediv> 34763 <refname>__audit_sockaddr</refname> 34764 <refpurpose> 34765 record audit data for sys_bind, sys_connect, sys_sendto 34766 </refpurpose> 34767</refnamediv> 34768<refsynopsisdiv> 34769 <title>Synopsis</title> 34770 <funcsynopsis><funcprototype> 34771 <funcdef>int <function>__audit_sockaddr </function></funcdef> 34772 <paramdef>int <parameter>len</parameter></paramdef> 34773 <paramdef>void * <parameter>a</parameter></paramdef> 34774 </funcprototype></funcsynopsis> 34775</refsynopsisdiv> 34776<refsect1> 34777 <title>Arguments</title> 34778 <variablelist> 34779 <varlistentry> 34780 <term><parameter>len</parameter></term> 34781 <listitem> 34782 <para> 34783 data length in user space 34784 </para> 34785 </listitem> 34786 </varlistentry> 34787 <varlistentry> 34788 <term><parameter>a</parameter></term> 34789 <listitem> 34790 <para> 34791 data address in kernel space 34792 </para> 34793 </listitem> 34794 </varlistentry> 34795 </variablelist> 34796</refsect1> 34797<refsect1> 34798<title>Description</title> 34799<para> 34800 Returns 0 for success or NULL context or < 0 on error. 34801</para> 34802</refsect1> 34803</refentry> 34804 34805<refentry id="API---audit-signal-info"> 34806<refentryinfo> 34807 <title>LINUX</title> 34808 <productname>Kernel Hackers Manual</productname> 34809 <date>July 2017</date> 34810</refentryinfo> 34811<refmeta> 34812 <refentrytitle><phrase>__audit_signal_info</phrase></refentrytitle> 34813 <manvolnum>9</manvolnum> 34814 <refmiscinfo class="version">4.1.27</refmiscinfo> 34815</refmeta> 34816<refnamediv> 34817 <refname>__audit_signal_info</refname> 34818 <refpurpose> 34819 record signal info for shutting down audit subsystem 34820 </refpurpose> 34821</refnamediv> 34822<refsynopsisdiv> 34823 <title>Synopsis</title> 34824 <funcsynopsis><funcprototype> 34825 <funcdef>int <function>__audit_signal_info </function></funcdef> 34826 <paramdef>int <parameter>sig</parameter></paramdef> 34827 <paramdef>struct task_struct * <parameter>t</parameter></paramdef> 34828 </funcprototype></funcsynopsis> 34829</refsynopsisdiv> 34830<refsect1> 34831 <title>Arguments</title> 34832 <variablelist> 34833 <varlistentry> 34834 <term><parameter>sig</parameter></term> 34835 <listitem> 34836 <para> 34837 signal value 34838 </para> 34839 </listitem> 34840 </varlistentry> 34841 <varlistentry> 34842 <term><parameter>t</parameter></term> 34843 <listitem> 34844 <para> 34845 task being signaled 34846 </para> 34847 </listitem> 34848 </varlistentry> 34849 </variablelist> 34850</refsect1> 34851<refsect1> 34852<title>Description</title> 34853<para> 34854 If the audit subsystem is being terminated, record the task (pid) 34855 and uid that is doing that. 34856</para> 34857</refsect1> 34858</refentry> 34859 34860<refentry id="API---audit-log-bprm-fcaps"> 34861<refentryinfo> 34862 <title>LINUX</title> 34863 <productname>Kernel Hackers Manual</productname> 34864 <date>July 2017</date> 34865</refentryinfo> 34866<refmeta> 34867 <refentrytitle><phrase>__audit_log_bprm_fcaps</phrase></refentrytitle> 34868 <manvolnum>9</manvolnum> 34869 <refmiscinfo class="version">4.1.27</refmiscinfo> 34870</refmeta> 34871<refnamediv> 34872 <refname>__audit_log_bprm_fcaps</refname> 34873 <refpurpose> 34874 store information about a loading bprm and relevant fcaps 34875 </refpurpose> 34876</refnamediv> 34877<refsynopsisdiv> 34878 <title>Synopsis</title> 34879 <funcsynopsis><funcprototype> 34880 <funcdef>int <function>__audit_log_bprm_fcaps </function></funcdef> 34881 <paramdef>struct linux_binprm * <parameter>bprm</parameter></paramdef> 34882 <paramdef>const struct cred * <parameter>new</parameter></paramdef> 34883 <paramdef>const struct cred * <parameter>old</parameter></paramdef> 34884 </funcprototype></funcsynopsis> 34885</refsynopsisdiv> 34886<refsect1> 34887 <title>Arguments</title> 34888 <variablelist> 34889 <varlistentry> 34890 <term><parameter>bprm</parameter></term> 34891 <listitem> 34892 <para> 34893 pointer to the bprm being processed 34894 </para> 34895 </listitem> 34896 </varlistentry> 34897 <varlistentry> 34898 <term><parameter>new</parameter></term> 34899 <listitem> 34900 <para> 34901 the proposed new credentials 34902 </para> 34903 </listitem> 34904 </varlistentry> 34905 <varlistentry> 34906 <term><parameter>old</parameter></term> 34907 <listitem> 34908 <para> 34909 the old credentials 34910 </para> 34911 </listitem> 34912 </varlistentry> 34913 </variablelist> 34914</refsect1> 34915<refsect1> 34916<title>Description</title> 34917<para> 34918 Simply check if the proc already has the caps given by the file and if not 34919 store the priv escalation info for later auditing at the end of the syscall 34920 </para><para> 34921 34922 -Eric 34923</para> 34924</refsect1> 34925</refentry> 34926 34927<refentry id="API---audit-log-capset"> 34928<refentryinfo> 34929 <title>LINUX</title> 34930 <productname>Kernel Hackers Manual</productname> 34931 <date>July 2017</date> 34932</refentryinfo> 34933<refmeta> 34934 <refentrytitle><phrase>__audit_log_capset</phrase></refentrytitle> 34935 <manvolnum>9</manvolnum> 34936 <refmiscinfo class="version">4.1.27</refmiscinfo> 34937</refmeta> 34938<refnamediv> 34939 <refname>__audit_log_capset</refname> 34940 <refpurpose> 34941 store information about the arguments to the capset syscall 34942 </refpurpose> 34943</refnamediv> 34944<refsynopsisdiv> 34945 <title>Synopsis</title> 34946 <funcsynopsis><funcprototype> 34947 <funcdef>void <function>__audit_log_capset </function></funcdef> 34948 <paramdef>const struct cred * <parameter>new</parameter></paramdef> 34949 <paramdef>const struct cred * <parameter>old</parameter></paramdef> 34950 </funcprototype></funcsynopsis> 34951</refsynopsisdiv> 34952<refsect1> 34953 <title>Arguments</title> 34954 <variablelist> 34955 <varlistentry> 34956 <term><parameter>new</parameter></term> 34957 <listitem> 34958 <para> 34959 the new credentials 34960 </para> 34961 </listitem> 34962 </varlistentry> 34963 <varlistentry> 34964 <term><parameter>old</parameter></term> 34965 <listitem> 34966 <para> 34967 the old (current) credentials 34968 </para> 34969 </listitem> 34970 </varlistentry> 34971 </variablelist> 34972</refsect1> 34973<refsect1> 34974<title>Description</title> 34975<para> 34976 Record the arguments userspace sent to sys_capset for later printing by the 34977 audit system if applicable 34978</para> 34979</refsect1> 34980</refentry> 34981 34982<refentry id="API-audit-core-dumps"> 34983<refentryinfo> 34984 <title>LINUX</title> 34985 <productname>Kernel Hackers Manual</productname> 34986 <date>July 2017</date> 34987</refentryinfo> 34988<refmeta> 34989 <refentrytitle><phrase>audit_core_dumps</phrase></refentrytitle> 34990 <manvolnum>9</manvolnum> 34991 <refmiscinfo class="version">4.1.27</refmiscinfo> 34992</refmeta> 34993<refnamediv> 34994 <refname>audit_core_dumps</refname> 34995 <refpurpose> 34996 record information about processes that end abnormally 34997 </refpurpose> 34998</refnamediv> 34999<refsynopsisdiv> 35000 <title>Synopsis</title> 35001 <funcsynopsis><funcprototype> 35002 <funcdef>void <function>audit_core_dumps </function></funcdef> 35003 <paramdef>long <parameter>signr</parameter></paramdef> 35004 </funcprototype></funcsynopsis> 35005</refsynopsisdiv> 35006<refsect1> 35007 <title>Arguments</title> 35008 <variablelist> 35009 <varlistentry> 35010 <term><parameter>signr</parameter></term> 35011 <listitem> 35012 <para> 35013 signal value 35014 </para> 35015 </listitem> 35016 </varlistentry> 35017 </variablelist> 35018</refsect1> 35019<refsect1> 35020<title>Description</title> 35021<para> 35022 If a process ends with a core dump, something fishy is going on and we 35023 should record the event for investigation. 35024</para> 35025</refsect1> 35026</refentry> 35027 35028<!-- kernel/auditfilter.c --> 35029<refentry id="API-audit-rule-change"> 35030<refentryinfo> 35031 <title>LINUX</title> 35032 <productname>Kernel Hackers Manual</productname> 35033 <date>July 2017</date> 35034</refentryinfo> 35035<refmeta> 35036 <refentrytitle><phrase>audit_rule_change</phrase></refentrytitle> 35037 <manvolnum>9</manvolnum> 35038 <refmiscinfo class="version">4.1.27</refmiscinfo> 35039</refmeta> 35040<refnamediv> 35041 <refname>audit_rule_change</refname> 35042 <refpurpose> 35043 apply all rules to the specified message type 35044 </refpurpose> 35045</refnamediv> 35046<refsynopsisdiv> 35047 <title>Synopsis</title> 35048 <funcsynopsis><funcprototype> 35049 <funcdef>int <function>audit_rule_change </function></funcdef> 35050 <paramdef>int <parameter>type</parameter></paramdef> 35051 <paramdef>__u32 <parameter>portid</parameter></paramdef> 35052 <paramdef>int <parameter>seq</parameter></paramdef> 35053 <paramdef>void * <parameter>data</parameter></paramdef> 35054 <paramdef>size_t <parameter>datasz</parameter></paramdef> 35055 </funcprototype></funcsynopsis> 35056</refsynopsisdiv> 35057<refsect1> 35058 <title>Arguments</title> 35059 <variablelist> 35060 <varlistentry> 35061 <term><parameter>type</parameter></term> 35062 <listitem> 35063 <para> 35064 audit message type 35065 </para> 35066 </listitem> 35067 </varlistentry> 35068 <varlistentry> 35069 <term><parameter>portid</parameter></term> 35070 <listitem> 35071 <para> 35072 target port id for netlink audit messages 35073 </para> 35074 </listitem> 35075 </varlistentry> 35076 <varlistentry> 35077 <term><parameter>seq</parameter></term> 35078 <listitem> 35079 <para> 35080 netlink audit message sequence (serial) number 35081 </para> 35082 </listitem> 35083 </varlistentry> 35084 <varlistentry> 35085 <term><parameter>data</parameter></term> 35086 <listitem> 35087 <para> 35088 payload data 35089 </para> 35090 </listitem> 35091 </varlistentry> 35092 <varlistentry> 35093 <term><parameter>datasz</parameter></term> 35094 <listitem> 35095 <para> 35096 size of payload data 35097 </para> 35098 </listitem> 35099 </varlistentry> 35100 </variablelist> 35101</refsect1> 35102</refentry> 35103 35104<refentry id="API-audit-list-rules-send"> 35105<refentryinfo> 35106 <title>LINUX</title> 35107 <productname>Kernel Hackers Manual</productname> 35108 <date>July 2017</date> 35109</refentryinfo> 35110<refmeta> 35111 <refentrytitle><phrase>audit_list_rules_send</phrase></refentrytitle> 35112 <manvolnum>9</manvolnum> 35113 <refmiscinfo class="version">4.1.27</refmiscinfo> 35114</refmeta> 35115<refnamediv> 35116 <refname>audit_list_rules_send</refname> 35117 <refpurpose> 35118 list the audit rules 35119 </refpurpose> 35120</refnamediv> 35121<refsynopsisdiv> 35122 <title>Synopsis</title> 35123 <funcsynopsis><funcprototype> 35124 <funcdef>int <function>audit_list_rules_send </function></funcdef> 35125 <paramdef>struct sk_buff * <parameter>request_skb</parameter></paramdef> 35126 <paramdef>int <parameter>seq</parameter></paramdef> 35127 </funcprototype></funcsynopsis> 35128</refsynopsisdiv> 35129<refsect1> 35130 <title>Arguments</title> 35131 <variablelist> 35132 <varlistentry> 35133 <term><parameter>request_skb</parameter></term> 35134 <listitem> 35135 <para> 35136 skb of request we are replying to (used to target the reply) 35137 </para> 35138 </listitem> 35139 </varlistentry> 35140 <varlistentry> 35141 <term><parameter>seq</parameter></term> 35142 <listitem> 35143 <para> 35144 netlink audit message sequence (serial) number 35145 </para> 35146 </listitem> 35147 </varlistentry> 35148 </variablelist> 35149</refsect1> 35150</refentry> 35151 35152<refentry id="API-parent-len"> 35153<refentryinfo> 35154 <title>LINUX</title> 35155 <productname>Kernel Hackers Manual</productname> 35156 <date>July 2017</date> 35157</refentryinfo> 35158<refmeta> 35159 <refentrytitle><phrase>parent_len</phrase></refentrytitle> 35160 <manvolnum>9</manvolnum> 35161 <refmiscinfo class="version">4.1.27</refmiscinfo> 35162</refmeta> 35163<refnamediv> 35164 <refname>parent_len</refname> 35165 <refpurpose> 35166 find the length of the parent portion of a pathname 35167 </refpurpose> 35168</refnamediv> 35169<refsynopsisdiv> 35170 <title>Synopsis</title> 35171 <funcsynopsis><funcprototype> 35172 <funcdef>int <function>parent_len </function></funcdef> 35173 <paramdef>const char * <parameter>path</parameter></paramdef> 35174 </funcprototype></funcsynopsis> 35175</refsynopsisdiv> 35176<refsect1> 35177 <title>Arguments</title> 35178 <variablelist> 35179 <varlistentry> 35180 <term><parameter>path</parameter></term> 35181 <listitem> 35182 <para> 35183 pathname of which to determine length 35184 </para> 35185 </listitem> 35186 </varlistentry> 35187 </variablelist> 35188</refsect1> 35189</refentry> 35190 35191<refentry id="API-audit-compare-dname-path"> 35192<refentryinfo> 35193 <title>LINUX</title> 35194 <productname>Kernel Hackers Manual</productname> 35195 <date>July 2017</date> 35196</refentryinfo> 35197<refmeta> 35198 <refentrytitle><phrase>audit_compare_dname_path</phrase></refentrytitle> 35199 <manvolnum>9</manvolnum> 35200 <refmiscinfo class="version">4.1.27</refmiscinfo> 35201</refmeta> 35202<refnamediv> 35203 <refname>audit_compare_dname_path</refname> 35204 <refpurpose> 35205 compare given dentry name with last component in given path. Return of 0 indicates a match. 35206 </refpurpose> 35207</refnamediv> 35208<refsynopsisdiv> 35209 <title>Synopsis</title> 35210 <funcsynopsis><funcprototype> 35211 <funcdef>int <function>audit_compare_dname_path </function></funcdef> 35212 <paramdef>const char * <parameter>dname</parameter></paramdef> 35213 <paramdef>const char * <parameter>path</parameter></paramdef> 35214 <paramdef>int <parameter>parentlen</parameter></paramdef> 35215 </funcprototype></funcsynopsis> 35216</refsynopsisdiv> 35217<refsect1> 35218 <title>Arguments</title> 35219 <variablelist> 35220 <varlistentry> 35221 <term><parameter>dname</parameter></term> 35222 <listitem> 35223 <para> 35224 dentry name that we're comparing 35225 </para> 35226 </listitem> 35227 </varlistentry> 35228 <varlistentry> 35229 <term><parameter>path</parameter></term> 35230 <listitem> 35231 <para> 35232 full pathname that we're comparing 35233 </para> 35234 </listitem> 35235 </varlistentry> 35236 <varlistentry> 35237 <term><parameter>parentlen</parameter></term> 35238 <listitem> 35239 <para> 35240 length of the parent if known. Passing in AUDIT_NAME_FULL 35241 here indicates that we must compute this value. 35242 </para> 35243 </listitem> 35244 </varlistentry> 35245 </variablelist> 35246</refsect1> 35247</refentry> 35248 35249 </chapter> 35250 35251 <chapter id="accounting"> 35252 <title>Accounting Framework</title> 35253<!-- kernel/acct.c --> 35254<refentry id="API-sys-acct"> 35255<refentryinfo> 35256 <title>LINUX</title> 35257 <productname>Kernel Hackers Manual</productname> 35258 <date>July 2017</date> 35259</refentryinfo> 35260<refmeta> 35261 <refentrytitle><phrase>sys_acct</phrase></refentrytitle> 35262 <manvolnum>9</manvolnum> 35263 <refmiscinfo class="version">4.1.27</refmiscinfo> 35264</refmeta> 35265<refnamediv> 35266 <refname>sys_acct</refname> 35267 <refpurpose> 35268 enable/disable process accounting 35269 </refpurpose> 35270</refnamediv> 35271<refsynopsisdiv> 35272 <title>Synopsis</title> 35273 <funcsynopsis><funcprototype> 35274 <funcdef>long <function>sys_acct </function></funcdef> 35275 <paramdef>const char __user * <parameter>name</parameter></paramdef> 35276 </funcprototype></funcsynopsis> 35277</refsynopsisdiv> 35278<refsect1> 35279 <title>Arguments</title> 35280 <variablelist> 35281 <varlistentry> 35282 <term><parameter>name</parameter></term> 35283 <listitem> 35284 <para> 35285 file name for accounting records or NULL to shutdown accounting 35286 </para> 35287 </listitem> 35288 </varlistentry> 35289 </variablelist> 35290</refsect1> 35291<refsect1> 35292<title>Description</title> 35293<para> 35294 Returns 0 for success or negative errno values for failure. 35295 </para><para> 35296 35297 <function>sys_acct</function> is the only system call needed to implement process 35298 accounting. It takes the name of the file where accounting records 35299 should be written. If the filename is NULL, accounting will be 35300 shutdown. 35301</para> 35302</refsect1> 35303</refentry> 35304 35305<refentry id="API-acct-collect"> 35306<refentryinfo> 35307 <title>LINUX</title> 35308 <productname>Kernel Hackers Manual</productname> 35309 <date>July 2017</date> 35310</refentryinfo> 35311<refmeta> 35312 <refentrytitle><phrase>acct_collect</phrase></refentrytitle> 35313 <manvolnum>9</manvolnum> 35314 <refmiscinfo class="version">4.1.27</refmiscinfo> 35315</refmeta> 35316<refnamediv> 35317 <refname>acct_collect</refname> 35318 <refpurpose> 35319 collect accounting information into pacct_struct 35320 </refpurpose> 35321</refnamediv> 35322<refsynopsisdiv> 35323 <title>Synopsis</title> 35324 <funcsynopsis><funcprototype> 35325 <funcdef>void <function>acct_collect </function></funcdef> 35326 <paramdef>long <parameter>exitcode</parameter></paramdef> 35327 <paramdef>int <parameter>group_dead</parameter></paramdef> 35328 </funcprototype></funcsynopsis> 35329</refsynopsisdiv> 35330<refsect1> 35331 <title>Arguments</title> 35332 <variablelist> 35333 <varlistentry> 35334 <term><parameter>exitcode</parameter></term> 35335 <listitem> 35336 <para> 35337 task exit code 35338 </para> 35339 </listitem> 35340 </varlistentry> 35341 <varlistentry> 35342 <term><parameter>group_dead</parameter></term> 35343 <listitem> 35344 <para> 35345 not 0, if this thread is the last one in the process. 35346 </para> 35347 </listitem> 35348 </varlistentry> 35349 </variablelist> 35350</refsect1> 35351</refentry> 35352 35353<refentry id="API-acct-process"> 35354<refentryinfo> 35355 <title>LINUX</title> 35356 <productname>Kernel Hackers Manual</productname> 35357 <date>July 2017</date> 35358</refentryinfo> 35359<refmeta> 35360 <refentrytitle><phrase>acct_process</phrase></refentrytitle> 35361 <manvolnum>9</manvolnum> 35362 <refmiscinfo class="version">4.1.27</refmiscinfo> 35363</refmeta> 35364<refnamediv> 35365 <refname>acct_process</refname> 35366 <refpurpose> 35367 </refpurpose> 35368</refnamediv> 35369<refsynopsisdiv> 35370 <title>Synopsis</title> 35371 <funcsynopsis><funcprototype> 35372 <funcdef>void <function>acct_process </function></funcdef> 35373 <paramdef> <parameter>void</parameter></paramdef> 35374 </funcprototype></funcsynopsis> 35375</refsynopsisdiv> 35376<refsect1> 35377 <title>Arguments</title> 35378 <variablelist> 35379 <varlistentry> 35380 <term><parameter>void</parameter></term> 35381 <listitem> 35382 <para> 35383 no arguments 35384 </para> 35385 </listitem> 35386 </varlistentry> 35387 </variablelist> 35388</refsect1> 35389<refsect1> 35390<title>Description</title> 35391<para> 35392 </para><para> 35393 35394 handles process accounting for an exiting task 35395</para> 35396</refsect1> 35397</refentry> 35398 35399 </chapter> 35400 35401 <chapter id="blkdev"> 35402 <title>Block Devices</title> 35403<!-- block/blk-core.c --> 35404<refentry id="API-blk-get-backing-dev-info"> 35405<refentryinfo> 35406 <title>LINUX</title> 35407 <productname>Kernel Hackers Manual</productname> 35408 <date>July 2017</date> 35409</refentryinfo> 35410<refmeta> 35411 <refentrytitle><phrase>blk_get_backing_dev_info</phrase></refentrytitle> 35412 <manvolnum>9</manvolnum> 35413 <refmiscinfo class="version">4.1.27</refmiscinfo> 35414</refmeta> 35415<refnamediv> 35416 <refname>blk_get_backing_dev_info</refname> 35417 <refpurpose> 35418 get the address of a queue's backing_dev_info 35419 </refpurpose> 35420</refnamediv> 35421<refsynopsisdiv> 35422 <title>Synopsis</title> 35423 <funcsynopsis><funcprototype> 35424 <funcdef>struct backing_dev_info * <function>blk_get_backing_dev_info </function></funcdef> 35425 <paramdef>struct block_device * <parameter>bdev</parameter></paramdef> 35426 </funcprototype></funcsynopsis> 35427</refsynopsisdiv> 35428<refsect1> 35429 <title>Arguments</title> 35430 <variablelist> 35431 <varlistentry> 35432 <term><parameter>bdev</parameter></term> 35433 <listitem> 35434 <para> 35435 device 35436 </para> 35437 </listitem> 35438 </varlistentry> 35439 </variablelist> 35440</refsect1> 35441<refsect1> 35442<title>Description</title> 35443<para> 35444 Locates the passed device's request queue and returns the address of its 35445 backing_dev_info. This function can only be called if <parameter>bdev</parameter> is opened 35446 and the return value is never NULL. 35447</para> 35448</refsect1> 35449</refentry> 35450 35451<refentry id="API-blk-delay-queue"> 35452<refentryinfo> 35453 <title>LINUX</title> 35454 <productname>Kernel Hackers Manual</productname> 35455 <date>July 2017</date> 35456</refentryinfo> 35457<refmeta> 35458 <refentrytitle><phrase>blk_delay_queue</phrase></refentrytitle> 35459 <manvolnum>9</manvolnum> 35460 <refmiscinfo class="version">4.1.27</refmiscinfo> 35461</refmeta> 35462<refnamediv> 35463 <refname>blk_delay_queue</refname> 35464 <refpurpose> 35465 restart queueing after defined interval 35466 </refpurpose> 35467</refnamediv> 35468<refsynopsisdiv> 35469 <title>Synopsis</title> 35470 <funcsynopsis><funcprototype> 35471 <funcdef>void <function>blk_delay_queue </function></funcdef> 35472 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 35473 <paramdef>unsigned long <parameter>msecs</parameter></paramdef> 35474 </funcprototype></funcsynopsis> 35475</refsynopsisdiv> 35476<refsect1> 35477 <title>Arguments</title> 35478 <variablelist> 35479 <varlistentry> 35480 <term><parameter>q</parameter></term> 35481 <listitem> 35482 <para> 35483 The <structname>struct request_queue</structname> in question 35484 </para> 35485 </listitem> 35486 </varlistentry> 35487 <varlistentry> 35488 <term><parameter>msecs</parameter></term> 35489 <listitem> 35490 <para> 35491 Delay in msecs 35492 </para> 35493 </listitem> 35494 </varlistentry> 35495 </variablelist> 35496</refsect1> 35497<refsect1> 35498<title>Description</title> 35499<para> 35500 Sometimes queueing needs to be postponed for a little while, to allow 35501 resources to come back. This function will make sure that queueing is 35502 restarted around the specified time. Queue lock must be held. 35503</para> 35504</refsect1> 35505</refentry> 35506 35507<refentry id="API-blk-start-queue"> 35508<refentryinfo> 35509 <title>LINUX</title> 35510 <productname>Kernel Hackers Manual</productname> 35511 <date>July 2017</date> 35512</refentryinfo> 35513<refmeta> 35514 <refentrytitle><phrase>blk_start_queue</phrase></refentrytitle> 35515 <manvolnum>9</manvolnum> 35516 <refmiscinfo class="version">4.1.27</refmiscinfo> 35517</refmeta> 35518<refnamediv> 35519 <refname>blk_start_queue</refname> 35520 <refpurpose> 35521 restart a previously stopped queue 35522 </refpurpose> 35523</refnamediv> 35524<refsynopsisdiv> 35525 <title>Synopsis</title> 35526 <funcsynopsis><funcprototype> 35527 <funcdef>void <function>blk_start_queue </function></funcdef> 35528 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 35529 </funcprototype></funcsynopsis> 35530</refsynopsisdiv> 35531<refsect1> 35532 <title>Arguments</title> 35533 <variablelist> 35534 <varlistentry> 35535 <term><parameter>q</parameter></term> 35536 <listitem> 35537 <para> 35538 The <structname>struct request_queue</structname> in question 35539 </para> 35540 </listitem> 35541 </varlistentry> 35542 </variablelist> 35543</refsect1> 35544<refsect1> 35545<title>Description</title> 35546<para> 35547 <function>blk_start_queue</function> will clear the stop flag on the queue, and call 35548 the request_fn for the queue if it was in a stopped state when 35549 entered. Also see <function>blk_stop_queue</function>. Queue lock must be held. 35550</para> 35551</refsect1> 35552</refentry> 35553 35554<refentry id="API-blk-stop-queue"> 35555<refentryinfo> 35556 <title>LINUX</title> 35557 <productname>Kernel Hackers Manual</productname> 35558 <date>July 2017</date> 35559</refentryinfo> 35560<refmeta> 35561 <refentrytitle><phrase>blk_stop_queue</phrase></refentrytitle> 35562 <manvolnum>9</manvolnum> 35563 <refmiscinfo class="version">4.1.27</refmiscinfo> 35564</refmeta> 35565<refnamediv> 35566 <refname>blk_stop_queue</refname> 35567 <refpurpose> 35568 stop a queue 35569 </refpurpose> 35570</refnamediv> 35571<refsynopsisdiv> 35572 <title>Synopsis</title> 35573 <funcsynopsis><funcprototype> 35574 <funcdef>void <function>blk_stop_queue </function></funcdef> 35575 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 35576 </funcprototype></funcsynopsis> 35577</refsynopsisdiv> 35578<refsect1> 35579 <title>Arguments</title> 35580 <variablelist> 35581 <varlistentry> 35582 <term><parameter>q</parameter></term> 35583 <listitem> 35584 <para> 35585 The <structname>struct request_queue</structname> in question 35586 </para> 35587 </listitem> 35588 </varlistentry> 35589 </variablelist> 35590</refsect1> 35591<refsect1> 35592<title>Description</title> 35593<para> 35594 The Linux block layer assumes that a block driver will consume all 35595 entries on the request queue when the request_fn strategy is called. 35596 Often this will not happen, because of hardware limitations (queue 35597 depth settings). If a device driver gets a 'queue full' response, 35598 or if it simply chooses not to queue more I/O at one point, it can 35599 call this function to prevent the request_fn from being called until 35600 the driver has signalled it's ready to go again. This happens by calling 35601 <function>blk_start_queue</function> to restart queue operations. Queue lock must be held. 35602</para> 35603</refsect1> 35604</refentry> 35605 35606<refentry id="API-blk-sync-queue"> 35607<refentryinfo> 35608 <title>LINUX</title> 35609 <productname>Kernel Hackers Manual</productname> 35610 <date>July 2017</date> 35611</refentryinfo> 35612<refmeta> 35613 <refentrytitle><phrase>blk_sync_queue</phrase></refentrytitle> 35614 <manvolnum>9</manvolnum> 35615 <refmiscinfo class="version">4.1.27</refmiscinfo> 35616</refmeta> 35617<refnamediv> 35618 <refname>blk_sync_queue</refname> 35619 <refpurpose> 35620 cancel any pending callbacks on a queue 35621 </refpurpose> 35622</refnamediv> 35623<refsynopsisdiv> 35624 <title>Synopsis</title> 35625 <funcsynopsis><funcprototype> 35626 <funcdef>void <function>blk_sync_queue </function></funcdef> 35627 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 35628 </funcprototype></funcsynopsis> 35629</refsynopsisdiv> 35630<refsect1> 35631 <title>Arguments</title> 35632 <variablelist> 35633 <varlistentry> 35634 <term><parameter>q</parameter></term> 35635 <listitem> 35636 <para> 35637 the queue 35638 </para> 35639 </listitem> 35640 </varlistentry> 35641 </variablelist> 35642</refsect1> 35643<refsect1> 35644<title>Description</title> 35645<para> 35646 The block layer may perform asynchronous callback activity 35647 on a queue, such as calling the unplug function after a timeout. 35648 A block device may call blk_sync_queue to ensure that any 35649 such activity is cancelled, thus allowing it to release resources 35650 that the callbacks might use. The caller must already have made sure 35651 that its ->make_request_fn will not re-add plugging prior to calling 35652 this function. 35653 </para><para> 35654 35655 This function does not cancel any asynchronous activity arising 35656 out of elevator or throttling code. That would require <function>elevator_exit</function> 35657 and <function>blkcg_exit_queue</function> to be called with queue lock initialized. 35658</para> 35659</refsect1> 35660</refentry> 35661 35662<refentry id="API---blk-run-queue"> 35663<refentryinfo> 35664 <title>LINUX</title> 35665 <productname>Kernel Hackers Manual</productname> 35666 <date>July 2017</date> 35667</refentryinfo> 35668<refmeta> 35669 <refentrytitle><phrase>__blk_run_queue</phrase></refentrytitle> 35670 <manvolnum>9</manvolnum> 35671 <refmiscinfo class="version">4.1.27</refmiscinfo> 35672</refmeta> 35673<refnamediv> 35674 <refname>__blk_run_queue</refname> 35675 <refpurpose> 35676 run a single device queue 35677 </refpurpose> 35678</refnamediv> 35679<refsynopsisdiv> 35680 <title>Synopsis</title> 35681 <funcsynopsis><funcprototype> 35682 <funcdef>void <function>__blk_run_queue </function></funcdef> 35683 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 35684 </funcprototype></funcsynopsis> 35685</refsynopsisdiv> 35686<refsect1> 35687 <title>Arguments</title> 35688 <variablelist> 35689 <varlistentry> 35690 <term><parameter>q</parameter></term> 35691 <listitem> 35692 <para> 35693 The queue to run 35694 </para> 35695 </listitem> 35696 </varlistentry> 35697 </variablelist> 35698</refsect1> 35699<refsect1> 35700<title>Description</title> 35701<para> 35702 See <parameter>blk_run_queue</parameter>. This variant must be called with the queue lock 35703 held and interrupts disabled. 35704</para> 35705</refsect1> 35706</refentry> 35707 35708<refentry id="API-blk-run-queue-async"> 35709<refentryinfo> 35710 <title>LINUX</title> 35711 <productname>Kernel Hackers Manual</productname> 35712 <date>July 2017</date> 35713</refentryinfo> 35714<refmeta> 35715 <refentrytitle><phrase>blk_run_queue_async</phrase></refentrytitle> 35716 <manvolnum>9</manvolnum> 35717 <refmiscinfo class="version">4.1.27</refmiscinfo> 35718</refmeta> 35719<refnamediv> 35720 <refname>blk_run_queue_async</refname> 35721 <refpurpose> 35722 run a single device queue in workqueue context 35723 </refpurpose> 35724</refnamediv> 35725<refsynopsisdiv> 35726 <title>Synopsis</title> 35727 <funcsynopsis><funcprototype> 35728 <funcdef>void <function>blk_run_queue_async </function></funcdef> 35729 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 35730 </funcprototype></funcsynopsis> 35731</refsynopsisdiv> 35732<refsect1> 35733 <title>Arguments</title> 35734 <variablelist> 35735 <varlistentry> 35736 <term><parameter>q</parameter></term> 35737 <listitem> 35738 <para> 35739 The queue to run 35740 </para> 35741 </listitem> 35742 </varlistentry> 35743 </variablelist> 35744</refsect1> 35745<refsect1> 35746<title>Description</title> 35747<para> 35748 Tells kblockd to perform the equivalent of <parameter>blk_run_queue</parameter> on behalf 35749 of us. The caller must hold the queue lock. 35750</para> 35751</refsect1> 35752</refentry> 35753 35754<refentry id="API-blk-run-queue"> 35755<refentryinfo> 35756 <title>LINUX</title> 35757 <productname>Kernel Hackers Manual</productname> 35758 <date>July 2017</date> 35759</refentryinfo> 35760<refmeta> 35761 <refentrytitle><phrase>blk_run_queue</phrase></refentrytitle> 35762 <manvolnum>9</manvolnum> 35763 <refmiscinfo class="version">4.1.27</refmiscinfo> 35764</refmeta> 35765<refnamediv> 35766 <refname>blk_run_queue</refname> 35767 <refpurpose> 35768 run a single device queue 35769 </refpurpose> 35770</refnamediv> 35771<refsynopsisdiv> 35772 <title>Synopsis</title> 35773 <funcsynopsis><funcprototype> 35774 <funcdef>void <function>blk_run_queue </function></funcdef> 35775 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 35776 </funcprototype></funcsynopsis> 35777</refsynopsisdiv> 35778<refsect1> 35779 <title>Arguments</title> 35780 <variablelist> 35781 <varlistentry> 35782 <term><parameter>q</parameter></term> 35783 <listitem> 35784 <para> 35785 The queue to run 35786 </para> 35787 </listitem> 35788 </varlistentry> 35789 </variablelist> 35790</refsect1> 35791<refsect1> 35792<title>Description</title> 35793<para> 35794 Invoke request handling on this queue, if it has pending work to do. 35795 May be used to restart queueing when a request has completed. 35796</para> 35797</refsect1> 35798</refentry> 35799 35800<refentry id="API-blk-queue-bypass-start"> 35801<refentryinfo> 35802 <title>LINUX</title> 35803 <productname>Kernel Hackers Manual</productname> 35804 <date>July 2017</date> 35805</refentryinfo> 35806<refmeta> 35807 <refentrytitle><phrase>blk_queue_bypass_start</phrase></refentrytitle> 35808 <manvolnum>9</manvolnum> 35809 <refmiscinfo class="version">4.1.27</refmiscinfo> 35810</refmeta> 35811<refnamediv> 35812 <refname>blk_queue_bypass_start</refname> 35813 <refpurpose> 35814 enter queue bypass mode 35815 </refpurpose> 35816</refnamediv> 35817<refsynopsisdiv> 35818 <title>Synopsis</title> 35819 <funcsynopsis><funcprototype> 35820 <funcdef>void <function>blk_queue_bypass_start </function></funcdef> 35821 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 35822 </funcprototype></funcsynopsis> 35823</refsynopsisdiv> 35824<refsect1> 35825 <title>Arguments</title> 35826 <variablelist> 35827 <varlistentry> 35828 <term><parameter>q</parameter></term> 35829 <listitem> 35830 <para> 35831 queue of interest 35832 </para> 35833 </listitem> 35834 </varlistentry> 35835 </variablelist> 35836</refsect1> 35837<refsect1> 35838<title>Description</title> 35839<para> 35840 In bypass mode, only the dispatch FIFO queue of <parameter>q</parameter> is used. This 35841 function makes <parameter>q</parameter> enter bypass mode and drains all requests which were 35842 throttled or issued before. On return, it's guaranteed that no request 35843 is being throttled or has ELVPRIV set and <function>blk_queue_bypass</function> <constant>true</constant> 35844 inside queue or RCU read lock. 35845</para> 35846</refsect1> 35847</refentry> 35848 35849<refentry id="API-blk-queue-bypass-end"> 35850<refentryinfo> 35851 <title>LINUX</title> 35852 <productname>Kernel Hackers Manual</productname> 35853 <date>July 2017</date> 35854</refentryinfo> 35855<refmeta> 35856 <refentrytitle><phrase>blk_queue_bypass_end</phrase></refentrytitle> 35857 <manvolnum>9</manvolnum> 35858 <refmiscinfo class="version">4.1.27</refmiscinfo> 35859</refmeta> 35860<refnamediv> 35861 <refname>blk_queue_bypass_end</refname> 35862 <refpurpose> 35863 leave queue bypass mode 35864 </refpurpose> 35865</refnamediv> 35866<refsynopsisdiv> 35867 <title>Synopsis</title> 35868 <funcsynopsis><funcprototype> 35869 <funcdef>void <function>blk_queue_bypass_end </function></funcdef> 35870 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 35871 </funcprototype></funcsynopsis> 35872</refsynopsisdiv> 35873<refsect1> 35874 <title>Arguments</title> 35875 <variablelist> 35876 <varlistentry> 35877 <term><parameter>q</parameter></term> 35878 <listitem> 35879 <para> 35880 queue of interest 35881 </para> 35882 </listitem> 35883 </varlistentry> 35884 </variablelist> 35885</refsect1> 35886<refsect1> 35887<title>Description</title> 35888<para> 35889 Leave bypass mode and restore the normal queueing behavior. 35890</para> 35891</refsect1> 35892</refentry> 35893 35894<refentry id="API-blk-cleanup-queue"> 35895<refentryinfo> 35896 <title>LINUX</title> 35897 <productname>Kernel Hackers Manual</productname> 35898 <date>July 2017</date> 35899</refentryinfo> 35900<refmeta> 35901 <refentrytitle><phrase>blk_cleanup_queue</phrase></refentrytitle> 35902 <manvolnum>9</manvolnum> 35903 <refmiscinfo class="version">4.1.27</refmiscinfo> 35904</refmeta> 35905<refnamediv> 35906 <refname>blk_cleanup_queue</refname> 35907 <refpurpose> 35908 shutdown a request queue 35909 </refpurpose> 35910</refnamediv> 35911<refsynopsisdiv> 35912 <title>Synopsis</title> 35913 <funcsynopsis><funcprototype> 35914 <funcdef>void <function>blk_cleanup_queue </function></funcdef> 35915 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 35916 </funcprototype></funcsynopsis> 35917</refsynopsisdiv> 35918<refsect1> 35919 <title>Arguments</title> 35920 <variablelist> 35921 <varlistentry> 35922 <term><parameter>q</parameter></term> 35923 <listitem> 35924 <para> 35925 request queue to shutdown 35926 </para> 35927 </listitem> 35928 </varlistentry> 35929 </variablelist> 35930</refsect1> 35931<refsect1> 35932<title>Description</title> 35933<para> 35934 Mark <parameter>q</parameter> DYING, drain all pending requests, mark <parameter>q</parameter> DEAD, destroy and 35935 put it. All future requests will be failed immediately with -ENODEV. 35936</para> 35937</refsect1> 35938</refentry> 35939 35940<refentry id="API-blk-init-queue"> 35941<refentryinfo> 35942 <title>LINUX</title> 35943 <productname>Kernel Hackers Manual</productname> 35944 <date>July 2017</date> 35945</refentryinfo> 35946<refmeta> 35947 <refentrytitle><phrase>blk_init_queue</phrase></refentrytitle> 35948 <manvolnum>9</manvolnum> 35949 <refmiscinfo class="version">4.1.27</refmiscinfo> 35950</refmeta> 35951<refnamediv> 35952 <refname>blk_init_queue</refname> 35953 <refpurpose> 35954 prepare a request queue for use with a block device 35955 </refpurpose> 35956</refnamediv> 35957<refsynopsisdiv> 35958 <title>Synopsis</title> 35959 <funcsynopsis><funcprototype> 35960 <funcdef>struct request_queue * <function>blk_init_queue </function></funcdef> 35961 <paramdef>request_fn_proc * <parameter>rfn</parameter></paramdef> 35962 <paramdef>spinlock_t * <parameter>lock</parameter></paramdef> 35963 </funcprototype></funcsynopsis> 35964</refsynopsisdiv> 35965<refsect1> 35966 <title>Arguments</title> 35967 <variablelist> 35968 <varlistentry> 35969 <term><parameter>rfn</parameter></term> 35970 <listitem> 35971 <para> 35972 The function to be called to process requests that have been 35973 placed on the queue. 35974 </para> 35975 </listitem> 35976 </varlistentry> 35977 <varlistentry> 35978 <term><parameter>lock</parameter></term> 35979 <listitem> 35980 <para> 35981 Request queue spin lock 35982 </para> 35983 </listitem> 35984 </varlistentry> 35985 </variablelist> 35986</refsect1> 35987<refsect1> 35988<title>Description</title> 35989<para> 35990 If a block device wishes to use the standard request handling procedures, 35991 which sorts requests and coalesces adjacent requests, then it must 35992 call <function>blk_init_queue</function>. The function <parameter>rfn</parameter> will be called when there 35993 are requests on the queue that need to be processed. If the device 35994 supports plugging, then <parameter>rfn</parameter> may not be called immediately when requests 35995 are available on the queue, but may be called at some time later instead. 35996 Plugged queues are generally unplugged when a buffer belonging to one 35997 of the requests on the queue is needed, or due to memory pressure. 35998 </para><para> 35999 36000 <parameter>rfn</parameter> is not required, or even expected, to remove all requests off the 36001 queue, but only as many as it can handle at a time. If it does leave 36002 requests on the queue, it is responsible for arranging that the requests 36003 get dealt with eventually. 36004 </para><para> 36005 36006 The queue spin lock must be held while manipulating the requests on the 36007 request queue; this lock will be taken also from interrupt context, so irq 36008 disabling is needed for it. 36009 </para><para> 36010 36011 Function returns a pointer to the initialized request queue, or <constant>NULL</constant> if 36012 it didn't succeed. 36013</para> 36014</refsect1> 36015<refsect1> 36016<title>Note</title> 36017<para> 36018 <function>blk_init_queue</function> must be paired with a <function>blk_cleanup_queue</function> call 36019 when the block device is deactivated (such as at module unload). 36020</para> 36021</refsect1> 36022</refentry> 36023 36024<refentry id="API-blk-make-request"> 36025<refentryinfo> 36026 <title>LINUX</title> 36027 <productname>Kernel Hackers Manual</productname> 36028 <date>July 2017</date> 36029</refentryinfo> 36030<refmeta> 36031 <refentrytitle><phrase>blk_make_request</phrase></refentrytitle> 36032 <manvolnum>9</manvolnum> 36033 <refmiscinfo class="version">4.1.27</refmiscinfo> 36034</refmeta> 36035<refnamediv> 36036 <refname>blk_make_request</refname> 36037 <refpurpose> 36038 given a bio, allocate a corresponding struct request. 36039 </refpurpose> 36040</refnamediv> 36041<refsynopsisdiv> 36042 <title>Synopsis</title> 36043 <funcsynopsis><funcprototype> 36044 <funcdef>struct request * <function>blk_make_request </function></funcdef> 36045 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 36046 <paramdef>struct bio * <parameter>bio</parameter></paramdef> 36047 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 36048 </funcprototype></funcsynopsis> 36049</refsynopsisdiv> 36050<refsect1> 36051 <title>Arguments</title> 36052 <variablelist> 36053 <varlistentry> 36054 <term><parameter>q</parameter></term> 36055 <listitem> 36056 <para> 36057 target request queue 36058 </para> 36059 </listitem> 36060 </varlistentry> 36061 <varlistentry> 36062 <term><parameter>bio</parameter></term> 36063 <listitem> 36064 <para> 36065 The bio describing the memory mappings that will be submitted for IO. 36066 It may be a chained-bio properly constructed by block/bio layer. 36067 </para> 36068 </listitem> 36069 </varlistentry> 36070 <varlistentry> 36071 <term><parameter>gfp_mask</parameter></term> 36072 <listitem> 36073 <para> 36074 gfp flags to be used for memory allocation 36075 </para> 36076 </listitem> 36077 </varlistentry> 36078 </variablelist> 36079</refsect1> 36080<refsect1> 36081<title>Description</title> 36082<para> 36083 blk_make_request is the parallel of generic_make_request for BLOCK_PC 36084 type commands. Where the struct request needs to be farther initialized by 36085 the caller. It is passed a <structname>struct bio</structname>, which describes the memory info of 36086 the I/O transfer. 36087 </para><para> 36088 36089 The caller of blk_make_request must make sure that bi_io_vec 36090 are set to describe the memory buffers. That <function>bio_data_dir</function> will return 36091 the needed direction of the request. (And all bio's in the passed bio-chain 36092 are properly set accordingly) 36093 </para><para> 36094 36095 If called under none-sleepable conditions, mapped bio buffers must not 36096 need bouncing, by calling the appropriate masked or flagged allocator, 36097 suitable for the target device. Otherwise the call to blk_queue_bounce will 36098 BUG. 36099</para> 36100</refsect1> 36101<refsect1> 36102<title>WARNING</title> 36103<para> 36104 When allocating/cloning a bio-chain, careful consideration should be 36105 given to how you allocate bios. In particular, you cannot use __GFP_WAIT for 36106 anything but the first bio in the chain. Otherwise you risk waiting for IO 36107 completion of a bio that hasn't been submitted yet, thus resulting in a 36108 deadlock. Alternatively bios should be allocated using <function>bio_kmalloc</function> instead 36109 of <function>bio_alloc</function>, as that avoids the mempool deadlock. 36110 If possible a big IO should be split into smaller parts when allocation 36111 fails. Partial allocation should not be an error, or you risk a live-lock. 36112</para> 36113</refsect1> 36114</refentry> 36115 36116<refentry id="API-blk-rq-set-block-pc"> 36117<refentryinfo> 36118 <title>LINUX</title> 36119 <productname>Kernel Hackers Manual</productname> 36120 <date>July 2017</date> 36121</refentryinfo> 36122<refmeta> 36123 <refentrytitle><phrase>blk_rq_set_block_pc</phrase></refentrytitle> 36124 <manvolnum>9</manvolnum> 36125 <refmiscinfo class="version">4.1.27</refmiscinfo> 36126</refmeta> 36127<refnamediv> 36128 <refname>blk_rq_set_block_pc</refname> 36129 <refpurpose> 36130 initialize a request to type BLOCK_PC 36131 </refpurpose> 36132</refnamediv> 36133<refsynopsisdiv> 36134 <title>Synopsis</title> 36135 <funcsynopsis><funcprototype> 36136 <funcdef>void <function>blk_rq_set_block_pc </function></funcdef> 36137 <paramdef>struct request * <parameter>rq</parameter></paramdef> 36138 </funcprototype></funcsynopsis> 36139</refsynopsisdiv> 36140<refsect1> 36141 <title>Arguments</title> 36142 <variablelist> 36143 <varlistentry> 36144 <term><parameter>rq</parameter></term> 36145 <listitem> 36146 <para> 36147 request to be initialized 36148 </para> 36149 </listitem> 36150 </varlistentry> 36151 </variablelist> 36152</refsect1> 36153</refentry> 36154 36155<refentry id="API-blk-requeue-request"> 36156<refentryinfo> 36157 <title>LINUX</title> 36158 <productname>Kernel Hackers Manual</productname> 36159 <date>July 2017</date> 36160</refentryinfo> 36161<refmeta> 36162 <refentrytitle><phrase>blk_requeue_request</phrase></refentrytitle> 36163 <manvolnum>9</manvolnum> 36164 <refmiscinfo class="version">4.1.27</refmiscinfo> 36165</refmeta> 36166<refnamediv> 36167 <refname>blk_requeue_request</refname> 36168 <refpurpose> 36169 put a request back on queue 36170 </refpurpose> 36171</refnamediv> 36172<refsynopsisdiv> 36173 <title>Synopsis</title> 36174 <funcsynopsis><funcprototype> 36175 <funcdef>void <function>blk_requeue_request </function></funcdef> 36176 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 36177 <paramdef>struct request * <parameter>rq</parameter></paramdef> 36178 </funcprototype></funcsynopsis> 36179</refsynopsisdiv> 36180<refsect1> 36181 <title>Arguments</title> 36182 <variablelist> 36183 <varlistentry> 36184 <term><parameter>q</parameter></term> 36185 <listitem> 36186 <para> 36187 request queue where request should be inserted 36188 </para> 36189 </listitem> 36190 </varlistentry> 36191 <varlistentry> 36192 <term><parameter>rq</parameter></term> 36193 <listitem> 36194 <para> 36195 request to be inserted 36196 </para> 36197 </listitem> 36198 </varlistentry> 36199 </variablelist> 36200</refsect1> 36201<refsect1> 36202<title>Description</title> 36203<para> 36204 Drivers often keep queueing requests until the hardware cannot accept 36205 more, when that condition happens we need to put the request back 36206 on the queue. Must be called with queue lock held. 36207</para> 36208</refsect1> 36209</refentry> 36210 36211<refentry id="API-part-round-stats"> 36212<refentryinfo> 36213 <title>LINUX</title> 36214 <productname>Kernel Hackers Manual</productname> 36215 <date>July 2017</date> 36216</refentryinfo> 36217<refmeta> 36218 <refentrytitle><phrase>part_round_stats</phrase></refentrytitle> 36219 <manvolnum>9</manvolnum> 36220 <refmiscinfo class="version">4.1.27</refmiscinfo> 36221</refmeta> 36222<refnamediv> 36223 <refname>part_round_stats</refname> 36224 <refpurpose> 36225 Round off the performance stats on a struct disk_stats. 36226 </refpurpose> 36227</refnamediv> 36228<refsynopsisdiv> 36229 <title>Synopsis</title> 36230 <funcsynopsis><funcprototype> 36231 <funcdef>void <function>part_round_stats </function></funcdef> 36232 <paramdef>int <parameter>cpu</parameter></paramdef> 36233 <paramdef>struct hd_struct * <parameter>part</parameter></paramdef> 36234 </funcprototype></funcsynopsis> 36235</refsynopsisdiv> 36236<refsect1> 36237 <title>Arguments</title> 36238 <variablelist> 36239 <varlistentry> 36240 <term><parameter>cpu</parameter></term> 36241 <listitem> 36242 <para> 36243 cpu number for stats access 36244 </para> 36245 </listitem> 36246 </varlistentry> 36247 <varlistentry> 36248 <term><parameter>part</parameter></term> 36249 <listitem> 36250 <para> 36251 target partition 36252 </para> 36253 </listitem> 36254 </varlistentry> 36255 </variablelist> 36256</refsect1> 36257<refsect1> 36258<title>Description</title> 36259<para> 36260 The average IO queue length and utilisation statistics are maintained 36261 by observing the current state of the queue length and the amount of 36262 time it has been in this state for. 36263 </para><para> 36264 36265 Normally, that accounting is done on IO completion, but that can result 36266 in more than a second's worth of IO being accounted for within any one 36267 second, leading to >100% utilisation. To deal with that, we call this 36268 function to do a round-off before returning the results when reading 36269 /proc/diskstats. This accounts immediately for all queue usage up to 36270 the current jiffies and restarts the counters again. 36271</para> 36272</refsect1> 36273</refentry> 36274 36275<refentry id="API-blk-add-request-payload"> 36276<refentryinfo> 36277 <title>LINUX</title> 36278 <productname>Kernel Hackers Manual</productname> 36279 <date>July 2017</date> 36280</refentryinfo> 36281<refmeta> 36282 <refentrytitle><phrase>blk_add_request_payload</phrase></refentrytitle> 36283 <manvolnum>9</manvolnum> 36284 <refmiscinfo class="version">4.1.27</refmiscinfo> 36285</refmeta> 36286<refnamediv> 36287 <refname>blk_add_request_payload</refname> 36288 <refpurpose> 36289 add a payload to a request 36290 </refpurpose> 36291</refnamediv> 36292<refsynopsisdiv> 36293 <title>Synopsis</title> 36294 <funcsynopsis><funcprototype> 36295 <funcdef>void <function>blk_add_request_payload </function></funcdef> 36296 <paramdef>struct request * <parameter>rq</parameter></paramdef> 36297 <paramdef>struct page * <parameter>page</parameter></paramdef> 36298 <paramdef>unsigned int <parameter>len</parameter></paramdef> 36299 </funcprototype></funcsynopsis> 36300</refsynopsisdiv> 36301<refsect1> 36302 <title>Arguments</title> 36303 <variablelist> 36304 <varlistentry> 36305 <term><parameter>rq</parameter></term> 36306 <listitem> 36307 <para> 36308 request to update 36309 </para> 36310 </listitem> 36311 </varlistentry> 36312 <varlistentry> 36313 <term><parameter>page</parameter></term> 36314 <listitem> 36315 <para> 36316 page backing the payload 36317 </para> 36318 </listitem> 36319 </varlistentry> 36320 <varlistentry> 36321 <term><parameter>len</parameter></term> 36322 <listitem> 36323 <para> 36324 length of the payload. 36325 </para> 36326 </listitem> 36327 </varlistentry> 36328 </variablelist> 36329</refsect1> 36330<refsect1> 36331<title>Description</title> 36332<para> 36333 This allows to later add a payload to an already submitted request by 36334 a block driver. The driver needs to take care of freeing the payload 36335 itself. 36336 </para><para> 36337 36338 Note that this is a quite horrible hack and nothing but handling of 36339 discard requests should ever use it. 36340</para> 36341</refsect1> 36342</refentry> 36343 36344<refentry id="API-generic-make-request"> 36345<refentryinfo> 36346 <title>LINUX</title> 36347 <productname>Kernel Hackers Manual</productname> 36348 <date>July 2017</date> 36349</refentryinfo> 36350<refmeta> 36351 <refentrytitle><phrase>generic_make_request</phrase></refentrytitle> 36352 <manvolnum>9</manvolnum> 36353 <refmiscinfo class="version">4.1.27</refmiscinfo> 36354</refmeta> 36355<refnamediv> 36356 <refname>generic_make_request</refname> 36357 <refpurpose> 36358 hand a buffer to its device driver for I/O 36359 </refpurpose> 36360</refnamediv> 36361<refsynopsisdiv> 36362 <title>Synopsis</title> 36363 <funcsynopsis><funcprototype> 36364 <funcdef>void <function>generic_make_request </function></funcdef> 36365 <paramdef>struct bio * <parameter>bio</parameter></paramdef> 36366 </funcprototype></funcsynopsis> 36367</refsynopsisdiv> 36368<refsect1> 36369 <title>Arguments</title> 36370 <variablelist> 36371 <varlistentry> 36372 <term><parameter>bio</parameter></term> 36373 <listitem> 36374 <para> 36375 The bio describing the location in memory and on the device. 36376 </para> 36377 </listitem> 36378 </varlistentry> 36379 </variablelist> 36380</refsect1> 36381<refsect1> 36382<title>Description</title> 36383<para> 36384 <function>generic_make_request</function> is used to make I/O requests of block 36385 devices. It is passed a <structname>struct bio</structname>, which describes the I/O that needs 36386 to be done. 36387 </para><para> 36388 36389 <function>generic_make_request</function> does not return any status. The 36390 success/failure status of the request, along with notification of 36391 completion, is delivered asynchronously through the bio->bi_end_io 36392 function described (one day) else where. 36393 </para><para> 36394 36395 The caller of generic_make_request must make sure that bi_io_vec 36396 are set to describe the memory buffer, and that bi_dev and bi_sector are 36397 set to describe the device address, and the 36398 bi_end_io and optionally bi_private are set to describe how 36399 completion notification should be signaled. 36400 </para><para> 36401 36402 generic_make_request and the drivers it calls may use bi_next if this 36403 bio happens to be merged with someone else, and may resubmit the bio to 36404 a lower device by calling into generic_make_request recursively, which 36405 means the bio should NOT be touched after the call to ->make_request_fn. 36406</para> 36407</refsect1> 36408</refentry> 36409 36410<refentry id="API-submit-bio"> 36411<refentryinfo> 36412 <title>LINUX</title> 36413 <productname>Kernel Hackers Manual</productname> 36414 <date>July 2017</date> 36415</refentryinfo> 36416<refmeta> 36417 <refentrytitle><phrase>submit_bio</phrase></refentrytitle> 36418 <manvolnum>9</manvolnum> 36419 <refmiscinfo class="version">4.1.27</refmiscinfo> 36420</refmeta> 36421<refnamediv> 36422 <refname>submit_bio</refname> 36423 <refpurpose> 36424 submit a bio to the block device layer for I/O 36425 </refpurpose> 36426</refnamediv> 36427<refsynopsisdiv> 36428 <title>Synopsis</title> 36429 <funcsynopsis><funcprototype> 36430 <funcdef>void <function>submit_bio </function></funcdef> 36431 <paramdef>int <parameter>rw</parameter></paramdef> 36432 <paramdef>struct bio * <parameter>bio</parameter></paramdef> 36433 </funcprototype></funcsynopsis> 36434</refsynopsisdiv> 36435<refsect1> 36436 <title>Arguments</title> 36437 <variablelist> 36438 <varlistentry> 36439 <term><parameter>rw</parameter></term> 36440 <listitem> 36441 <para> 36442 whether to <constant>READ</constant> or <constant>WRITE</constant>, or maybe to <constant>READA</constant> (read ahead) 36443 </para> 36444 </listitem> 36445 </varlistentry> 36446 <varlistentry> 36447 <term><parameter>bio</parameter></term> 36448 <listitem> 36449 <para> 36450 The <structname>struct bio</structname> which describes the I/O 36451 </para> 36452 </listitem> 36453 </varlistentry> 36454 </variablelist> 36455</refsect1> 36456<refsect1> 36457<title>Description</title> 36458<para> 36459 <function>submit_bio</function> is very similar in purpose to <function>generic_make_request</function>, and 36460 uses that function to do most of the work. Both are fairly rough 36461 interfaces; <parameter>bio</parameter> must be presetup and ready for I/O. 36462</para> 36463</refsect1> 36464</refentry> 36465 36466<refentry id="API-blk-rq-check-limits"> 36467<refentryinfo> 36468 <title>LINUX</title> 36469 <productname>Kernel Hackers Manual</productname> 36470 <date>July 2017</date> 36471</refentryinfo> 36472<refmeta> 36473 <refentrytitle><phrase>blk_rq_check_limits</phrase></refentrytitle> 36474 <manvolnum>9</manvolnum> 36475 <refmiscinfo class="version">4.1.27</refmiscinfo> 36476</refmeta> 36477<refnamediv> 36478 <refname>blk_rq_check_limits</refname> 36479 <refpurpose> 36480 Helper function to check a request for the queue limit 36481 </refpurpose> 36482</refnamediv> 36483<refsynopsisdiv> 36484 <title>Synopsis</title> 36485 <funcsynopsis><funcprototype> 36486 <funcdef>int <function>blk_rq_check_limits </function></funcdef> 36487 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 36488 <paramdef>struct request * <parameter>rq</parameter></paramdef> 36489 </funcprototype></funcsynopsis> 36490</refsynopsisdiv> 36491<refsect1> 36492 <title>Arguments</title> 36493 <variablelist> 36494 <varlistentry> 36495 <term><parameter>q</parameter></term> 36496 <listitem> 36497 <para> 36498 the queue 36499 </para> 36500 </listitem> 36501 </varlistentry> 36502 <varlistentry> 36503 <term><parameter>rq</parameter></term> 36504 <listitem> 36505 <para> 36506 the request being checked 36507 </para> 36508 </listitem> 36509 </varlistentry> 36510 </variablelist> 36511</refsect1> 36512<refsect1> 36513<title>Description</title> 36514<para> 36515 <parameter>rq</parameter> may have been made based on weaker limitations of upper-level queues 36516 in request stacking drivers, and it may violate the limitation of <parameter>q</parameter>. 36517 Since the block layer and the underlying device driver trust <parameter>rq</parameter> 36518 after it is inserted to <parameter>q</parameter>, it should be checked against <parameter>q</parameter> before 36519 the insertion using this generic function. 36520 </para><para> 36521 36522 This function should also be useful for request stacking drivers 36523 in some cases below, so export this function. 36524 Request stacking drivers like request-based dm may change the queue 36525 limits while requests are in the queue (e.g. dm's table swapping). 36526 Such request stacking drivers should check those requests against 36527 the new queue limits again when they dispatch those requests, 36528 although such checkings are also done against the old queue limits 36529 when submitting requests. 36530</para> 36531</refsect1> 36532</refentry> 36533 36534<refentry id="API-blk-insert-cloned-request"> 36535<refentryinfo> 36536 <title>LINUX</title> 36537 <productname>Kernel Hackers Manual</productname> 36538 <date>July 2017</date> 36539</refentryinfo> 36540<refmeta> 36541 <refentrytitle><phrase>blk_insert_cloned_request</phrase></refentrytitle> 36542 <manvolnum>9</manvolnum> 36543 <refmiscinfo class="version">4.1.27</refmiscinfo> 36544</refmeta> 36545<refnamediv> 36546 <refname>blk_insert_cloned_request</refname> 36547 <refpurpose> 36548 Helper for stacking drivers to submit a request 36549 </refpurpose> 36550</refnamediv> 36551<refsynopsisdiv> 36552 <title>Synopsis</title> 36553 <funcsynopsis><funcprototype> 36554 <funcdef>int <function>blk_insert_cloned_request </function></funcdef> 36555 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 36556 <paramdef>struct request * <parameter>rq</parameter></paramdef> 36557 </funcprototype></funcsynopsis> 36558</refsynopsisdiv> 36559<refsect1> 36560 <title>Arguments</title> 36561 <variablelist> 36562 <varlistentry> 36563 <term><parameter>q</parameter></term> 36564 <listitem> 36565 <para> 36566 the queue to submit the request 36567 </para> 36568 </listitem> 36569 </varlistentry> 36570 <varlistentry> 36571 <term><parameter>rq</parameter></term> 36572 <listitem> 36573 <para> 36574 the request being queued 36575 </para> 36576 </listitem> 36577 </varlistentry> 36578 </variablelist> 36579</refsect1> 36580</refentry> 36581 36582<refentry id="API-blk-rq-err-bytes"> 36583<refentryinfo> 36584 <title>LINUX</title> 36585 <productname>Kernel Hackers Manual</productname> 36586 <date>July 2017</date> 36587</refentryinfo> 36588<refmeta> 36589 <refentrytitle><phrase>blk_rq_err_bytes</phrase></refentrytitle> 36590 <manvolnum>9</manvolnum> 36591 <refmiscinfo class="version">4.1.27</refmiscinfo> 36592</refmeta> 36593<refnamediv> 36594 <refname>blk_rq_err_bytes</refname> 36595 <refpurpose> 36596 determine number of bytes till the next failure boundary 36597 </refpurpose> 36598</refnamediv> 36599<refsynopsisdiv> 36600 <title>Synopsis</title> 36601 <funcsynopsis><funcprototype> 36602 <funcdef>unsigned int <function>blk_rq_err_bytes </function></funcdef> 36603 <paramdef>const struct request * <parameter>rq</parameter></paramdef> 36604 </funcprototype></funcsynopsis> 36605</refsynopsisdiv> 36606<refsect1> 36607 <title>Arguments</title> 36608 <variablelist> 36609 <varlistentry> 36610 <term><parameter>rq</parameter></term> 36611 <listitem> 36612 <para> 36613 request to examine 36614 </para> 36615 </listitem> 36616 </varlistentry> 36617 </variablelist> 36618</refsect1> 36619<refsect1> 36620<title>Description</title> 36621<para> 36622 A request could be merge of IOs which require different failure 36623 handling. This function determines the number of bytes which 36624 can be failed from the beginning of the request without 36625 crossing into area which need to be retried further. 36626</para> 36627</refsect1> 36628<refsect1> 36629<title>Return</title> 36630<para> 36631 The number of bytes to fail. 36632</para> 36633</refsect1> 36634<refsect1> 36635<title>Context</title> 36636<para> 36637 queue_lock must be held. 36638</para> 36639</refsect1> 36640</refentry> 36641 36642<refentry id="API-blk-peek-request"> 36643<refentryinfo> 36644 <title>LINUX</title> 36645 <productname>Kernel Hackers Manual</productname> 36646 <date>July 2017</date> 36647</refentryinfo> 36648<refmeta> 36649 <refentrytitle><phrase>blk_peek_request</phrase></refentrytitle> 36650 <manvolnum>9</manvolnum> 36651 <refmiscinfo class="version">4.1.27</refmiscinfo> 36652</refmeta> 36653<refnamediv> 36654 <refname>blk_peek_request</refname> 36655 <refpurpose> 36656 peek at the top of a request queue 36657 </refpurpose> 36658</refnamediv> 36659<refsynopsisdiv> 36660 <title>Synopsis</title> 36661 <funcsynopsis><funcprototype> 36662 <funcdef>struct request * <function>blk_peek_request </function></funcdef> 36663 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 36664 </funcprototype></funcsynopsis> 36665</refsynopsisdiv> 36666<refsect1> 36667 <title>Arguments</title> 36668 <variablelist> 36669 <varlistentry> 36670 <term><parameter>q</parameter></term> 36671 <listitem> 36672 <para> 36673 request queue to peek at 36674 </para> 36675 </listitem> 36676 </varlistentry> 36677 </variablelist> 36678</refsect1> 36679<refsect1> 36680<title>Description</title> 36681<para> 36682 Return the request at the top of <parameter>q</parameter>. The returned request 36683 should be started using <function>blk_start_request</function> before LLD starts 36684 processing it. 36685</para> 36686</refsect1> 36687<refsect1> 36688<title>Return</title> 36689<para> 36690 Pointer to the request at the top of <parameter>q</parameter> if available. Null 36691 otherwise. 36692</para> 36693</refsect1> 36694<refsect1> 36695<title>Context</title> 36696<para> 36697 queue_lock must be held. 36698</para> 36699</refsect1> 36700</refentry> 36701 36702<refentry id="API-blk-start-request"> 36703<refentryinfo> 36704 <title>LINUX</title> 36705 <productname>Kernel Hackers Manual</productname> 36706 <date>July 2017</date> 36707</refentryinfo> 36708<refmeta> 36709 <refentrytitle><phrase>blk_start_request</phrase></refentrytitle> 36710 <manvolnum>9</manvolnum> 36711 <refmiscinfo class="version">4.1.27</refmiscinfo> 36712</refmeta> 36713<refnamediv> 36714 <refname>blk_start_request</refname> 36715 <refpurpose> 36716 start request processing on the driver 36717 </refpurpose> 36718</refnamediv> 36719<refsynopsisdiv> 36720 <title>Synopsis</title> 36721 <funcsynopsis><funcprototype> 36722 <funcdef>void <function>blk_start_request </function></funcdef> 36723 <paramdef>struct request * <parameter>req</parameter></paramdef> 36724 </funcprototype></funcsynopsis> 36725</refsynopsisdiv> 36726<refsect1> 36727 <title>Arguments</title> 36728 <variablelist> 36729 <varlistentry> 36730 <term><parameter>req</parameter></term> 36731 <listitem> 36732 <para> 36733 request to dequeue 36734 </para> 36735 </listitem> 36736 </varlistentry> 36737 </variablelist> 36738</refsect1> 36739<refsect1> 36740<title>Description</title> 36741<para> 36742 Dequeue <parameter>req</parameter> and start timeout timer on it. This hands off the 36743 request to the driver. 36744 </para><para> 36745 36746 Block internal functions which don't want to start timer should 36747 call <function>blk_dequeue_request</function>. 36748</para> 36749</refsect1> 36750<refsect1> 36751<title>Context</title> 36752<para> 36753 queue_lock must be held. 36754</para> 36755</refsect1> 36756</refentry> 36757 36758<refentry id="API-blk-fetch-request"> 36759<refentryinfo> 36760 <title>LINUX</title> 36761 <productname>Kernel Hackers Manual</productname> 36762 <date>July 2017</date> 36763</refentryinfo> 36764<refmeta> 36765 <refentrytitle><phrase>blk_fetch_request</phrase></refentrytitle> 36766 <manvolnum>9</manvolnum> 36767 <refmiscinfo class="version">4.1.27</refmiscinfo> 36768</refmeta> 36769<refnamediv> 36770 <refname>blk_fetch_request</refname> 36771 <refpurpose> 36772 fetch a request from a request queue 36773 </refpurpose> 36774</refnamediv> 36775<refsynopsisdiv> 36776 <title>Synopsis</title> 36777 <funcsynopsis><funcprototype> 36778 <funcdef>struct request * <function>blk_fetch_request </function></funcdef> 36779 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 36780 </funcprototype></funcsynopsis> 36781</refsynopsisdiv> 36782<refsect1> 36783 <title>Arguments</title> 36784 <variablelist> 36785 <varlistentry> 36786 <term><parameter>q</parameter></term> 36787 <listitem> 36788 <para> 36789 request queue to fetch a request from 36790 </para> 36791 </listitem> 36792 </varlistentry> 36793 </variablelist> 36794</refsect1> 36795<refsect1> 36796<title>Description</title> 36797<para> 36798 Return the request at the top of <parameter>q</parameter>. The request is started on 36799 return and LLD can start processing it immediately. 36800</para> 36801</refsect1> 36802<refsect1> 36803<title>Return</title> 36804<para> 36805 Pointer to the request at the top of <parameter>q</parameter> if available. Null 36806 otherwise. 36807</para> 36808</refsect1> 36809<refsect1> 36810<title>Context</title> 36811<para> 36812 queue_lock must be held. 36813</para> 36814</refsect1> 36815</refentry> 36816 36817<refentry id="API-blk-update-request"> 36818<refentryinfo> 36819 <title>LINUX</title> 36820 <productname>Kernel Hackers Manual</productname> 36821 <date>July 2017</date> 36822</refentryinfo> 36823<refmeta> 36824 <refentrytitle><phrase>blk_update_request</phrase></refentrytitle> 36825 <manvolnum>9</manvolnum> 36826 <refmiscinfo class="version">4.1.27</refmiscinfo> 36827</refmeta> 36828<refnamediv> 36829 <refname>blk_update_request</refname> 36830 <refpurpose> 36831 Special helper function for request stacking drivers 36832 </refpurpose> 36833</refnamediv> 36834<refsynopsisdiv> 36835 <title>Synopsis</title> 36836 <funcsynopsis><funcprototype> 36837 <funcdef>bool <function>blk_update_request </function></funcdef> 36838 <paramdef>struct request * <parameter>req</parameter></paramdef> 36839 <paramdef>int <parameter>error</parameter></paramdef> 36840 <paramdef>unsigned int <parameter>nr_bytes</parameter></paramdef> 36841 </funcprototype></funcsynopsis> 36842</refsynopsisdiv> 36843<refsect1> 36844 <title>Arguments</title> 36845 <variablelist> 36846 <varlistentry> 36847 <term><parameter>req</parameter></term> 36848 <listitem> 36849 <para> 36850 the request being processed 36851 </para> 36852 </listitem> 36853 </varlistentry> 36854 <varlistentry> 36855 <term><parameter>error</parameter></term> 36856 <listitem> 36857 <para> 36858 <constant>0</constant> for success, < <constant>0</constant> for error 36859 </para> 36860 </listitem> 36861 </varlistentry> 36862 <varlistentry> 36863 <term><parameter>nr_bytes</parameter></term> 36864 <listitem> 36865 <para> 36866 number of bytes to complete <parameter>req</parameter> 36867 </para> 36868 </listitem> 36869 </varlistentry> 36870 </variablelist> 36871</refsect1> 36872<refsect1> 36873<title>Description</title> 36874<para> 36875 Ends I/O on a number of bytes attached to <parameter>req</parameter>, but doesn't complete 36876 the request structure even if <parameter>req</parameter> doesn't have leftover. 36877 If <parameter>req</parameter> has leftover, sets it up for the next range of segments. 36878 </para><para> 36879 36880 This special helper function is only for request stacking drivers 36881 (e.g. request-based dm) so that they can handle partial completion. 36882 Actual device drivers should use blk_end_request instead. 36883 </para><para> 36884 36885 Passing the result of <function>blk_rq_bytes</function> as <parameter>nr_bytes</parameter> guarantees 36886 <constant>false</constant> return from this function. 36887</para> 36888</refsect1> 36889<refsect1> 36890<title>Return</title> 36891<para> 36892 <constant>false</constant> - this request doesn't have any more data 36893 <constant>true</constant> - this request has more data 36894</para> 36895</refsect1> 36896</refentry> 36897 36898<refentry id="API-blk-unprep-request"> 36899<refentryinfo> 36900 <title>LINUX</title> 36901 <productname>Kernel Hackers Manual</productname> 36902 <date>July 2017</date> 36903</refentryinfo> 36904<refmeta> 36905 <refentrytitle><phrase>blk_unprep_request</phrase></refentrytitle> 36906 <manvolnum>9</manvolnum> 36907 <refmiscinfo class="version">4.1.27</refmiscinfo> 36908</refmeta> 36909<refnamediv> 36910 <refname>blk_unprep_request</refname> 36911 <refpurpose> 36912 unprepare a request 36913 </refpurpose> 36914</refnamediv> 36915<refsynopsisdiv> 36916 <title>Synopsis</title> 36917 <funcsynopsis><funcprototype> 36918 <funcdef>void <function>blk_unprep_request </function></funcdef> 36919 <paramdef>struct request * <parameter>req</parameter></paramdef> 36920 </funcprototype></funcsynopsis> 36921</refsynopsisdiv> 36922<refsect1> 36923 <title>Arguments</title> 36924 <variablelist> 36925 <varlistentry> 36926 <term><parameter>req</parameter></term> 36927 <listitem> 36928 <para> 36929 the request 36930 </para> 36931 </listitem> 36932 </varlistentry> 36933 </variablelist> 36934</refsect1> 36935<refsect1> 36936<title>Description</title> 36937<para> 36938 This function makes a request ready for complete resubmission (or 36939 completion). It happens only after all error handling is complete, 36940 so represents the appropriate moment to deallocate any resources 36941 that were allocated to the request in the prep_rq_fn. The queue 36942 lock is held when calling this. 36943</para> 36944</refsect1> 36945</refentry> 36946 36947<refentry id="API-blk-end-request"> 36948<refentryinfo> 36949 <title>LINUX</title> 36950 <productname>Kernel Hackers Manual</productname> 36951 <date>July 2017</date> 36952</refentryinfo> 36953<refmeta> 36954 <refentrytitle><phrase>blk_end_request</phrase></refentrytitle> 36955 <manvolnum>9</manvolnum> 36956 <refmiscinfo class="version">4.1.27</refmiscinfo> 36957</refmeta> 36958<refnamediv> 36959 <refname>blk_end_request</refname> 36960 <refpurpose> 36961 Helper function for drivers to complete the request. 36962 </refpurpose> 36963</refnamediv> 36964<refsynopsisdiv> 36965 <title>Synopsis</title> 36966 <funcsynopsis><funcprototype> 36967 <funcdef>bool <function>blk_end_request </function></funcdef> 36968 <paramdef>struct request * <parameter>rq</parameter></paramdef> 36969 <paramdef>int <parameter>error</parameter></paramdef> 36970 <paramdef>unsigned int <parameter>nr_bytes</parameter></paramdef> 36971 </funcprototype></funcsynopsis> 36972</refsynopsisdiv> 36973<refsect1> 36974 <title>Arguments</title> 36975 <variablelist> 36976 <varlistentry> 36977 <term><parameter>rq</parameter></term> 36978 <listitem> 36979 <para> 36980 the request being processed 36981 </para> 36982 </listitem> 36983 </varlistentry> 36984 <varlistentry> 36985 <term><parameter>error</parameter></term> 36986 <listitem> 36987 <para> 36988 <constant>0</constant> for success, < <constant>0</constant> for error 36989 </para> 36990 </listitem> 36991 </varlistentry> 36992 <varlistentry> 36993 <term><parameter>nr_bytes</parameter></term> 36994 <listitem> 36995 <para> 36996 number of bytes to complete 36997 </para> 36998 </listitem> 36999 </varlistentry> 37000 </variablelist> 37001</refsect1> 37002<refsect1> 37003<title>Description</title> 37004<para> 37005 Ends I/O on a number of bytes attached to <parameter>rq</parameter>. 37006 If <parameter>rq</parameter> has leftover, sets it up for the next range of segments. 37007</para> 37008</refsect1> 37009<refsect1> 37010<title>Return</title> 37011<para> 37012 <constant>false</constant> - we are done with this request 37013 <constant>true</constant> - still buffers pending for this request 37014</para> 37015</refsect1> 37016</refentry> 37017 37018<refentry id="API-blk-end-request-all"> 37019<refentryinfo> 37020 <title>LINUX</title> 37021 <productname>Kernel Hackers Manual</productname> 37022 <date>July 2017</date> 37023</refentryinfo> 37024<refmeta> 37025 <refentrytitle><phrase>blk_end_request_all</phrase></refentrytitle> 37026 <manvolnum>9</manvolnum> 37027 <refmiscinfo class="version">4.1.27</refmiscinfo> 37028</refmeta> 37029<refnamediv> 37030 <refname>blk_end_request_all</refname> 37031 <refpurpose> 37032 Helper function for drives to finish the request. 37033 </refpurpose> 37034</refnamediv> 37035<refsynopsisdiv> 37036 <title>Synopsis</title> 37037 <funcsynopsis><funcprototype> 37038 <funcdef>void <function>blk_end_request_all </function></funcdef> 37039 <paramdef>struct request * <parameter>rq</parameter></paramdef> 37040 <paramdef>int <parameter>error</parameter></paramdef> 37041 </funcprototype></funcsynopsis> 37042</refsynopsisdiv> 37043<refsect1> 37044 <title>Arguments</title> 37045 <variablelist> 37046 <varlistentry> 37047 <term><parameter>rq</parameter></term> 37048 <listitem> 37049 <para> 37050 the request to finish 37051 </para> 37052 </listitem> 37053 </varlistentry> 37054 <varlistentry> 37055 <term><parameter>error</parameter></term> 37056 <listitem> 37057 <para> 37058 <constant>0</constant> for success, < <constant>0</constant> for error 37059 </para> 37060 </listitem> 37061 </varlistentry> 37062 </variablelist> 37063</refsect1> 37064<refsect1> 37065<title>Description</title> 37066<para> 37067 Completely finish <parameter>rq</parameter>. 37068</para> 37069</refsect1> 37070</refentry> 37071 37072<refentry id="API-blk-end-request-cur"> 37073<refentryinfo> 37074 <title>LINUX</title> 37075 <productname>Kernel Hackers Manual</productname> 37076 <date>July 2017</date> 37077</refentryinfo> 37078<refmeta> 37079 <refentrytitle><phrase>blk_end_request_cur</phrase></refentrytitle> 37080 <manvolnum>9</manvolnum> 37081 <refmiscinfo class="version">4.1.27</refmiscinfo> 37082</refmeta> 37083<refnamediv> 37084 <refname>blk_end_request_cur</refname> 37085 <refpurpose> 37086 Helper function to finish the current request chunk. 37087 </refpurpose> 37088</refnamediv> 37089<refsynopsisdiv> 37090 <title>Synopsis</title> 37091 <funcsynopsis><funcprototype> 37092 <funcdef>bool <function>blk_end_request_cur </function></funcdef> 37093 <paramdef>struct request * <parameter>rq</parameter></paramdef> 37094 <paramdef>int <parameter>error</parameter></paramdef> 37095 </funcprototype></funcsynopsis> 37096</refsynopsisdiv> 37097<refsect1> 37098 <title>Arguments</title> 37099 <variablelist> 37100 <varlistentry> 37101 <term><parameter>rq</parameter></term> 37102 <listitem> 37103 <para> 37104 the request to finish the current chunk for 37105 </para> 37106 </listitem> 37107 </varlistentry> 37108 <varlistentry> 37109 <term><parameter>error</parameter></term> 37110 <listitem> 37111 <para> 37112 <constant>0</constant> for success, < <constant>0</constant> for error 37113 </para> 37114 </listitem> 37115 </varlistentry> 37116 </variablelist> 37117</refsect1> 37118<refsect1> 37119<title>Description</title> 37120<para> 37121 Complete the current consecutively mapped chunk from <parameter>rq</parameter>. 37122</para> 37123</refsect1> 37124<refsect1> 37125<title>Return</title> 37126<para> 37127 <constant>false</constant> - we are done with this request 37128 <constant>true</constant> - still buffers pending for this request 37129</para> 37130</refsect1> 37131</refentry> 37132 37133<refentry id="API-blk-end-request-err"> 37134<refentryinfo> 37135 <title>LINUX</title> 37136 <productname>Kernel Hackers Manual</productname> 37137 <date>July 2017</date> 37138</refentryinfo> 37139<refmeta> 37140 <refentrytitle><phrase>blk_end_request_err</phrase></refentrytitle> 37141 <manvolnum>9</manvolnum> 37142 <refmiscinfo class="version">4.1.27</refmiscinfo> 37143</refmeta> 37144<refnamediv> 37145 <refname>blk_end_request_err</refname> 37146 <refpurpose> 37147 Finish a request till the next failure boundary. 37148 </refpurpose> 37149</refnamediv> 37150<refsynopsisdiv> 37151 <title>Synopsis</title> 37152 <funcsynopsis><funcprototype> 37153 <funcdef>bool <function>blk_end_request_err </function></funcdef> 37154 <paramdef>struct request * <parameter>rq</parameter></paramdef> 37155 <paramdef>int <parameter>error</parameter></paramdef> 37156 </funcprototype></funcsynopsis> 37157</refsynopsisdiv> 37158<refsect1> 37159 <title>Arguments</title> 37160 <variablelist> 37161 <varlistentry> 37162 <term><parameter>rq</parameter></term> 37163 <listitem> 37164 <para> 37165 the request to finish till the next failure boundary for 37166 </para> 37167 </listitem> 37168 </varlistentry> 37169 <varlistentry> 37170 <term><parameter>error</parameter></term> 37171 <listitem> 37172 <para> 37173 must be negative errno 37174 </para> 37175 </listitem> 37176 </varlistentry> 37177 </variablelist> 37178</refsect1> 37179<refsect1> 37180<title>Description</title> 37181<para> 37182 Complete <parameter>rq</parameter> till the next failure boundary. 37183</para> 37184</refsect1> 37185<refsect1> 37186<title>Return</title> 37187<para> 37188 <constant>false</constant> - we are done with this request 37189 <constant>true</constant> - still buffers pending for this request 37190</para> 37191</refsect1> 37192</refentry> 37193 37194<refentry id="API---blk-end-request"> 37195<refentryinfo> 37196 <title>LINUX</title> 37197 <productname>Kernel Hackers Manual</productname> 37198 <date>July 2017</date> 37199</refentryinfo> 37200<refmeta> 37201 <refentrytitle><phrase>__blk_end_request</phrase></refentrytitle> 37202 <manvolnum>9</manvolnum> 37203 <refmiscinfo class="version">4.1.27</refmiscinfo> 37204</refmeta> 37205<refnamediv> 37206 <refname>__blk_end_request</refname> 37207 <refpurpose> 37208 Helper function for drivers to complete the request. 37209 </refpurpose> 37210</refnamediv> 37211<refsynopsisdiv> 37212 <title>Synopsis</title> 37213 <funcsynopsis><funcprototype> 37214 <funcdef>bool <function>__blk_end_request </function></funcdef> 37215 <paramdef>struct request * <parameter>rq</parameter></paramdef> 37216 <paramdef>int <parameter>error</parameter></paramdef> 37217 <paramdef>unsigned int <parameter>nr_bytes</parameter></paramdef> 37218 </funcprototype></funcsynopsis> 37219</refsynopsisdiv> 37220<refsect1> 37221 <title>Arguments</title> 37222 <variablelist> 37223 <varlistentry> 37224 <term><parameter>rq</parameter></term> 37225 <listitem> 37226 <para> 37227 the request being processed 37228 </para> 37229 </listitem> 37230 </varlistentry> 37231 <varlistentry> 37232 <term><parameter>error</parameter></term> 37233 <listitem> 37234 <para> 37235 <constant>0</constant> for success, < <constant>0</constant> for error 37236 </para> 37237 </listitem> 37238 </varlistentry> 37239 <varlistentry> 37240 <term><parameter>nr_bytes</parameter></term> 37241 <listitem> 37242 <para> 37243 number of bytes to complete 37244 </para> 37245 </listitem> 37246 </varlistentry> 37247 </variablelist> 37248</refsect1> 37249<refsect1> 37250<title>Description</title> 37251<para> 37252 Must be called with queue lock held unlike <function>blk_end_request</function>. 37253</para> 37254</refsect1> 37255<refsect1> 37256<title>Return</title> 37257<para> 37258 <constant>false</constant> - we are done with this request 37259 <constant>true</constant> - still buffers pending for this request 37260</para> 37261</refsect1> 37262</refentry> 37263 37264<refentry id="API---blk-end-request-all"> 37265<refentryinfo> 37266 <title>LINUX</title> 37267 <productname>Kernel Hackers Manual</productname> 37268 <date>July 2017</date> 37269</refentryinfo> 37270<refmeta> 37271 <refentrytitle><phrase>__blk_end_request_all</phrase></refentrytitle> 37272 <manvolnum>9</manvolnum> 37273 <refmiscinfo class="version">4.1.27</refmiscinfo> 37274</refmeta> 37275<refnamediv> 37276 <refname>__blk_end_request_all</refname> 37277 <refpurpose> 37278 Helper function for drives to finish the request. 37279 </refpurpose> 37280</refnamediv> 37281<refsynopsisdiv> 37282 <title>Synopsis</title> 37283 <funcsynopsis><funcprototype> 37284 <funcdef>void <function>__blk_end_request_all </function></funcdef> 37285 <paramdef>struct request * <parameter>rq</parameter></paramdef> 37286 <paramdef>int <parameter>error</parameter></paramdef> 37287 </funcprototype></funcsynopsis> 37288</refsynopsisdiv> 37289<refsect1> 37290 <title>Arguments</title> 37291 <variablelist> 37292 <varlistentry> 37293 <term><parameter>rq</parameter></term> 37294 <listitem> 37295 <para> 37296 the request to finish 37297 </para> 37298 </listitem> 37299 </varlistentry> 37300 <varlistentry> 37301 <term><parameter>error</parameter></term> 37302 <listitem> 37303 <para> 37304 <constant>0</constant> for success, < <constant>0</constant> for error 37305 </para> 37306 </listitem> 37307 </varlistentry> 37308 </variablelist> 37309</refsect1> 37310<refsect1> 37311<title>Description</title> 37312<para> 37313 Completely finish <parameter>rq</parameter>. Must be called with queue lock held. 37314</para> 37315</refsect1> 37316</refentry> 37317 37318<refentry id="API---blk-end-request-cur"> 37319<refentryinfo> 37320 <title>LINUX</title> 37321 <productname>Kernel Hackers Manual</productname> 37322 <date>July 2017</date> 37323</refentryinfo> 37324<refmeta> 37325 <refentrytitle><phrase>__blk_end_request_cur</phrase></refentrytitle> 37326 <manvolnum>9</manvolnum> 37327 <refmiscinfo class="version">4.1.27</refmiscinfo> 37328</refmeta> 37329<refnamediv> 37330 <refname>__blk_end_request_cur</refname> 37331 <refpurpose> 37332 Helper function to finish the current request chunk. 37333 </refpurpose> 37334</refnamediv> 37335<refsynopsisdiv> 37336 <title>Synopsis</title> 37337 <funcsynopsis><funcprototype> 37338 <funcdef>bool <function>__blk_end_request_cur </function></funcdef> 37339 <paramdef>struct request * <parameter>rq</parameter></paramdef> 37340 <paramdef>int <parameter>error</parameter></paramdef> 37341 </funcprototype></funcsynopsis> 37342</refsynopsisdiv> 37343<refsect1> 37344 <title>Arguments</title> 37345 <variablelist> 37346 <varlistentry> 37347 <term><parameter>rq</parameter></term> 37348 <listitem> 37349 <para> 37350 the request to finish the current chunk for 37351 </para> 37352 </listitem> 37353 </varlistentry> 37354 <varlistentry> 37355 <term><parameter>error</parameter></term> 37356 <listitem> 37357 <para> 37358 <constant>0</constant> for success, < <constant>0</constant> for error 37359 </para> 37360 </listitem> 37361 </varlistentry> 37362 </variablelist> 37363</refsect1> 37364<refsect1> 37365<title>Description</title> 37366<para> 37367 Complete the current consecutively mapped chunk from <parameter>rq</parameter>. Must 37368 be called with queue lock held. 37369</para> 37370</refsect1> 37371<refsect1> 37372<title>Return</title> 37373<para> 37374 <constant>false</constant> - we are done with this request 37375 <constant>true</constant> - still buffers pending for this request 37376</para> 37377</refsect1> 37378</refentry> 37379 37380<refentry id="API---blk-end-request-err"> 37381<refentryinfo> 37382 <title>LINUX</title> 37383 <productname>Kernel Hackers Manual</productname> 37384 <date>July 2017</date> 37385</refentryinfo> 37386<refmeta> 37387 <refentrytitle><phrase>__blk_end_request_err</phrase></refentrytitle> 37388 <manvolnum>9</manvolnum> 37389 <refmiscinfo class="version">4.1.27</refmiscinfo> 37390</refmeta> 37391<refnamediv> 37392 <refname>__blk_end_request_err</refname> 37393 <refpurpose> 37394 Finish a request till the next failure boundary. 37395 </refpurpose> 37396</refnamediv> 37397<refsynopsisdiv> 37398 <title>Synopsis</title> 37399 <funcsynopsis><funcprototype> 37400 <funcdef>bool <function>__blk_end_request_err </function></funcdef> 37401 <paramdef>struct request * <parameter>rq</parameter></paramdef> 37402 <paramdef>int <parameter>error</parameter></paramdef> 37403 </funcprototype></funcsynopsis> 37404</refsynopsisdiv> 37405<refsect1> 37406 <title>Arguments</title> 37407 <variablelist> 37408 <varlistentry> 37409 <term><parameter>rq</parameter></term> 37410 <listitem> 37411 <para> 37412 the request to finish till the next failure boundary for 37413 </para> 37414 </listitem> 37415 </varlistentry> 37416 <varlistentry> 37417 <term><parameter>error</parameter></term> 37418 <listitem> 37419 <para> 37420 must be negative errno 37421 </para> 37422 </listitem> 37423 </varlistentry> 37424 </variablelist> 37425</refsect1> 37426<refsect1> 37427<title>Description</title> 37428<para> 37429 Complete <parameter>rq</parameter> till the next failure boundary. Must be called 37430 with queue lock held. 37431</para> 37432</refsect1> 37433<refsect1> 37434<title>Return</title> 37435<para> 37436 <constant>false</constant> - we are done with this request 37437 <constant>true</constant> - still buffers pending for this request 37438</para> 37439</refsect1> 37440</refentry> 37441 37442<refentry id="API-rq-flush-dcache-pages"> 37443<refentryinfo> 37444 <title>LINUX</title> 37445 <productname>Kernel Hackers Manual</productname> 37446 <date>July 2017</date> 37447</refentryinfo> 37448<refmeta> 37449 <refentrytitle><phrase>rq_flush_dcache_pages</phrase></refentrytitle> 37450 <manvolnum>9</manvolnum> 37451 <refmiscinfo class="version">4.1.27</refmiscinfo> 37452</refmeta> 37453<refnamediv> 37454 <refname>rq_flush_dcache_pages</refname> 37455 <refpurpose> 37456 Helper function to flush all pages in a request 37457 </refpurpose> 37458</refnamediv> 37459<refsynopsisdiv> 37460 <title>Synopsis</title> 37461 <funcsynopsis><funcprototype> 37462 <funcdef>void <function>rq_flush_dcache_pages </function></funcdef> 37463 <paramdef>struct request * <parameter>rq</parameter></paramdef> 37464 </funcprototype></funcsynopsis> 37465</refsynopsisdiv> 37466<refsect1> 37467 <title>Arguments</title> 37468 <variablelist> 37469 <varlistentry> 37470 <term><parameter>rq</parameter></term> 37471 <listitem> 37472 <para> 37473 the request to be flushed 37474 </para> 37475 </listitem> 37476 </varlistentry> 37477 </variablelist> 37478</refsect1> 37479<refsect1> 37480<title>Description</title> 37481<para> 37482 Flush all pages in <parameter>rq</parameter>. 37483</para> 37484</refsect1> 37485</refentry> 37486 37487<refentry id="API-blk-lld-busy"> 37488<refentryinfo> 37489 <title>LINUX</title> 37490 <productname>Kernel Hackers Manual</productname> 37491 <date>July 2017</date> 37492</refentryinfo> 37493<refmeta> 37494 <refentrytitle><phrase>blk_lld_busy</phrase></refentrytitle> 37495 <manvolnum>9</manvolnum> 37496 <refmiscinfo class="version">4.1.27</refmiscinfo> 37497</refmeta> 37498<refnamediv> 37499 <refname>blk_lld_busy</refname> 37500 <refpurpose> 37501 Check if underlying low-level drivers of a device are busy 37502 </refpurpose> 37503</refnamediv> 37504<refsynopsisdiv> 37505 <title>Synopsis</title> 37506 <funcsynopsis><funcprototype> 37507 <funcdef>int <function>blk_lld_busy </function></funcdef> 37508 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 37509 </funcprototype></funcsynopsis> 37510</refsynopsisdiv> 37511<refsect1> 37512 <title>Arguments</title> 37513 <variablelist> 37514 <varlistentry> 37515 <term><parameter>q</parameter></term> 37516 <listitem> 37517 <para> 37518 the queue of the device being checked 37519 </para> 37520 </listitem> 37521 </varlistentry> 37522 </variablelist> 37523</refsect1> 37524<refsect1> 37525<title>Description</title> 37526<para> 37527 Check if underlying low-level drivers of a device are busy. 37528 If the drivers want to export their busy state, they must set own 37529 exporting function using <function>blk_queue_lld_busy</function> first. 37530 </para><para> 37531 37532 Basically, this function is used only by request stacking drivers 37533 to stop dispatching requests to underlying devices when underlying 37534 devices are busy. This behavior helps more I/O merging on the queue 37535 of the request stacking driver and prevents I/O throughput regression 37536 on burst I/O load. 37537</para> 37538</refsect1> 37539<refsect1> 37540<title>Return</title> 37541<para> 37542 0 - Not busy (The request stacking driver should dispatch request) 37543 1 - Busy (The request stacking driver should stop dispatching request) 37544</para> 37545</refsect1> 37546</refentry> 37547 37548<refentry id="API-blk-rq-unprep-clone"> 37549<refentryinfo> 37550 <title>LINUX</title> 37551 <productname>Kernel Hackers Manual</productname> 37552 <date>July 2017</date> 37553</refentryinfo> 37554<refmeta> 37555 <refentrytitle><phrase>blk_rq_unprep_clone</phrase></refentrytitle> 37556 <manvolnum>9</manvolnum> 37557 <refmiscinfo class="version">4.1.27</refmiscinfo> 37558</refmeta> 37559<refnamediv> 37560 <refname>blk_rq_unprep_clone</refname> 37561 <refpurpose> 37562 Helper function to free all bios in a cloned request 37563 </refpurpose> 37564</refnamediv> 37565<refsynopsisdiv> 37566 <title>Synopsis</title> 37567 <funcsynopsis><funcprototype> 37568 <funcdef>void <function>blk_rq_unprep_clone </function></funcdef> 37569 <paramdef>struct request * <parameter>rq</parameter></paramdef> 37570 </funcprototype></funcsynopsis> 37571</refsynopsisdiv> 37572<refsect1> 37573 <title>Arguments</title> 37574 <variablelist> 37575 <varlistentry> 37576 <term><parameter>rq</parameter></term> 37577 <listitem> 37578 <para> 37579 the clone request to be cleaned up 37580 </para> 37581 </listitem> 37582 </varlistentry> 37583 </variablelist> 37584</refsect1> 37585<refsect1> 37586<title>Description</title> 37587<para> 37588 Free all bios in <parameter>rq</parameter> for a cloned request. 37589</para> 37590</refsect1> 37591</refentry> 37592 37593<refentry id="API-blk-rq-prep-clone"> 37594<refentryinfo> 37595 <title>LINUX</title> 37596 <productname>Kernel Hackers Manual</productname> 37597 <date>July 2017</date> 37598</refentryinfo> 37599<refmeta> 37600 <refentrytitle><phrase>blk_rq_prep_clone</phrase></refentrytitle> 37601 <manvolnum>9</manvolnum> 37602 <refmiscinfo class="version">4.1.27</refmiscinfo> 37603</refmeta> 37604<refnamediv> 37605 <refname>blk_rq_prep_clone</refname> 37606 <refpurpose> 37607 Helper function to setup clone request 37608 </refpurpose> 37609</refnamediv> 37610<refsynopsisdiv> 37611 <title>Synopsis</title> 37612 <funcsynopsis><funcprototype> 37613 <funcdef>int <function>blk_rq_prep_clone </function></funcdef> 37614 <paramdef>struct request * <parameter>rq</parameter></paramdef> 37615 <paramdef>struct request * <parameter>rq_src</parameter></paramdef> 37616 <paramdef>struct bio_set * <parameter>bs</parameter></paramdef> 37617 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 37618 <paramdef>int (*<parameter>bio_ctr</parameter>) 37619 <funcparams>struct bio *, struct bio *, void *</funcparams></paramdef> 37620 <paramdef>void * <parameter>data</parameter></paramdef> 37621 </funcprototype></funcsynopsis> 37622</refsynopsisdiv> 37623<refsect1> 37624 <title>Arguments</title> 37625 <variablelist> 37626 <varlistentry> 37627 <term><parameter>rq</parameter></term> 37628 <listitem> 37629 <para> 37630 the request to be setup 37631 </para> 37632 </listitem> 37633 </varlistentry> 37634 <varlistentry> 37635 <term><parameter>rq_src</parameter></term> 37636 <listitem> 37637 <para> 37638 original request to be cloned 37639 </para> 37640 </listitem> 37641 </varlistentry> 37642 <varlistentry> 37643 <term><parameter>bs</parameter></term> 37644 <listitem> 37645 <para> 37646 bio_set that bios for clone are allocated from 37647 </para> 37648 </listitem> 37649 </varlistentry> 37650 <varlistentry> 37651 <term><parameter>gfp_mask</parameter></term> 37652 <listitem> 37653 <para> 37654 memory allocation mask for bio 37655 </para> 37656 </listitem> 37657 </varlistentry> 37658 <varlistentry> 37659 <term><parameter>bio_ctr</parameter></term> 37660 <listitem> 37661 <para> 37662 setup function to be called for each clone bio. 37663 Returns <constant>0</constant> for success, non <constant>0</constant> for failure. 37664 </para> 37665 </listitem> 37666 </varlistentry> 37667 <varlistentry> 37668 <term><parameter>data</parameter></term> 37669 <listitem> 37670 <para> 37671 private data to be passed to <parameter>bio_ctr</parameter> 37672 </para> 37673 </listitem> 37674 </varlistentry> 37675 </variablelist> 37676</refsect1> 37677<refsect1> 37678<title>Description</title> 37679<para> 37680 Clones bios in <parameter>rq_src</parameter> to <parameter>rq</parameter>, and copies attributes of <parameter>rq_src</parameter> to <parameter>rq</parameter>. 37681 The actual data parts of <parameter>rq_src</parameter> (e.g. ->cmd, ->sense) 37682 are not copied, and copying such parts is the caller's responsibility. 37683 Also, pages which the original bios are pointing to are not copied 37684 and the cloned bios just point same pages. 37685 So cloned bios must be completed before original bios, which means 37686 the caller must complete <parameter>rq</parameter> before <parameter>rq_src</parameter>. 37687</para> 37688</refsect1> 37689</refentry> 37690 37691<refentry id="API-blk-start-plug"> 37692<refentryinfo> 37693 <title>LINUX</title> 37694 <productname>Kernel Hackers Manual</productname> 37695 <date>July 2017</date> 37696</refentryinfo> 37697<refmeta> 37698 <refentrytitle><phrase>blk_start_plug</phrase></refentrytitle> 37699 <manvolnum>9</manvolnum> 37700 <refmiscinfo class="version">4.1.27</refmiscinfo> 37701</refmeta> 37702<refnamediv> 37703 <refname>blk_start_plug</refname> 37704 <refpurpose> 37705 initialize blk_plug and track it inside the task_struct 37706 </refpurpose> 37707</refnamediv> 37708<refsynopsisdiv> 37709 <title>Synopsis</title> 37710 <funcsynopsis><funcprototype> 37711 <funcdef>void <function>blk_start_plug </function></funcdef> 37712 <paramdef>struct blk_plug * <parameter>plug</parameter></paramdef> 37713 </funcprototype></funcsynopsis> 37714</refsynopsisdiv> 37715<refsect1> 37716 <title>Arguments</title> 37717 <variablelist> 37718 <varlistentry> 37719 <term><parameter>plug</parameter></term> 37720 <listitem> 37721 <para> 37722 The <structname>struct blk_plug</structname> that needs to be initialized 37723 </para> 37724 </listitem> 37725 </varlistentry> 37726 </variablelist> 37727</refsect1> 37728<refsect1> 37729<title>Description</title> 37730<para> 37731 Tracking blk_plug inside the task_struct will help with auto-flushing the 37732 pending I/O should the task end up blocking between <function>blk_start_plug</function> and 37733 <function>blk_finish_plug</function>. This is important from a performance perspective, but 37734 also ensures that we don't deadlock. For instance, if the task is blocking 37735 for a memory allocation, memory reclaim could end up wanting to free a 37736 page belonging to that request that is currently residing in our private 37737 plug. By flushing the pending I/O when the process goes to sleep, we avoid 37738 this kind of deadlock. 37739</para> 37740</refsect1> 37741</refentry> 37742 37743<refentry id="API-blk-pm-runtime-init"> 37744<refentryinfo> 37745 <title>LINUX</title> 37746 <productname>Kernel Hackers Manual</productname> 37747 <date>July 2017</date> 37748</refentryinfo> 37749<refmeta> 37750 <refentrytitle><phrase>blk_pm_runtime_init</phrase></refentrytitle> 37751 <manvolnum>9</manvolnum> 37752 <refmiscinfo class="version">4.1.27</refmiscinfo> 37753</refmeta> 37754<refnamediv> 37755 <refname>blk_pm_runtime_init</refname> 37756 <refpurpose> 37757 Block layer runtime PM initialization routine 37758 </refpurpose> 37759</refnamediv> 37760<refsynopsisdiv> 37761 <title>Synopsis</title> 37762 <funcsynopsis><funcprototype> 37763 <funcdef>void <function>blk_pm_runtime_init </function></funcdef> 37764 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 37765 <paramdef>struct device * <parameter>dev</parameter></paramdef> 37766 </funcprototype></funcsynopsis> 37767</refsynopsisdiv> 37768<refsect1> 37769 <title>Arguments</title> 37770 <variablelist> 37771 <varlistentry> 37772 <term><parameter>q</parameter></term> 37773 <listitem> 37774 <para> 37775 the queue of the device 37776 </para> 37777 </listitem> 37778 </varlistentry> 37779 <varlistentry> 37780 <term><parameter>dev</parameter></term> 37781 <listitem> 37782 <para> 37783 the device the queue belongs to 37784 </para> 37785 </listitem> 37786 </varlistentry> 37787 </variablelist> 37788</refsect1> 37789<refsect1> 37790<title>Description</title> 37791<para> 37792 Initialize runtime-PM-related fields for <parameter>q</parameter> and start auto suspend for 37793 <parameter>dev</parameter>. Drivers that want to take advantage of request-based runtime PM 37794 should call this function after <parameter>dev</parameter> has been initialized, and its 37795 request queue <parameter>q</parameter> has been allocated, and runtime PM for it can not happen 37796 yet(either due to disabled/forbidden or its usage_count > 0). In most 37797 cases, driver should call this function before any I/O has taken place. 37798 </para><para> 37799 37800 This function takes care of setting up using auto suspend for the device, 37801 the autosuspend delay is set to -1 to make runtime suspend impossible 37802 until an updated value is either set by user or by driver. Drivers do 37803 not need to touch other autosuspend settings. 37804 </para><para> 37805 37806 The block layer runtime PM is request based, so only works for drivers 37807 that use request as their IO unit instead of those directly use bio's. 37808</para> 37809</refsect1> 37810</refentry> 37811 37812<refentry id="API-blk-pre-runtime-suspend"> 37813<refentryinfo> 37814 <title>LINUX</title> 37815 <productname>Kernel Hackers Manual</productname> 37816 <date>July 2017</date> 37817</refentryinfo> 37818<refmeta> 37819 <refentrytitle><phrase>blk_pre_runtime_suspend</phrase></refentrytitle> 37820 <manvolnum>9</manvolnum> 37821 <refmiscinfo class="version">4.1.27</refmiscinfo> 37822</refmeta> 37823<refnamediv> 37824 <refname>blk_pre_runtime_suspend</refname> 37825 <refpurpose> 37826 Pre runtime suspend check 37827 </refpurpose> 37828</refnamediv> 37829<refsynopsisdiv> 37830 <title>Synopsis</title> 37831 <funcsynopsis><funcprototype> 37832 <funcdef>int <function>blk_pre_runtime_suspend </function></funcdef> 37833 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 37834 </funcprototype></funcsynopsis> 37835</refsynopsisdiv> 37836<refsect1> 37837 <title>Arguments</title> 37838 <variablelist> 37839 <varlistentry> 37840 <term><parameter>q</parameter></term> 37841 <listitem> 37842 <para> 37843 the queue of the device 37844 </para> 37845 </listitem> 37846 </varlistentry> 37847 </variablelist> 37848</refsect1> 37849<refsect1> 37850<title>Description</title> 37851<para> 37852 This function will check if runtime suspend is allowed for the device 37853 by examining if there are any requests pending in the queue. If there 37854 are requests pending, the device can not be runtime suspended; otherwise, 37855 the queue's status will be updated to SUSPENDING and the driver can 37856 proceed to suspend the device. 37857 </para><para> 37858 37859 For the not allowed case, we mark last busy for the device so that 37860 runtime PM core will try to autosuspend it some time later. 37861 </para><para> 37862 37863 This function should be called near the start of the device's 37864 runtime_suspend callback. 37865</para> 37866</refsect1> 37867<refsect1> 37868<title>Return</title> 37869<para> 37870 0 - OK to runtime suspend the device 37871 -EBUSY - Device should not be runtime suspended 37872</para> 37873</refsect1> 37874</refentry> 37875 37876<refentry id="API-blk-post-runtime-suspend"> 37877<refentryinfo> 37878 <title>LINUX</title> 37879 <productname>Kernel Hackers Manual</productname> 37880 <date>July 2017</date> 37881</refentryinfo> 37882<refmeta> 37883 <refentrytitle><phrase>blk_post_runtime_suspend</phrase></refentrytitle> 37884 <manvolnum>9</manvolnum> 37885 <refmiscinfo class="version">4.1.27</refmiscinfo> 37886</refmeta> 37887<refnamediv> 37888 <refname>blk_post_runtime_suspend</refname> 37889 <refpurpose> 37890 Post runtime suspend processing 37891 </refpurpose> 37892</refnamediv> 37893<refsynopsisdiv> 37894 <title>Synopsis</title> 37895 <funcsynopsis><funcprototype> 37896 <funcdef>void <function>blk_post_runtime_suspend </function></funcdef> 37897 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 37898 <paramdef>int <parameter>err</parameter></paramdef> 37899 </funcprototype></funcsynopsis> 37900</refsynopsisdiv> 37901<refsect1> 37902 <title>Arguments</title> 37903 <variablelist> 37904 <varlistentry> 37905 <term><parameter>q</parameter></term> 37906 <listitem> 37907 <para> 37908 the queue of the device 37909 </para> 37910 </listitem> 37911 </varlistentry> 37912 <varlistentry> 37913 <term><parameter>err</parameter></term> 37914 <listitem> 37915 <para> 37916 return value of the device's runtime_suspend function 37917 </para> 37918 </listitem> 37919 </varlistentry> 37920 </variablelist> 37921</refsect1> 37922<refsect1> 37923<title>Description</title> 37924<para> 37925 Update the queue's runtime status according to the return value of the 37926 device's runtime suspend function and mark last busy for the device so 37927 that PM core will try to auto suspend the device at a later time. 37928 </para><para> 37929 37930 This function should be called near the end of the device's 37931 runtime_suspend callback. 37932</para> 37933</refsect1> 37934</refentry> 37935 37936<refentry id="API-blk-pre-runtime-resume"> 37937<refentryinfo> 37938 <title>LINUX</title> 37939 <productname>Kernel Hackers Manual</productname> 37940 <date>July 2017</date> 37941</refentryinfo> 37942<refmeta> 37943 <refentrytitle><phrase>blk_pre_runtime_resume</phrase></refentrytitle> 37944 <manvolnum>9</manvolnum> 37945 <refmiscinfo class="version">4.1.27</refmiscinfo> 37946</refmeta> 37947<refnamediv> 37948 <refname>blk_pre_runtime_resume</refname> 37949 <refpurpose> 37950 Pre runtime resume processing 37951 </refpurpose> 37952</refnamediv> 37953<refsynopsisdiv> 37954 <title>Synopsis</title> 37955 <funcsynopsis><funcprototype> 37956 <funcdef>void <function>blk_pre_runtime_resume </function></funcdef> 37957 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 37958 </funcprototype></funcsynopsis> 37959</refsynopsisdiv> 37960<refsect1> 37961 <title>Arguments</title> 37962 <variablelist> 37963 <varlistentry> 37964 <term><parameter>q</parameter></term> 37965 <listitem> 37966 <para> 37967 the queue of the device 37968 </para> 37969 </listitem> 37970 </varlistentry> 37971 </variablelist> 37972</refsect1> 37973<refsect1> 37974<title>Description</title> 37975<para> 37976 Update the queue's runtime status to RESUMING in preparation for the 37977 runtime resume of the device. 37978 </para><para> 37979 37980 This function should be called near the start of the device's 37981 runtime_resume callback. 37982</para> 37983</refsect1> 37984</refentry> 37985 37986<refentry id="API-blk-post-runtime-resume"> 37987<refentryinfo> 37988 <title>LINUX</title> 37989 <productname>Kernel Hackers Manual</productname> 37990 <date>July 2017</date> 37991</refentryinfo> 37992<refmeta> 37993 <refentrytitle><phrase>blk_post_runtime_resume</phrase></refentrytitle> 37994 <manvolnum>9</manvolnum> 37995 <refmiscinfo class="version">4.1.27</refmiscinfo> 37996</refmeta> 37997<refnamediv> 37998 <refname>blk_post_runtime_resume</refname> 37999 <refpurpose> 38000 Post runtime resume processing 38001 </refpurpose> 38002</refnamediv> 38003<refsynopsisdiv> 38004 <title>Synopsis</title> 38005 <funcsynopsis><funcprototype> 38006 <funcdef>void <function>blk_post_runtime_resume </function></funcdef> 38007 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 38008 <paramdef>int <parameter>err</parameter></paramdef> 38009 </funcprototype></funcsynopsis> 38010</refsynopsisdiv> 38011<refsect1> 38012 <title>Arguments</title> 38013 <variablelist> 38014 <varlistentry> 38015 <term><parameter>q</parameter></term> 38016 <listitem> 38017 <para> 38018 the queue of the device 38019 </para> 38020 </listitem> 38021 </varlistentry> 38022 <varlistentry> 38023 <term><parameter>err</parameter></term> 38024 <listitem> 38025 <para> 38026 return value of the device's runtime_resume function 38027 </para> 38028 </listitem> 38029 </varlistentry> 38030 </variablelist> 38031</refsect1> 38032<refsect1> 38033<title>Description</title> 38034<para> 38035 Update the queue's runtime status according to the return value of the 38036 device's runtime_resume function. If it is successfully resumed, process 38037 the requests that are queued into the device's queue when it is resuming 38038 and then mark last busy and initiate autosuspend for it. 38039 </para><para> 38040 38041 This function should be called near the end of the device's 38042 runtime_resume callback. 38043</para> 38044</refsect1> 38045</refentry> 38046 38047<!-- block/blk-core.c --> 38048<refentry id="API---blk-run-queue-uncond"> 38049<refentryinfo> 38050 <title>LINUX</title> 38051 <productname>Kernel Hackers Manual</productname> 38052 <date>July 2017</date> 38053</refentryinfo> 38054<refmeta> 38055 <refentrytitle><phrase>__blk_run_queue_uncond</phrase></refentrytitle> 38056 <manvolnum>9</manvolnum> 38057 <refmiscinfo class="version">4.1.27</refmiscinfo> 38058</refmeta> 38059<refnamediv> 38060 <refname>__blk_run_queue_uncond</refname> 38061 <refpurpose> 38062 run a queue whether or not it has been stopped 38063 </refpurpose> 38064</refnamediv> 38065<refsynopsisdiv> 38066 <title>Synopsis</title> 38067 <funcsynopsis><funcprototype> 38068 <funcdef>void <function>__blk_run_queue_uncond </function></funcdef> 38069 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 38070 </funcprototype></funcsynopsis> 38071</refsynopsisdiv> 38072<refsect1> 38073 <title>Arguments</title> 38074 <variablelist> 38075 <varlistentry> 38076 <term><parameter>q</parameter></term> 38077 <listitem> 38078 <para> 38079 The queue to run 38080 </para> 38081 </listitem> 38082 </varlistentry> 38083 </variablelist> 38084</refsect1> 38085<refsect1> 38086<title>Description</title> 38087<para> 38088 Invoke request handling on a queue if there are any pending requests. 38089 May be used to restart request handling after a request has completed. 38090 This variant runs the queue whether or not the queue has been 38091 stopped. Must be called with the queue lock held and interrupts 38092 disabled. See also <parameter>blk_run_queue</parameter>. 38093</para> 38094</refsect1> 38095</refentry> 38096 38097<refentry id="API---blk-drain-queue"> 38098<refentryinfo> 38099 <title>LINUX</title> 38100 <productname>Kernel Hackers Manual</productname> 38101 <date>July 2017</date> 38102</refentryinfo> 38103<refmeta> 38104 <refentrytitle><phrase>__blk_drain_queue</phrase></refentrytitle> 38105 <manvolnum>9</manvolnum> 38106 <refmiscinfo class="version">4.1.27</refmiscinfo> 38107</refmeta> 38108<refnamediv> 38109 <refname>__blk_drain_queue</refname> 38110 <refpurpose> 38111 drain requests from request_queue 38112 </refpurpose> 38113</refnamediv> 38114<refsynopsisdiv> 38115 <title>Synopsis</title> 38116 <funcsynopsis><funcprototype> 38117 <funcdef>void <function>__blk_drain_queue </function></funcdef> 38118 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 38119 <paramdef>bool <parameter>drain_all</parameter></paramdef> 38120 </funcprototype></funcsynopsis> 38121</refsynopsisdiv> 38122<refsect1> 38123 <title>Arguments</title> 38124 <variablelist> 38125 <varlistentry> 38126 <term><parameter>q</parameter></term> 38127 <listitem> 38128 <para> 38129 queue to drain 38130 </para> 38131 </listitem> 38132 </varlistentry> 38133 <varlistentry> 38134 <term><parameter>drain_all</parameter></term> 38135 <listitem> 38136 <para> 38137 whether to drain all requests or only the ones w/ ELVPRIV 38138 </para> 38139 </listitem> 38140 </varlistentry> 38141 </variablelist> 38142</refsect1> 38143<refsect1> 38144<title>Description</title> 38145<para> 38146 Drain requests from <parameter>q</parameter>. If <parameter>drain_all</parameter> is set, all requests are drained. 38147 If not, only ELVPRIV requests are drained. The caller is responsible 38148 for ensuring that no new requests which need to be drained are queued. 38149</para> 38150</refsect1> 38151</refentry> 38152 38153<refentry id="API-rq-ioc"> 38154<refentryinfo> 38155 <title>LINUX</title> 38156 <productname>Kernel Hackers Manual</productname> 38157 <date>July 2017</date> 38158</refentryinfo> 38159<refmeta> 38160 <refentrytitle><phrase>rq_ioc</phrase></refentrytitle> 38161 <manvolnum>9</manvolnum> 38162 <refmiscinfo class="version">4.1.27</refmiscinfo> 38163</refmeta> 38164<refnamediv> 38165 <refname>rq_ioc</refname> 38166 <refpurpose> 38167 determine io_context for request allocation 38168 </refpurpose> 38169</refnamediv> 38170<refsynopsisdiv> 38171 <title>Synopsis</title> 38172 <funcsynopsis><funcprototype> 38173 <funcdef>struct io_context * <function>rq_ioc </function></funcdef> 38174 <paramdef>struct bio * <parameter>bio</parameter></paramdef> 38175 </funcprototype></funcsynopsis> 38176</refsynopsisdiv> 38177<refsect1> 38178 <title>Arguments</title> 38179 <variablelist> 38180 <varlistentry> 38181 <term><parameter>bio</parameter></term> 38182 <listitem> 38183 <para> 38184 request being allocated is for this bio (can be <constant>NULL</constant>) 38185 </para> 38186 </listitem> 38187 </varlistentry> 38188 </variablelist> 38189</refsect1> 38190<refsect1> 38191<title>Description</title> 38192<para> 38193 Determine io_context to use for request allocation for <parameter>bio</parameter>. May return 38194 <constant>NULL</constant> if <constant>current-</constant>>io_context doesn't exist. 38195</para> 38196</refsect1> 38197</refentry> 38198 38199<refentry id="API---get-request"> 38200<refentryinfo> 38201 <title>LINUX</title> 38202 <productname>Kernel Hackers Manual</productname> 38203 <date>July 2017</date> 38204</refentryinfo> 38205<refmeta> 38206 <refentrytitle><phrase>__get_request</phrase></refentrytitle> 38207 <manvolnum>9</manvolnum> 38208 <refmiscinfo class="version">4.1.27</refmiscinfo> 38209</refmeta> 38210<refnamediv> 38211 <refname>__get_request</refname> 38212 <refpurpose> 38213 get a free request 38214 </refpurpose> 38215</refnamediv> 38216<refsynopsisdiv> 38217 <title>Synopsis</title> 38218 <funcsynopsis><funcprototype> 38219 <funcdef>struct request * <function>__get_request </function></funcdef> 38220 <paramdef>struct request_list * <parameter>rl</parameter></paramdef> 38221 <paramdef>int <parameter>rw_flags</parameter></paramdef> 38222 <paramdef>struct bio * <parameter>bio</parameter></paramdef> 38223 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 38224 </funcprototype></funcsynopsis> 38225</refsynopsisdiv> 38226<refsect1> 38227 <title>Arguments</title> 38228 <variablelist> 38229 <varlistentry> 38230 <term><parameter>rl</parameter></term> 38231 <listitem> 38232 <para> 38233 request list to allocate from 38234 </para> 38235 </listitem> 38236 </varlistentry> 38237 <varlistentry> 38238 <term><parameter>rw_flags</parameter></term> 38239 <listitem> 38240 <para> 38241 RW and SYNC flags 38242 </para> 38243 </listitem> 38244 </varlistentry> 38245 <varlistentry> 38246 <term><parameter>bio</parameter></term> 38247 <listitem> 38248 <para> 38249 bio to allocate request for (can be <constant>NULL</constant>) 38250 </para> 38251 </listitem> 38252 </varlistentry> 38253 <varlistentry> 38254 <term><parameter>gfp_mask</parameter></term> 38255 <listitem> 38256 <para> 38257 allocation mask 38258 </para> 38259 </listitem> 38260 </varlistentry> 38261 </variablelist> 38262</refsect1> 38263<refsect1> 38264<title>Description</title> 38265<para> 38266 Get a free request from <parameter>q</parameter>. This function may fail under memory 38267 pressure or if <parameter>q</parameter> is dead. 38268 </para><para> 38269 38270 Must be called with <parameter>q</parameter>->queue_lock held and, 38271 Returns ERR_PTR on failure, with <parameter>q</parameter>->queue_lock held. 38272 Returns request pointer on success, with <parameter>q</parameter>->queue_lock *not held*. 38273</para> 38274</refsect1> 38275</refentry> 38276 38277<refentry id="API-get-request"> 38278<refentryinfo> 38279 <title>LINUX</title> 38280 <productname>Kernel Hackers Manual</productname> 38281 <date>July 2017</date> 38282</refentryinfo> 38283<refmeta> 38284 <refentrytitle><phrase>get_request</phrase></refentrytitle> 38285 <manvolnum>9</manvolnum> 38286 <refmiscinfo class="version">4.1.27</refmiscinfo> 38287</refmeta> 38288<refnamediv> 38289 <refname>get_request</refname> 38290 <refpurpose> 38291 get a free request 38292 </refpurpose> 38293</refnamediv> 38294<refsynopsisdiv> 38295 <title>Synopsis</title> 38296 <funcsynopsis><funcprototype> 38297 <funcdef>struct request * <function>get_request </function></funcdef> 38298 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 38299 <paramdef>int <parameter>rw_flags</parameter></paramdef> 38300 <paramdef>struct bio * <parameter>bio</parameter></paramdef> 38301 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 38302 </funcprototype></funcsynopsis> 38303</refsynopsisdiv> 38304<refsect1> 38305 <title>Arguments</title> 38306 <variablelist> 38307 <varlistentry> 38308 <term><parameter>q</parameter></term> 38309 <listitem> 38310 <para> 38311 request_queue to allocate request from 38312 </para> 38313 </listitem> 38314 </varlistentry> 38315 <varlistentry> 38316 <term><parameter>rw_flags</parameter></term> 38317 <listitem> 38318 <para> 38319 RW and SYNC flags 38320 </para> 38321 </listitem> 38322 </varlistentry> 38323 <varlistentry> 38324 <term><parameter>bio</parameter></term> 38325 <listitem> 38326 <para> 38327 bio to allocate request for (can be <constant>NULL</constant>) 38328 </para> 38329 </listitem> 38330 </varlistentry> 38331 <varlistentry> 38332 <term><parameter>gfp_mask</parameter></term> 38333 <listitem> 38334 <para> 38335 allocation mask 38336 </para> 38337 </listitem> 38338 </varlistentry> 38339 </variablelist> 38340</refsect1> 38341<refsect1> 38342<title>Description</title> 38343<para> 38344 Get a free request from <parameter>q</parameter>. If <constant>__GFP_WAIT</constant> is set in <parameter>gfp_mask</parameter>, this 38345 function keeps retrying under memory pressure and fails iff <parameter>q</parameter> is dead. 38346 </para><para> 38347 38348 Must be called with <parameter>q</parameter>->queue_lock held and, 38349 Returns ERR_PTR on failure, with <parameter>q</parameter>->queue_lock held. 38350 Returns request pointer on success, with <parameter>q</parameter>->queue_lock *not held*. 38351</para> 38352</refsect1> 38353</refentry> 38354 38355<refentry id="API-blk-attempt-plug-merge"> 38356<refentryinfo> 38357 <title>LINUX</title> 38358 <productname>Kernel Hackers Manual</productname> 38359 <date>July 2017</date> 38360</refentryinfo> 38361<refmeta> 38362 <refentrytitle><phrase>blk_attempt_plug_merge</phrase></refentrytitle> 38363 <manvolnum>9</manvolnum> 38364 <refmiscinfo class="version">4.1.27</refmiscinfo> 38365</refmeta> 38366<refnamediv> 38367 <refname>blk_attempt_plug_merge</refname> 38368 <refpurpose> 38369 try to merge with <constant>current</constant>'s plugged list 38370 </refpurpose> 38371</refnamediv> 38372<refsynopsisdiv> 38373 <title>Synopsis</title> 38374 <funcsynopsis><funcprototype> 38375 <funcdef>bool <function>blk_attempt_plug_merge </function></funcdef> 38376 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 38377 <paramdef>struct bio * <parameter>bio</parameter></paramdef> 38378 <paramdef>unsigned int * <parameter>request_count</parameter></paramdef> 38379 </funcprototype></funcsynopsis> 38380</refsynopsisdiv> 38381<refsect1> 38382 <title>Arguments</title> 38383 <variablelist> 38384 <varlistentry> 38385 <term><parameter>q</parameter></term> 38386 <listitem> 38387 <para> 38388 request_queue new bio is being queued at 38389 </para> 38390 </listitem> 38391 </varlistentry> 38392 <varlistentry> 38393 <term><parameter>bio</parameter></term> 38394 <listitem> 38395 <para> 38396 new bio being queued 38397 </para> 38398 </listitem> 38399 </varlistentry> 38400 <varlistentry> 38401 <term><parameter>request_count</parameter></term> 38402 <listitem> 38403 <para> 38404 out parameter for number of traversed plugged requests 38405 </para> 38406 </listitem> 38407 </varlistentry> 38408 </variablelist> 38409</refsect1> 38410<refsect1> 38411<title>Description</title> 38412<para> 38413 Determine whether <parameter>bio</parameter> being queued on <parameter>q</parameter> can be merged with a request 38414 on <constant>current</constant>'s plugged list. Returns <constant>true</constant> if merge was successful, 38415 otherwise <constant>false</constant>. 38416 </para><para> 38417 38418 Plugging coalesces IOs from the same issuer for the same purpose without 38419 going through <parameter>q</parameter>->queue_lock. As such it's more of an issuing mechanism 38420 than scheduling, and the request, while may have elvpriv data, is not 38421 added on the elevator at this point. In addition, we don't have 38422 reliable access to the elevator outside queue lock. Only check basic 38423 merging parameters without querying the elevator. 38424 </para><para> 38425 38426 Caller must ensure !blk_queue_nomerges(q) beforehand. 38427</para> 38428</refsect1> 38429</refentry> 38430 38431<refentry id="API-blk-end-bidi-request"> 38432<refentryinfo> 38433 <title>LINUX</title> 38434 <productname>Kernel Hackers Manual</productname> 38435 <date>July 2017</date> 38436</refentryinfo> 38437<refmeta> 38438 <refentrytitle><phrase>blk_end_bidi_request</phrase></refentrytitle> 38439 <manvolnum>9</manvolnum> 38440 <refmiscinfo class="version">4.1.27</refmiscinfo> 38441</refmeta> 38442<refnamediv> 38443 <refname>blk_end_bidi_request</refname> 38444 <refpurpose> 38445 Complete a bidi request 38446 </refpurpose> 38447</refnamediv> 38448<refsynopsisdiv> 38449 <title>Synopsis</title> 38450 <funcsynopsis><funcprototype> 38451 <funcdef>bool <function>blk_end_bidi_request </function></funcdef> 38452 <paramdef>struct request * <parameter>rq</parameter></paramdef> 38453 <paramdef>int <parameter>error</parameter></paramdef> 38454 <paramdef>unsigned int <parameter>nr_bytes</parameter></paramdef> 38455 <paramdef>unsigned int <parameter>bidi_bytes</parameter></paramdef> 38456 </funcprototype></funcsynopsis> 38457</refsynopsisdiv> 38458<refsect1> 38459 <title>Arguments</title> 38460 <variablelist> 38461 <varlistentry> 38462 <term><parameter>rq</parameter></term> 38463 <listitem> 38464 <para> 38465 the request to complete 38466 </para> 38467 </listitem> 38468 </varlistentry> 38469 <varlistentry> 38470 <term><parameter>error</parameter></term> 38471 <listitem> 38472 <para> 38473 <constant>0</constant> for success, < <constant>0</constant> for error 38474 </para> 38475 </listitem> 38476 </varlistentry> 38477 <varlistentry> 38478 <term><parameter>nr_bytes</parameter></term> 38479 <listitem> 38480 <para> 38481 number of bytes to complete <parameter>rq</parameter> 38482 </para> 38483 </listitem> 38484 </varlistentry> 38485 <varlistentry> 38486 <term><parameter>bidi_bytes</parameter></term> 38487 <listitem> 38488 <para> 38489 number of bytes to complete <parameter>rq</parameter>->next_rq 38490 </para> 38491 </listitem> 38492 </varlistentry> 38493 </variablelist> 38494</refsect1> 38495<refsect1> 38496<title>Description</title> 38497<para> 38498 Ends I/O on a number of bytes attached to <parameter>rq</parameter> and <parameter>rq</parameter>->next_rq. 38499 Drivers that supports bidi can safely call this member for any 38500 type of request, bidi or uni. In the later case <parameter>bidi_bytes</parameter> is 38501 just ignored. 38502</para> 38503</refsect1> 38504<refsect1> 38505<title>Return</title> 38506<para> 38507 <constant>false</constant> - we are done with this request 38508 <constant>true</constant> - still buffers pending for this request 38509</para> 38510</refsect1> 38511</refentry> 38512 38513<refentry id="API---blk-end-bidi-request"> 38514<refentryinfo> 38515 <title>LINUX</title> 38516 <productname>Kernel Hackers Manual</productname> 38517 <date>July 2017</date> 38518</refentryinfo> 38519<refmeta> 38520 <refentrytitle><phrase>__blk_end_bidi_request</phrase></refentrytitle> 38521 <manvolnum>9</manvolnum> 38522 <refmiscinfo class="version">4.1.27</refmiscinfo> 38523</refmeta> 38524<refnamediv> 38525 <refname>__blk_end_bidi_request</refname> 38526 <refpurpose> 38527 Complete a bidi request with queue lock held 38528 </refpurpose> 38529</refnamediv> 38530<refsynopsisdiv> 38531 <title>Synopsis</title> 38532 <funcsynopsis><funcprototype> 38533 <funcdef>bool <function>__blk_end_bidi_request </function></funcdef> 38534 <paramdef>struct request * <parameter>rq</parameter></paramdef> 38535 <paramdef>int <parameter>error</parameter></paramdef> 38536 <paramdef>unsigned int <parameter>nr_bytes</parameter></paramdef> 38537 <paramdef>unsigned int <parameter>bidi_bytes</parameter></paramdef> 38538 </funcprototype></funcsynopsis> 38539</refsynopsisdiv> 38540<refsect1> 38541 <title>Arguments</title> 38542 <variablelist> 38543 <varlistentry> 38544 <term><parameter>rq</parameter></term> 38545 <listitem> 38546 <para> 38547 the request to complete 38548 </para> 38549 </listitem> 38550 </varlistentry> 38551 <varlistentry> 38552 <term><parameter>error</parameter></term> 38553 <listitem> 38554 <para> 38555 <constant>0</constant> for success, < <constant>0</constant> for error 38556 </para> 38557 </listitem> 38558 </varlistentry> 38559 <varlistentry> 38560 <term><parameter>nr_bytes</parameter></term> 38561 <listitem> 38562 <para> 38563 number of bytes to complete <parameter>rq</parameter> 38564 </para> 38565 </listitem> 38566 </varlistentry> 38567 <varlistentry> 38568 <term><parameter>bidi_bytes</parameter></term> 38569 <listitem> 38570 <para> 38571 number of bytes to complete <parameter>rq</parameter>->next_rq 38572 </para> 38573 </listitem> 38574 </varlistentry> 38575 </variablelist> 38576</refsect1> 38577<refsect1> 38578<title>Description</title> 38579<para> 38580 Identical to <function>blk_end_bidi_request</function> except that queue lock is 38581 assumed to be locked on entry and remains so on return. 38582</para> 38583</refsect1> 38584<refsect1> 38585<title>Return</title> 38586<para> 38587 <constant>false</constant> - we are done with this request 38588 <constant>true</constant> - still buffers pending for this request 38589</para> 38590</refsect1> 38591</refentry> 38592 38593<!-- block/blk-map.c --> 38594<refentry id="API-blk-rq-map-user-iov"> 38595<refentryinfo> 38596 <title>LINUX</title> 38597 <productname>Kernel Hackers Manual</productname> 38598 <date>July 2017</date> 38599</refentryinfo> 38600<refmeta> 38601 <refentrytitle><phrase>blk_rq_map_user_iov</phrase></refentrytitle> 38602 <manvolnum>9</manvolnum> 38603 <refmiscinfo class="version">4.1.27</refmiscinfo> 38604</refmeta> 38605<refnamediv> 38606 <refname>blk_rq_map_user_iov</refname> 38607 <refpurpose> 38608 map user data to a request, for REQ_TYPE_BLOCK_PC usage 38609 </refpurpose> 38610</refnamediv> 38611<refsynopsisdiv> 38612 <title>Synopsis</title> 38613 <funcsynopsis><funcprototype> 38614 <funcdef>int <function>blk_rq_map_user_iov </function></funcdef> 38615 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 38616 <paramdef>struct request * <parameter>rq</parameter></paramdef> 38617 <paramdef>struct rq_map_data * <parameter>map_data</parameter></paramdef> 38618 <paramdef>const struct iov_iter * <parameter>iter</parameter></paramdef> 38619 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 38620 </funcprototype></funcsynopsis> 38621</refsynopsisdiv> 38622<refsect1> 38623 <title>Arguments</title> 38624 <variablelist> 38625 <varlistentry> 38626 <term><parameter>q</parameter></term> 38627 <listitem> 38628 <para> 38629 request queue where request should be inserted 38630 </para> 38631 </listitem> 38632 </varlistentry> 38633 <varlistentry> 38634 <term><parameter>rq</parameter></term> 38635 <listitem> 38636 <para> 38637 request to map data to 38638 </para> 38639 </listitem> 38640 </varlistentry> 38641 <varlistentry> 38642 <term><parameter>map_data</parameter></term> 38643 <listitem> 38644 <para> 38645 pointer to the rq_map_data holding pages (if necessary) 38646 </para> 38647 </listitem> 38648 </varlistentry> 38649 <varlistentry> 38650 <term><parameter>iter</parameter></term> 38651 <listitem> 38652 <para> 38653 iovec iterator 38654 </para> 38655 </listitem> 38656 </varlistentry> 38657 <varlistentry> 38658 <term><parameter>gfp_mask</parameter></term> 38659 <listitem> 38660 <para> 38661 memory allocation flags 38662 </para> 38663 </listitem> 38664 </varlistentry> 38665 </variablelist> 38666</refsect1> 38667<refsect1> 38668<title>Description</title> 38669<para> 38670 Data will be mapped directly for zero copy I/O, if possible. Otherwise 38671 a kernel bounce buffer is used. 38672 </para><para> 38673 38674 A matching <function>blk_rq_unmap_user</function> must be issued at the end of I/O, while 38675 still in process context. 38676</para> 38677</refsect1> 38678<refsect1> 38679<title>Note</title> 38680<para> 38681 The mapped bio may need to be bounced through <function>blk_queue_bounce</function> 38682 before being submitted to the device, as pages mapped may be out of 38683 reach. It's the callers responsibility to make sure this happens. The 38684 original bio must be passed back in to <function>blk_rq_unmap_user</function> for proper 38685 unmapping. 38686</para> 38687</refsect1> 38688</refentry> 38689 38690<refentry id="API-blk-rq-unmap-user"> 38691<refentryinfo> 38692 <title>LINUX</title> 38693 <productname>Kernel Hackers Manual</productname> 38694 <date>July 2017</date> 38695</refentryinfo> 38696<refmeta> 38697 <refentrytitle><phrase>blk_rq_unmap_user</phrase></refentrytitle> 38698 <manvolnum>9</manvolnum> 38699 <refmiscinfo class="version">4.1.27</refmiscinfo> 38700</refmeta> 38701<refnamediv> 38702 <refname>blk_rq_unmap_user</refname> 38703 <refpurpose> 38704 unmap a request with user data 38705 </refpurpose> 38706</refnamediv> 38707<refsynopsisdiv> 38708 <title>Synopsis</title> 38709 <funcsynopsis><funcprototype> 38710 <funcdef>int <function>blk_rq_unmap_user </function></funcdef> 38711 <paramdef>struct bio * <parameter>bio</parameter></paramdef> 38712 </funcprototype></funcsynopsis> 38713</refsynopsisdiv> 38714<refsect1> 38715 <title>Arguments</title> 38716 <variablelist> 38717 <varlistentry> 38718 <term><parameter>bio</parameter></term> 38719 <listitem> 38720 <para> 38721 start of bio list 38722 </para> 38723 </listitem> 38724 </varlistentry> 38725 </variablelist> 38726</refsect1> 38727<refsect1> 38728<title>Description</title> 38729<para> 38730 Unmap a rq previously mapped by <function>blk_rq_map_user</function>. The caller must 38731 supply the original rq->bio from the <function>blk_rq_map_user</function> return, since 38732 the I/O completion may have changed rq->bio. 38733</para> 38734</refsect1> 38735</refentry> 38736 38737<refentry id="API-blk-rq-map-kern"> 38738<refentryinfo> 38739 <title>LINUX</title> 38740 <productname>Kernel Hackers Manual</productname> 38741 <date>July 2017</date> 38742</refentryinfo> 38743<refmeta> 38744 <refentrytitle><phrase>blk_rq_map_kern</phrase></refentrytitle> 38745 <manvolnum>9</manvolnum> 38746 <refmiscinfo class="version">4.1.27</refmiscinfo> 38747</refmeta> 38748<refnamediv> 38749 <refname>blk_rq_map_kern</refname> 38750 <refpurpose> 38751 map kernel data to a request, for REQ_TYPE_BLOCK_PC usage 38752 </refpurpose> 38753</refnamediv> 38754<refsynopsisdiv> 38755 <title>Synopsis</title> 38756 <funcsynopsis><funcprototype> 38757 <funcdef>int <function>blk_rq_map_kern </function></funcdef> 38758 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 38759 <paramdef>struct request * <parameter>rq</parameter></paramdef> 38760 <paramdef>void * <parameter>kbuf</parameter></paramdef> 38761 <paramdef>unsigned int <parameter>len</parameter></paramdef> 38762 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 38763 </funcprototype></funcsynopsis> 38764</refsynopsisdiv> 38765<refsect1> 38766 <title>Arguments</title> 38767 <variablelist> 38768 <varlistentry> 38769 <term><parameter>q</parameter></term> 38770 <listitem> 38771 <para> 38772 request queue where request should be inserted 38773 </para> 38774 </listitem> 38775 </varlistentry> 38776 <varlistentry> 38777 <term><parameter>rq</parameter></term> 38778 <listitem> 38779 <para> 38780 request to fill 38781 </para> 38782 </listitem> 38783 </varlistentry> 38784 <varlistentry> 38785 <term><parameter>kbuf</parameter></term> 38786 <listitem> 38787 <para> 38788 the kernel buffer 38789 </para> 38790 </listitem> 38791 </varlistentry> 38792 <varlistentry> 38793 <term><parameter>len</parameter></term> 38794 <listitem> 38795 <para> 38796 length of user data 38797 </para> 38798 </listitem> 38799 </varlistentry> 38800 <varlistentry> 38801 <term><parameter>gfp_mask</parameter></term> 38802 <listitem> 38803 <para> 38804 memory allocation flags 38805 </para> 38806 </listitem> 38807 </varlistentry> 38808 </variablelist> 38809</refsect1> 38810<refsect1> 38811<title>Description</title> 38812<para> 38813 Data will be mapped directly if possible. Otherwise a bounce 38814 buffer is used. Can be called multiple times to append multiple 38815 buffers. 38816</para> 38817</refsect1> 38818</refentry> 38819 38820<!-- block/blk-sysfs.c --> 38821<refentry id="API-blk-release-queue"> 38822<refentryinfo> 38823 <title>LINUX</title> 38824 <productname>Kernel Hackers Manual</productname> 38825 <date>July 2017</date> 38826</refentryinfo> 38827<refmeta> 38828 <refentrytitle><phrase>blk_release_queue</phrase></refentrytitle> 38829 <manvolnum>9</manvolnum> 38830 <refmiscinfo class="version">4.1.27</refmiscinfo> 38831</refmeta> 38832<refnamediv> 38833 <refname>blk_release_queue</refname> 38834 <refpurpose> 38835 release a <structname>struct request_queue</structname> when it is no longer needed 38836 </refpurpose> 38837</refnamediv> 38838<refsynopsisdiv> 38839 <title>Synopsis</title> 38840 <funcsynopsis><funcprototype> 38841 <funcdef>void <function>blk_release_queue </function></funcdef> 38842 <paramdef>struct kobject * <parameter>kobj</parameter></paramdef> 38843 </funcprototype></funcsynopsis> 38844</refsynopsisdiv> 38845<refsect1> 38846 <title>Arguments</title> 38847 <variablelist> 38848 <varlistentry> 38849 <term><parameter>kobj</parameter></term> 38850 <listitem> 38851 <para> 38852 the kobj belonging to the request queue to be released 38853 </para> 38854 </listitem> 38855 </varlistentry> 38856 </variablelist> 38857</refsect1> 38858<refsect1> 38859<title>Description</title> 38860<para> 38861 blk_release_queue is the pair to <function>blk_init_queue</function> or 38862 <function>blk_queue_make_request</function>. It should be called when a request queue is 38863 being released; typically when a block device is being de-registered. 38864 Currently, its primary task it to free all the <structname>struct request</structname> 38865 structures that were allocated to the queue and the queue itself. 38866</para> 38867</refsect1> 38868<refsect1> 38869<title>Note</title> 38870<para> 38871 The low level driver must have finished any outstanding requests first 38872 via <function>blk_cleanup_queue</function>. 38873</para> 38874</refsect1> 38875</refentry> 38876 38877<!-- block/blk-settings.c --> 38878<refentry id="API-blk-queue-prep-rq"> 38879<refentryinfo> 38880 <title>LINUX</title> 38881 <productname>Kernel Hackers Manual</productname> 38882 <date>July 2017</date> 38883</refentryinfo> 38884<refmeta> 38885 <refentrytitle><phrase>blk_queue_prep_rq</phrase></refentrytitle> 38886 <manvolnum>9</manvolnum> 38887 <refmiscinfo class="version">4.1.27</refmiscinfo> 38888</refmeta> 38889<refnamediv> 38890 <refname>blk_queue_prep_rq</refname> 38891 <refpurpose> 38892 set a prepare_request function for queue 38893 </refpurpose> 38894</refnamediv> 38895<refsynopsisdiv> 38896 <title>Synopsis</title> 38897 <funcsynopsis><funcprototype> 38898 <funcdef>void <function>blk_queue_prep_rq </function></funcdef> 38899 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 38900 <paramdef>prep_rq_fn * <parameter>pfn</parameter></paramdef> 38901 </funcprototype></funcsynopsis> 38902</refsynopsisdiv> 38903<refsect1> 38904 <title>Arguments</title> 38905 <variablelist> 38906 <varlistentry> 38907 <term><parameter>q</parameter></term> 38908 <listitem> 38909 <para> 38910 queue 38911 </para> 38912 </listitem> 38913 </varlistentry> 38914 <varlistentry> 38915 <term><parameter>pfn</parameter></term> 38916 <listitem> 38917 <para> 38918 prepare_request function 38919 </para> 38920 </listitem> 38921 </varlistentry> 38922 </variablelist> 38923</refsect1> 38924<refsect1> 38925<title>Description</title> 38926<para> 38927 It's possible for a queue to register a prepare_request callback which 38928 is invoked before the request is handed to the request_fn. The goal of 38929 the function is to prepare a request for I/O, it can be used to build a 38930 cdb from the request data for instance. 38931</para> 38932</refsect1> 38933</refentry> 38934 38935<refentry id="API-blk-queue-unprep-rq"> 38936<refentryinfo> 38937 <title>LINUX</title> 38938 <productname>Kernel Hackers Manual</productname> 38939 <date>July 2017</date> 38940</refentryinfo> 38941<refmeta> 38942 <refentrytitle><phrase>blk_queue_unprep_rq</phrase></refentrytitle> 38943 <manvolnum>9</manvolnum> 38944 <refmiscinfo class="version">4.1.27</refmiscinfo> 38945</refmeta> 38946<refnamediv> 38947 <refname>blk_queue_unprep_rq</refname> 38948 <refpurpose> 38949 set an unprepare_request function for queue 38950 </refpurpose> 38951</refnamediv> 38952<refsynopsisdiv> 38953 <title>Synopsis</title> 38954 <funcsynopsis><funcprototype> 38955 <funcdef>void <function>blk_queue_unprep_rq </function></funcdef> 38956 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 38957 <paramdef>unprep_rq_fn * <parameter>ufn</parameter></paramdef> 38958 </funcprototype></funcsynopsis> 38959</refsynopsisdiv> 38960<refsect1> 38961 <title>Arguments</title> 38962 <variablelist> 38963 <varlistentry> 38964 <term><parameter>q</parameter></term> 38965 <listitem> 38966 <para> 38967 queue 38968 </para> 38969 </listitem> 38970 </varlistentry> 38971 <varlistentry> 38972 <term><parameter>ufn</parameter></term> 38973 <listitem> 38974 <para> 38975 unprepare_request function 38976 </para> 38977 </listitem> 38978 </varlistentry> 38979 </variablelist> 38980</refsect1> 38981<refsect1> 38982<title>Description</title> 38983<para> 38984 It's possible for a queue to register an unprepare_request callback 38985 which is invoked before the request is finally completed. The goal 38986 of the function is to deallocate any data that was allocated in the 38987 prepare_request callback. 38988</para> 38989</refsect1> 38990</refentry> 38991 38992<refentry id="API-blk-queue-merge-bvec"> 38993<refentryinfo> 38994 <title>LINUX</title> 38995 <productname>Kernel Hackers Manual</productname> 38996 <date>July 2017</date> 38997</refentryinfo> 38998<refmeta> 38999 <refentrytitle><phrase>blk_queue_merge_bvec</phrase></refentrytitle> 39000 <manvolnum>9</manvolnum> 39001 <refmiscinfo class="version">4.1.27</refmiscinfo> 39002</refmeta> 39003<refnamediv> 39004 <refname>blk_queue_merge_bvec</refname> 39005 <refpurpose> 39006 set a merge_bvec function for queue 39007 </refpurpose> 39008</refnamediv> 39009<refsynopsisdiv> 39010 <title>Synopsis</title> 39011 <funcsynopsis><funcprototype> 39012 <funcdef>void <function>blk_queue_merge_bvec </function></funcdef> 39013 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 39014 <paramdef>merge_bvec_fn * <parameter>mbfn</parameter></paramdef> 39015 </funcprototype></funcsynopsis> 39016</refsynopsisdiv> 39017<refsect1> 39018 <title>Arguments</title> 39019 <variablelist> 39020 <varlistentry> 39021 <term><parameter>q</parameter></term> 39022 <listitem> 39023 <para> 39024 queue 39025 </para> 39026 </listitem> 39027 </varlistentry> 39028 <varlistentry> 39029 <term><parameter>mbfn</parameter></term> 39030 <listitem> 39031 <para> 39032 merge_bvec_fn 39033 </para> 39034 </listitem> 39035 </varlistentry> 39036 </variablelist> 39037</refsect1> 39038<refsect1> 39039<title>Description</title> 39040<para> 39041 Usually queues have static limitations on the max sectors or segments that 39042 we can put in a request. Stacking drivers may have some settings that 39043 are dynamic, and thus we have to query the queue whether it is ok to 39044 add a new bio_vec to a bio at a given offset or not. If the block device 39045 has such limitations, it needs to register a merge_bvec_fn to control 39046 the size of bio's sent to it. Note that a block device *must* allow a 39047 single page to be added to an empty bio. The block device driver may want 39048 to use the <function>bio_split</function> function to deal with these bio's. By default 39049 no merge_bvec_fn is defined for a queue, and only the fixed limits are 39050 honored. 39051</para> 39052</refsect1> 39053</refentry> 39054 39055<refentry id="API-blk-set-default-limits"> 39056<refentryinfo> 39057 <title>LINUX</title> 39058 <productname>Kernel Hackers Manual</productname> 39059 <date>July 2017</date> 39060</refentryinfo> 39061<refmeta> 39062 <refentrytitle><phrase>blk_set_default_limits</phrase></refentrytitle> 39063 <manvolnum>9</manvolnum> 39064 <refmiscinfo class="version">4.1.27</refmiscinfo> 39065</refmeta> 39066<refnamediv> 39067 <refname>blk_set_default_limits</refname> 39068 <refpurpose> 39069 reset limits to default values 39070 </refpurpose> 39071</refnamediv> 39072<refsynopsisdiv> 39073 <title>Synopsis</title> 39074 <funcsynopsis><funcprototype> 39075 <funcdef>void <function>blk_set_default_limits </function></funcdef> 39076 <paramdef>struct queue_limits * <parameter>lim</parameter></paramdef> 39077 </funcprototype></funcsynopsis> 39078</refsynopsisdiv> 39079<refsect1> 39080 <title>Arguments</title> 39081 <variablelist> 39082 <varlistentry> 39083 <term><parameter>lim</parameter></term> 39084 <listitem> 39085 <para> 39086 the queue_limits structure to reset 39087 </para> 39088 </listitem> 39089 </varlistentry> 39090 </variablelist> 39091</refsect1> 39092<refsect1> 39093<title>Description</title> 39094<para> 39095 Returns a queue_limit struct to its default state. 39096</para> 39097</refsect1> 39098</refentry> 39099 39100<refentry id="API-blk-set-stacking-limits"> 39101<refentryinfo> 39102 <title>LINUX</title> 39103 <productname>Kernel Hackers Manual</productname> 39104 <date>July 2017</date> 39105</refentryinfo> 39106<refmeta> 39107 <refentrytitle><phrase>blk_set_stacking_limits</phrase></refentrytitle> 39108 <manvolnum>9</manvolnum> 39109 <refmiscinfo class="version">4.1.27</refmiscinfo> 39110</refmeta> 39111<refnamediv> 39112 <refname>blk_set_stacking_limits</refname> 39113 <refpurpose> 39114 set default limits for stacking devices 39115 </refpurpose> 39116</refnamediv> 39117<refsynopsisdiv> 39118 <title>Synopsis</title> 39119 <funcsynopsis><funcprototype> 39120 <funcdef>void <function>blk_set_stacking_limits </function></funcdef> 39121 <paramdef>struct queue_limits * <parameter>lim</parameter></paramdef> 39122 </funcprototype></funcsynopsis> 39123</refsynopsisdiv> 39124<refsect1> 39125 <title>Arguments</title> 39126 <variablelist> 39127 <varlistentry> 39128 <term><parameter>lim</parameter></term> 39129 <listitem> 39130 <para> 39131 the queue_limits structure to reset 39132 </para> 39133 </listitem> 39134 </varlistentry> 39135 </variablelist> 39136</refsect1> 39137<refsect1> 39138<title>Description</title> 39139<para> 39140 Returns a queue_limit struct to its default state. Should be used 39141 by stacking drivers like DM that have no internal limits. 39142</para> 39143</refsect1> 39144</refentry> 39145 39146<refentry id="API-blk-queue-make-request"> 39147<refentryinfo> 39148 <title>LINUX</title> 39149 <productname>Kernel Hackers Manual</productname> 39150 <date>July 2017</date> 39151</refentryinfo> 39152<refmeta> 39153 <refentrytitle><phrase>blk_queue_make_request</phrase></refentrytitle> 39154 <manvolnum>9</manvolnum> 39155 <refmiscinfo class="version">4.1.27</refmiscinfo> 39156</refmeta> 39157<refnamediv> 39158 <refname>blk_queue_make_request</refname> 39159 <refpurpose> 39160 define an alternate make_request function for a device 39161 </refpurpose> 39162</refnamediv> 39163<refsynopsisdiv> 39164 <title>Synopsis</title> 39165 <funcsynopsis><funcprototype> 39166 <funcdef>void <function>blk_queue_make_request </function></funcdef> 39167 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 39168 <paramdef>make_request_fn * <parameter>mfn</parameter></paramdef> 39169 </funcprototype></funcsynopsis> 39170</refsynopsisdiv> 39171<refsect1> 39172 <title>Arguments</title> 39173 <variablelist> 39174 <varlistentry> 39175 <term><parameter>q</parameter></term> 39176 <listitem> 39177 <para> 39178 the request queue for the device to be affected 39179 </para> 39180 </listitem> 39181 </varlistentry> 39182 <varlistentry> 39183 <term><parameter>mfn</parameter></term> 39184 <listitem> 39185 <para> 39186 the alternate make_request function 39187 </para> 39188 </listitem> 39189 </varlistentry> 39190 </variablelist> 39191</refsect1> 39192<refsect1> 39193<title>Description</title> 39194<para> 39195 The normal way for <structname>struct bios</structname> to be passed to a device 39196 driver is for them to be collected into requests on a request 39197 queue, and then to allow the device driver to select requests 39198 off that queue when it is ready. This works well for many block 39199 devices. However some block devices (typically virtual devices 39200 such as md or lvm) do not benefit from the processing on the 39201 request queue, and are served best by having the requests passed 39202 directly to them. This can be achieved by providing a function 39203 to <function>blk_queue_make_request</function>. 39204</para> 39205</refsect1> 39206<refsect1> 39207<title>Caveat</title> 39208<para> 39209 The driver that does this *must* be able to deal appropriately 39210 with buffers in <quote>highmemory</quote>. This can be accomplished by either calling 39211 <function>__bio_kmap_atomic</function> to get a temporary kernel mapping, or by calling 39212 <function>blk_queue_bounce</function> to create a buffer in normal memory. 39213</para> 39214</refsect1> 39215</refentry> 39216 39217<refentry id="API-blk-queue-bounce-limit"> 39218<refentryinfo> 39219 <title>LINUX</title> 39220 <productname>Kernel Hackers Manual</productname> 39221 <date>July 2017</date> 39222</refentryinfo> 39223<refmeta> 39224 <refentrytitle><phrase>blk_queue_bounce_limit</phrase></refentrytitle> 39225 <manvolnum>9</manvolnum> 39226 <refmiscinfo class="version">4.1.27</refmiscinfo> 39227</refmeta> 39228<refnamediv> 39229 <refname>blk_queue_bounce_limit</refname> 39230 <refpurpose> 39231 set bounce buffer limit for queue 39232 </refpurpose> 39233</refnamediv> 39234<refsynopsisdiv> 39235 <title>Synopsis</title> 39236 <funcsynopsis><funcprototype> 39237 <funcdef>void <function>blk_queue_bounce_limit </function></funcdef> 39238 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 39239 <paramdef>u64 <parameter>max_addr</parameter></paramdef> 39240 </funcprototype></funcsynopsis> 39241</refsynopsisdiv> 39242<refsect1> 39243 <title>Arguments</title> 39244 <variablelist> 39245 <varlistentry> 39246 <term><parameter>q</parameter></term> 39247 <listitem> 39248 <para> 39249 the request queue for the device 39250 </para> 39251 </listitem> 39252 </varlistentry> 39253 <varlistentry> 39254 <term><parameter>max_addr</parameter></term> 39255 <listitem> 39256 <para> 39257 the maximum address the device can handle 39258 </para> 39259 </listitem> 39260 </varlistentry> 39261 </variablelist> 39262</refsect1> 39263<refsect1> 39264<title>Description</title> 39265<para> 39266 Different hardware can have different requirements as to what pages 39267 it can do I/O directly to. A low level driver can call 39268 blk_queue_bounce_limit to have lower memory pages allocated as bounce 39269 buffers for doing I/O to pages residing above <parameter>max_addr</parameter>. 39270</para> 39271</refsect1> 39272</refentry> 39273 39274<refentry id="API-blk-limits-max-hw-sectors"> 39275<refentryinfo> 39276 <title>LINUX</title> 39277 <productname>Kernel Hackers Manual</productname> 39278 <date>July 2017</date> 39279</refentryinfo> 39280<refmeta> 39281 <refentrytitle><phrase>blk_limits_max_hw_sectors</phrase></refentrytitle> 39282 <manvolnum>9</manvolnum> 39283 <refmiscinfo class="version">4.1.27</refmiscinfo> 39284</refmeta> 39285<refnamediv> 39286 <refname>blk_limits_max_hw_sectors</refname> 39287 <refpurpose> 39288 set hard and soft limit of max sectors for request 39289 </refpurpose> 39290</refnamediv> 39291<refsynopsisdiv> 39292 <title>Synopsis</title> 39293 <funcsynopsis><funcprototype> 39294 <funcdef>void <function>blk_limits_max_hw_sectors </function></funcdef> 39295 <paramdef>struct queue_limits * <parameter>limits</parameter></paramdef> 39296 <paramdef>unsigned int <parameter>max_hw_sectors</parameter></paramdef> 39297 </funcprototype></funcsynopsis> 39298</refsynopsisdiv> 39299<refsect1> 39300 <title>Arguments</title> 39301 <variablelist> 39302 <varlistentry> 39303 <term><parameter>limits</parameter></term> 39304 <listitem> 39305 <para> 39306 the queue limits 39307 </para> 39308 </listitem> 39309 </varlistentry> 39310 <varlistentry> 39311 <term><parameter>max_hw_sectors</parameter></term> 39312 <listitem> 39313 <para> 39314 max hardware sectors in the usual 512b unit 39315 </para> 39316 </listitem> 39317 </varlistentry> 39318 </variablelist> 39319</refsect1> 39320<refsect1> 39321<title>Description</title> 39322<para> 39323 Enables a low level driver to set a hard upper limit, 39324 max_hw_sectors, on the size of requests. max_hw_sectors is set by 39325 the device driver based upon the capabilities of the I/O 39326 controller. 39327 </para><para> 39328 39329 max_sectors is a soft limit imposed by the block layer for 39330 filesystem type requests. This value can be overridden on a 39331 per-device basis in /sys/block/<device>/queue/max_sectors_kb. 39332 The soft limit can not exceed max_hw_sectors. 39333</para> 39334</refsect1> 39335</refentry> 39336 39337<refentry id="API-blk-queue-max-hw-sectors"> 39338<refentryinfo> 39339 <title>LINUX</title> 39340 <productname>Kernel Hackers Manual</productname> 39341 <date>July 2017</date> 39342</refentryinfo> 39343<refmeta> 39344 <refentrytitle><phrase>blk_queue_max_hw_sectors</phrase></refentrytitle> 39345 <manvolnum>9</manvolnum> 39346 <refmiscinfo class="version">4.1.27</refmiscinfo> 39347</refmeta> 39348<refnamediv> 39349 <refname>blk_queue_max_hw_sectors</refname> 39350 <refpurpose> 39351 set max sectors for a request for this queue 39352 </refpurpose> 39353</refnamediv> 39354<refsynopsisdiv> 39355 <title>Synopsis</title> 39356 <funcsynopsis><funcprototype> 39357 <funcdef>void <function>blk_queue_max_hw_sectors </function></funcdef> 39358 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 39359 <paramdef>unsigned int <parameter>max_hw_sectors</parameter></paramdef> 39360 </funcprototype></funcsynopsis> 39361</refsynopsisdiv> 39362<refsect1> 39363 <title>Arguments</title> 39364 <variablelist> 39365 <varlistentry> 39366 <term><parameter>q</parameter></term> 39367 <listitem> 39368 <para> 39369 the request queue for the device 39370 </para> 39371 </listitem> 39372 </varlistentry> 39373 <varlistentry> 39374 <term><parameter>max_hw_sectors</parameter></term> 39375 <listitem> 39376 <para> 39377 max hardware sectors in the usual 512b unit 39378 </para> 39379 </listitem> 39380 </varlistentry> 39381 </variablelist> 39382</refsect1> 39383<refsect1> 39384<title>Description</title> 39385<para> 39386 See description for <function>blk_limits_max_hw_sectors</function>. 39387</para> 39388</refsect1> 39389</refentry> 39390 39391<refentry id="API-blk-queue-chunk-sectors"> 39392<refentryinfo> 39393 <title>LINUX</title> 39394 <productname>Kernel Hackers Manual</productname> 39395 <date>July 2017</date> 39396</refentryinfo> 39397<refmeta> 39398 <refentrytitle><phrase>blk_queue_chunk_sectors</phrase></refentrytitle> 39399 <manvolnum>9</manvolnum> 39400 <refmiscinfo class="version">4.1.27</refmiscinfo> 39401</refmeta> 39402<refnamediv> 39403 <refname>blk_queue_chunk_sectors</refname> 39404 <refpurpose> 39405 set size of the chunk for this queue 39406 </refpurpose> 39407</refnamediv> 39408<refsynopsisdiv> 39409 <title>Synopsis</title> 39410 <funcsynopsis><funcprototype> 39411 <funcdef>void <function>blk_queue_chunk_sectors </function></funcdef> 39412 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 39413 <paramdef>unsigned int <parameter>chunk_sectors</parameter></paramdef> 39414 </funcprototype></funcsynopsis> 39415</refsynopsisdiv> 39416<refsect1> 39417 <title>Arguments</title> 39418 <variablelist> 39419 <varlistentry> 39420 <term><parameter>q</parameter></term> 39421 <listitem> 39422 <para> 39423 the request queue for the device 39424 </para> 39425 </listitem> 39426 </varlistentry> 39427 <varlistentry> 39428 <term><parameter>chunk_sectors</parameter></term> 39429 <listitem> 39430 <para> 39431 chunk sectors in the usual 512b unit 39432 </para> 39433 </listitem> 39434 </varlistentry> 39435 </variablelist> 39436</refsect1> 39437<refsect1> 39438<title>Description</title> 39439<para> 39440 If a driver doesn't want IOs to cross a given chunk size, it can set 39441 this limit and prevent merging across chunks. Note that the chunk size 39442 must currently be a power-of-2 in sectors. Also note that the block 39443 layer must accept a page worth of data at any offset. So if the 39444 crossing of chunks is a hard limitation in the driver, it must still be 39445 prepared to split single page bios. 39446</para> 39447</refsect1> 39448</refentry> 39449 39450<refentry id="API-blk-queue-max-discard-sectors"> 39451<refentryinfo> 39452 <title>LINUX</title> 39453 <productname>Kernel Hackers Manual</productname> 39454 <date>July 2017</date> 39455</refentryinfo> 39456<refmeta> 39457 <refentrytitle><phrase>blk_queue_max_discard_sectors</phrase></refentrytitle> 39458 <manvolnum>9</manvolnum> 39459 <refmiscinfo class="version">4.1.27</refmiscinfo> 39460</refmeta> 39461<refnamediv> 39462 <refname>blk_queue_max_discard_sectors</refname> 39463 <refpurpose> 39464 set max sectors for a single discard 39465 </refpurpose> 39466</refnamediv> 39467<refsynopsisdiv> 39468 <title>Synopsis</title> 39469 <funcsynopsis><funcprototype> 39470 <funcdef>void <function>blk_queue_max_discard_sectors </function></funcdef> 39471 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 39472 <paramdef>unsigned int <parameter>max_discard_sectors</parameter></paramdef> 39473 </funcprototype></funcsynopsis> 39474</refsynopsisdiv> 39475<refsect1> 39476 <title>Arguments</title> 39477 <variablelist> 39478 <varlistentry> 39479 <term><parameter>q</parameter></term> 39480 <listitem> 39481 <para> 39482 the request queue for the device 39483 </para> 39484 </listitem> 39485 </varlistentry> 39486 <varlistentry> 39487 <term><parameter>max_discard_sectors</parameter></term> 39488 <listitem> 39489 <para> 39490 maximum number of sectors to discard 39491 </para> 39492 </listitem> 39493 </varlistentry> 39494 </variablelist> 39495</refsect1> 39496</refentry> 39497 39498<refentry id="API-blk-queue-max-write-same-sectors"> 39499<refentryinfo> 39500 <title>LINUX</title> 39501 <productname>Kernel Hackers Manual</productname> 39502 <date>July 2017</date> 39503</refentryinfo> 39504<refmeta> 39505 <refentrytitle><phrase>blk_queue_max_write_same_sectors</phrase></refentrytitle> 39506 <manvolnum>9</manvolnum> 39507 <refmiscinfo class="version">4.1.27</refmiscinfo> 39508</refmeta> 39509<refnamediv> 39510 <refname>blk_queue_max_write_same_sectors</refname> 39511 <refpurpose> 39512 set max sectors for a single write same 39513 </refpurpose> 39514</refnamediv> 39515<refsynopsisdiv> 39516 <title>Synopsis</title> 39517 <funcsynopsis><funcprototype> 39518 <funcdef>void <function>blk_queue_max_write_same_sectors </function></funcdef> 39519 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 39520 <paramdef>unsigned int <parameter>max_write_same_sectors</parameter></paramdef> 39521 </funcprototype></funcsynopsis> 39522</refsynopsisdiv> 39523<refsect1> 39524 <title>Arguments</title> 39525 <variablelist> 39526 <varlistentry> 39527 <term><parameter>q</parameter></term> 39528 <listitem> 39529 <para> 39530 the request queue for the device 39531 </para> 39532 </listitem> 39533 </varlistentry> 39534 <varlistentry> 39535 <term><parameter>max_write_same_sectors</parameter></term> 39536 <listitem> 39537 <para> 39538 maximum number of sectors to write per command 39539 </para> 39540 </listitem> 39541 </varlistentry> 39542 </variablelist> 39543</refsect1> 39544</refentry> 39545 39546<refentry id="API-blk-queue-max-segments"> 39547<refentryinfo> 39548 <title>LINUX</title> 39549 <productname>Kernel Hackers Manual</productname> 39550 <date>July 2017</date> 39551</refentryinfo> 39552<refmeta> 39553 <refentrytitle><phrase>blk_queue_max_segments</phrase></refentrytitle> 39554 <manvolnum>9</manvolnum> 39555 <refmiscinfo class="version">4.1.27</refmiscinfo> 39556</refmeta> 39557<refnamediv> 39558 <refname>blk_queue_max_segments</refname> 39559 <refpurpose> 39560 set max hw segments for a request for this queue 39561 </refpurpose> 39562</refnamediv> 39563<refsynopsisdiv> 39564 <title>Synopsis</title> 39565 <funcsynopsis><funcprototype> 39566 <funcdef>void <function>blk_queue_max_segments </function></funcdef> 39567 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 39568 <paramdef>unsigned short <parameter>max_segments</parameter></paramdef> 39569 </funcprototype></funcsynopsis> 39570</refsynopsisdiv> 39571<refsect1> 39572 <title>Arguments</title> 39573 <variablelist> 39574 <varlistentry> 39575 <term><parameter>q</parameter></term> 39576 <listitem> 39577 <para> 39578 the request queue for the device 39579 </para> 39580 </listitem> 39581 </varlistentry> 39582 <varlistentry> 39583 <term><parameter>max_segments</parameter></term> 39584 <listitem> 39585 <para> 39586 max number of segments 39587 </para> 39588 </listitem> 39589 </varlistentry> 39590 </variablelist> 39591</refsect1> 39592<refsect1> 39593<title>Description</title> 39594<para> 39595 Enables a low level driver to set an upper limit on the number of 39596 hw data segments in a request. 39597</para> 39598</refsect1> 39599</refentry> 39600 39601<refentry id="API-blk-queue-max-segment-size"> 39602<refentryinfo> 39603 <title>LINUX</title> 39604 <productname>Kernel Hackers Manual</productname> 39605 <date>July 2017</date> 39606</refentryinfo> 39607<refmeta> 39608 <refentrytitle><phrase>blk_queue_max_segment_size</phrase></refentrytitle> 39609 <manvolnum>9</manvolnum> 39610 <refmiscinfo class="version">4.1.27</refmiscinfo> 39611</refmeta> 39612<refnamediv> 39613 <refname>blk_queue_max_segment_size</refname> 39614 <refpurpose> 39615 set max segment size for blk_rq_map_sg 39616 </refpurpose> 39617</refnamediv> 39618<refsynopsisdiv> 39619 <title>Synopsis</title> 39620 <funcsynopsis><funcprototype> 39621 <funcdef>void <function>blk_queue_max_segment_size </function></funcdef> 39622 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 39623 <paramdef>unsigned int <parameter>max_size</parameter></paramdef> 39624 </funcprototype></funcsynopsis> 39625</refsynopsisdiv> 39626<refsect1> 39627 <title>Arguments</title> 39628 <variablelist> 39629 <varlistentry> 39630 <term><parameter>q</parameter></term> 39631 <listitem> 39632 <para> 39633 the request queue for the device 39634 </para> 39635 </listitem> 39636 </varlistentry> 39637 <varlistentry> 39638 <term><parameter>max_size</parameter></term> 39639 <listitem> 39640 <para> 39641 max size of segment in bytes 39642 </para> 39643 </listitem> 39644 </varlistentry> 39645 </variablelist> 39646</refsect1> 39647<refsect1> 39648<title>Description</title> 39649<para> 39650 Enables a low level driver to set an upper limit on the size of a 39651 coalesced segment 39652</para> 39653</refsect1> 39654</refentry> 39655 39656<refentry id="API-blk-queue-logical-block-size"> 39657<refentryinfo> 39658 <title>LINUX</title> 39659 <productname>Kernel Hackers Manual</productname> 39660 <date>July 2017</date> 39661</refentryinfo> 39662<refmeta> 39663 <refentrytitle><phrase>blk_queue_logical_block_size</phrase></refentrytitle> 39664 <manvolnum>9</manvolnum> 39665 <refmiscinfo class="version">4.1.27</refmiscinfo> 39666</refmeta> 39667<refnamediv> 39668 <refname>blk_queue_logical_block_size</refname> 39669 <refpurpose> 39670 set logical block size for the queue 39671 </refpurpose> 39672</refnamediv> 39673<refsynopsisdiv> 39674 <title>Synopsis</title> 39675 <funcsynopsis><funcprototype> 39676 <funcdef>void <function>blk_queue_logical_block_size </function></funcdef> 39677 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 39678 <paramdef>unsigned short <parameter>size</parameter></paramdef> 39679 </funcprototype></funcsynopsis> 39680</refsynopsisdiv> 39681<refsect1> 39682 <title>Arguments</title> 39683 <variablelist> 39684 <varlistentry> 39685 <term><parameter>q</parameter></term> 39686 <listitem> 39687 <para> 39688 the request queue for the device 39689 </para> 39690 </listitem> 39691 </varlistentry> 39692 <varlistentry> 39693 <term><parameter>size</parameter></term> 39694 <listitem> 39695 <para> 39696 the logical block size, in bytes 39697 </para> 39698 </listitem> 39699 </varlistentry> 39700 </variablelist> 39701</refsect1> 39702<refsect1> 39703<title>Description</title> 39704<para> 39705 This should be set to the lowest possible block size that the 39706 storage device can address. The default of 512 covers most 39707 hardware. 39708</para> 39709</refsect1> 39710</refentry> 39711 39712<refentry id="API-blk-queue-physical-block-size"> 39713<refentryinfo> 39714 <title>LINUX</title> 39715 <productname>Kernel Hackers Manual</productname> 39716 <date>July 2017</date> 39717</refentryinfo> 39718<refmeta> 39719 <refentrytitle><phrase>blk_queue_physical_block_size</phrase></refentrytitle> 39720 <manvolnum>9</manvolnum> 39721 <refmiscinfo class="version">4.1.27</refmiscinfo> 39722</refmeta> 39723<refnamediv> 39724 <refname>blk_queue_physical_block_size</refname> 39725 <refpurpose> 39726 set physical block size for the queue 39727 </refpurpose> 39728</refnamediv> 39729<refsynopsisdiv> 39730 <title>Synopsis</title> 39731 <funcsynopsis><funcprototype> 39732 <funcdef>void <function>blk_queue_physical_block_size </function></funcdef> 39733 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 39734 <paramdef>unsigned int <parameter>size</parameter></paramdef> 39735 </funcprototype></funcsynopsis> 39736</refsynopsisdiv> 39737<refsect1> 39738 <title>Arguments</title> 39739 <variablelist> 39740 <varlistentry> 39741 <term><parameter>q</parameter></term> 39742 <listitem> 39743 <para> 39744 the request queue for the device 39745 </para> 39746 </listitem> 39747 </varlistentry> 39748 <varlistentry> 39749 <term><parameter>size</parameter></term> 39750 <listitem> 39751 <para> 39752 the physical block size, in bytes 39753 </para> 39754 </listitem> 39755 </varlistentry> 39756 </variablelist> 39757</refsect1> 39758<refsect1> 39759<title>Description</title> 39760<para> 39761 This should be set to the lowest possible sector size that the 39762 hardware can operate on without reverting to read-modify-write 39763 operations. 39764</para> 39765</refsect1> 39766</refentry> 39767 39768<refentry id="API-blk-queue-alignment-offset"> 39769<refentryinfo> 39770 <title>LINUX</title> 39771 <productname>Kernel Hackers Manual</productname> 39772 <date>July 2017</date> 39773</refentryinfo> 39774<refmeta> 39775 <refentrytitle><phrase>blk_queue_alignment_offset</phrase></refentrytitle> 39776 <manvolnum>9</manvolnum> 39777 <refmiscinfo class="version">4.1.27</refmiscinfo> 39778</refmeta> 39779<refnamediv> 39780 <refname>blk_queue_alignment_offset</refname> 39781 <refpurpose> 39782 set physical block alignment offset 39783 </refpurpose> 39784</refnamediv> 39785<refsynopsisdiv> 39786 <title>Synopsis</title> 39787 <funcsynopsis><funcprototype> 39788 <funcdef>void <function>blk_queue_alignment_offset </function></funcdef> 39789 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 39790 <paramdef>unsigned int <parameter>offset</parameter></paramdef> 39791 </funcprototype></funcsynopsis> 39792</refsynopsisdiv> 39793<refsect1> 39794 <title>Arguments</title> 39795 <variablelist> 39796 <varlistentry> 39797 <term><parameter>q</parameter></term> 39798 <listitem> 39799 <para> 39800 the request queue for the device 39801 </para> 39802 </listitem> 39803 </varlistentry> 39804 <varlistentry> 39805 <term><parameter>offset</parameter></term> 39806 <listitem> 39807 <para> 39808 alignment offset in bytes 39809 </para> 39810 </listitem> 39811 </varlistentry> 39812 </variablelist> 39813</refsect1> 39814<refsect1> 39815<title>Description</title> 39816<para> 39817 Some devices are naturally misaligned to compensate for things like 39818 the legacy DOS partition table 63-sector offset. Low-level drivers 39819 should call this function for devices whose first sector is not 39820 naturally aligned. 39821</para> 39822</refsect1> 39823</refentry> 39824 39825<refentry id="API-blk-limits-io-min"> 39826<refentryinfo> 39827 <title>LINUX</title> 39828 <productname>Kernel Hackers Manual</productname> 39829 <date>July 2017</date> 39830</refentryinfo> 39831<refmeta> 39832 <refentrytitle><phrase>blk_limits_io_min</phrase></refentrytitle> 39833 <manvolnum>9</manvolnum> 39834 <refmiscinfo class="version">4.1.27</refmiscinfo> 39835</refmeta> 39836<refnamediv> 39837 <refname>blk_limits_io_min</refname> 39838 <refpurpose> 39839 set minimum request size for a device 39840 </refpurpose> 39841</refnamediv> 39842<refsynopsisdiv> 39843 <title>Synopsis</title> 39844 <funcsynopsis><funcprototype> 39845 <funcdef>void <function>blk_limits_io_min </function></funcdef> 39846 <paramdef>struct queue_limits * <parameter>limits</parameter></paramdef> 39847 <paramdef>unsigned int <parameter>min</parameter></paramdef> 39848 </funcprototype></funcsynopsis> 39849</refsynopsisdiv> 39850<refsect1> 39851 <title>Arguments</title> 39852 <variablelist> 39853 <varlistentry> 39854 <term><parameter>limits</parameter></term> 39855 <listitem> 39856 <para> 39857 the queue limits 39858 </para> 39859 </listitem> 39860 </varlistentry> 39861 <varlistentry> 39862 <term><parameter>min</parameter></term> 39863 <listitem> 39864 <para> 39865 smallest I/O size in bytes 39866 </para> 39867 </listitem> 39868 </varlistentry> 39869 </variablelist> 39870</refsect1> 39871<refsect1> 39872<title>Description</title> 39873<para> 39874 Some devices have an internal block size bigger than the reported 39875 hardware sector size. This function can be used to signal the 39876 smallest I/O the device can perform without incurring a performance 39877 penalty. 39878</para> 39879</refsect1> 39880</refentry> 39881 39882<refentry id="API-blk-queue-io-min"> 39883<refentryinfo> 39884 <title>LINUX</title> 39885 <productname>Kernel Hackers Manual</productname> 39886 <date>July 2017</date> 39887</refentryinfo> 39888<refmeta> 39889 <refentrytitle><phrase>blk_queue_io_min</phrase></refentrytitle> 39890 <manvolnum>9</manvolnum> 39891 <refmiscinfo class="version">4.1.27</refmiscinfo> 39892</refmeta> 39893<refnamediv> 39894 <refname>blk_queue_io_min</refname> 39895 <refpurpose> 39896 set minimum request size for the queue 39897 </refpurpose> 39898</refnamediv> 39899<refsynopsisdiv> 39900 <title>Synopsis</title> 39901 <funcsynopsis><funcprototype> 39902 <funcdef>void <function>blk_queue_io_min </function></funcdef> 39903 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 39904 <paramdef>unsigned int <parameter>min</parameter></paramdef> 39905 </funcprototype></funcsynopsis> 39906</refsynopsisdiv> 39907<refsect1> 39908 <title>Arguments</title> 39909 <variablelist> 39910 <varlistentry> 39911 <term><parameter>q</parameter></term> 39912 <listitem> 39913 <para> 39914 the request queue for the device 39915 </para> 39916 </listitem> 39917 </varlistentry> 39918 <varlistentry> 39919 <term><parameter>min</parameter></term> 39920 <listitem> 39921 <para> 39922 smallest I/O size in bytes 39923 </para> 39924 </listitem> 39925 </varlistentry> 39926 </variablelist> 39927</refsect1> 39928<refsect1> 39929<title>Description</title> 39930<para> 39931 Storage devices may report a granularity or preferred minimum I/O 39932 size which is the smallest request the device can perform without 39933 incurring a performance penalty. For disk drives this is often the 39934 physical block size. For RAID arrays it is often the stripe chunk 39935 size. A properly aligned multiple of minimum_io_size is the 39936 preferred request size for workloads where a high number of I/O 39937 operations is desired. 39938</para> 39939</refsect1> 39940</refentry> 39941 39942<refentry id="API-blk-limits-io-opt"> 39943<refentryinfo> 39944 <title>LINUX</title> 39945 <productname>Kernel Hackers Manual</productname> 39946 <date>July 2017</date> 39947</refentryinfo> 39948<refmeta> 39949 <refentrytitle><phrase>blk_limits_io_opt</phrase></refentrytitle> 39950 <manvolnum>9</manvolnum> 39951 <refmiscinfo class="version">4.1.27</refmiscinfo> 39952</refmeta> 39953<refnamediv> 39954 <refname>blk_limits_io_opt</refname> 39955 <refpurpose> 39956 set optimal request size for a device 39957 </refpurpose> 39958</refnamediv> 39959<refsynopsisdiv> 39960 <title>Synopsis</title> 39961 <funcsynopsis><funcprototype> 39962 <funcdef>void <function>blk_limits_io_opt </function></funcdef> 39963 <paramdef>struct queue_limits * <parameter>limits</parameter></paramdef> 39964 <paramdef>unsigned int <parameter>opt</parameter></paramdef> 39965 </funcprototype></funcsynopsis> 39966</refsynopsisdiv> 39967<refsect1> 39968 <title>Arguments</title> 39969 <variablelist> 39970 <varlistentry> 39971 <term><parameter>limits</parameter></term> 39972 <listitem> 39973 <para> 39974 the queue limits 39975 </para> 39976 </listitem> 39977 </varlistentry> 39978 <varlistentry> 39979 <term><parameter>opt</parameter></term> 39980 <listitem> 39981 <para> 39982 smallest I/O size in bytes 39983 </para> 39984 </listitem> 39985 </varlistentry> 39986 </variablelist> 39987</refsect1> 39988<refsect1> 39989<title>Description</title> 39990<para> 39991 Storage devices may report an optimal I/O size, which is the 39992 device's preferred unit for sustained I/O. This is rarely reported 39993 for disk drives. For RAID arrays it is usually the stripe width or 39994 the internal track size. A properly aligned multiple of 39995 optimal_io_size is the preferred request size for workloads where 39996 sustained throughput is desired. 39997</para> 39998</refsect1> 39999</refentry> 40000 40001<refentry id="API-blk-queue-io-opt"> 40002<refentryinfo> 40003 <title>LINUX</title> 40004 <productname>Kernel Hackers Manual</productname> 40005 <date>July 2017</date> 40006</refentryinfo> 40007<refmeta> 40008 <refentrytitle><phrase>blk_queue_io_opt</phrase></refentrytitle> 40009 <manvolnum>9</manvolnum> 40010 <refmiscinfo class="version">4.1.27</refmiscinfo> 40011</refmeta> 40012<refnamediv> 40013 <refname>blk_queue_io_opt</refname> 40014 <refpurpose> 40015 set optimal request size for the queue 40016 </refpurpose> 40017</refnamediv> 40018<refsynopsisdiv> 40019 <title>Synopsis</title> 40020 <funcsynopsis><funcprototype> 40021 <funcdef>void <function>blk_queue_io_opt </function></funcdef> 40022 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 40023 <paramdef>unsigned int <parameter>opt</parameter></paramdef> 40024 </funcprototype></funcsynopsis> 40025</refsynopsisdiv> 40026<refsect1> 40027 <title>Arguments</title> 40028 <variablelist> 40029 <varlistentry> 40030 <term><parameter>q</parameter></term> 40031 <listitem> 40032 <para> 40033 the request queue for the device 40034 </para> 40035 </listitem> 40036 </varlistentry> 40037 <varlistentry> 40038 <term><parameter>opt</parameter></term> 40039 <listitem> 40040 <para> 40041 optimal request size in bytes 40042 </para> 40043 </listitem> 40044 </varlistentry> 40045 </variablelist> 40046</refsect1> 40047<refsect1> 40048<title>Description</title> 40049<para> 40050 Storage devices may report an optimal I/O size, which is the 40051 device's preferred unit for sustained I/O. This is rarely reported 40052 for disk drives. For RAID arrays it is usually the stripe width or 40053 the internal track size. A properly aligned multiple of 40054 optimal_io_size is the preferred request size for workloads where 40055 sustained throughput is desired. 40056</para> 40057</refsect1> 40058</refentry> 40059 40060<refentry id="API-blk-queue-stack-limits"> 40061<refentryinfo> 40062 <title>LINUX</title> 40063 <productname>Kernel Hackers Manual</productname> 40064 <date>July 2017</date> 40065</refentryinfo> 40066<refmeta> 40067 <refentrytitle><phrase>blk_queue_stack_limits</phrase></refentrytitle> 40068 <manvolnum>9</manvolnum> 40069 <refmiscinfo class="version">4.1.27</refmiscinfo> 40070</refmeta> 40071<refnamediv> 40072 <refname>blk_queue_stack_limits</refname> 40073 <refpurpose> 40074 inherit underlying queue limits for stacked drivers 40075 </refpurpose> 40076</refnamediv> 40077<refsynopsisdiv> 40078 <title>Synopsis</title> 40079 <funcsynopsis><funcprototype> 40080 <funcdef>void <function>blk_queue_stack_limits </function></funcdef> 40081 <paramdef>struct request_queue * <parameter>t</parameter></paramdef> 40082 <paramdef>struct request_queue * <parameter>b</parameter></paramdef> 40083 </funcprototype></funcsynopsis> 40084</refsynopsisdiv> 40085<refsect1> 40086 <title>Arguments</title> 40087 <variablelist> 40088 <varlistentry> 40089 <term><parameter>t</parameter></term> 40090 <listitem> 40091 <para> 40092 the stacking driver (top) 40093 </para> 40094 </listitem> 40095 </varlistentry> 40096 <varlistentry> 40097 <term><parameter>b</parameter></term> 40098 <listitem> 40099 <para> 40100 the underlying device (bottom) 40101 </para> 40102 </listitem> 40103 </varlistentry> 40104 </variablelist> 40105</refsect1> 40106</refentry> 40107 40108<refentry id="API-blk-stack-limits"> 40109<refentryinfo> 40110 <title>LINUX</title> 40111 <productname>Kernel Hackers Manual</productname> 40112 <date>July 2017</date> 40113</refentryinfo> 40114<refmeta> 40115 <refentrytitle><phrase>blk_stack_limits</phrase></refentrytitle> 40116 <manvolnum>9</manvolnum> 40117 <refmiscinfo class="version">4.1.27</refmiscinfo> 40118</refmeta> 40119<refnamediv> 40120 <refname>blk_stack_limits</refname> 40121 <refpurpose> 40122 adjust queue_limits for stacked devices 40123 </refpurpose> 40124</refnamediv> 40125<refsynopsisdiv> 40126 <title>Synopsis</title> 40127 <funcsynopsis><funcprototype> 40128 <funcdef>int <function>blk_stack_limits </function></funcdef> 40129 <paramdef>struct queue_limits * <parameter>t</parameter></paramdef> 40130 <paramdef>struct queue_limits * <parameter>b</parameter></paramdef> 40131 <paramdef>sector_t <parameter>start</parameter></paramdef> 40132 </funcprototype></funcsynopsis> 40133</refsynopsisdiv> 40134<refsect1> 40135 <title>Arguments</title> 40136 <variablelist> 40137 <varlistentry> 40138 <term><parameter>t</parameter></term> 40139 <listitem> 40140 <para> 40141 the stacking driver limits (top device) 40142 </para> 40143 </listitem> 40144 </varlistentry> 40145 <varlistentry> 40146 <term><parameter>b</parameter></term> 40147 <listitem> 40148 <para> 40149 the underlying queue limits (bottom, component device) 40150 </para> 40151 </listitem> 40152 </varlistentry> 40153 <varlistentry> 40154 <term><parameter>start</parameter></term> 40155 <listitem> 40156 <para> 40157 first data sector within component device 40158 </para> 40159 </listitem> 40160 </varlistentry> 40161 </variablelist> 40162</refsect1> 40163<refsect1> 40164<title>Description</title> 40165<para> 40166 This function is used by stacking drivers like MD and DM to ensure 40167 that all component devices have compatible block sizes and 40168 alignments. The stacking driver must provide a queue_limits 40169 struct (top) and then iteratively call the stacking function for 40170 all component (bottom) devices. The stacking function will 40171 attempt to combine the values and ensure proper alignment. 40172 </para><para> 40173 40174 Returns 0 if the top and bottom queue_limits are compatible. The 40175 top device's block sizes and alignment offsets may be adjusted to 40176 ensure alignment with the bottom device. If no compatible sizes 40177 and alignments exist, -1 is returned and the resulting top 40178 queue_limits will have the misaligned flag set to indicate that 40179 the alignment_offset is undefined. 40180</para> 40181</refsect1> 40182</refentry> 40183 40184<refentry id="API-bdev-stack-limits"> 40185<refentryinfo> 40186 <title>LINUX</title> 40187 <productname>Kernel Hackers Manual</productname> 40188 <date>July 2017</date> 40189</refentryinfo> 40190<refmeta> 40191 <refentrytitle><phrase>bdev_stack_limits</phrase></refentrytitle> 40192 <manvolnum>9</manvolnum> 40193 <refmiscinfo class="version">4.1.27</refmiscinfo> 40194</refmeta> 40195<refnamediv> 40196 <refname>bdev_stack_limits</refname> 40197 <refpurpose> 40198 adjust queue limits for stacked drivers 40199 </refpurpose> 40200</refnamediv> 40201<refsynopsisdiv> 40202 <title>Synopsis</title> 40203 <funcsynopsis><funcprototype> 40204 <funcdef>int <function>bdev_stack_limits </function></funcdef> 40205 <paramdef>struct queue_limits * <parameter>t</parameter></paramdef> 40206 <paramdef>struct block_device * <parameter>bdev</parameter></paramdef> 40207 <paramdef>sector_t <parameter>start</parameter></paramdef> 40208 </funcprototype></funcsynopsis> 40209</refsynopsisdiv> 40210<refsect1> 40211 <title>Arguments</title> 40212 <variablelist> 40213 <varlistentry> 40214 <term><parameter>t</parameter></term> 40215 <listitem> 40216 <para> 40217 the stacking driver limits (top device) 40218 </para> 40219 </listitem> 40220 </varlistentry> 40221 <varlistentry> 40222 <term><parameter>bdev</parameter></term> 40223 <listitem> 40224 <para> 40225 the component block_device (bottom) 40226 </para> 40227 </listitem> 40228 </varlistentry> 40229 <varlistentry> 40230 <term><parameter>start</parameter></term> 40231 <listitem> 40232 <para> 40233 first data sector within component device 40234 </para> 40235 </listitem> 40236 </varlistentry> 40237 </variablelist> 40238</refsect1> 40239<refsect1> 40240<title>Description</title> 40241<para> 40242 Merges queue limits for a top device and a block_device. Returns 40243 0 if alignment didn't change. Returns -1 if adding the bottom 40244 device caused misalignment. 40245</para> 40246</refsect1> 40247</refentry> 40248 40249<refentry id="API-disk-stack-limits"> 40250<refentryinfo> 40251 <title>LINUX</title> 40252 <productname>Kernel Hackers Manual</productname> 40253 <date>July 2017</date> 40254</refentryinfo> 40255<refmeta> 40256 <refentrytitle><phrase>disk_stack_limits</phrase></refentrytitle> 40257 <manvolnum>9</manvolnum> 40258 <refmiscinfo class="version">4.1.27</refmiscinfo> 40259</refmeta> 40260<refnamediv> 40261 <refname>disk_stack_limits</refname> 40262 <refpurpose> 40263 adjust queue limits for stacked drivers 40264 </refpurpose> 40265</refnamediv> 40266<refsynopsisdiv> 40267 <title>Synopsis</title> 40268 <funcsynopsis><funcprototype> 40269 <funcdef>void <function>disk_stack_limits </function></funcdef> 40270 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 40271 <paramdef>struct block_device * <parameter>bdev</parameter></paramdef> 40272 <paramdef>sector_t <parameter>offset</parameter></paramdef> 40273 </funcprototype></funcsynopsis> 40274</refsynopsisdiv> 40275<refsect1> 40276 <title>Arguments</title> 40277 <variablelist> 40278 <varlistentry> 40279 <term><parameter>disk</parameter></term> 40280 <listitem> 40281 <para> 40282 MD/DM gendisk (top) 40283 </para> 40284 </listitem> 40285 </varlistentry> 40286 <varlistentry> 40287 <term><parameter>bdev</parameter></term> 40288 <listitem> 40289 <para> 40290 the underlying block device (bottom) 40291 </para> 40292 </listitem> 40293 </varlistentry> 40294 <varlistentry> 40295 <term><parameter>offset</parameter></term> 40296 <listitem> 40297 <para> 40298 offset to beginning of data within component device 40299 </para> 40300 </listitem> 40301 </varlistentry> 40302 </variablelist> 40303</refsect1> 40304<refsect1> 40305<title>Description</title> 40306<para> 40307 Merges the limits for a top level gendisk and a bottom level 40308 block_device. 40309</para> 40310</refsect1> 40311</refentry> 40312 40313<refentry id="API-blk-queue-dma-pad"> 40314<refentryinfo> 40315 <title>LINUX</title> 40316 <productname>Kernel Hackers Manual</productname> 40317 <date>July 2017</date> 40318</refentryinfo> 40319<refmeta> 40320 <refentrytitle><phrase>blk_queue_dma_pad</phrase></refentrytitle> 40321 <manvolnum>9</manvolnum> 40322 <refmiscinfo class="version">4.1.27</refmiscinfo> 40323</refmeta> 40324<refnamediv> 40325 <refname>blk_queue_dma_pad</refname> 40326 <refpurpose> 40327 set pad mask 40328 </refpurpose> 40329</refnamediv> 40330<refsynopsisdiv> 40331 <title>Synopsis</title> 40332 <funcsynopsis><funcprototype> 40333 <funcdef>void <function>blk_queue_dma_pad </function></funcdef> 40334 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 40335 <paramdef>unsigned int <parameter>mask</parameter></paramdef> 40336 </funcprototype></funcsynopsis> 40337</refsynopsisdiv> 40338<refsect1> 40339 <title>Arguments</title> 40340 <variablelist> 40341 <varlistentry> 40342 <term><parameter>q</parameter></term> 40343 <listitem> 40344 <para> 40345 the request queue for the device 40346 </para> 40347 </listitem> 40348 </varlistentry> 40349 <varlistentry> 40350 <term><parameter>mask</parameter></term> 40351 <listitem> 40352 <para> 40353 pad mask 40354 </para> 40355 </listitem> 40356 </varlistentry> 40357 </variablelist> 40358</refsect1> 40359<refsect1> 40360<title>Description</title> 40361<para> 40362 Set dma pad mask. 40363 </para><para> 40364 40365 Appending pad buffer to a request modifies the last entry of a 40366 scatter list such that it includes the pad buffer. 40367</para> 40368</refsect1> 40369</refentry> 40370 40371<refentry id="API-blk-queue-update-dma-pad"> 40372<refentryinfo> 40373 <title>LINUX</title> 40374 <productname>Kernel Hackers Manual</productname> 40375 <date>July 2017</date> 40376</refentryinfo> 40377<refmeta> 40378 <refentrytitle><phrase>blk_queue_update_dma_pad</phrase></refentrytitle> 40379 <manvolnum>9</manvolnum> 40380 <refmiscinfo class="version">4.1.27</refmiscinfo> 40381</refmeta> 40382<refnamediv> 40383 <refname>blk_queue_update_dma_pad</refname> 40384 <refpurpose> 40385 update pad mask 40386 </refpurpose> 40387</refnamediv> 40388<refsynopsisdiv> 40389 <title>Synopsis</title> 40390 <funcsynopsis><funcprototype> 40391 <funcdef>void <function>blk_queue_update_dma_pad </function></funcdef> 40392 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 40393 <paramdef>unsigned int <parameter>mask</parameter></paramdef> 40394 </funcprototype></funcsynopsis> 40395</refsynopsisdiv> 40396<refsect1> 40397 <title>Arguments</title> 40398 <variablelist> 40399 <varlistentry> 40400 <term><parameter>q</parameter></term> 40401 <listitem> 40402 <para> 40403 the request queue for the device 40404 </para> 40405 </listitem> 40406 </varlistentry> 40407 <varlistentry> 40408 <term><parameter>mask</parameter></term> 40409 <listitem> 40410 <para> 40411 pad mask 40412 </para> 40413 </listitem> 40414 </varlistentry> 40415 </variablelist> 40416</refsect1> 40417<refsect1> 40418<title>Description</title> 40419<para> 40420 Update dma pad mask. 40421 </para><para> 40422 40423 Appending pad buffer to a request modifies the last entry of a 40424 scatter list such that it includes the pad buffer. 40425</para> 40426</refsect1> 40427</refentry> 40428 40429<refentry id="API-blk-queue-dma-drain"> 40430<refentryinfo> 40431 <title>LINUX</title> 40432 <productname>Kernel Hackers Manual</productname> 40433 <date>July 2017</date> 40434</refentryinfo> 40435<refmeta> 40436 <refentrytitle><phrase>blk_queue_dma_drain</phrase></refentrytitle> 40437 <manvolnum>9</manvolnum> 40438 <refmiscinfo class="version">4.1.27</refmiscinfo> 40439</refmeta> 40440<refnamediv> 40441 <refname>blk_queue_dma_drain</refname> 40442 <refpurpose> 40443 Set up a drain buffer for excess dma. 40444 </refpurpose> 40445</refnamediv> 40446<refsynopsisdiv> 40447 <title>Synopsis</title> 40448 <funcsynopsis><funcprototype> 40449 <funcdef>int <function>blk_queue_dma_drain </function></funcdef> 40450 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 40451 <paramdef>dma_drain_needed_fn * <parameter>dma_drain_needed</parameter></paramdef> 40452 <paramdef>void * <parameter>buf</parameter></paramdef> 40453 <paramdef>unsigned int <parameter>size</parameter></paramdef> 40454 </funcprototype></funcsynopsis> 40455</refsynopsisdiv> 40456<refsect1> 40457 <title>Arguments</title> 40458 <variablelist> 40459 <varlistentry> 40460 <term><parameter>q</parameter></term> 40461 <listitem> 40462 <para> 40463 the request queue for the device 40464 </para> 40465 </listitem> 40466 </varlistentry> 40467 <varlistentry> 40468 <term><parameter>dma_drain_needed</parameter></term> 40469 <listitem> 40470 <para> 40471 fn which returns non-zero if drain is necessary 40472 </para> 40473 </listitem> 40474 </varlistentry> 40475 <varlistentry> 40476 <term><parameter>buf</parameter></term> 40477 <listitem> 40478 <para> 40479 physically contiguous buffer 40480 </para> 40481 </listitem> 40482 </varlistentry> 40483 <varlistentry> 40484 <term><parameter>size</parameter></term> 40485 <listitem> 40486 <para> 40487 size of the buffer in bytes 40488 </para> 40489 </listitem> 40490 </varlistentry> 40491 </variablelist> 40492</refsect1> 40493<refsect1> 40494<title>Description</title> 40495<para> 40496 Some devices have excess DMA problems and can't simply discard (or 40497 zero fill) the unwanted piece of the transfer. They have to have a 40498 real area of memory to transfer it into. The use case for this is 40499 ATAPI devices in DMA mode. If the packet command causes a transfer 40500 bigger than the transfer size some HBAs will lock up if there 40501 aren't DMA elements to contain the excess transfer. What this API 40502 does is adjust the queue so that the buf is always appended 40503 silently to the scatterlist. 40504</para> 40505</refsect1> 40506<refsect1> 40507<title>Note</title> 40508<para> 40509 This routine adjusts max_hw_segments to make room for appending 40510 the drain buffer. If you call <function>blk_queue_max_segments</function> after calling 40511 this routine, you must set the limit to one fewer than your device 40512 can support otherwise there won't be room for the drain buffer. 40513</para> 40514</refsect1> 40515</refentry> 40516 40517<refentry id="API-blk-queue-segment-boundary"> 40518<refentryinfo> 40519 <title>LINUX</title> 40520 <productname>Kernel Hackers Manual</productname> 40521 <date>July 2017</date> 40522</refentryinfo> 40523<refmeta> 40524 <refentrytitle><phrase>blk_queue_segment_boundary</phrase></refentrytitle> 40525 <manvolnum>9</manvolnum> 40526 <refmiscinfo class="version">4.1.27</refmiscinfo> 40527</refmeta> 40528<refnamediv> 40529 <refname>blk_queue_segment_boundary</refname> 40530 <refpurpose> 40531 set boundary rules for segment merging 40532 </refpurpose> 40533</refnamediv> 40534<refsynopsisdiv> 40535 <title>Synopsis</title> 40536 <funcsynopsis><funcprototype> 40537 <funcdef>void <function>blk_queue_segment_boundary </function></funcdef> 40538 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 40539 <paramdef>unsigned long <parameter>mask</parameter></paramdef> 40540 </funcprototype></funcsynopsis> 40541</refsynopsisdiv> 40542<refsect1> 40543 <title>Arguments</title> 40544 <variablelist> 40545 <varlistentry> 40546 <term><parameter>q</parameter></term> 40547 <listitem> 40548 <para> 40549 the request queue for the device 40550 </para> 40551 </listitem> 40552 </varlistentry> 40553 <varlistentry> 40554 <term><parameter>mask</parameter></term> 40555 <listitem> 40556 <para> 40557 the memory boundary mask 40558 </para> 40559 </listitem> 40560 </varlistentry> 40561 </variablelist> 40562</refsect1> 40563</refentry> 40564 40565<refentry id="API-blk-queue-dma-alignment"> 40566<refentryinfo> 40567 <title>LINUX</title> 40568 <productname>Kernel Hackers Manual</productname> 40569 <date>July 2017</date> 40570</refentryinfo> 40571<refmeta> 40572 <refentrytitle><phrase>blk_queue_dma_alignment</phrase></refentrytitle> 40573 <manvolnum>9</manvolnum> 40574 <refmiscinfo class="version">4.1.27</refmiscinfo> 40575</refmeta> 40576<refnamediv> 40577 <refname>blk_queue_dma_alignment</refname> 40578 <refpurpose> 40579 set dma length and memory alignment 40580 </refpurpose> 40581</refnamediv> 40582<refsynopsisdiv> 40583 <title>Synopsis</title> 40584 <funcsynopsis><funcprototype> 40585 <funcdef>void <function>blk_queue_dma_alignment </function></funcdef> 40586 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 40587 <paramdef>int <parameter>mask</parameter></paramdef> 40588 </funcprototype></funcsynopsis> 40589</refsynopsisdiv> 40590<refsect1> 40591 <title>Arguments</title> 40592 <variablelist> 40593 <varlistentry> 40594 <term><parameter>q</parameter></term> 40595 <listitem> 40596 <para> 40597 the request queue for the device 40598 </para> 40599 </listitem> 40600 </varlistentry> 40601 <varlistentry> 40602 <term><parameter>mask</parameter></term> 40603 <listitem> 40604 <para> 40605 alignment mask 40606 </para> 40607 </listitem> 40608 </varlistentry> 40609 </variablelist> 40610</refsect1> 40611<refsect1> 40612<title>description</title> 40613<para> 40614 set required memory and length alignment for direct dma transactions. 40615 this is used when building direct io requests for the queue. 40616</para> 40617</refsect1> 40618</refentry> 40619 40620<refentry id="API-blk-queue-update-dma-alignment"> 40621<refentryinfo> 40622 <title>LINUX</title> 40623 <productname>Kernel Hackers Manual</productname> 40624 <date>July 2017</date> 40625</refentryinfo> 40626<refmeta> 40627 <refentrytitle><phrase>blk_queue_update_dma_alignment</phrase></refentrytitle> 40628 <manvolnum>9</manvolnum> 40629 <refmiscinfo class="version">4.1.27</refmiscinfo> 40630</refmeta> 40631<refnamediv> 40632 <refname>blk_queue_update_dma_alignment</refname> 40633 <refpurpose> 40634 update dma length and memory alignment 40635 </refpurpose> 40636</refnamediv> 40637<refsynopsisdiv> 40638 <title>Synopsis</title> 40639 <funcsynopsis><funcprototype> 40640 <funcdef>void <function>blk_queue_update_dma_alignment </function></funcdef> 40641 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 40642 <paramdef>int <parameter>mask</parameter></paramdef> 40643 </funcprototype></funcsynopsis> 40644</refsynopsisdiv> 40645<refsect1> 40646 <title>Arguments</title> 40647 <variablelist> 40648 <varlistentry> 40649 <term><parameter>q</parameter></term> 40650 <listitem> 40651 <para> 40652 the request queue for the device 40653 </para> 40654 </listitem> 40655 </varlistentry> 40656 <varlistentry> 40657 <term><parameter>mask</parameter></term> 40658 <listitem> 40659 <para> 40660 alignment mask 40661 </para> 40662 </listitem> 40663 </varlistentry> 40664 </variablelist> 40665</refsect1> 40666<refsect1> 40667<title>description</title> 40668<para> 40669 update required memory and length alignment for direct dma transactions. 40670 If the requested alignment is larger than the current alignment, then 40671 the current queue alignment is updated to the new value, otherwise it 40672 is left alone. The design of this is to allow multiple objects 40673 (driver, device, transport etc) to set their respective 40674 alignments without having them interfere. 40675</para> 40676</refsect1> 40677</refentry> 40678 40679<refentry id="API-blk-queue-flush"> 40680<refentryinfo> 40681 <title>LINUX</title> 40682 <productname>Kernel Hackers Manual</productname> 40683 <date>July 2017</date> 40684</refentryinfo> 40685<refmeta> 40686 <refentrytitle><phrase>blk_queue_flush</phrase></refentrytitle> 40687 <manvolnum>9</manvolnum> 40688 <refmiscinfo class="version">4.1.27</refmiscinfo> 40689</refmeta> 40690<refnamediv> 40691 <refname>blk_queue_flush</refname> 40692 <refpurpose> 40693 configure queue's cache flush capability 40694 </refpurpose> 40695</refnamediv> 40696<refsynopsisdiv> 40697 <title>Synopsis</title> 40698 <funcsynopsis><funcprototype> 40699 <funcdef>void <function>blk_queue_flush </function></funcdef> 40700 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 40701 <paramdef>unsigned int <parameter>flush</parameter></paramdef> 40702 </funcprototype></funcsynopsis> 40703</refsynopsisdiv> 40704<refsect1> 40705 <title>Arguments</title> 40706 <variablelist> 40707 <varlistentry> 40708 <term><parameter>q</parameter></term> 40709 <listitem> 40710 <para> 40711 the request queue for the device 40712 </para> 40713 </listitem> 40714 </varlistentry> 40715 <varlistentry> 40716 <term><parameter>flush</parameter></term> 40717 <listitem> 40718 <para> 40719 0, REQ_FLUSH or REQ_FLUSH | REQ_FUA 40720 </para> 40721 </listitem> 40722 </varlistentry> 40723 </variablelist> 40724</refsect1> 40725<refsect1> 40726<title>Description</title> 40727<para> 40728 Tell block layer cache flush capability of <parameter>q</parameter>. If it supports 40729 flushing, REQ_FLUSH should be set. If it supports bypassing 40730 write cache for individual writes, REQ_FUA should be set. 40731</para> 40732</refsect1> 40733</refentry> 40734 40735<!-- block/blk-exec.c --> 40736<refentry id="API-blk-execute-rq-nowait"> 40737<refentryinfo> 40738 <title>LINUX</title> 40739 <productname>Kernel Hackers Manual</productname> 40740 <date>July 2017</date> 40741</refentryinfo> 40742<refmeta> 40743 <refentrytitle><phrase>blk_execute_rq_nowait</phrase></refentrytitle> 40744 <manvolnum>9</manvolnum> 40745 <refmiscinfo class="version">4.1.27</refmiscinfo> 40746</refmeta> 40747<refnamediv> 40748 <refname>blk_execute_rq_nowait</refname> 40749 <refpurpose> 40750 insert a request into queue for execution 40751 </refpurpose> 40752</refnamediv> 40753<refsynopsisdiv> 40754 <title>Synopsis</title> 40755 <funcsynopsis><funcprototype> 40756 <funcdef>void <function>blk_execute_rq_nowait </function></funcdef> 40757 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 40758 <paramdef>struct gendisk * <parameter>bd_disk</parameter></paramdef> 40759 <paramdef>struct request * <parameter>rq</parameter></paramdef> 40760 <paramdef>int <parameter>at_head</parameter></paramdef> 40761 <paramdef>rq_end_io_fn * <parameter>done</parameter></paramdef> 40762 </funcprototype></funcsynopsis> 40763</refsynopsisdiv> 40764<refsect1> 40765 <title>Arguments</title> 40766 <variablelist> 40767 <varlistentry> 40768 <term><parameter>q</parameter></term> 40769 <listitem> 40770 <para> 40771 queue to insert the request in 40772 </para> 40773 </listitem> 40774 </varlistentry> 40775 <varlistentry> 40776 <term><parameter>bd_disk</parameter></term> 40777 <listitem> 40778 <para> 40779 matching gendisk 40780 </para> 40781 </listitem> 40782 </varlistentry> 40783 <varlistentry> 40784 <term><parameter>rq</parameter></term> 40785 <listitem> 40786 <para> 40787 request to insert 40788 </para> 40789 </listitem> 40790 </varlistentry> 40791 <varlistentry> 40792 <term><parameter>at_head</parameter></term> 40793 <listitem> 40794 <para> 40795 insert request at head or tail of queue 40796 </para> 40797 </listitem> 40798 </varlistentry> 40799 <varlistentry> 40800 <term><parameter>done</parameter></term> 40801 <listitem> 40802 <para> 40803 I/O completion handler 40804 </para> 40805 </listitem> 40806 </varlistentry> 40807 </variablelist> 40808</refsect1> 40809<refsect1> 40810<title>Description</title> 40811<para> 40812 Insert a fully prepared request at the back of the I/O scheduler queue 40813 for execution. Don't wait for completion. 40814</para> 40815</refsect1> 40816<refsect1> 40817<title>Note</title> 40818<para> 40819 This function will invoke <parameter>done</parameter> directly if the queue is dead. 40820</para> 40821</refsect1> 40822</refentry> 40823 40824<refentry id="API-blk-execute-rq"> 40825<refentryinfo> 40826 <title>LINUX</title> 40827 <productname>Kernel Hackers Manual</productname> 40828 <date>July 2017</date> 40829</refentryinfo> 40830<refmeta> 40831 <refentrytitle><phrase>blk_execute_rq</phrase></refentrytitle> 40832 <manvolnum>9</manvolnum> 40833 <refmiscinfo class="version">4.1.27</refmiscinfo> 40834</refmeta> 40835<refnamediv> 40836 <refname>blk_execute_rq</refname> 40837 <refpurpose> 40838 insert a request into queue for execution 40839 </refpurpose> 40840</refnamediv> 40841<refsynopsisdiv> 40842 <title>Synopsis</title> 40843 <funcsynopsis><funcprototype> 40844 <funcdef>int <function>blk_execute_rq </function></funcdef> 40845 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 40846 <paramdef>struct gendisk * <parameter>bd_disk</parameter></paramdef> 40847 <paramdef>struct request * <parameter>rq</parameter></paramdef> 40848 <paramdef>int <parameter>at_head</parameter></paramdef> 40849 </funcprototype></funcsynopsis> 40850</refsynopsisdiv> 40851<refsect1> 40852 <title>Arguments</title> 40853 <variablelist> 40854 <varlistentry> 40855 <term><parameter>q</parameter></term> 40856 <listitem> 40857 <para> 40858 queue to insert the request in 40859 </para> 40860 </listitem> 40861 </varlistentry> 40862 <varlistentry> 40863 <term><parameter>bd_disk</parameter></term> 40864 <listitem> 40865 <para> 40866 matching gendisk 40867 </para> 40868 </listitem> 40869 </varlistentry> 40870 <varlistentry> 40871 <term><parameter>rq</parameter></term> 40872 <listitem> 40873 <para> 40874 request to insert 40875 </para> 40876 </listitem> 40877 </varlistentry> 40878 <varlistentry> 40879 <term><parameter>at_head</parameter></term> 40880 <listitem> 40881 <para> 40882 insert request at head or tail of queue 40883 </para> 40884 </listitem> 40885 </varlistentry> 40886 </variablelist> 40887</refsect1> 40888<refsect1> 40889<title>Description</title> 40890<para> 40891 Insert a fully prepared request at the back of the I/O scheduler queue 40892 for execution and wait for completion. 40893</para> 40894</refsect1> 40895</refentry> 40896 40897<!-- block/blk-flush.c --> 40898<refentry id="API-blkdev-issue-flush"> 40899<refentryinfo> 40900 <title>LINUX</title> 40901 <productname>Kernel Hackers Manual</productname> 40902 <date>July 2017</date> 40903</refentryinfo> 40904<refmeta> 40905 <refentrytitle><phrase>blkdev_issue_flush</phrase></refentrytitle> 40906 <manvolnum>9</manvolnum> 40907 <refmiscinfo class="version">4.1.27</refmiscinfo> 40908</refmeta> 40909<refnamediv> 40910 <refname>blkdev_issue_flush</refname> 40911 <refpurpose> 40912 queue a flush 40913 </refpurpose> 40914</refnamediv> 40915<refsynopsisdiv> 40916 <title>Synopsis</title> 40917 <funcsynopsis><funcprototype> 40918 <funcdef>int <function>blkdev_issue_flush </function></funcdef> 40919 <paramdef>struct block_device * <parameter>bdev</parameter></paramdef> 40920 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 40921 <paramdef>sector_t * <parameter>error_sector</parameter></paramdef> 40922 </funcprototype></funcsynopsis> 40923</refsynopsisdiv> 40924<refsect1> 40925 <title>Arguments</title> 40926 <variablelist> 40927 <varlistentry> 40928 <term><parameter>bdev</parameter></term> 40929 <listitem> 40930 <para> 40931 blockdev to issue flush for 40932 </para> 40933 </listitem> 40934 </varlistentry> 40935 <varlistentry> 40936 <term><parameter>gfp_mask</parameter></term> 40937 <listitem> 40938 <para> 40939 memory allocation flags (for bio_alloc) 40940 </para> 40941 </listitem> 40942 </varlistentry> 40943 <varlistentry> 40944 <term><parameter>error_sector</parameter></term> 40945 <listitem> 40946 <para> 40947 error sector 40948 </para> 40949 </listitem> 40950 </varlistentry> 40951 </variablelist> 40952</refsect1> 40953<refsect1> 40954<title>Description</title> 40955<para> 40956 Issue a flush for the block device in question. Caller can supply 40957 room for storing the error offset in case of a flush error, if they 40958 wish to. If WAIT flag is not passed then caller may check only what 40959 request was pushed in some internal queue for later handling. 40960</para> 40961</refsect1> 40962</refentry> 40963 40964<!-- block/blk-lib.c --> 40965<refentry id="API-blkdev-issue-discard"> 40966<refentryinfo> 40967 <title>LINUX</title> 40968 <productname>Kernel Hackers Manual</productname> 40969 <date>July 2017</date> 40970</refentryinfo> 40971<refmeta> 40972 <refentrytitle><phrase>blkdev_issue_discard</phrase></refentrytitle> 40973 <manvolnum>9</manvolnum> 40974 <refmiscinfo class="version">4.1.27</refmiscinfo> 40975</refmeta> 40976<refnamediv> 40977 <refname>blkdev_issue_discard</refname> 40978 <refpurpose> 40979 queue a discard 40980 </refpurpose> 40981</refnamediv> 40982<refsynopsisdiv> 40983 <title>Synopsis</title> 40984 <funcsynopsis><funcprototype> 40985 <funcdef>int <function>blkdev_issue_discard </function></funcdef> 40986 <paramdef>struct block_device * <parameter>bdev</parameter></paramdef> 40987 <paramdef>sector_t <parameter>sector</parameter></paramdef> 40988 <paramdef>sector_t <parameter>nr_sects</parameter></paramdef> 40989 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 40990 <paramdef>unsigned long <parameter>flags</parameter></paramdef> 40991 </funcprototype></funcsynopsis> 40992</refsynopsisdiv> 40993<refsect1> 40994 <title>Arguments</title> 40995 <variablelist> 40996 <varlistentry> 40997 <term><parameter>bdev</parameter></term> 40998 <listitem> 40999 <para> 41000 blockdev to issue discard for 41001 </para> 41002 </listitem> 41003 </varlistentry> 41004 <varlistentry> 41005 <term><parameter>sector</parameter></term> 41006 <listitem> 41007 <para> 41008 start sector 41009 </para> 41010 </listitem> 41011 </varlistentry> 41012 <varlistentry> 41013 <term><parameter>nr_sects</parameter></term> 41014 <listitem> 41015 <para> 41016 number of sectors to discard 41017 </para> 41018 </listitem> 41019 </varlistentry> 41020 <varlistentry> 41021 <term><parameter>gfp_mask</parameter></term> 41022 <listitem> 41023 <para> 41024 memory allocation flags (for bio_alloc) 41025 </para> 41026 </listitem> 41027 </varlistentry> 41028 <varlistentry> 41029 <term><parameter>flags</parameter></term> 41030 <listitem> 41031 <para> 41032 BLKDEV_IFL_* flags to control behaviour 41033 </para> 41034 </listitem> 41035 </varlistentry> 41036 </variablelist> 41037</refsect1> 41038<refsect1> 41039<title>Description</title> 41040<para> 41041 Issue a discard request for the sectors in question. 41042</para> 41043</refsect1> 41044</refentry> 41045 41046<refentry id="API-blkdev-issue-write-same"> 41047<refentryinfo> 41048 <title>LINUX</title> 41049 <productname>Kernel Hackers Manual</productname> 41050 <date>July 2017</date> 41051</refentryinfo> 41052<refmeta> 41053 <refentrytitle><phrase>blkdev_issue_write_same</phrase></refentrytitle> 41054 <manvolnum>9</manvolnum> 41055 <refmiscinfo class="version">4.1.27</refmiscinfo> 41056</refmeta> 41057<refnamediv> 41058 <refname>blkdev_issue_write_same</refname> 41059 <refpurpose> 41060 queue a write same operation 41061 </refpurpose> 41062</refnamediv> 41063<refsynopsisdiv> 41064 <title>Synopsis</title> 41065 <funcsynopsis><funcprototype> 41066 <funcdef>int <function>blkdev_issue_write_same </function></funcdef> 41067 <paramdef>struct block_device * <parameter>bdev</parameter></paramdef> 41068 <paramdef>sector_t <parameter>sector</parameter></paramdef> 41069 <paramdef>sector_t <parameter>nr_sects</parameter></paramdef> 41070 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 41071 <paramdef>struct page * <parameter>page</parameter></paramdef> 41072 </funcprototype></funcsynopsis> 41073</refsynopsisdiv> 41074<refsect1> 41075 <title>Arguments</title> 41076 <variablelist> 41077 <varlistentry> 41078 <term><parameter>bdev</parameter></term> 41079 <listitem> 41080 <para> 41081 target blockdev 41082 </para> 41083 </listitem> 41084 </varlistentry> 41085 <varlistentry> 41086 <term><parameter>sector</parameter></term> 41087 <listitem> 41088 <para> 41089 start sector 41090 </para> 41091 </listitem> 41092 </varlistentry> 41093 <varlistentry> 41094 <term><parameter>nr_sects</parameter></term> 41095 <listitem> 41096 <para> 41097 number of sectors to write 41098 </para> 41099 </listitem> 41100 </varlistentry> 41101 <varlistentry> 41102 <term><parameter>gfp_mask</parameter></term> 41103 <listitem> 41104 <para> 41105 memory allocation flags (for bio_alloc) 41106 </para> 41107 </listitem> 41108 </varlistentry> 41109 <varlistentry> 41110 <term><parameter>page</parameter></term> 41111 <listitem> 41112 <para> 41113 page containing data to write 41114 </para> 41115 </listitem> 41116 </varlistentry> 41117 </variablelist> 41118</refsect1> 41119<refsect1> 41120<title>Description</title> 41121<para> 41122 Issue a write same request for the sectors in question. 41123</para> 41124</refsect1> 41125</refentry> 41126 41127<refentry id="API-blkdev-issue-zeroout"> 41128<refentryinfo> 41129 <title>LINUX</title> 41130 <productname>Kernel Hackers Manual</productname> 41131 <date>July 2017</date> 41132</refentryinfo> 41133<refmeta> 41134 <refentrytitle><phrase>blkdev_issue_zeroout</phrase></refentrytitle> 41135 <manvolnum>9</manvolnum> 41136 <refmiscinfo class="version">4.1.27</refmiscinfo> 41137</refmeta> 41138<refnamediv> 41139 <refname>blkdev_issue_zeroout</refname> 41140 <refpurpose> 41141 zero-fill a block range 41142 </refpurpose> 41143</refnamediv> 41144<refsynopsisdiv> 41145 <title>Synopsis</title> 41146 <funcsynopsis><funcprototype> 41147 <funcdef>int <function>blkdev_issue_zeroout </function></funcdef> 41148 <paramdef>struct block_device * <parameter>bdev</parameter></paramdef> 41149 <paramdef>sector_t <parameter>sector</parameter></paramdef> 41150 <paramdef>sector_t <parameter>nr_sects</parameter></paramdef> 41151 <paramdef>gfp_t <parameter>gfp_mask</parameter></paramdef> 41152 <paramdef>bool <parameter>discard</parameter></paramdef> 41153 </funcprototype></funcsynopsis> 41154</refsynopsisdiv> 41155<refsect1> 41156 <title>Arguments</title> 41157 <variablelist> 41158 <varlistentry> 41159 <term><parameter>bdev</parameter></term> 41160 <listitem> 41161 <para> 41162 blockdev to write 41163 </para> 41164 </listitem> 41165 </varlistentry> 41166 <varlistentry> 41167 <term><parameter>sector</parameter></term> 41168 <listitem> 41169 <para> 41170 start sector 41171 </para> 41172 </listitem> 41173 </varlistentry> 41174 <varlistentry> 41175 <term><parameter>nr_sects</parameter></term> 41176 <listitem> 41177 <para> 41178 number of sectors to write 41179 </para> 41180 </listitem> 41181 </varlistentry> 41182 <varlistentry> 41183 <term><parameter>gfp_mask</parameter></term> 41184 <listitem> 41185 <para> 41186 memory allocation flags (for bio_alloc) 41187 </para> 41188 </listitem> 41189 </varlistentry> 41190 <varlistentry> 41191 <term><parameter>discard</parameter></term> 41192 <listitem> 41193 <para> 41194 whether to discard the block range 41195 </para> 41196 </listitem> 41197 </varlistentry> 41198 </variablelist> 41199</refsect1> 41200<refsect1> 41201<title>Description</title> 41202<para> 41203 Zero-fill a block range. If the discard flag is set and the block 41204 device guarantees that subsequent READ operations to the block range 41205 in question will return zeroes, the blocks will be discarded. Should 41206 the discard request fail, if the discard flag is not set, or if 41207 discard_zeroes_data is not supported, this function will resort to 41208 zeroing the blocks manually, thus provisioning (allocating, 41209 anchoring) them. If the block device supports the WRITE SAME command 41210 <function>blkdev_issue_zeroout</function> will use it to optimize the process of 41211 clearing the block range. Otherwise the zeroing will be performed 41212 using regular WRITE calls. 41213</para> 41214</refsect1> 41215</refentry> 41216 41217<!-- block/blk-tag.c --> 41218<refentry id="API-blk-queue-find-tag"> 41219<refentryinfo> 41220 <title>LINUX</title> 41221 <productname>Kernel Hackers Manual</productname> 41222 <date>July 2017</date> 41223</refentryinfo> 41224<refmeta> 41225 <refentrytitle><phrase>blk_queue_find_tag</phrase></refentrytitle> 41226 <manvolnum>9</manvolnum> 41227 <refmiscinfo class="version">4.1.27</refmiscinfo> 41228</refmeta> 41229<refnamediv> 41230 <refname>blk_queue_find_tag</refname> 41231 <refpurpose> 41232 find a request by its tag and queue 41233 </refpurpose> 41234</refnamediv> 41235<refsynopsisdiv> 41236 <title>Synopsis</title> 41237 <funcsynopsis><funcprototype> 41238 <funcdef>struct request * <function>blk_queue_find_tag </function></funcdef> 41239 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 41240 <paramdef>int <parameter>tag</parameter></paramdef> 41241 </funcprototype></funcsynopsis> 41242</refsynopsisdiv> 41243<refsect1> 41244 <title>Arguments</title> 41245 <variablelist> 41246 <varlistentry> 41247 <term><parameter>q</parameter></term> 41248 <listitem> 41249 <para> 41250 The request queue for the device 41251 </para> 41252 </listitem> 41253 </varlistentry> 41254 <varlistentry> 41255 <term><parameter>tag</parameter></term> 41256 <listitem> 41257 <para> 41258 The tag of the request 41259 </para> 41260 </listitem> 41261 </varlistentry> 41262 </variablelist> 41263</refsect1> 41264<refsect1> 41265<title>Notes</title> 41266<para> 41267 Should be used when a device returns a tag and you want to match 41268 it with a request. 41269 </para><para> 41270 41271 no locks need be held. 41272</para> 41273</refsect1> 41274</refentry> 41275 41276<refentry id="API-blk-free-tags"> 41277<refentryinfo> 41278 <title>LINUX</title> 41279 <productname>Kernel Hackers Manual</productname> 41280 <date>July 2017</date> 41281</refentryinfo> 41282<refmeta> 41283 <refentrytitle><phrase>blk_free_tags</phrase></refentrytitle> 41284 <manvolnum>9</manvolnum> 41285 <refmiscinfo class="version">4.1.27</refmiscinfo> 41286</refmeta> 41287<refnamediv> 41288 <refname>blk_free_tags</refname> 41289 <refpurpose> 41290 release a given set of tag maintenance info 41291 </refpurpose> 41292</refnamediv> 41293<refsynopsisdiv> 41294 <title>Synopsis</title> 41295 <funcsynopsis><funcprototype> 41296 <funcdef>void <function>blk_free_tags </function></funcdef> 41297 <paramdef>struct blk_queue_tag * <parameter>bqt</parameter></paramdef> 41298 </funcprototype></funcsynopsis> 41299</refsynopsisdiv> 41300<refsect1> 41301 <title>Arguments</title> 41302 <variablelist> 41303 <varlistentry> 41304 <term><parameter>bqt</parameter></term> 41305 <listitem> 41306 <para> 41307 the tag map to free 41308 </para> 41309 </listitem> 41310 </varlistentry> 41311 </variablelist> 41312</refsect1> 41313<refsect1> 41314<title>Description</title> 41315<para> 41316 Drop the reference count on <parameter>bqt</parameter> and frees it when the last reference 41317 is dropped. 41318</para> 41319</refsect1> 41320</refentry> 41321 41322<refentry id="API-blk-queue-free-tags"> 41323<refentryinfo> 41324 <title>LINUX</title> 41325 <productname>Kernel Hackers Manual</productname> 41326 <date>July 2017</date> 41327</refentryinfo> 41328<refmeta> 41329 <refentrytitle><phrase>blk_queue_free_tags</phrase></refentrytitle> 41330 <manvolnum>9</manvolnum> 41331 <refmiscinfo class="version">4.1.27</refmiscinfo> 41332</refmeta> 41333<refnamediv> 41334 <refname>blk_queue_free_tags</refname> 41335 <refpurpose> 41336 release tag maintenance info 41337 </refpurpose> 41338</refnamediv> 41339<refsynopsisdiv> 41340 <title>Synopsis</title> 41341 <funcsynopsis><funcprototype> 41342 <funcdef>void <function>blk_queue_free_tags </function></funcdef> 41343 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 41344 </funcprototype></funcsynopsis> 41345</refsynopsisdiv> 41346<refsect1> 41347 <title>Arguments</title> 41348 <variablelist> 41349 <varlistentry> 41350 <term><parameter>q</parameter></term> 41351 <listitem> 41352 <para> 41353 the request queue for the device 41354 </para> 41355 </listitem> 41356 </varlistentry> 41357 </variablelist> 41358</refsect1> 41359<refsect1> 41360<title>Notes</title> 41361<para> 41362 This is used to disable tagged queuing to a device, yet leave 41363 queue in function. 41364</para> 41365</refsect1> 41366</refentry> 41367 41368<refentry id="API-blk-init-tags"> 41369<refentryinfo> 41370 <title>LINUX</title> 41371 <productname>Kernel Hackers Manual</productname> 41372 <date>July 2017</date> 41373</refentryinfo> 41374<refmeta> 41375 <refentrytitle><phrase>blk_init_tags</phrase></refentrytitle> 41376 <manvolnum>9</manvolnum> 41377 <refmiscinfo class="version">4.1.27</refmiscinfo> 41378</refmeta> 41379<refnamediv> 41380 <refname>blk_init_tags</refname> 41381 <refpurpose> 41382 initialize the tag info for an external tag map 41383 </refpurpose> 41384</refnamediv> 41385<refsynopsisdiv> 41386 <title>Synopsis</title> 41387 <funcsynopsis><funcprototype> 41388 <funcdef>struct blk_queue_tag * <function>blk_init_tags </function></funcdef> 41389 <paramdef>int <parameter>depth</parameter></paramdef> 41390 <paramdef>int <parameter>alloc_policy</parameter></paramdef> 41391 </funcprototype></funcsynopsis> 41392</refsynopsisdiv> 41393<refsect1> 41394 <title>Arguments</title> 41395 <variablelist> 41396 <varlistentry> 41397 <term><parameter>depth</parameter></term> 41398 <listitem> 41399 <para> 41400 the maximum queue depth supported 41401 </para> 41402 </listitem> 41403 </varlistentry> 41404 <varlistentry> 41405 <term><parameter>alloc_policy</parameter></term> 41406 <listitem> 41407 <para> 41408 tag allocation policy 41409 </para> 41410 </listitem> 41411 </varlistentry> 41412 </variablelist> 41413</refsect1> 41414</refentry> 41415 41416<refentry id="API-blk-queue-init-tags"> 41417<refentryinfo> 41418 <title>LINUX</title> 41419 <productname>Kernel Hackers Manual</productname> 41420 <date>July 2017</date> 41421</refentryinfo> 41422<refmeta> 41423 <refentrytitle><phrase>blk_queue_init_tags</phrase></refentrytitle> 41424 <manvolnum>9</manvolnum> 41425 <refmiscinfo class="version">4.1.27</refmiscinfo> 41426</refmeta> 41427<refnamediv> 41428 <refname>blk_queue_init_tags</refname> 41429 <refpurpose> 41430 initialize the queue tag info 41431 </refpurpose> 41432</refnamediv> 41433<refsynopsisdiv> 41434 <title>Synopsis</title> 41435 <funcsynopsis><funcprototype> 41436 <funcdef>int <function>blk_queue_init_tags </function></funcdef> 41437 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 41438 <paramdef>int <parameter>depth</parameter></paramdef> 41439 <paramdef>struct blk_queue_tag * <parameter>tags</parameter></paramdef> 41440 <paramdef>int <parameter>alloc_policy</parameter></paramdef> 41441 </funcprototype></funcsynopsis> 41442</refsynopsisdiv> 41443<refsect1> 41444 <title>Arguments</title> 41445 <variablelist> 41446 <varlistentry> 41447 <term><parameter>q</parameter></term> 41448 <listitem> 41449 <para> 41450 the request queue for the device 41451 </para> 41452 </listitem> 41453 </varlistentry> 41454 <varlistentry> 41455 <term><parameter>depth</parameter></term> 41456 <listitem> 41457 <para> 41458 the maximum queue depth supported 41459 </para> 41460 </listitem> 41461 </varlistentry> 41462 <varlistentry> 41463 <term><parameter>tags</parameter></term> 41464 <listitem> 41465 <para> 41466 the tag to use 41467 </para> 41468 </listitem> 41469 </varlistentry> 41470 <varlistentry> 41471 <term><parameter>alloc_policy</parameter></term> 41472 <listitem> 41473 <para> 41474 tag allocation policy 41475 </para> 41476 </listitem> 41477 </varlistentry> 41478 </variablelist> 41479</refsect1> 41480<refsect1> 41481<title>Description</title> 41482<para> 41483 Queue lock must be held here if the function is called to resize an 41484 existing map. 41485</para> 41486</refsect1> 41487</refentry> 41488 41489<refentry id="API-blk-queue-resize-tags"> 41490<refentryinfo> 41491 <title>LINUX</title> 41492 <productname>Kernel Hackers Manual</productname> 41493 <date>July 2017</date> 41494</refentryinfo> 41495<refmeta> 41496 <refentrytitle><phrase>blk_queue_resize_tags</phrase></refentrytitle> 41497 <manvolnum>9</manvolnum> 41498 <refmiscinfo class="version">4.1.27</refmiscinfo> 41499</refmeta> 41500<refnamediv> 41501 <refname>blk_queue_resize_tags</refname> 41502 <refpurpose> 41503 change the queueing depth 41504 </refpurpose> 41505</refnamediv> 41506<refsynopsisdiv> 41507 <title>Synopsis</title> 41508 <funcsynopsis><funcprototype> 41509 <funcdef>int <function>blk_queue_resize_tags </function></funcdef> 41510 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 41511 <paramdef>int <parameter>new_depth</parameter></paramdef> 41512 </funcprototype></funcsynopsis> 41513</refsynopsisdiv> 41514<refsect1> 41515 <title>Arguments</title> 41516 <variablelist> 41517 <varlistentry> 41518 <term><parameter>q</parameter></term> 41519 <listitem> 41520 <para> 41521 the request queue for the device 41522 </para> 41523 </listitem> 41524 </varlistentry> 41525 <varlistentry> 41526 <term><parameter>new_depth</parameter></term> 41527 <listitem> 41528 <para> 41529 the new max command queueing depth 41530 </para> 41531 </listitem> 41532 </varlistentry> 41533 </variablelist> 41534</refsect1> 41535<refsect1> 41536<title>Notes</title> 41537<para> 41538 Must be called with the queue lock held. 41539</para> 41540</refsect1> 41541</refentry> 41542 41543<refentry id="API-blk-queue-end-tag"> 41544<refentryinfo> 41545 <title>LINUX</title> 41546 <productname>Kernel Hackers Manual</productname> 41547 <date>July 2017</date> 41548</refentryinfo> 41549<refmeta> 41550 <refentrytitle><phrase>blk_queue_end_tag</phrase></refentrytitle> 41551 <manvolnum>9</manvolnum> 41552 <refmiscinfo class="version">4.1.27</refmiscinfo> 41553</refmeta> 41554<refnamediv> 41555 <refname>blk_queue_end_tag</refname> 41556 <refpurpose> 41557 end tag operations for a request 41558 </refpurpose> 41559</refnamediv> 41560<refsynopsisdiv> 41561 <title>Synopsis</title> 41562 <funcsynopsis><funcprototype> 41563 <funcdef>void <function>blk_queue_end_tag </function></funcdef> 41564 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 41565 <paramdef>struct request * <parameter>rq</parameter></paramdef> 41566 </funcprototype></funcsynopsis> 41567</refsynopsisdiv> 41568<refsect1> 41569 <title>Arguments</title> 41570 <variablelist> 41571 <varlistentry> 41572 <term><parameter>q</parameter></term> 41573 <listitem> 41574 <para> 41575 the request queue for the device 41576 </para> 41577 </listitem> 41578 </varlistentry> 41579 <varlistentry> 41580 <term><parameter>rq</parameter></term> 41581 <listitem> 41582 <para> 41583 the request that has completed 41584 </para> 41585 </listitem> 41586 </varlistentry> 41587 </variablelist> 41588</refsect1> 41589<refsect1> 41590<title>Description</title> 41591<para> 41592 Typically called when <function>end_that_request_first</function> returns <constant>0</constant>, meaning 41593 all transfers have been done for a request. It's important to call 41594 this function before <function>end_that_request_last</function>, as that will put the 41595 request back on the free list thus corrupting the internal tag list. 41596</para> 41597</refsect1> 41598<refsect1> 41599<title>Notes</title> 41600<para> 41601 queue lock must be held. 41602</para> 41603</refsect1> 41604</refentry> 41605 41606<refentry id="API-blk-queue-start-tag"> 41607<refentryinfo> 41608 <title>LINUX</title> 41609 <productname>Kernel Hackers Manual</productname> 41610 <date>July 2017</date> 41611</refentryinfo> 41612<refmeta> 41613 <refentrytitle><phrase>blk_queue_start_tag</phrase></refentrytitle> 41614 <manvolnum>9</manvolnum> 41615 <refmiscinfo class="version">4.1.27</refmiscinfo> 41616</refmeta> 41617<refnamediv> 41618 <refname>blk_queue_start_tag</refname> 41619 <refpurpose> 41620 find a free tag and assign it 41621 </refpurpose> 41622</refnamediv> 41623<refsynopsisdiv> 41624 <title>Synopsis</title> 41625 <funcsynopsis><funcprototype> 41626 <funcdef>int <function>blk_queue_start_tag </function></funcdef> 41627 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 41628 <paramdef>struct request * <parameter>rq</parameter></paramdef> 41629 </funcprototype></funcsynopsis> 41630</refsynopsisdiv> 41631<refsect1> 41632 <title>Arguments</title> 41633 <variablelist> 41634 <varlistentry> 41635 <term><parameter>q</parameter></term> 41636 <listitem> 41637 <para> 41638 the request queue for the device 41639 </para> 41640 </listitem> 41641 </varlistentry> 41642 <varlistentry> 41643 <term><parameter>rq</parameter></term> 41644 <listitem> 41645 <para> 41646 the block request that needs tagging 41647 </para> 41648 </listitem> 41649 </varlistentry> 41650 </variablelist> 41651</refsect1> 41652<refsect1> 41653<title>Description</title> 41654<para> 41655 This can either be used as a stand-alone helper, or possibly be 41656 assigned as the queue <structname>prep_rq_fn</structname> (in which case <structname>struct request</structname> 41657 automagically gets a tag assigned). Note that this function 41658 assumes that any type of request can be queued! if this is not 41659 true for your device, you must check the request type before 41660 calling this function. The request will also be removed from 41661 the request queue, so it's the drivers responsibility to readd 41662 it if it should need to be restarted for some reason. 41663</para> 41664</refsect1> 41665<refsect1> 41666<title>Notes</title> 41667<para> 41668 queue lock must be held. 41669</para> 41670</refsect1> 41671</refentry> 41672 41673<refentry id="API-blk-queue-invalidate-tags"> 41674<refentryinfo> 41675 <title>LINUX</title> 41676 <productname>Kernel Hackers Manual</productname> 41677 <date>July 2017</date> 41678</refentryinfo> 41679<refmeta> 41680 <refentrytitle><phrase>blk_queue_invalidate_tags</phrase></refentrytitle> 41681 <manvolnum>9</manvolnum> 41682 <refmiscinfo class="version">4.1.27</refmiscinfo> 41683</refmeta> 41684<refnamediv> 41685 <refname>blk_queue_invalidate_tags</refname> 41686 <refpurpose> 41687 invalidate all pending tags 41688 </refpurpose> 41689</refnamediv> 41690<refsynopsisdiv> 41691 <title>Synopsis</title> 41692 <funcsynopsis><funcprototype> 41693 <funcdef>void <function>blk_queue_invalidate_tags </function></funcdef> 41694 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 41695 </funcprototype></funcsynopsis> 41696</refsynopsisdiv> 41697<refsect1> 41698 <title>Arguments</title> 41699 <variablelist> 41700 <varlistentry> 41701 <term><parameter>q</parameter></term> 41702 <listitem> 41703 <para> 41704 the request queue for the device 41705 </para> 41706 </listitem> 41707 </varlistentry> 41708 </variablelist> 41709</refsect1> 41710<refsect1> 41711<title>Description</title> 41712<para> 41713 Hardware conditions may dictate a need to stop all pending requests. 41714 In this case, we will safely clear the block side of the tag queue and 41715 readd all requests to the request queue in the right order. 41716</para> 41717</refsect1> 41718<refsect1> 41719<title>Notes</title> 41720<para> 41721 queue lock must be held. 41722</para> 41723</refsect1> 41724</refentry> 41725 41726<!-- block/blk-tag.c --> 41727<refentry id="API---blk-queue-free-tags"> 41728<refentryinfo> 41729 <title>LINUX</title> 41730 <productname>Kernel Hackers Manual</productname> 41731 <date>July 2017</date> 41732</refentryinfo> 41733<refmeta> 41734 <refentrytitle><phrase>__blk_queue_free_tags</phrase></refentrytitle> 41735 <manvolnum>9</manvolnum> 41736 <refmiscinfo class="version">4.1.27</refmiscinfo> 41737</refmeta> 41738<refnamediv> 41739 <refname>__blk_queue_free_tags</refname> 41740 <refpurpose> 41741 release tag maintenance info 41742 </refpurpose> 41743</refnamediv> 41744<refsynopsisdiv> 41745 <title>Synopsis</title> 41746 <funcsynopsis><funcprototype> 41747 <funcdef>void <function>__blk_queue_free_tags </function></funcdef> 41748 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 41749 </funcprototype></funcsynopsis> 41750</refsynopsisdiv> 41751<refsect1> 41752 <title>Arguments</title> 41753 <variablelist> 41754 <varlistentry> 41755 <term><parameter>q</parameter></term> 41756 <listitem> 41757 <para> 41758 the request queue for the device 41759 </para> 41760 </listitem> 41761 </varlistentry> 41762 </variablelist> 41763</refsect1> 41764<refsect1> 41765<title>Notes</title> 41766<para> 41767 <function>blk_cleanup_queue</function> will take care of calling this function, if tagging 41768 has been used. So there's no need to call this directly. 41769</para> 41770</refsect1> 41771</refentry> 41772 41773<!-- block/blk-integrity.c --> 41774<refentry id="API-blk-rq-count-integrity-sg"> 41775<refentryinfo> 41776 <title>LINUX</title> 41777 <productname>Kernel Hackers Manual</productname> 41778 <date>July 2017</date> 41779</refentryinfo> 41780<refmeta> 41781 <refentrytitle><phrase>blk_rq_count_integrity_sg</phrase></refentrytitle> 41782 <manvolnum>9</manvolnum> 41783 <refmiscinfo class="version">4.1.27</refmiscinfo> 41784</refmeta> 41785<refnamediv> 41786 <refname>blk_rq_count_integrity_sg</refname> 41787 <refpurpose> 41788 Count number of integrity scatterlist elements 41789 </refpurpose> 41790</refnamediv> 41791<refsynopsisdiv> 41792 <title>Synopsis</title> 41793 <funcsynopsis><funcprototype> 41794 <funcdef>int <function>blk_rq_count_integrity_sg </function></funcdef> 41795 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 41796 <paramdef>struct bio * <parameter>bio</parameter></paramdef> 41797 </funcprototype></funcsynopsis> 41798</refsynopsisdiv> 41799<refsect1> 41800 <title>Arguments</title> 41801 <variablelist> 41802 <varlistentry> 41803 <term><parameter>q</parameter></term> 41804 <listitem> 41805 <para> 41806 request queue 41807 </para> 41808 </listitem> 41809 </varlistentry> 41810 <varlistentry> 41811 <term><parameter>bio</parameter></term> 41812 <listitem> 41813 <para> 41814 bio with integrity metadata attached 41815 </para> 41816 </listitem> 41817 </varlistentry> 41818 </variablelist> 41819</refsect1> 41820<refsect1> 41821<title>Description</title> 41822<para> 41823 Returns the number of elements required in a 41824 scatterlist corresponding to the integrity metadata in a bio. 41825</para> 41826</refsect1> 41827</refentry> 41828 41829<refentry id="API-blk-rq-map-integrity-sg"> 41830<refentryinfo> 41831 <title>LINUX</title> 41832 <productname>Kernel Hackers Manual</productname> 41833 <date>July 2017</date> 41834</refentryinfo> 41835<refmeta> 41836 <refentrytitle><phrase>blk_rq_map_integrity_sg</phrase></refentrytitle> 41837 <manvolnum>9</manvolnum> 41838 <refmiscinfo class="version">4.1.27</refmiscinfo> 41839</refmeta> 41840<refnamediv> 41841 <refname>blk_rq_map_integrity_sg</refname> 41842 <refpurpose> 41843 Map integrity metadata into a scatterlist 41844 </refpurpose> 41845</refnamediv> 41846<refsynopsisdiv> 41847 <title>Synopsis</title> 41848 <funcsynopsis><funcprototype> 41849 <funcdef>int <function>blk_rq_map_integrity_sg </function></funcdef> 41850 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 41851 <paramdef>struct bio * <parameter>bio</parameter></paramdef> 41852 <paramdef>struct scatterlist * <parameter>sglist</parameter></paramdef> 41853 </funcprototype></funcsynopsis> 41854</refsynopsisdiv> 41855<refsect1> 41856 <title>Arguments</title> 41857 <variablelist> 41858 <varlistentry> 41859 <term><parameter>q</parameter></term> 41860 <listitem> 41861 <para> 41862 request queue 41863 </para> 41864 </listitem> 41865 </varlistentry> 41866 <varlistentry> 41867 <term><parameter>bio</parameter></term> 41868 <listitem> 41869 <para> 41870 bio with integrity metadata attached 41871 </para> 41872 </listitem> 41873 </varlistentry> 41874 <varlistentry> 41875 <term><parameter>sglist</parameter></term> 41876 <listitem> 41877 <para> 41878 target scatterlist 41879 </para> 41880 </listitem> 41881 </varlistentry> 41882 </variablelist> 41883</refsect1> 41884<refsect1> 41885<title>Description</title> 41886<para> 41887 Map the integrity vectors in request into a 41888 scatterlist. The scatterlist must be big enough to hold all 41889 elements. I.e. sized using <function>blk_rq_count_integrity_sg</function>. 41890</para> 41891</refsect1> 41892</refentry> 41893 41894<refentry id="API-blk-integrity-compare"> 41895<refentryinfo> 41896 <title>LINUX</title> 41897 <productname>Kernel Hackers Manual</productname> 41898 <date>July 2017</date> 41899</refentryinfo> 41900<refmeta> 41901 <refentrytitle><phrase>blk_integrity_compare</phrase></refentrytitle> 41902 <manvolnum>9</manvolnum> 41903 <refmiscinfo class="version">4.1.27</refmiscinfo> 41904</refmeta> 41905<refnamediv> 41906 <refname>blk_integrity_compare</refname> 41907 <refpurpose> 41908 Compare integrity profile of two disks 41909 </refpurpose> 41910</refnamediv> 41911<refsynopsisdiv> 41912 <title>Synopsis</title> 41913 <funcsynopsis><funcprototype> 41914 <funcdef>int <function>blk_integrity_compare </function></funcdef> 41915 <paramdef>struct gendisk * <parameter>gd1</parameter></paramdef> 41916 <paramdef>struct gendisk * <parameter>gd2</parameter></paramdef> 41917 </funcprototype></funcsynopsis> 41918</refsynopsisdiv> 41919<refsect1> 41920 <title>Arguments</title> 41921 <variablelist> 41922 <varlistentry> 41923 <term><parameter>gd1</parameter></term> 41924 <listitem> 41925 <para> 41926 Disk to compare 41927 </para> 41928 </listitem> 41929 </varlistentry> 41930 <varlistentry> 41931 <term><parameter>gd2</parameter></term> 41932 <listitem> 41933 <para> 41934 Disk to compare 41935 </para> 41936 </listitem> 41937 </varlistentry> 41938 </variablelist> 41939</refsect1> 41940<refsect1> 41941<title>Description</title> 41942<para> 41943 Meta-devices like DM and MD need to verify that all 41944 sub-devices use the same integrity format before advertising to 41945 upper layers that they can send/receive integrity metadata. This 41946 function can be used to check whether two gendisk devices have 41947 compatible integrity formats. 41948</para> 41949</refsect1> 41950</refentry> 41951 41952<refentry id="API-blk-integrity-register"> 41953<refentryinfo> 41954 <title>LINUX</title> 41955 <productname>Kernel Hackers Manual</productname> 41956 <date>July 2017</date> 41957</refentryinfo> 41958<refmeta> 41959 <refentrytitle><phrase>blk_integrity_register</phrase></refentrytitle> 41960 <manvolnum>9</manvolnum> 41961 <refmiscinfo class="version">4.1.27</refmiscinfo> 41962</refmeta> 41963<refnamediv> 41964 <refname>blk_integrity_register</refname> 41965 <refpurpose> 41966 Register a gendisk as being integrity-capable 41967 </refpurpose> 41968</refnamediv> 41969<refsynopsisdiv> 41970 <title>Synopsis</title> 41971 <funcsynopsis><funcprototype> 41972 <funcdef>int <function>blk_integrity_register </function></funcdef> 41973 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 41974 <paramdef>struct blk_integrity * <parameter>template</parameter></paramdef> 41975 </funcprototype></funcsynopsis> 41976</refsynopsisdiv> 41977<refsect1> 41978 <title>Arguments</title> 41979 <variablelist> 41980 <varlistentry> 41981 <term><parameter>disk</parameter></term> 41982 <listitem> 41983 <para> 41984 struct gendisk pointer to make integrity-aware 41985 </para> 41986 </listitem> 41987 </varlistentry> 41988 <varlistentry> 41989 <term><parameter>template</parameter></term> 41990 <listitem> 41991 <para> 41992 optional integrity profile to register 41993 </para> 41994 </listitem> 41995 </varlistentry> 41996 </variablelist> 41997</refsect1> 41998<refsect1> 41999<title>Description</title> 42000<para> 42001 When a device needs to advertise itself as being able 42002 to send/receive integrity metadata it must use this function to 42003 register the capability with the block layer. The template is a 42004 blk_integrity struct with values appropriate for the underlying 42005 hardware. If template is NULL the new profile is allocated but 42006 not filled out. See Documentation/block/data-integrity.txt. 42007</para> 42008</refsect1> 42009</refentry> 42010 42011<refentry id="API-blk-integrity-unregister"> 42012<refentryinfo> 42013 <title>LINUX</title> 42014 <productname>Kernel Hackers Manual</productname> 42015 <date>July 2017</date> 42016</refentryinfo> 42017<refmeta> 42018 <refentrytitle><phrase>blk_integrity_unregister</phrase></refentrytitle> 42019 <manvolnum>9</manvolnum> 42020 <refmiscinfo class="version">4.1.27</refmiscinfo> 42021</refmeta> 42022<refnamediv> 42023 <refname>blk_integrity_unregister</refname> 42024 <refpurpose> 42025 Remove block integrity profile 42026 </refpurpose> 42027</refnamediv> 42028<refsynopsisdiv> 42029 <title>Synopsis</title> 42030 <funcsynopsis><funcprototype> 42031 <funcdef>void <function>blk_integrity_unregister </function></funcdef> 42032 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 42033 </funcprototype></funcsynopsis> 42034</refsynopsisdiv> 42035<refsect1> 42036 <title>Arguments</title> 42037 <variablelist> 42038 <varlistentry> 42039 <term><parameter>disk</parameter></term> 42040 <listitem> 42041 <para> 42042 disk whose integrity profile to deallocate 42043 </para> 42044 </listitem> 42045 </varlistentry> 42046 </variablelist> 42047</refsect1> 42048<refsect1> 42049<title>Description</title> 42050<para> 42051 This function frees all memory used by the block 42052 integrity profile. To be called at device teardown. 42053</para> 42054</refsect1> 42055</refentry> 42056 42057<!-- kernel/trace/blktrace.c --> 42058<refentry id="API-blk-trace-ioctl"> 42059<refentryinfo> 42060 <title>LINUX</title> 42061 <productname>Kernel Hackers Manual</productname> 42062 <date>July 2017</date> 42063</refentryinfo> 42064<refmeta> 42065 <refentrytitle><phrase>blk_trace_ioctl</phrase></refentrytitle> 42066 <manvolnum>9</manvolnum> 42067 <refmiscinfo class="version">4.1.27</refmiscinfo> 42068</refmeta> 42069<refnamediv> 42070 <refname>blk_trace_ioctl</refname> 42071 <refpurpose> 42072 handle the ioctls associated with tracing 42073 </refpurpose> 42074</refnamediv> 42075<refsynopsisdiv> 42076 <title>Synopsis</title> 42077 <funcsynopsis><funcprototype> 42078 <funcdef>int <function>blk_trace_ioctl </function></funcdef> 42079 <paramdef>struct block_device * <parameter>bdev</parameter></paramdef> 42080 <paramdef>unsigned <parameter>cmd</parameter></paramdef> 42081 <paramdef>char __user * <parameter>arg</parameter></paramdef> 42082 </funcprototype></funcsynopsis> 42083</refsynopsisdiv> 42084<refsect1> 42085 <title>Arguments</title> 42086 <variablelist> 42087 <varlistentry> 42088 <term><parameter>bdev</parameter></term> 42089 <listitem> 42090 <para> 42091 the block device 42092 </para> 42093 </listitem> 42094 </varlistentry> 42095 <varlistentry> 42096 <term><parameter>cmd</parameter></term> 42097 <listitem> 42098 <para> 42099 the ioctl cmd 42100 </para> 42101 </listitem> 42102 </varlistentry> 42103 <varlistentry> 42104 <term><parameter>arg</parameter></term> 42105 <listitem> 42106 <para> 42107 the argument data, if any 42108 </para> 42109 </listitem> 42110 </varlistentry> 42111 </variablelist> 42112</refsect1> 42113</refentry> 42114 42115<refentry id="API-blk-trace-shutdown"> 42116<refentryinfo> 42117 <title>LINUX</title> 42118 <productname>Kernel Hackers Manual</productname> 42119 <date>July 2017</date> 42120</refentryinfo> 42121<refmeta> 42122 <refentrytitle><phrase>blk_trace_shutdown</phrase></refentrytitle> 42123 <manvolnum>9</manvolnum> 42124 <refmiscinfo class="version">4.1.27</refmiscinfo> 42125</refmeta> 42126<refnamediv> 42127 <refname>blk_trace_shutdown</refname> 42128 <refpurpose> 42129 stop and cleanup trace structures 42130 </refpurpose> 42131</refnamediv> 42132<refsynopsisdiv> 42133 <title>Synopsis</title> 42134 <funcsynopsis><funcprototype> 42135 <funcdef>void <function>blk_trace_shutdown </function></funcdef> 42136 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 42137 </funcprototype></funcsynopsis> 42138</refsynopsisdiv> 42139<refsect1> 42140 <title>Arguments</title> 42141 <variablelist> 42142 <varlistentry> 42143 <term><parameter>q</parameter></term> 42144 <listitem> 42145 <para> 42146 the request queue associated with the device 42147 </para> 42148 </listitem> 42149 </varlistentry> 42150 </variablelist> 42151</refsect1> 42152</refentry> 42153 42154<refentry id="API-blk-add-trace-rq"> 42155<refentryinfo> 42156 <title>LINUX</title> 42157 <productname>Kernel Hackers Manual</productname> 42158 <date>July 2017</date> 42159</refentryinfo> 42160<refmeta> 42161 <refentrytitle><phrase>blk_add_trace_rq</phrase></refentrytitle> 42162 <manvolnum>9</manvolnum> 42163 <refmiscinfo class="version">4.1.27</refmiscinfo> 42164</refmeta> 42165<refnamediv> 42166 <refname>blk_add_trace_rq</refname> 42167 <refpurpose> 42168 Add a trace for a request oriented action 42169 </refpurpose> 42170</refnamediv> 42171<refsynopsisdiv> 42172 <title>Synopsis</title> 42173 <funcsynopsis><funcprototype> 42174 <funcdef>void <function>blk_add_trace_rq </function></funcdef> 42175 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 42176 <paramdef>struct request * <parameter>rq</parameter></paramdef> 42177 <paramdef>unsigned int <parameter>nr_bytes</parameter></paramdef> 42178 <paramdef>u32 <parameter>what</parameter></paramdef> 42179 </funcprototype></funcsynopsis> 42180</refsynopsisdiv> 42181<refsect1> 42182 <title>Arguments</title> 42183 <variablelist> 42184 <varlistentry> 42185 <term><parameter>q</parameter></term> 42186 <listitem> 42187 <para> 42188 queue the io is for 42189 </para> 42190 </listitem> 42191 </varlistentry> 42192 <varlistentry> 42193 <term><parameter>rq</parameter></term> 42194 <listitem> 42195 <para> 42196 the source request 42197 </para> 42198 </listitem> 42199 </varlistentry> 42200 <varlistentry> 42201 <term><parameter>nr_bytes</parameter></term> 42202 <listitem> 42203 <para> 42204 number of completed bytes 42205 </para> 42206 </listitem> 42207 </varlistentry> 42208 <varlistentry> 42209 <term><parameter>what</parameter></term> 42210 <listitem> 42211 <para> 42212 the action 42213 </para> 42214 </listitem> 42215 </varlistentry> 42216 </variablelist> 42217</refsect1> 42218<refsect1> 42219<title>Description</title> 42220<para> 42221 Records an action against a request. Will log the bio offset + size. 42222</para> 42223</refsect1> 42224</refentry> 42225 42226<refentry id="API-blk-add-trace-bio"> 42227<refentryinfo> 42228 <title>LINUX</title> 42229 <productname>Kernel Hackers Manual</productname> 42230 <date>July 2017</date> 42231</refentryinfo> 42232<refmeta> 42233 <refentrytitle><phrase>blk_add_trace_bio</phrase></refentrytitle> 42234 <manvolnum>9</manvolnum> 42235 <refmiscinfo class="version">4.1.27</refmiscinfo> 42236</refmeta> 42237<refnamediv> 42238 <refname>blk_add_trace_bio</refname> 42239 <refpurpose> 42240 Add a trace for a bio oriented action 42241 </refpurpose> 42242</refnamediv> 42243<refsynopsisdiv> 42244 <title>Synopsis</title> 42245 <funcsynopsis><funcprototype> 42246 <funcdef>void <function>blk_add_trace_bio </function></funcdef> 42247 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 42248 <paramdef>struct bio * <parameter>bio</parameter></paramdef> 42249 <paramdef>u32 <parameter>what</parameter></paramdef> 42250 <paramdef>int <parameter>error</parameter></paramdef> 42251 </funcprototype></funcsynopsis> 42252</refsynopsisdiv> 42253<refsect1> 42254 <title>Arguments</title> 42255 <variablelist> 42256 <varlistentry> 42257 <term><parameter>q</parameter></term> 42258 <listitem> 42259 <para> 42260 queue the io is for 42261 </para> 42262 </listitem> 42263 </varlistentry> 42264 <varlistentry> 42265 <term><parameter>bio</parameter></term> 42266 <listitem> 42267 <para> 42268 the source bio 42269 </para> 42270 </listitem> 42271 </varlistentry> 42272 <varlistentry> 42273 <term><parameter>what</parameter></term> 42274 <listitem> 42275 <para> 42276 the action 42277 </para> 42278 </listitem> 42279 </varlistentry> 42280 <varlistentry> 42281 <term><parameter>error</parameter></term> 42282 <listitem> 42283 <para> 42284 error, if any 42285 </para> 42286 </listitem> 42287 </varlistentry> 42288 </variablelist> 42289</refsect1> 42290<refsect1> 42291<title>Description</title> 42292<para> 42293 Records an action against a bio. Will log the bio offset + size. 42294</para> 42295</refsect1> 42296</refentry> 42297 42298<refentry id="API-blk-add-trace-bio-remap"> 42299<refentryinfo> 42300 <title>LINUX</title> 42301 <productname>Kernel Hackers Manual</productname> 42302 <date>July 2017</date> 42303</refentryinfo> 42304<refmeta> 42305 <refentrytitle><phrase>blk_add_trace_bio_remap</phrase></refentrytitle> 42306 <manvolnum>9</manvolnum> 42307 <refmiscinfo class="version">4.1.27</refmiscinfo> 42308</refmeta> 42309<refnamediv> 42310 <refname>blk_add_trace_bio_remap</refname> 42311 <refpurpose> 42312 Add a trace for a bio-remap operation 42313 </refpurpose> 42314</refnamediv> 42315<refsynopsisdiv> 42316 <title>Synopsis</title> 42317 <funcsynopsis><funcprototype> 42318 <funcdef>void <function>blk_add_trace_bio_remap </function></funcdef> 42319 <paramdef>void * <parameter>ignore</parameter></paramdef> 42320 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 42321 <paramdef>struct bio * <parameter>bio</parameter></paramdef> 42322 <paramdef>dev_t <parameter>dev</parameter></paramdef> 42323 <paramdef>sector_t <parameter>from</parameter></paramdef> 42324 </funcprototype></funcsynopsis> 42325</refsynopsisdiv> 42326<refsect1> 42327 <title>Arguments</title> 42328 <variablelist> 42329 <varlistentry> 42330 <term><parameter>ignore</parameter></term> 42331 <listitem> 42332 <para> 42333 trace callback data parameter (not used) 42334 </para> 42335 </listitem> 42336 </varlistentry> 42337 <varlistentry> 42338 <term><parameter>q</parameter></term> 42339 <listitem> 42340 <para> 42341 queue the io is for 42342 </para> 42343 </listitem> 42344 </varlistentry> 42345 <varlistentry> 42346 <term><parameter>bio</parameter></term> 42347 <listitem> 42348 <para> 42349 the source bio 42350 </para> 42351 </listitem> 42352 </varlistentry> 42353 <varlistentry> 42354 <term><parameter>dev</parameter></term> 42355 <listitem> 42356 <para> 42357 target device 42358 </para> 42359 </listitem> 42360 </varlistentry> 42361 <varlistentry> 42362 <term><parameter>from</parameter></term> 42363 <listitem> 42364 <para> 42365 source sector 42366 </para> 42367 </listitem> 42368 </varlistentry> 42369 </variablelist> 42370</refsect1> 42371<refsect1> 42372<title>Description</title> 42373<para> 42374 Device mapper or raid target sometimes need to split a bio because 42375 it spans a stripe (or similar). Add a trace for that action. 42376</para> 42377</refsect1> 42378</refentry> 42379 42380<refentry id="API-blk-add-trace-rq-remap"> 42381<refentryinfo> 42382 <title>LINUX</title> 42383 <productname>Kernel Hackers Manual</productname> 42384 <date>July 2017</date> 42385</refentryinfo> 42386<refmeta> 42387 <refentrytitle><phrase>blk_add_trace_rq_remap</phrase></refentrytitle> 42388 <manvolnum>9</manvolnum> 42389 <refmiscinfo class="version">4.1.27</refmiscinfo> 42390</refmeta> 42391<refnamediv> 42392 <refname>blk_add_trace_rq_remap</refname> 42393 <refpurpose> 42394 Add a trace for a request-remap operation 42395 </refpurpose> 42396</refnamediv> 42397<refsynopsisdiv> 42398 <title>Synopsis</title> 42399 <funcsynopsis><funcprototype> 42400 <funcdef>void <function>blk_add_trace_rq_remap </function></funcdef> 42401 <paramdef>void * <parameter>ignore</parameter></paramdef> 42402 <paramdef>struct request_queue * <parameter>q</parameter></paramdef> 42403 <paramdef>struct request * <parameter>rq</parameter></paramdef> 42404 <paramdef>dev_t <parameter>dev</parameter></paramdef> 42405 <paramdef>sector_t <parameter>from</parameter></paramdef> 42406 </funcprototype></funcsynopsis> 42407</refsynopsisdiv> 42408<refsect1> 42409 <title>Arguments</title> 42410 <variablelist> 42411 <varlistentry> 42412 <term><parameter>ignore</parameter></term> 42413 <listitem> 42414 <para> 42415 trace callback data parameter (not used) 42416 </para> 42417 </listitem> 42418 </varlistentry> 42419 <varlistentry> 42420 <term><parameter>q</parameter></term> 42421 <listitem> 42422 <para> 42423 queue the io is for 42424 </para> 42425 </listitem> 42426 </varlistentry> 42427 <varlistentry> 42428 <term><parameter>rq</parameter></term> 42429 <listitem> 42430 <para> 42431 the source request 42432 </para> 42433 </listitem> 42434 </varlistentry> 42435 <varlistentry> 42436 <term><parameter>dev</parameter></term> 42437 <listitem> 42438 <para> 42439 target device 42440 </para> 42441 </listitem> 42442 </varlistentry> 42443 <varlistentry> 42444 <term><parameter>from</parameter></term> 42445 <listitem> 42446 <para> 42447 source sector 42448 </para> 42449 </listitem> 42450 </varlistentry> 42451 </variablelist> 42452</refsect1> 42453<refsect1> 42454<title>Description</title> 42455<para> 42456 Device mapper remaps request to other devices. 42457 Add a trace for that action. 42458</para> 42459</refsect1> 42460</refentry> 42461 42462<!-- block/genhd.c --> 42463<refentry id="API-blk-mangle-minor"> 42464<refentryinfo> 42465 <title>LINUX</title> 42466 <productname>Kernel Hackers Manual</productname> 42467 <date>July 2017</date> 42468</refentryinfo> 42469<refmeta> 42470 <refentrytitle><phrase>blk_mangle_minor</phrase></refentrytitle> 42471 <manvolnum>9</manvolnum> 42472 <refmiscinfo class="version">4.1.27</refmiscinfo> 42473</refmeta> 42474<refnamediv> 42475 <refname>blk_mangle_minor</refname> 42476 <refpurpose> 42477 scatter minor numbers apart 42478 </refpurpose> 42479</refnamediv> 42480<refsynopsisdiv> 42481 <title>Synopsis</title> 42482 <funcsynopsis><funcprototype> 42483 <funcdef>int <function>blk_mangle_minor </function></funcdef> 42484 <paramdef>int <parameter>minor</parameter></paramdef> 42485 </funcprototype></funcsynopsis> 42486</refsynopsisdiv> 42487<refsect1> 42488 <title>Arguments</title> 42489 <variablelist> 42490 <varlistentry> 42491 <term><parameter>minor</parameter></term> 42492 <listitem> 42493 <para> 42494 minor number to mangle 42495 </para> 42496 </listitem> 42497 </varlistentry> 42498 </variablelist> 42499</refsect1> 42500<refsect1> 42501<title>Description</title> 42502<para> 42503 Scatter consecutively allocated <parameter>minor</parameter> number apart if MANGLE_DEVT 42504 is enabled. Mangling twice gives the original value. 42505</para> 42506</refsect1> 42507<refsect1> 42508<title>RETURNS</title> 42509<para> 42510 Mangled value. 42511</para> 42512</refsect1> 42513<refsect1> 42514<title>CONTEXT</title> 42515<para> 42516 Don't care. 42517</para> 42518</refsect1> 42519</refentry> 42520 42521<refentry id="API-blk-alloc-devt"> 42522<refentryinfo> 42523 <title>LINUX</title> 42524 <productname>Kernel Hackers Manual</productname> 42525 <date>July 2017</date> 42526</refentryinfo> 42527<refmeta> 42528 <refentrytitle><phrase>blk_alloc_devt</phrase></refentrytitle> 42529 <manvolnum>9</manvolnum> 42530 <refmiscinfo class="version">4.1.27</refmiscinfo> 42531</refmeta> 42532<refnamediv> 42533 <refname>blk_alloc_devt</refname> 42534 <refpurpose> 42535 allocate a dev_t for a partition 42536 </refpurpose> 42537</refnamediv> 42538<refsynopsisdiv> 42539 <title>Synopsis</title> 42540 <funcsynopsis><funcprototype> 42541 <funcdef>int <function>blk_alloc_devt </function></funcdef> 42542 <paramdef>struct hd_struct * <parameter>part</parameter></paramdef> 42543 <paramdef>dev_t * <parameter>devt</parameter></paramdef> 42544 </funcprototype></funcsynopsis> 42545</refsynopsisdiv> 42546<refsect1> 42547 <title>Arguments</title> 42548 <variablelist> 42549 <varlistentry> 42550 <term><parameter>part</parameter></term> 42551 <listitem> 42552 <para> 42553 partition to allocate dev_t for 42554 </para> 42555 </listitem> 42556 </varlistentry> 42557 <varlistentry> 42558 <term><parameter>devt</parameter></term> 42559 <listitem> 42560 <para> 42561 out parameter for resulting dev_t 42562 </para> 42563 </listitem> 42564 </varlistentry> 42565 </variablelist> 42566</refsect1> 42567<refsect1> 42568<title>Description</title> 42569<para> 42570 Allocate a dev_t for block device. 42571</para> 42572</refsect1> 42573<refsect1> 42574<title>RETURNS</title> 42575<para> 42576 0 on success, allocated dev_t is returned in *<parameter>devt</parameter>. -errno on 42577 failure. 42578</para> 42579</refsect1> 42580<refsect1> 42581<title>CONTEXT</title> 42582<para> 42583 Might sleep. 42584</para> 42585</refsect1> 42586</refentry> 42587 42588<refentry id="API-blk-free-devt"> 42589<refentryinfo> 42590 <title>LINUX</title> 42591 <productname>Kernel Hackers Manual</productname> 42592 <date>July 2017</date> 42593</refentryinfo> 42594<refmeta> 42595 <refentrytitle><phrase>blk_free_devt</phrase></refentrytitle> 42596 <manvolnum>9</manvolnum> 42597 <refmiscinfo class="version">4.1.27</refmiscinfo> 42598</refmeta> 42599<refnamediv> 42600 <refname>blk_free_devt</refname> 42601 <refpurpose> 42602 free a dev_t 42603 </refpurpose> 42604</refnamediv> 42605<refsynopsisdiv> 42606 <title>Synopsis</title> 42607 <funcsynopsis><funcprototype> 42608 <funcdef>void <function>blk_free_devt </function></funcdef> 42609 <paramdef>dev_t <parameter>devt</parameter></paramdef> 42610 </funcprototype></funcsynopsis> 42611</refsynopsisdiv> 42612<refsect1> 42613 <title>Arguments</title> 42614 <variablelist> 42615 <varlistentry> 42616 <term><parameter>devt</parameter></term> 42617 <listitem> 42618 <para> 42619 dev_t to free 42620 </para> 42621 </listitem> 42622 </varlistentry> 42623 </variablelist> 42624</refsect1> 42625<refsect1> 42626<title>Description</title> 42627<para> 42628 Free <parameter>devt</parameter> which was allocated using <function>blk_alloc_devt</function>. 42629</para> 42630</refsect1> 42631<refsect1> 42632<title>CONTEXT</title> 42633<para> 42634 Might sleep. 42635</para> 42636</refsect1> 42637</refentry> 42638 42639<refentry id="API-disk-replace-part-tbl"> 42640<refentryinfo> 42641 <title>LINUX</title> 42642 <productname>Kernel Hackers Manual</productname> 42643 <date>July 2017</date> 42644</refentryinfo> 42645<refmeta> 42646 <refentrytitle><phrase>disk_replace_part_tbl</phrase></refentrytitle> 42647 <manvolnum>9</manvolnum> 42648 <refmiscinfo class="version">4.1.27</refmiscinfo> 42649</refmeta> 42650<refnamediv> 42651 <refname>disk_replace_part_tbl</refname> 42652 <refpurpose> 42653 replace disk->part_tbl in RCU-safe way 42654 </refpurpose> 42655</refnamediv> 42656<refsynopsisdiv> 42657 <title>Synopsis</title> 42658 <funcsynopsis><funcprototype> 42659 <funcdef>void <function>disk_replace_part_tbl </function></funcdef> 42660 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 42661 <paramdef>struct disk_part_tbl * <parameter>new_ptbl</parameter></paramdef> 42662 </funcprototype></funcsynopsis> 42663</refsynopsisdiv> 42664<refsect1> 42665 <title>Arguments</title> 42666 <variablelist> 42667 <varlistentry> 42668 <term><parameter>disk</parameter></term> 42669 <listitem> 42670 <para> 42671 disk to replace part_tbl for 42672 </para> 42673 </listitem> 42674 </varlistentry> 42675 <varlistentry> 42676 <term><parameter>new_ptbl</parameter></term> 42677 <listitem> 42678 <para> 42679 new part_tbl to install 42680 </para> 42681 </listitem> 42682 </varlistentry> 42683 </variablelist> 42684</refsect1> 42685<refsect1> 42686<title>Description</title> 42687<para> 42688 Replace disk->part_tbl with <parameter>new_ptbl</parameter> in RCU-safe way. The 42689 original ptbl is freed using RCU callback. 42690</para> 42691</refsect1> 42692<refsect1> 42693<title>LOCKING</title> 42694<para> 42695 Matching bd_mutx locked. 42696</para> 42697</refsect1> 42698</refentry> 42699 42700<refentry id="API-disk-expand-part-tbl"> 42701<refentryinfo> 42702 <title>LINUX</title> 42703 <productname>Kernel Hackers Manual</productname> 42704 <date>July 2017</date> 42705</refentryinfo> 42706<refmeta> 42707 <refentrytitle><phrase>disk_expand_part_tbl</phrase></refentrytitle> 42708 <manvolnum>9</manvolnum> 42709 <refmiscinfo class="version">4.1.27</refmiscinfo> 42710</refmeta> 42711<refnamediv> 42712 <refname>disk_expand_part_tbl</refname> 42713 <refpurpose> 42714 expand disk->part_tbl 42715 </refpurpose> 42716</refnamediv> 42717<refsynopsisdiv> 42718 <title>Synopsis</title> 42719 <funcsynopsis><funcprototype> 42720 <funcdef>int <function>disk_expand_part_tbl </function></funcdef> 42721 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 42722 <paramdef>int <parameter>partno</parameter></paramdef> 42723 </funcprototype></funcsynopsis> 42724</refsynopsisdiv> 42725<refsect1> 42726 <title>Arguments</title> 42727 <variablelist> 42728 <varlistentry> 42729 <term><parameter>disk</parameter></term> 42730 <listitem> 42731 <para> 42732 disk to expand part_tbl for 42733 </para> 42734 </listitem> 42735 </varlistentry> 42736 <varlistentry> 42737 <term><parameter>partno</parameter></term> 42738 <listitem> 42739 <para> 42740 expand such that this partno can fit in 42741 </para> 42742 </listitem> 42743 </varlistentry> 42744 </variablelist> 42745</refsect1> 42746<refsect1> 42747<title>Description</title> 42748<para> 42749 Expand disk->part_tbl such that <parameter>partno</parameter> can fit in. disk->part_tbl 42750 uses RCU to allow unlocked dereferencing for stats and other stuff. 42751</para> 42752</refsect1> 42753<refsect1> 42754<title>LOCKING</title> 42755<para> 42756 Matching bd_mutex locked, might sleep. 42757</para> 42758</refsect1> 42759<refsect1> 42760<title>RETURNS</title> 42761<para> 42762 0 on success, -errno on failure. 42763</para> 42764</refsect1> 42765</refentry> 42766 42767<refentry id="API-disk-block-events"> 42768<refentryinfo> 42769 <title>LINUX</title> 42770 <productname>Kernel Hackers Manual</productname> 42771 <date>July 2017</date> 42772</refentryinfo> 42773<refmeta> 42774 <refentrytitle><phrase>disk_block_events</phrase></refentrytitle> 42775 <manvolnum>9</manvolnum> 42776 <refmiscinfo class="version">4.1.27</refmiscinfo> 42777</refmeta> 42778<refnamediv> 42779 <refname>disk_block_events</refname> 42780 <refpurpose> 42781 block and flush disk event checking 42782 </refpurpose> 42783</refnamediv> 42784<refsynopsisdiv> 42785 <title>Synopsis</title> 42786 <funcsynopsis><funcprototype> 42787 <funcdef>void <function>disk_block_events </function></funcdef> 42788 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 42789 </funcprototype></funcsynopsis> 42790</refsynopsisdiv> 42791<refsect1> 42792 <title>Arguments</title> 42793 <variablelist> 42794 <varlistentry> 42795 <term><parameter>disk</parameter></term> 42796 <listitem> 42797 <para> 42798 disk to block events for 42799 </para> 42800 </listitem> 42801 </varlistentry> 42802 </variablelist> 42803</refsect1> 42804<refsect1> 42805<title>Description</title> 42806<para> 42807 On return from this function, it is guaranteed that event checking 42808 isn't in progress and won't happen until unblocked by 42809 <function>disk_unblock_events</function>. Events blocking is counted and the actual 42810 unblocking happens after the matching number of unblocks are done. 42811 </para><para> 42812 42813 Note that this intentionally does not block event checking from 42814 <function>disk_clear_events</function>. 42815</para> 42816</refsect1> 42817<refsect1> 42818<title>CONTEXT</title> 42819<para> 42820 Might sleep. 42821</para> 42822</refsect1> 42823</refentry> 42824 42825<refentry id="API-disk-unblock-events"> 42826<refentryinfo> 42827 <title>LINUX</title> 42828 <productname>Kernel Hackers Manual</productname> 42829 <date>July 2017</date> 42830</refentryinfo> 42831<refmeta> 42832 <refentrytitle><phrase>disk_unblock_events</phrase></refentrytitle> 42833 <manvolnum>9</manvolnum> 42834 <refmiscinfo class="version">4.1.27</refmiscinfo> 42835</refmeta> 42836<refnamediv> 42837 <refname>disk_unblock_events</refname> 42838 <refpurpose> 42839 unblock disk event checking 42840 </refpurpose> 42841</refnamediv> 42842<refsynopsisdiv> 42843 <title>Synopsis</title> 42844 <funcsynopsis><funcprototype> 42845 <funcdef>void <function>disk_unblock_events </function></funcdef> 42846 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 42847 </funcprototype></funcsynopsis> 42848</refsynopsisdiv> 42849<refsect1> 42850 <title>Arguments</title> 42851 <variablelist> 42852 <varlistentry> 42853 <term><parameter>disk</parameter></term> 42854 <listitem> 42855 <para> 42856 disk to unblock events for 42857 </para> 42858 </listitem> 42859 </varlistentry> 42860 </variablelist> 42861</refsect1> 42862<refsect1> 42863<title>Description</title> 42864<para> 42865 Undo <function>disk_block_events</function>. When the block count reaches zero, it 42866 starts events polling if configured. 42867</para> 42868</refsect1> 42869<refsect1> 42870<title>CONTEXT</title> 42871<para> 42872 Don't care. Safe to call from irq context. 42873</para> 42874</refsect1> 42875</refentry> 42876 42877<refentry id="API-disk-flush-events"> 42878<refentryinfo> 42879 <title>LINUX</title> 42880 <productname>Kernel Hackers Manual</productname> 42881 <date>July 2017</date> 42882</refentryinfo> 42883<refmeta> 42884 <refentrytitle><phrase>disk_flush_events</phrase></refentrytitle> 42885 <manvolnum>9</manvolnum> 42886 <refmiscinfo class="version">4.1.27</refmiscinfo> 42887</refmeta> 42888<refnamediv> 42889 <refname>disk_flush_events</refname> 42890 <refpurpose> 42891 schedule immediate event checking and flushing 42892 </refpurpose> 42893</refnamediv> 42894<refsynopsisdiv> 42895 <title>Synopsis</title> 42896 <funcsynopsis><funcprototype> 42897 <funcdef>void <function>disk_flush_events </function></funcdef> 42898 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 42899 <paramdef>unsigned int <parameter>mask</parameter></paramdef> 42900 </funcprototype></funcsynopsis> 42901</refsynopsisdiv> 42902<refsect1> 42903 <title>Arguments</title> 42904 <variablelist> 42905 <varlistentry> 42906 <term><parameter>disk</parameter></term> 42907 <listitem> 42908 <para> 42909 disk to check and flush events for 42910 </para> 42911 </listitem> 42912 </varlistentry> 42913 <varlistentry> 42914 <term><parameter>mask</parameter></term> 42915 <listitem> 42916 <para> 42917 events to flush 42918 </para> 42919 </listitem> 42920 </varlistentry> 42921 </variablelist> 42922</refsect1> 42923<refsect1> 42924<title>Description</title> 42925<para> 42926 Schedule immediate event checking on <parameter>disk</parameter> if not blocked. Events in 42927 <parameter>mask</parameter> are scheduled to be cleared from the driver. Note that this 42928 doesn't clear the events from <parameter>disk</parameter>->ev. 42929</para> 42930</refsect1> 42931<refsect1> 42932<title>CONTEXT</title> 42933<para> 42934 If <parameter>mask</parameter> is non-zero must be called with bdev->bd_mutex held. 42935</para> 42936</refsect1> 42937</refentry> 42938 42939<refentry id="API-disk-clear-events"> 42940<refentryinfo> 42941 <title>LINUX</title> 42942 <productname>Kernel Hackers Manual</productname> 42943 <date>July 2017</date> 42944</refentryinfo> 42945<refmeta> 42946 <refentrytitle><phrase>disk_clear_events</phrase></refentrytitle> 42947 <manvolnum>9</manvolnum> 42948 <refmiscinfo class="version">4.1.27</refmiscinfo> 42949</refmeta> 42950<refnamediv> 42951 <refname>disk_clear_events</refname> 42952 <refpurpose> 42953 synchronously check, clear and return pending events 42954 </refpurpose> 42955</refnamediv> 42956<refsynopsisdiv> 42957 <title>Synopsis</title> 42958 <funcsynopsis><funcprototype> 42959 <funcdef>unsigned int <function>disk_clear_events </function></funcdef> 42960 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 42961 <paramdef>unsigned int <parameter>mask</parameter></paramdef> 42962 </funcprototype></funcsynopsis> 42963</refsynopsisdiv> 42964<refsect1> 42965 <title>Arguments</title> 42966 <variablelist> 42967 <varlistentry> 42968 <term><parameter>disk</parameter></term> 42969 <listitem> 42970 <para> 42971 disk to fetch and clear events from 42972 </para> 42973 </listitem> 42974 </varlistentry> 42975 <varlistentry> 42976 <term><parameter>mask</parameter></term> 42977 <listitem> 42978 <para> 42979 mask of events to be fetched and cleared 42980 </para> 42981 </listitem> 42982 </varlistentry> 42983 </variablelist> 42984</refsect1> 42985<refsect1> 42986<title>Description</title> 42987<para> 42988 Disk events are synchronously checked and pending events in <parameter>mask</parameter> 42989 are cleared and returned. This ignores the block count. 42990</para> 42991</refsect1> 42992<refsect1> 42993<title>CONTEXT</title> 42994<para> 42995 Might sleep. 42996</para> 42997</refsect1> 42998</refentry> 42999 43000<!-- block/genhd.c --> 43001<refentry id="API-disk-get-part"> 43002<refentryinfo> 43003 <title>LINUX</title> 43004 <productname>Kernel Hackers Manual</productname> 43005 <date>July 2017</date> 43006</refentryinfo> 43007<refmeta> 43008 <refentrytitle><phrase>disk_get_part</phrase></refentrytitle> 43009 <manvolnum>9</manvolnum> 43010 <refmiscinfo class="version">4.1.27</refmiscinfo> 43011</refmeta> 43012<refnamediv> 43013 <refname>disk_get_part</refname> 43014 <refpurpose> 43015 get partition 43016 </refpurpose> 43017</refnamediv> 43018<refsynopsisdiv> 43019 <title>Synopsis</title> 43020 <funcsynopsis><funcprototype> 43021 <funcdef>struct hd_struct * <function>disk_get_part </function></funcdef> 43022 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 43023 <paramdef>int <parameter>partno</parameter></paramdef> 43024 </funcprototype></funcsynopsis> 43025</refsynopsisdiv> 43026<refsect1> 43027 <title>Arguments</title> 43028 <variablelist> 43029 <varlistentry> 43030 <term><parameter>disk</parameter></term> 43031 <listitem> 43032 <para> 43033 disk to look partition from 43034 </para> 43035 </listitem> 43036 </varlistentry> 43037 <varlistentry> 43038 <term><parameter>partno</parameter></term> 43039 <listitem> 43040 <para> 43041 partition number 43042 </para> 43043 </listitem> 43044 </varlistentry> 43045 </variablelist> 43046</refsect1> 43047<refsect1> 43048<title>Description</title> 43049<para> 43050 Look for partition <parameter>partno</parameter> from <parameter>disk</parameter>. If found, increment 43051 reference count and return it. 43052</para> 43053</refsect1> 43054<refsect1> 43055<title>CONTEXT</title> 43056<para> 43057 Don't care. 43058</para> 43059</refsect1> 43060<refsect1> 43061<title>RETURNS</title> 43062<para> 43063 Pointer to the found partition on success, NULL if not found. 43064</para> 43065</refsect1> 43066</refentry> 43067 43068<refentry id="API-disk-part-iter-init"> 43069<refentryinfo> 43070 <title>LINUX</title> 43071 <productname>Kernel Hackers Manual</productname> 43072 <date>July 2017</date> 43073</refentryinfo> 43074<refmeta> 43075 <refentrytitle><phrase>disk_part_iter_init</phrase></refentrytitle> 43076 <manvolnum>9</manvolnum> 43077 <refmiscinfo class="version">4.1.27</refmiscinfo> 43078</refmeta> 43079<refnamediv> 43080 <refname>disk_part_iter_init</refname> 43081 <refpurpose> 43082 initialize partition iterator 43083 </refpurpose> 43084</refnamediv> 43085<refsynopsisdiv> 43086 <title>Synopsis</title> 43087 <funcsynopsis><funcprototype> 43088 <funcdef>void <function>disk_part_iter_init </function></funcdef> 43089 <paramdef>struct disk_part_iter * <parameter>piter</parameter></paramdef> 43090 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 43091 <paramdef>unsigned int <parameter>flags</parameter></paramdef> 43092 </funcprototype></funcsynopsis> 43093</refsynopsisdiv> 43094<refsect1> 43095 <title>Arguments</title> 43096 <variablelist> 43097 <varlistentry> 43098 <term><parameter>piter</parameter></term> 43099 <listitem> 43100 <para> 43101 iterator to initialize 43102 </para> 43103 </listitem> 43104 </varlistentry> 43105 <varlistentry> 43106 <term><parameter>disk</parameter></term> 43107 <listitem> 43108 <para> 43109 disk to iterate over 43110 </para> 43111 </listitem> 43112 </varlistentry> 43113 <varlistentry> 43114 <term><parameter>flags</parameter></term> 43115 <listitem> 43116 <para> 43117 DISK_PITER_* flags 43118 </para> 43119 </listitem> 43120 </varlistentry> 43121 </variablelist> 43122</refsect1> 43123<refsect1> 43124<title>Description</title> 43125<para> 43126 Initialize <parameter>piter</parameter> so that it iterates over partitions of <parameter>disk</parameter>. 43127</para> 43128</refsect1> 43129<refsect1> 43130<title>CONTEXT</title> 43131<para> 43132 Don't care. 43133</para> 43134</refsect1> 43135</refentry> 43136 43137<refentry id="API-disk-part-iter-next"> 43138<refentryinfo> 43139 <title>LINUX</title> 43140 <productname>Kernel Hackers Manual</productname> 43141 <date>July 2017</date> 43142</refentryinfo> 43143<refmeta> 43144 <refentrytitle><phrase>disk_part_iter_next</phrase></refentrytitle> 43145 <manvolnum>9</manvolnum> 43146 <refmiscinfo class="version">4.1.27</refmiscinfo> 43147</refmeta> 43148<refnamediv> 43149 <refname>disk_part_iter_next</refname> 43150 <refpurpose> 43151 proceed iterator to the next partition and return it 43152 </refpurpose> 43153</refnamediv> 43154<refsynopsisdiv> 43155 <title>Synopsis</title> 43156 <funcsynopsis><funcprototype> 43157 <funcdef>struct hd_struct * <function>disk_part_iter_next </function></funcdef> 43158 <paramdef>struct disk_part_iter * <parameter>piter</parameter></paramdef> 43159 </funcprototype></funcsynopsis> 43160</refsynopsisdiv> 43161<refsect1> 43162 <title>Arguments</title> 43163 <variablelist> 43164 <varlistentry> 43165 <term><parameter>piter</parameter></term> 43166 <listitem> 43167 <para> 43168 iterator of interest 43169 </para> 43170 </listitem> 43171 </varlistentry> 43172 </variablelist> 43173</refsect1> 43174<refsect1> 43175<title>Description</title> 43176<para> 43177 Proceed <parameter>piter</parameter> to the next partition and return it. 43178</para> 43179</refsect1> 43180<refsect1> 43181<title>CONTEXT</title> 43182<para> 43183 Don't care. 43184</para> 43185</refsect1> 43186</refentry> 43187 43188<refentry id="API-disk-part-iter-exit"> 43189<refentryinfo> 43190 <title>LINUX</title> 43191 <productname>Kernel Hackers Manual</productname> 43192 <date>July 2017</date> 43193</refentryinfo> 43194<refmeta> 43195 <refentrytitle><phrase>disk_part_iter_exit</phrase></refentrytitle> 43196 <manvolnum>9</manvolnum> 43197 <refmiscinfo class="version">4.1.27</refmiscinfo> 43198</refmeta> 43199<refnamediv> 43200 <refname>disk_part_iter_exit</refname> 43201 <refpurpose> 43202 finish up partition iteration 43203 </refpurpose> 43204</refnamediv> 43205<refsynopsisdiv> 43206 <title>Synopsis</title> 43207 <funcsynopsis><funcprototype> 43208 <funcdef>void <function>disk_part_iter_exit </function></funcdef> 43209 <paramdef>struct disk_part_iter * <parameter>piter</parameter></paramdef> 43210 </funcprototype></funcsynopsis> 43211</refsynopsisdiv> 43212<refsect1> 43213 <title>Arguments</title> 43214 <variablelist> 43215 <varlistentry> 43216 <term><parameter>piter</parameter></term> 43217 <listitem> 43218 <para> 43219 iter of interest 43220 </para> 43221 </listitem> 43222 </varlistentry> 43223 </variablelist> 43224</refsect1> 43225<refsect1> 43226<title>Description</title> 43227<para> 43228 Called when iteration is over. Cleans up <parameter>piter</parameter>. 43229</para> 43230</refsect1> 43231<refsect1> 43232<title>CONTEXT</title> 43233<para> 43234 Don't care. 43235</para> 43236</refsect1> 43237</refentry> 43238 43239<refentry id="API-disk-map-sector-rcu"> 43240<refentryinfo> 43241 <title>LINUX</title> 43242 <productname>Kernel Hackers Manual</productname> 43243 <date>July 2017</date> 43244</refentryinfo> 43245<refmeta> 43246 <refentrytitle><phrase>disk_map_sector_rcu</phrase></refentrytitle> 43247 <manvolnum>9</manvolnum> 43248 <refmiscinfo class="version">4.1.27</refmiscinfo> 43249</refmeta> 43250<refnamediv> 43251 <refname>disk_map_sector_rcu</refname> 43252 <refpurpose> 43253 map sector to partition 43254 </refpurpose> 43255</refnamediv> 43256<refsynopsisdiv> 43257 <title>Synopsis</title> 43258 <funcsynopsis><funcprototype> 43259 <funcdef>struct hd_struct * <function>disk_map_sector_rcu </function></funcdef> 43260 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 43261 <paramdef>sector_t <parameter>sector</parameter></paramdef> 43262 </funcprototype></funcsynopsis> 43263</refsynopsisdiv> 43264<refsect1> 43265 <title>Arguments</title> 43266 <variablelist> 43267 <varlistentry> 43268 <term><parameter>disk</parameter></term> 43269 <listitem> 43270 <para> 43271 gendisk of interest 43272 </para> 43273 </listitem> 43274 </varlistentry> 43275 <varlistentry> 43276 <term><parameter>sector</parameter></term> 43277 <listitem> 43278 <para> 43279 sector to map 43280 </para> 43281 </listitem> 43282 </varlistentry> 43283 </variablelist> 43284</refsect1> 43285<refsect1> 43286<title>Description</title> 43287<para> 43288 Find out which partition <parameter>sector</parameter> maps to on <parameter>disk</parameter>. This is 43289 primarily used for stats accounting. 43290</para> 43291</refsect1> 43292<refsect1> 43293<title>CONTEXT</title> 43294<para> 43295 RCU read locked. The returned partition pointer is valid only 43296 while preemption is disabled. 43297</para> 43298</refsect1> 43299<refsect1> 43300<title>RETURNS</title> 43301<para> 43302 Found partition on success, part0 is returned if no partition matches 43303</para> 43304</refsect1> 43305</refentry> 43306 43307<refentry id="API-register-blkdev"> 43308<refentryinfo> 43309 <title>LINUX</title> 43310 <productname>Kernel Hackers Manual</productname> 43311 <date>July 2017</date> 43312</refentryinfo> 43313<refmeta> 43314 <refentrytitle><phrase>register_blkdev</phrase></refentrytitle> 43315 <manvolnum>9</manvolnum> 43316 <refmiscinfo class="version">4.1.27</refmiscinfo> 43317</refmeta> 43318<refnamediv> 43319 <refname>register_blkdev</refname> 43320 <refpurpose> 43321 register a new block device 43322 </refpurpose> 43323</refnamediv> 43324<refsynopsisdiv> 43325 <title>Synopsis</title> 43326 <funcsynopsis><funcprototype> 43327 <funcdef>int <function>register_blkdev </function></funcdef> 43328 <paramdef>unsigned int <parameter>major</parameter></paramdef> 43329 <paramdef>const char * <parameter>name</parameter></paramdef> 43330 </funcprototype></funcsynopsis> 43331</refsynopsisdiv> 43332<refsect1> 43333 <title>Arguments</title> 43334 <variablelist> 43335 <varlistentry> 43336 <term><parameter>major</parameter></term> 43337 <listitem> 43338 <para> 43339 the requested major device number [1..255]. If <parameter>major</parameter>=0, try to 43340 allocate any unused major number. 43341 </para> 43342 </listitem> 43343 </varlistentry> 43344 <varlistentry> 43345 <term><parameter>name</parameter></term> 43346 <listitem> 43347 <para> 43348 the name of the new block device as a zero terminated string 43349 </para> 43350 </listitem> 43351 </varlistentry> 43352 </variablelist> 43353</refsect1> 43354<refsect1> 43355<title>Description</title> 43356<para> 43357 The <parameter>name</parameter> must be unique within the system. 43358 </para><para> 43359 43360 The return value depends on the <parameter>major</parameter> input parameter. 43361 - if a major device number was requested in range [1..255] then the 43362 function returns zero on success, or a negative error code 43363 - if any unused major number was requested with <parameter>major</parameter>=0 parameter 43364 then the return value is the allocated major number in range 43365 [1..255] or a negative error code otherwise 43366</para> 43367</refsect1> 43368</refentry> 43369 43370<refentry id="API-add-disk"> 43371<refentryinfo> 43372 <title>LINUX</title> 43373 <productname>Kernel Hackers Manual</productname> 43374 <date>July 2017</date> 43375</refentryinfo> 43376<refmeta> 43377 <refentrytitle><phrase>add_disk</phrase></refentrytitle> 43378 <manvolnum>9</manvolnum> 43379 <refmiscinfo class="version">4.1.27</refmiscinfo> 43380</refmeta> 43381<refnamediv> 43382 <refname>add_disk</refname> 43383 <refpurpose> 43384 add partitioning information to kernel list 43385 </refpurpose> 43386</refnamediv> 43387<refsynopsisdiv> 43388 <title>Synopsis</title> 43389 <funcsynopsis><funcprototype> 43390 <funcdef>void <function>add_disk </function></funcdef> 43391 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 43392 </funcprototype></funcsynopsis> 43393</refsynopsisdiv> 43394<refsect1> 43395 <title>Arguments</title> 43396 <variablelist> 43397 <varlistentry> 43398 <term><parameter>disk</parameter></term> 43399 <listitem> 43400 <para> 43401 per-device partitioning information 43402 </para> 43403 </listitem> 43404 </varlistentry> 43405 </variablelist> 43406</refsect1> 43407<refsect1> 43408<title>Description</title> 43409<para> 43410 This function registers the partitioning information in <parameter>disk</parameter> 43411 with the kernel. 43412</para> 43413</refsect1> 43414<refsect1> 43415<title>FIXME</title> 43416<para> 43417 error handling 43418</para> 43419</refsect1> 43420</refentry> 43421 43422<refentry id="API-get-gendisk"> 43423<refentryinfo> 43424 <title>LINUX</title> 43425 <productname>Kernel Hackers Manual</productname> 43426 <date>July 2017</date> 43427</refentryinfo> 43428<refmeta> 43429 <refentrytitle><phrase>get_gendisk</phrase></refentrytitle> 43430 <manvolnum>9</manvolnum> 43431 <refmiscinfo class="version">4.1.27</refmiscinfo> 43432</refmeta> 43433<refnamediv> 43434 <refname>get_gendisk</refname> 43435 <refpurpose> 43436 get partitioning information for a given device 43437 </refpurpose> 43438</refnamediv> 43439<refsynopsisdiv> 43440 <title>Synopsis</title> 43441 <funcsynopsis><funcprototype> 43442 <funcdef>struct gendisk * <function>get_gendisk </function></funcdef> 43443 <paramdef>dev_t <parameter>devt</parameter></paramdef> 43444 <paramdef>int * <parameter>partno</parameter></paramdef> 43445 </funcprototype></funcsynopsis> 43446</refsynopsisdiv> 43447<refsect1> 43448 <title>Arguments</title> 43449 <variablelist> 43450 <varlistentry> 43451 <term><parameter>devt</parameter></term> 43452 <listitem> 43453 <para> 43454 device to get partitioning information for 43455 </para> 43456 </listitem> 43457 </varlistentry> 43458 <varlistentry> 43459 <term><parameter>partno</parameter></term> 43460 <listitem> 43461 <para> 43462 returned partition index 43463 </para> 43464 </listitem> 43465 </varlistentry> 43466 </variablelist> 43467</refsect1> 43468<refsect1> 43469<title>Description</title> 43470<para> 43471 This function gets the structure containing partitioning 43472 information for the given device <parameter>devt</parameter>. 43473</para> 43474</refsect1> 43475</refentry> 43476 43477<refentry id="API-bdget-disk"> 43478<refentryinfo> 43479 <title>LINUX</title> 43480 <productname>Kernel Hackers Manual</productname> 43481 <date>July 2017</date> 43482</refentryinfo> 43483<refmeta> 43484 <refentrytitle><phrase>bdget_disk</phrase></refentrytitle> 43485 <manvolnum>9</manvolnum> 43486 <refmiscinfo class="version">4.1.27</refmiscinfo> 43487</refmeta> 43488<refnamediv> 43489 <refname>bdget_disk</refname> 43490 <refpurpose> 43491 do <function>bdget</function> by gendisk and partition number 43492 </refpurpose> 43493</refnamediv> 43494<refsynopsisdiv> 43495 <title>Synopsis</title> 43496 <funcsynopsis><funcprototype> 43497 <funcdef>struct block_device * <function>bdget_disk </function></funcdef> 43498 <paramdef>struct gendisk * <parameter>disk</parameter></paramdef> 43499 <paramdef>int <parameter>partno</parameter></paramdef> 43500 </funcprototype></funcsynopsis> 43501</refsynopsisdiv> 43502<refsect1> 43503 <title>Arguments</title> 43504 <variablelist> 43505 <varlistentry> 43506 <term><parameter>disk</parameter></term> 43507 <listitem> 43508 <para> 43509 gendisk of interest 43510 </para> 43511 </listitem> 43512 </varlistentry> 43513 <varlistentry> 43514 <term><parameter>partno</parameter></term> 43515 <listitem> 43516 <para> 43517 partition number 43518 </para> 43519 </listitem> 43520 </varlistentry> 43521 </variablelist> 43522</refsect1> 43523<refsect1> 43524<title>Description</title> 43525<para> 43526 Find partition <parameter>partno</parameter> from <parameter>disk</parameter>, do <function>bdget</function> on it. 43527</para> 43528</refsect1> 43529<refsect1> 43530<title>CONTEXT</title> 43531<para> 43532 Don't care. 43533</para> 43534</refsect1> 43535<refsect1> 43536<title>RETURNS</title> 43537<para> 43538 Resulting block_device on success, NULL on failure. 43539</para> 43540</refsect1> 43541</refentry> 43542 43543 </chapter> 43544 43545 <chapter id="chrdev"> 43546 <title>Char devices</title> 43547<!-- fs/char_dev.c --> 43548<refentry id="API-register-chrdev-region"> 43549<refentryinfo> 43550 <title>LINUX</title> 43551 <productname>Kernel Hackers Manual</productname> 43552 <date>July 2017</date> 43553</refentryinfo> 43554<refmeta> 43555 <refentrytitle><phrase>register_chrdev_region</phrase></refentrytitle> 43556 <manvolnum>9</manvolnum> 43557 <refmiscinfo class="version">4.1.27</refmiscinfo> 43558</refmeta> 43559<refnamediv> 43560 <refname>register_chrdev_region</refname> 43561 <refpurpose> 43562 register a range of device numbers 43563 </refpurpose> 43564</refnamediv> 43565<refsynopsisdiv> 43566 <title>Synopsis</title> 43567 <funcsynopsis><funcprototype> 43568 <funcdef>int <function>register_chrdev_region </function></funcdef> 43569 <paramdef>dev_t <parameter>from</parameter></paramdef> 43570 <paramdef>unsigned <parameter>count</parameter></paramdef> 43571 <paramdef>const char * <parameter>name</parameter></paramdef> 43572 </funcprototype></funcsynopsis> 43573</refsynopsisdiv> 43574<refsect1> 43575 <title>Arguments</title> 43576 <variablelist> 43577 <varlistentry> 43578 <term><parameter>from</parameter></term> 43579 <listitem> 43580 <para> 43581 the first in the desired range of device numbers; must include 43582 the major number. 43583 </para> 43584 </listitem> 43585 </varlistentry> 43586 <varlistentry> 43587 <term><parameter>count</parameter></term> 43588 <listitem> 43589 <para> 43590 the number of consecutive device numbers required 43591 </para> 43592 </listitem> 43593 </varlistentry> 43594 <varlistentry> 43595 <term><parameter>name</parameter></term> 43596 <listitem> 43597 <para> 43598 the name of the device or driver. 43599 </para> 43600 </listitem> 43601 </varlistentry> 43602 </variablelist> 43603</refsect1> 43604<refsect1> 43605<title>Description</title> 43606<para> 43607 Return value is zero on success, a negative error code on failure. 43608</para> 43609</refsect1> 43610</refentry> 43611 43612<refentry id="API-alloc-chrdev-region"> 43613<refentryinfo> 43614 <title>LINUX</title> 43615 <productname>Kernel Hackers Manual</productname> 43616 <date>July 2017</date> 43617</refentryinfo> 43618<refmeta> 43619 <refentrytitle><phrase>alloc_chrdev_region</phrase></refentrytitle> 43620 <manvolnum>9</manvolnum> 43621 <refmiscinfo class="version">4.1.27</refmiscinfo> 43622</refmeta> 43623<refnamediv> 43624 <refname>alloc_chrdev_region</refname> 43625 <refpurpose> 43626 register a range of char device numbers 43627 </refpurpose> 43628</refnamediv> 43629<refsynopsisdiv> 43630 <title>Synopsis</title> 43631 <funcsynopsis><funcprototype> 43632 <funcdef>int <function>alloc_chrdev_region </function></funcdef> 43633 <paramdef>dev_t * <parameter>dev</parameter></paramdef> 43634 <paramdef>unsigned <parameter>baseminor</parameter></paramdef> 43635 <paramdef>unsigned <parameter>count</parameter></paramdef> 43636 <paramdef>const char * <parameter>name</parameter></paramdef> 43637 </funcprototype></funcsynopsis> 43638</refsynopsisdiv> 43639<refsect1> 43640 <title>Arguments</title> 43641 <variablelist> 43642 <varlistentry> 43643 <term><parameter>dev</parameter></term> 43644 <listitem> 43645 <para> 43646 output parameter for first assigned number 43647 </para> 43648 </listitem> 43649 </varlistentry> 43650 <varlistentry> 43651 <term><parameter>baseminor</parameter></term> 43652 <listitem> 43653 <para> 43654 first of the requested range of minor numbers 43655 </para> 43656 </listitem> 43657 </varlistentry> 43658 <varlistentry> 43659 <term><parameter>count</parameter></term> 43660 <listitem> 43661 <para> 43662 the number of minor numbers required 43663 </para> 43664 </listitem> 43665 </varlistentry> 43666 <varlistentry> 43667 <term><parameter>name</parameter></term> 43668 <listitem> 43669 <para> 43670 the name of the associated device or driver 43671 </para> 43672 </listitem> 43673 </varlistentry> 43674 </variablelist> 43675</refsect1> 43676<refsect1> 43677<title>Description</title> 43678<para> 43679 Allocates a range of char device numbers. The major number will be 43680 chosen dynamically, and returned (along with the first minor number) 43681 in <parameter>dev</parameter>. Returns zero or a negative error code. 43682</para> 43683</refsect1> 43684</refentry> 43685 43686<refentry id="API---register-chrdev"> 43687<refentryinfo> 43688 <title>LINUX</title> 43689 <productname>Kernel Hackers Manual</productname> 43690 <date>July 2017</date> 43691</refentryinfo> 43692<refmeta> 43693 <refentrytitle><phrase>__register_chrdev</phrase></refentrytitle> 43694 <manvolnum>9</manvolnum> 43695 <refmiscinfo class="version">4.1.27</refmiscinfo> 43696</refmeta> 43697<refnamediv> 43698 <refname>__register_chrdev</refname> 43699 <refpurpose> 43700 create and register a cdev occupying a range of minors 43701 </refpurpose> 43702</refnamediv> 43703<refsynopsisdiv> 43704 <title>Synopsis</title> 43705 <funcsynopsis><funcprototype> 43706 <funcdef>int <function>__register_chrdev </function></funcdef> 43707 <paramdef>unsigned int <parameter>major</parameter></paramdef> 43708 <paramdef>unsigned int <parameter>baseminor</parameter></paramdef> 43709 <paramdef>unsigned int <parameter>count</parameter></paramdef> 43710 <paramdef>const char * <parameter>name</parameter></paramdef> 43711 <paramdef>const struct file_operations * <parameter>fops</parameter></paramdef> 43712 </funcprototype></funcsynopsis> 43713</refsynopsisdiv> 43714<refsect1> 43715 <title>Arguments</title> 43716 <variablelist> 43717 <varlistentry> 43718 <term><parameter>major</parameter></term> 43719 <listitem> 43720 <para> 43721 major device number or 0 for dynamic allocation 43722 </para> 43723 </listitem> 43724 </varlistentry> 43725 <varlistentry> 43726 <term><parameter>baseminor</parameter></term> 43727 <listitem> 43728 <para> 43729 first of the requested range of minor numbers 43730 </para> 43731 </listitem> 43732 </varlistentry> 43733 <varlistentry> 43734 <term><parameter>count</parameter></term> 43735 <listitem> 43736 <para> 43737 the number of minor numbers required 43738 </para> 43739 </listitem> 43740 </varlistentry> 43741 <varlistentry> 43742 <term><parameter>name</parameter></term> 43743 <listitem> 43744 <para> 43745 name of this range of devices 43746 </para> 43747 </listitem> 43748 </varlistentry> 43749 <varlistentry> 43750 <term><parameter>fops</parameter></term> 43751 <listitem> 43752 <para> 43753 file operations associated with this devices 43754 </para> 43755 </listitem> 43756 </varlistentry> 43757 </variablelist> 43758</refsect1> 43759<refsect1> 43760<title>Description</title> 43761<para> 43762 If <parameter>major</parameter> == 0 this functions will dynamically allocate a major and return 43763 its number. 43764 </para><para> 43765 43766 If <parameter>major</parameter> > 0 this function will attempt to reserve a device with the given 43767 major number and will return zero on success. 43768 </para><para> 43769 43770 Returns a -ve errno on failure. 43771 </para><para> 43772 43773 The name of this device has nothing to do with the name of the device in 43774 /dev. It only helps to keep track of the different owners of devices. If 43775 your module name has only one type of devices it's ok to use e.g. the name 43776 of the module here. 43777</para> 43778</refsect1> 43779</refentry> 43780 43781<refentry id="API-unregister-chrdev-region"> 43782<refentryinfo> 43783 <title>LINUX</title> 43784 <productname>Kernel Hackers Manual</productname> 43785 <date>July 2017</date> 43786</refentryinfo> 43787<refmeta> 43788 <refentrytitle><phrase>unregister_chrdev_region</phrase></refentrytitle> 43789 <manvolnum>9</manvolnum> 43790 <refmiscinfo class="version">4.1.27</refmiscinfo> 43791</refmeta> 43792<refnamediv> 43793 <refname>unregister_chrdev_region</refname> 43794 <refpurpose> 43795 return a range of device numbers 43796 </refpurpose> 43797</refnamediv> 43798<refsynopsisdiv> 43799 <title>Synopsis</title> 43800 <funcsynopsis><funcprototype> 43801 <funcdef>void <function>unregister_chrdev_region </function></funcdef> 43802 <paramdef>dev_t <parameter>from</parameter></paramdef> 43803 <paramdef>unsigned <parameter>count</parameter></paramdef> 43804 </funcprototype></funcsynopsis> 43805</refsynopsisdiv> 43806<refsect1> 43807 <title>Arguments</title> 43808 <variablelist> 43809 <varlistentry> 43810 <term><parameter>from</parameter></term> 43811 <listitem> 43812 <para> 43813 the first in the range of numbers to unregister 43814 </para> 43815 </listitem> 43816 </varlistentry> 43817 <varlistentry> 43818 <term><parameter>count</parameter></term> 43819 <listitem> 43820 <para> 43821 the number of device numbers to unregister 43822 </para> 43823 </listitem> 43824 </varlistentry> 43825 </variablelist> 43826</refsect1> 43827<refsect1> 43828<title>Description</title> 43829<para> 43830 This function will unregister a range of <parameter>count</parameter> device numbers, 43831 starting with <parameter>from</parameter>. The caller should normally be the one who 43832 allocated those numbers in the first place... 43833</para> 43834</refsect1> 43835</refentry> 43836 43837<refentry id="API---unregister-chrdev"> 43838<refentryinfo> 43839 <title>LINUX</title> 43840 <productname>Kernel Hackers Manual</productname> 43841 <date>July 2017</date> 43842</refentryinfo> 43843<refmeta> 43844 <refentrytitle><phrase>__unregister_chrdev</phrase></refentrytitle> 43845 <manvolnum>9</manvolnum> 43846 <refmiscinfo class="version">4.1.27</refmiscinfo> 43847</refmeta> 43848<refnamediv> 43849 <refname>__unregister_chrdev</refname> 43850 <refpurpose> 43851 unregister and destroy a cdev 43852 </refpurpose> 43853</refnamediv> 43854<refsynopsisdiv> 43855 <title>Synopsis</title> 43856 <funcsynopsis><funcprototype> 43857 <funcdef>void <function>__unregister_chrdev </function></funcdef> 43858 <paramdef>unsigned int <parameter>major</parameter></paramdef> 43859 <paramdef>unsigned int <parameter>baseminor</parameter></paramdef> 43860 <paramdef>unsigned int <parameter>count</parameter></paramdef> 43861 <paramdef>const char * <parameter>name</parameter></paramdef> 43862 </funcprototype></funcsynopsis> 43863</refsynopsisdiv> 43864<refsect1> 43865 <title>Arguments</title> 43866 <variablelist> 43867 <varlistentry> 43868 <term><parameter>major</parameter></term> 43869 <listitem> 43870 <para> 43871 major device number 43872 </para> 43873 </listitem> 43874 </varlistentry> 43875 <varlistentry> 43876 <term><parameter>baseminor</parameter></term> 43877 <listitem> 43878 <para> 43879 first of the range of minor numbers 43880 </para> 43881 </listitem> 43882 </varlistentry> 43883 <varlistentry> 43884 <term><parameter>count</parameter></term> 43885 <listitem> 43886 <para> 43887 the number of minor numbers this cdev is occupying 43888 </para> 43889 </listitem> 43890 </varlistentry> 43891 <varlistentry> 43892 <term><parameter>name</parameter></term> 43893 <listitem> 43894 <para> 43895 name of this range of devices 43896 </para> 43897 </listitem> 43898 </varlistentry> 43899 </variablelist> 43900</refsect1> 43901<refsect1> 43902<title>Description</title> 43903<para> 43904 Unregister and destroy the cdev occupying the region described by 43905 <parameter>major</parameter>, <parameter>baseminor</parameter> and <parameter>count</parameter>. This function undoes what 43906 <function>__register_chrdev</function> did. 43907</para> 43908</refsect1> 43909</refentry> 43910 43911<refentry id="API-cdev-add"> 43912<refentryinfo> 43913 <title>LINUX</title> 43914 <productname>Kernel Hackers Manual</productname> 43915 <date>July 2017</date> 43916</refentryinfo> 43917<refmeta> 43918 <refentrytitle><phrase>cdev_add</phrase></refentrytitle> 43919 <manvolnum>9</manvolnum> 43920 <refmiscinfo class="version">4.1.27</refmiscinfo> 43921</refmeta> 43922<refnamediv> 43923 <refname>cdev_add</refname> 43924 <refpurpose> 43925 add a char device to the system 43926 </refpurpose> 43927</refnamediv> 43928<refsynopsisdiv> 43929 <title>Synopsis</title> 43930 <funcsynopsis><funcprototype> 43931 <funcdef>int <function>cdev_add </function></funcdef> 43932 <paramdef>struct cdev * <parameter>p</parameter></paramdef> 43933 <paramdef>dev_t <parameter>dev</parameter></paramdef> 43934 <paramdef>unsigned <parameter>count</parameter></paramdef> 43935 </funcprototype></funcsynopsis> 43936</refsynopsisdiv> 43937<refsect1> 43938 <title>Arguments</title> 43939 <variablelist> 43940 <varlistentry> 43941 <term><parameter>p</parameter></term> 43942 <listitem> 43943 <para> 43944 the cdev structure for the device 43945 </para> 43946 </listitem> 43947 </varlistentry> 43948 <varlistentry> 43949 <term><parameter>dev</parameter></term> 43950 <listitem> 43951 <para> 43952 the first device number for which this device is responsible 43953 </para> 43954 </listitem> 43955 </varlistentry> 43956 <varlistentry> 43957 <term><parameter>count</parameter></term> 43958 <listitem> 43959 <para> 43960 the number of consecutive minor numbers corresponding to this 43961 device 43962 </para> 43963 </listitem> 43964 </varlistentry> 43965 </variablelist> 43966</refsect1> 43967<refsect1> 43968<title>Description</title> 43969<para> 43970 <function>cdev_add</function> adds the device represented by <parameter>p</parameter> to the system, making it 43971 live immediately. A negative error code is returned on failure. 43972</para> 43973</refsect1> 43974</refentry> 43975 43976<refentry id="API-cdev-del"> 43977<refentryinfo> 43978 <title>LINUX</title> 43979 <productname>Kernel Hackers Manual</productname> 43980 <date>July 2017</date> 43981</refentryinfo> 43982<refmeta> 43983 <refentrytitle><phrase>cdev_del</phrase></refentrytitle> 43984 <manvolnum>9</manvolnum> 43985 <refmiscinfo class="version">4.1.27</refmiscinfo> 43986</refmeta> 43987<refnamediv> 43988 <refname>cdev_del</refname> 43989 <refpurpose> 43990 remove a cdev from the system 43991 </refpurpose> 43992</refnamediv> 43993<refsynopsisdiv> 43994 <title>Synopsis</title> 43995 <funcsynopsis><funcprototype> 43996 <funcdef>void <function>cdev_del </function></funcdef> 43997 <paramdef>struct cdev * <parameter>p</parameter></paramdef> 43998 </funcprototype></funcsynopsis> 43999</refsynopsisdiv> 44000<refsect1> 44001 <title>Arguments</title> 44002 <variablelist> 44003 <varlistentry> 44004 <term><parameter>p</parameter></term> 44005 <listitem> 44006 <para> 44007 the cdev structure to be removed 44008 </para> 44009 </listitem> 44010 </varlistentry> 44011 </variablelist> 44012</refsect1> 44013<refsect1> 44014<title>Description</title> 44015<para> 44016 <function>cdev_del</function> removes <parameter>p</parameter> from the system, possibly freeing the structure 44017 itself. 44018</para> 44019</refsect1> 44020</refentry> 44021 44022<refentry id="API-cdev-alloc"> 44023<refentryinfo> 44024 <title>LINUX</title> 44025 <productname>Kernel Hackers Manual</productname> 44026 <date>July 2017</date> 44027</refentryinfo> 44028<refmeta> 44029 <refentrytitle><phrase>cdev_alloc</phrase></refentrytitle> 44030 <manvolnum>9</manvolnum> 44031 <refmiscinfo class="version">4.1.27</refmiscinfo> 44032</refmeta> 44033<refnamediv> 44034 <refname>cdev_alloc</refname> 44035 <refpurpose> 44036 allocate a cdev structure 44037 </refpurpose> 44038</refnamediv> 44039<refsynopsisdiv> 44040 <title>Synopsis</title> 44041 <funcsynopsis><funcprototype> 44042 <funcdef>struct cdev * <function>cdev_alloc </function></funcdef> 44043 <paramdef> <parameter>void</parameter></paramdef> 44044 </funcprototype></funcsynopsis> 44045</refsynopsisdiv> 44046<refsect1> 44047 <title>Arguments</title> 44048 <variablelist> 44049 <varlistentry> 44050 <term><parameter>void</parameter></term> 44051 <listitem> 44052 <para> 44053 no arguments 44054 </para> 44055 </listitem> 44056 </varlistentry> 44057 </variablelist> 44058</refsect1> 44059<refsect1> 44060<title>Description</title> 44061<para> 44062 </para><para> 44063 44064 Allocates and returns a cdev structure, or NULL on failure. 44065</para> 44066</refsect1> 44067</refentry> 44068 44069<refentry id="API-cdev-init"> 44070<refentryinfo> 44071 <title>LINUX</title> 44072 <productname>Kernel Hackers Manual</productname> 44073 <date>July 2017</date> 44074</refentryinfo> 44075<refmeta> 44076 <refentrytitle><phrase>cdev_init</phrase></refentrytitle> 44077 <manvolnum>9</manvolnum> 44078 <refmiscinfo class="version">4.1.27</refmiscinfo> 44079</refmeta> 44080<refnamediv> 44081 <refname>cdev_init</refname> 44082 <refpurpose> 44083 initialize a cdev structure 44084 </refpurpose> 44085</refnamediv> 44086<refsynopsisdiv> 44087 <title>Synopsis</title> 44088 <funcsynopsis><funcprototype> 44089 <funcdef>void <function>cdev_init </function></funcdef> 44090 <paramdef>struct cdev * <parameter>cdev</parameter></paramdef> 44091 <paramdef>const struct file_operations * <parameter>fops</parameter></paramdef> 44092 </funcprototype></funcsynopsis> 44093</refsynopsisdiv> 44094<refsect1> 44095 <title>Arguments</title> 44096 <variablelist> 44097 <varlistentry> 44098 <term><parameter>cdev</parameter></term> 44099 <listitem> 44100 <para> 44101 the structure to initialize 44102 </para> 44103 </listitem> 44104 </varlistentry> 44105 <varlistentry> 44106 <term><parameter>fops</parameter></term> 44107 <listitem> 44108 <para> 44109 the file_operations for this device 44110 </para> 44111 </listitem> 44112 </varlistentry> 44113 </variablelist> 44114</refsect1> 44115<refsect1> 44116<title>Description</title> 44117<para> 44118 Initializes <parameter>cdev</parameter>, remembering <parameter>fops</parameter>, making it ready to add to the 44119 system with <function>cdev_add</function>. 44120</para> 44121</refsect1> 44122</refentry> 44123 44124 </chapter> 44125 44126 <chapter id="miscdev"> 44127 <title>Miscellaneous Devices</title> 44128<!-- drivers/char/misc.c --> 44129<refentry id="API-misc-register"> 44130<refentryinfo> 44131 <title>LINUX</title> 44132 <productname>Kernel Hackers Manual</productname> 44133 <date>July 2017</date> 44134</refentryinfo> 44135<refmeta> 44136 <refentrytitle><phrase>misc_register</phrase></refentrytitle> 44137 <manvolnum>9</manvolnum> 44138 <refmiscinfo class="version">4.1.27</refmiscinfo> 44139</refmeta> 44140<refnamediv> 44141 <refname>misc_register</refname> 44142 <refpurpose> 44143 register a miscellaneous device 44144 </refpurpose> 44145</refnamediv> 44146<refsynopsisdiv> 44147 <title>Synopsis</title> 44148 <funcsynopsis><funcprototype> 44149 <funcdef>int <function>misc_register </function></funcdef> 44150 <paramdef>struct miscdevice * <parameter>misc</parameter></paramdef> 44151 </funcprototype></funcsynopsis> 44152</refsynopsisdiv> 44153<refsect1> 44154 <title>Arguments</title> 44155 <variablelist> 44156 <varlistentry> 44157 <term><parameter>misc</parameter></term> 44158 <listitem> 44159 <para> 44160 device structure 44161 </para><para> 44162 44163 Register a miscellaneous device with the kernel. If the minor 44164 number is set to <constant>MISC_DYNAMIC_MINOR</constant> a minor number is assigned 44165 and placed in the minor field of the structure. For other cases 44166 the minor number requested is used. 44167 </para> 44168 </listitem> 44169 </varlistentry> 44170 </variablelist> 44171</refsect1> 44172<refsect1> 44173<title>Description</title> 44174<para> 44175 The structure passed is linked into the kernel and may not be 44176 destroyed until it has been unregistered. By default, an <function>open</function> 44177 syscall to the device sets file->private_data to point to the 44178 structure. Drivers don't need open in fops for this. 44179 </para><para> 44180 44181 A zero is returned on success and a negative errno code for 44182 failure. 44183</para> 44184</refsect1> 44185</refentry> 44186 44187<refentry id="API-misc-deregister"> 44188<refentryinfo> 44189 <title>LINUX</title> 44190 <productname>Kernel Hackers Manual</productname> 44191 <date>July 2017</date> 44192</refentryinfo> 44193<refmeta> 44194 <refentrytitle><phrase>misc_deregister</phrase></refentrytitle> 44195 <manvolnum>9</manvolnum> 44196 <refmiscinfo class="version">4.1.27</refmiscinfo> 44197</refmeta> 44198<refnamediv> 44199 <refname>misc_deregister</refname> 44200 <refpurpose> 44201 unregister a miscellaneous device 44202 </refpurpose> 44203</refnamediv> 44204<refsynopsisdiv> 44205 <title>Synopsis</title> 44206 <funcsynopsis><funcprototype> 44207 <funcdef>int <function>misc_deregister </function></funcdef> 44208 <paramdef>struct miscdevice * <parameter>misc</parameter></paramdef> 44209 </funcprototype></funcsynopsis> 44210</refsynopsisdiv> 44211<refsect1> 44212 <title>Arguments</title> 44213 <variablelist> 44214 <varlistentry> 44215 <term><parameter>misc</parameter></term> 44216 <listitem> 44217 <para> 44218 device to unregister 44219 </para> 44220 </listitem> 44221 </varlistentry> 44222 </variablelist> 44223</refsect1> 44224<refsect1> 44225<title>Description</title> 44226<para> 44227 Unregister a miscellaneous device that was previously 44228 successfully registered with <function>misc_register</function>. Success 44229 is indicated by a zero return, a negative errno code 44230 indicates an error. 44231</para> 44232</refsect1> 44233</refentry> 44234 44235 </chapter> 44236 44237 <chapter id="clk"> 44238 <title>Clock Framework</title> 44239 44240 <para> 44241 The clock framework defines programming interfaces to support 44242 software management of the system clock tree. 44243 This framework is widely used with System-On-Chip (SOC) platforms 44244 to support power management and various devices which may need 44245 custom clock rates. 44246 Note that these "clocks" don't relate to timekeeping or real 44247 time clocks (RTCs), each of which have separate frameworks. 44248 These <structname>struct clk</structname> instances may be used 44249 to manage for example a 96 MHz signal that is used to shift bits 44250 into and out of peripherals or busses, or otherwise trigger 44251 synchronous state machine transitions in system hardware. 44252 </para> 44253 44254 <para> 44255 Power management is supported by explicit software clock gating: 44256 unused clocks are disabled, so the system doesn't waste power 44257 changing the state of transistors that aren't in active use. 44258 On some systems this may be backed by hardware clock gating, 44259 where clocks are gated without being disabled in software. 44260 Sections of chips that are powered but not clocked may be able 44261 to retain their last state. 44262 This low power state is often called a <emphasis>retention 44263 mode</emphasis>. 44264 This mode still incurs leakage currents, especially with finer 44265 circuit geometries, but for CMOS circuits power is mostly used 44266 by clocked state changes. 44267 </para> 44268 44269 <para> 44270 Power-aware drivers only enable their clocks when the device 44271 they manage is in active use. Also, system sleep states often 44272 differ according to which clock domains are active: while a 44273 "standby" state may allow wakeup from several active domains, a 44274 "mem" (suspend-to-RAM) state may require a more wholesale shutdown 44275 of clocks derived from higher speed PLLs and oscillators, limiting 44276 the number of possible wakeup event sources. A driver's suspend 44277 method may need to be aware of system-specific clock constraints 44278 on the target sleep state. 44279 </para> 44280 44281 <para> 44282 Some platforms support programmable clock generators. These 44283 can be used by external chips of various kinds, such as other 44284 CPUs, multimedia codecs, and devices with strict requirements 44285 for interface clocking. 44286 </para> 44287 44288<!-- include/linux/clk.h --> 44289<refentry id="API-struct-clk-notifier"> 44290<refentryinfo> 44291 <title>LINUX</title> 44292 <productname>Kernel Hackers Manual</productname> 44293 <date>July 2017</date> 44294</refentryinfo> 44295<refmeta> 44296 <refentrytitle><phrase>struct clk_notifier</phrase></refentrytitle> 44297 <manvolnum>9</manvolnum> 44298 <refmiscinfo class="version">4.1.27</refmiscinfo> 44299</refmeta> 44300<refnamediv> 44301 <refname>struct clk_notifier</refname> 44302 <refpurpose> 44303 associate a clk with a notifier 44304 </refpurpose> 44305</refnamediv> 44306<refsynopsisdiv> 44307 <title>Synopsis</title> 44308 <programlisting> 44309struct clk_notifier { 44310 struct clk * clk; 44311 struct srcu_notifier_head notifier_head; 44312 struct list_head node; 44313}; </programlisting> 44314</refsynopsisdiv> 44315 <refsect1> 44316 <title>Members</title> 44317 <variablelist> 44318 <varlistentry> <term>clk</term> 44319 <listitem><para> 44320struct clk * to associate the notifier with 44321 </para></listitem> 44322 </varlistentry> 44323 <varlistentry> <term>notifier_head</term> 44324 <listitem><para> 44325a blocking_notifier_head for this clk 44326 </para></listitem> 44327 </varlistentry> 44328 <varlistentry> <term>node</term> 44329 <listitem><para> 44330linked list pointers 44331 </para></listitem> 44332 </varlistentry> 44333 </variablelist> 44334 </refsect1> 44335<refsect1> 44336<title>Description</title> 44337<para> 44338 A list of struct clk_notifier is maintained by the notifier code. 44339 An entry is created whenever code registers the first notifier on a 44340 particular <parameter>clk</parameter>. Future notifiers on that <parameter>clk</parameter> are added to the 44341 <parameter>notifier_head</parameter>. 44342</para> 44343</refsect1> 44344</refentry> 44345 44346<refentry id="API-struct-clk-notifier-data"> 44347<refentryinfo> 44348 <title>LINUX</title> 44349 <productname>Kernel Hackers Manual</productname> 44350 <date>July 2017</date> 44351</refentryinfo> 44352<refmeta> 44353 <refentrytitle><phrase>struct clk_notifier_data</phrase></refentrytitle> 44354 <manvolnum>9</manvolnum> 44355 <refmiscinfo class="version">4.1.27</refmiscinfo> 44356</refmeta> 44357<refnamediv> 44358 <refname>struct clk_notifier_data</refname> 44359 <refpurpose> 44360 rate data to pass to the notifier callback 44361 </refpurpose> 44362</refnamediv> 44363<refsynopsisdiv> 44364 <title>Synopsis</title> 44365 <programlisting> 44366struct clk_notifier_data { 44367 struct clk * clk; 44368 unsigned long old_rate; 44369 unsigned long new_rate; 44370}; </programlisting> 44371</refsynopsisdiv> 44372 <refsect1> 44373 <title>Members</title> 44374 <variablelist> 44375 <varlistentry> <term>clk</term> 44376 <listitem><para> 44377 struct clk * being changed 44378 </para></listitem> 44379 </varlistentry> 44380 <varlistentry> <term>old_rate</term> 44381 <listitem><para> 44382 previous rate of this clk 44383 </para></listitem> 44384 </varlistentry> 44385 <varlistentry> <term>new_rate</term> 44386 <listitem><para> 44387 new rate of this clk 44388 </para></listitem> 44389 </varlistentry> 44390 </variablelist> 44391 </refsect1> 44392<refsect1> 44393<title>Description</title> 44394<para> 44395 For a pre-notifier, old_rate is the clk's rate before this rate 44396 change, and new_rate is what the rate will be in the future. For a 44397 post-notifier, old_rate and new_rate are both set to the clk's 44398 current rate (this was done to optimize the implementation). 44399</para> 44400</refsect1> 44401</refentry> 44402 44403<refentry id="API-clk-notifier-register"> 44404<refentryinfo> 44405 <title>LINUX</title> 44406 <productname>Kernel Hackers Manual</productname> 44407 <date>July 2017</date> 44408</refentryinfo> 44409<refmeta> 44410 <refentrytitle><phrase>clk_notifier_register</phrase></refentrytitle> 44411 <manvolnum>9</manvolnum> 44412 <refmiscinfo class="version">4.1.27</refmiscinfo> 44413</refmeta> 44414<refnamediv> 44415 <refname>clk_notifier_register</refname> 44416 <refpurpose> 44417 change notifier callback 44418 </refpurpose> 44419</refnamediv> 44420<refsynopsisdiv> 44421 <title>Synopsis</title> 44422 <funcsynopsis><funcprototype> 44423 <funcdef>int <function>clk_notifier_register </function></funcdef> 44424 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 44425 <paramdef>struct notifier_block * <parameter>nb</parameter></paramdef> 44426 </funcprototype></funcsynopsis> 44427</refsynopsisdiv> 44428<refsect1> 44429 <title>Arguments</title> 44430 <variablelist> 44431 <varlistentry> 44432 <term><parameter>clk</parameter></term> 44433 <listitem> 44434 <para> 44435 clock whose rate we are interested in 44436 </para> 44437 </listitem> 44438 </varlistentry> 44439 <varlistentry> 44440 <term><parameter>nb</parameter></term> 44441 <listitem> 44442 <para> 44443 notifier block with callback function pointer 44444 </para> 44445 </listitem> 44446 </varlistentry> 44447 </variablelist> 44448</refsect1> 44449<refsect1> 44450<title>ProTip</title> 44451<para> 44452 debugging across notifier chains can be frustrating. Make sure that 44453 your notifier callback function prints a nice big warning in case of 44454 failure. 44455</para> 44456</refsect1> 44457</refentry> 44458 44459<refentry id="API-clk-notifier-unregister"> 44460<refentryinfo> 44461 <title>LINUX</title> 44462 <productname>Kernel Hackers Manual</productname> 44463 <date>July 2017</date> 44464</refentryinfo> 44465<refmeta> 44466 <refentrytitle><phrase>clk_notifier_unregister</phrase></refentrytitle> 44467 <manvolnum>9</manvolnum> 44468 <refmiscinfo class="version">4.1.27</refmiscinfo> 44469</refmeta> 44470<refnamediv> 44471 <refname>clk_notifier_unregister</refname> 44472 <refpurpose> 44473 change notifier callback 44474 </refpurpose> 44475</refnamediv> 44476<refsynopsisdiv> 44477 <title>Synopsis</title> 44478 <funcsynopsis><funcprototype> 44479 <funcdef>int <function>clk_notifier_unregister </function></funcdef> 44480 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 44481 <paramdef>struct notifier_block * <parameter>nb</parameter></paramdef> 44482 </funcprototype></funcsynopsis> 44483</refsynopsisdiv> 44484<refsect1> 44485 <title>Arguments</title> 44486 <variablelist> 44487 <varlistentry> 44488 <term><parameter>clk</parameter></term> 44489 <listitem> 44490 <para> 44491 clock whose rate we are no longer interested in 44492 </para> 44493 </listitem> 44494 </varlistentry> 44495 <varlistentry> 44496 <term><parameter>nb</parameter></term> 44497 <listitem> 44498 <para> 44499 notifier block which will be unregistered 44500 </para> 44501 </listitem> 44502 </varlistentry> 44503 </variablelist> 44504</refsect1> 44505</refentry> 44506 44507<refentry id="API-clk-get-accuracy"> 44508<refentryinfo> 44509 <title>LINUX</title> 44510 <productname>Kernel Hackers Manual</productname> 44511 <date>July 2017</date> 44512</refentryinfo> 44513<refmeta> 44514 <refentrytitle><phrase>clk_get_accuracy</phrase></refentrytitle> 44515 <manvolnum>9</manvolnum> 44516 <refmiscinfo class="version">4.1.27</refmiscinfo> 44517</refmeta> 44518<refnamediv> 44519 <refname>clk_get_accuracy</refname> 44520 <refpurpose> 44521 obtain the clock accuracy in ppb (parts per billion) for a clock source. 44522 </refpurpose> 44523</refnamediv> 44524<refsynopsisdiv> 44525 <title>Synopsis</title> 44526 <funcsynopsis><funcprototype> 44527 <funcdef>long <function>clk_get_accuracy </function></funcdef> 44528 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 44529 </funcprototype></funcsynopsis> 44530</refsynopsisdiv> 44531<refsect1> 44532 <title>Arguments</title> 44533 <variablelist> 44534 <varlistentry> 44535 <term><parameter>clk</parameter></term> 44536 <listitem> 44537 <para> 44538 clock source 44539 </para> 44540 </listitem> 44541 </varlistentry> 44542 </variablelist> 44543</refsect1> 44544<refsect1> 44545<title>Description</title> 44546<para> 44547 This gets the clock source accuracy expressed in ppb. 44548 A perfect clock returns 0. 44549</para> 44550</refsect1> 44551</refentry> 44552 44553<refentry id="API-clk-set-phase"> 44554<refentryinfo> 44555 <title>LINUX</title> 44556 <productname>Kernel Hackers Manual</productname> 44557 <date>July 2017</date> 44558</refentryinfo> 44559<refmeta> 44560 <refentrytitle><phrase>clk_set_phase</phrase></refentrytitle> 44561 <manvolnum>9</manvolnum> 44562 <refmiscinfo class="version">4.1.27</refmiscinfo> 44563</refmeta> 44564<refnamediv> 44565 <refname>clk_set_phase</refname> 44566 <refpurpose> 44567 adjust the phase shift of a clock signal 44568 </refpurpose> 44569</refnamediv> 44570<refsynopsisdiv> 44571 <title>Synopsis</title> 44572 <funcsynopsis><funcprototype> 44573 <funcdef>int <function>clk_set_phase </function></funcdef> 44574 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 44575 <paramdef>int <parameter>degrees</parameter></paramdef> 44576 </funcprototype></funcsynopsis> 44577</refsynopsisdiv> 44578<refsect1> 44579 <title>Arguments</title> 44580 <variablelist> 44581 <varlistentry> 44582 <term><parameter>clk</parameter></term> 44583 <listitem> 44584 <para> 44585 clock signal source 44586 </para> 44587 </listitem> 44588 </varlistentry> 44589 <varlistentry> 44590 <term><parameter>degrees</parameter></term> 44591 <listitem> 44592 <para> 44593 number of degrees the signal is shifted 44594 </para> 44595 </listitem> 44596 </varlistentry> 44597 </variablelist> 44598</refsect1> 44599<refsect1> 44600<title>Description</title> 44601<para> 44602 Shifts the phase of a clock signal by the specified degrees. Returns 0 on 44603 success, -EERROR otherwise. 44604</para> 44605</refsect1> 44606</refentry> 44607 44608<refentry id="API-clk-get-phase"> 44609<refentryinfo> 44610 <title>LINUX</title> 44611 <productname>Kernel Hackers Manual</productname> 44612 <date>July 2017</date> 44613</refentryinfo> 44614<refmeta> 44615 <refentrytitle><phrase>clk_get_phase</phrase></refentrytitle> 44616 <manvolnum>9</manvolnum> 44617 <refmiscinfo class="version">4.1.27</refmiscinfo> 44618</refmeta> 44619<refnamediv> 44620 <refname>clk_get_phase</refname> 44621 <refpurpose> 44622 return the phase shift of a clock signal 44623 </refpurpose> 44624</refnamediv> 44625<refsynopsisdiv> 44626 <title>Synopsis</title> 44627 <funcsynopsis><funcprototype> 44628 <funcdef>int <function>clk_get_phase </function></funcdef> 44629 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 44630 </funcprototype></funcsynopsis> 44631</refsynopsisdiv> 44632<refsect1> 44633 <title>Arguments</title> 44634 <variablelist> 44635 <varlistentry> 44636 <term><parameter>clk</parameter></term> 44637 <listitem> 44638 <para> 44639 clock signal source 44640 </para> 44641 </listitem> 44642 </varlistentry> 44643 </variablelist> 44644</refsect1> 44645<refsect1> 44646<title>Description</title> 44647<para> 44648 Returns the phase shift of a clock node in degrees, otherwise returns 44649 -EERROR. 44650</para> 44651</refsect1> 44652</refentry> 44653 44654<refentry id="API-clk-is-match"> 44655<refentryinfo> 44656 <title>LINUX</title> 44657 <productname>Kernel Hackers Manual</productname> 44658 <date>July 2017</date> 44659</refentryinfo> 44660<refmeta> 44661 <refentrytitle><phrase>clk_is_match</phrase></refentrytitle> 44662 <manvolnum>9</manvolnum> 44663 <refmiscinfo class="version">4.1.27</refmiscinfo> 44664</refmeta> 44665<refnamediv> 44666 <refname>clk_is_match</refname> 44667 <refpurpose> 44668 check if two clk's point to the same hardware clock 44669 </refpurpose> 44670</refnamediv> 44671<refsynopsisdiv> 44672 <title>Synopsis</title> 44673 <funcsynopsis><funcprototype> 44674 <funcdef>bool <function>clk_is_match </function></funcdef> 44675 <paramdef>const struct clk * <parameter>p</parameter></paramdef> 44676 <paramdef>const struct clk * <parameter>q</parameter></paramdef> 44677 </funcprototype></funcsynopsis> 44678</refsynopsisdiv> 44679<refsect1> 44680 <title>Arguments</title> 44681 <variablelist> 44682 <varlistentry> 44683 <term><parameter>p</parameter></term> 44684 <listitem> 44685 <para> 44686 clk compared against q 44687 </para> 44688 </listitem> 44689 </varlistentry> 44690 <varlistentry> 44691 <term><parameter>q</parameter></term> 44692 <listitem> 44693 <para> 44694 clk compared against p 44695 </para> 44696 </listitem> 44697 </varlistentry> 44698 </variablelist> 44699</refsect1> 44700<refsect1> 44701<title>Description</title> 44702<para> 44703 Returns true if the two struct clk pointers both point to the same hardware 44704 clock node. Put differently, returns true if struct clk *p and struct clk *q 44705 share the same struct clk_core object. 44706 </para><para> 44707 44708 Returns false otherwise. Note that two NULL clks are treated as matching. 44709</para> 44710</refsect1> 44711</refentry> 44712 44713<refentry id="API-clk-prepare"> 44714<refentryinfo> 44715 <title>LINUX</title> 44716 <productname>Kernel Hackers Manual</productname> 44717 <date>July 2017</date> 44718</refentryinfo> 44719<refmeta> 44720 <refentrytitle><phrase>clk_prepare</phrase></refentrytitle> 44721 <manvolnum>9</manvolnum> 44722 <refmiscinfo class="version">4.1.27</refmiscinfo> 44723</refmeta> 44724<refnamediv> 44725 <refname>clk_prepare</refname> 44726 <refpurpose> 44727 prepare a clock source 44728 </refpurpose> 44729</refnamediv> 44730<refsynopsisdiv> 44731 <title>Synopsis</title> 44732 <funcsynopsis><funcprototype> 44733 <funcdef>int <function>clk_prepare </function></funcdef> 44734 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 44735 </funcprototype></funcsynopsis> 44736</refsynopsisdiv> 44737<refsect1> 44738 <title>Arguments</title> 44739 <variablelist> 44740 <varlistentry> 44741 <term><parameter>clk</parameter></term> 44742 <listitem> 44743 <para> 44744 clock source 44745 </para> 44746 </listitem> 44747 </varlistentry> 44748 </variablelist> 44749</refsect1> 44750<refsect1> 44751<title>Description</title> 44752<para> 44753 This prepares the clock source for use. 44754 </para><para> 44755 44756 Must not be called from within atomic context. 44757</para> 44758</refsect1> 44759</refentry> 44760 44761<refentry id="API-clk-unprepare"> 44762<refentryinfo> 44763 <title>LINUX</title> 44764 <productname>Kernel Hackers Manual</productname> 44765 <date>July 2017</date> 44766</refentryinfo> 44767<refmeta> 44768 <refentrytitle><phrase>clk_unprepare</phrase></refentrytitle> 44769 <manvolnum>9</manvolnum> 44770 <refmiscinfo class="version">4.1.27</refmiscinfo> 44771</refmeta> 44772<refnamediv> 44773 <refname>clk_unprepare</refname> 44774 <refpurpose> 44775 undo preparation of a clock source 44776 </refpurpose> 44777</refnamediv> 44778<refsynopsisdiv> 44779 <title>Synopsis</title> 44780 <funcsynopsis><funcprototype> 44781 <funcdef>void <function>clk_unprepare </function></funcdef> 44782 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 44783 </funcprototype></funcsynopsis> 44784</refsynopsisdiv> 44785<refsect1> 44786 <title>Arguments</title> 44787 <variablelist> 44788 <varlistentry> 44789 <term><parameter>clk</parameter></term> 44790 <listitem> 44791 <para> 44792 clock source 44793 </para> 44794 </listitem> 44795 </varlistentry> 44796 </variablelist> 44797</refsect1> 44798<refsect1> 44799<title>Description</title> 44800<para> 44801 This undoes a previously prepared clock. The caller must balance 44802 the number of prepare and unprepare calls. 44803 </para><para> 44804 44805 Must not be called from within atomic context. 44806</para> 44807</refsect1> 44808</refentry> 44809 44810<refentry id="API-clk-get"> 44811<refentryinfo> 44812 <title>LINUX</title> 44813 <productname>Kernel Hackers Manual</productname> 44814 <date>July 2017</date> 44815</refentryinfo> 44816<refmeta> 44817 <refentrytitle><phrase>clk_get</phrase></refentrytitle> 44818 <manvolnum>9</manvolnum> 44819 <refmiscinfo class="version">4.1.27</refmiscinfo> 44820</refmeta> 44821<refnamediv> 44822 <refname>clk_get</refname> 44823 <refpurpose> 44824 lookup and obtain a reference to a clock producer. 44825 </refpurpose> 44826</refnamediv> 44827<refsynopsisdiv> 44828 <title>Synopsis</title> 44829 <funcsynopsis><funcprototype> 44830 <funcdef>struct clk * <function>clk_get </function></funcdef> 44831 <paramdef>struct device * <parameter>dev</parameter></paramdef> 44832 <paramdef>const char * <parameter>id</parameter></paramdef> 44833 </funcprototype></funcsynopsis> 44834</refsynopsisdiv> 44835<refsect1> 44836 <title>Arguments</title> 44837 <variablelist> 44838 <varlistentry> 44839 <term><parameter>dev</parameter></term> 44840 <listitem> 44841 <para> 44842 device for clock <quote>consumer</quote> 44843 </para> 44844 </listitem> 44845 </varlistentry> 44846 <varlistentry> 44847 <term><parameter>id</parameter></term> 44848 <listitem> 44849 <para> 44850 clock consumer ID 44851 </para> 44852 </listitem> 44853 </varlistentry> 44854 </variablelist> 44855</refsect1> 44856<refsect1> 44857<title>Description</title> 44858<para> 44859 Returns a struct clk corresponding to the clock producer, or 44860 valid <function>IS_ERR</function> condition containing errno. The implementation 44861 uses <parameter>dev</parameter> and <parameter>id</parameter> to determine the clock consumer, and thereby 44862 the clock producer. (IOW, <parameter>id</parameter> may be identical strings, but 44863 clk_get may return different clock producers depending on <parameter>dev</parameter>.) 44864 </para><para> 44865 44866 Drivers must assume that the clock source is not enabled. 44867 </para><para> 44868 44869 clk_get should not be called from within interrupt context. 44870</para> 44871</refsect1> 44872</refentry> 44873 44874<refentry id="API-devm-clk-get"> 44875<refentryinfo> 44876 <title>LINUX</title> 44877 <productname>Kernel Hackers Manual</productname> 44878 <date>July 2017</date> 44879</refentryinfo> 44880<refmeta> 44881 <refentrytitle><phrase>devm_clk_get</phrase></refentrytitle> 44882 <manvolnum>9</manvolnum> 44883 <refmiscinfo class="version">4.1.27</refmiscinfo> 44884</refmeta> 44885<refnamediv> 44886 <refname>devm_clk_get</refname> 44887 <refpurpose> 44888 lookup and obtain a managed reference to a clock producer. 44889 </refpurpose> 44890</refnamediv> 44891<refsynopsisdiv> 44892 <title>Synopsis</title> 44893 <funcsynopsis><funcprototype> 44894 <funcdef>struct clk * <function>devm_clk_get </function></funcdef> 44895 <paramdef>struct device * <parameter>dev</parameter></paramdef> 44896 <paramdef>const char * <parameter>id</parameter></paramdef> 44897 </funcprototype></funcsynopsis> 44898</refsynopsisdiv> 44899<refsect1> 44900 <title>Arguments</title> 44901 <variablelist> 44902 <varlistentry> 44903 <term><parameter>dev</parameter></term> 44904 <listitem> 44905 <para> 44906 device for clock <quote>consumer</quote> 44907 </para> 44908 </listitem> 44909 </varlistentry> 44910 <varlistentry> 44911 <term><parameter>id</parameter></term> 44912 <listitem> 44913 <para> 44914 clock consumer ID 44915 </para> 44916 </listitem> 44917 </varlistentry> 44918 </variablelist> 44919</refsect1> 44920<refsect1> 44921<title>Description</title> 44922<para> 44923 Returns a struct clk corresponding to the clock producer, or 44924 valid <function>IS_ERR</function> condition containing errno. The implementation 44925 uses <parameter>dev</parameter> and <parameter>id</parameter> to determine the clock consumer, and thereby 44926 the clock producer. (IOW, <parameter>id</parameter> may be identical strings, but 44927 clk_get may return different clock producers depending on <parameter>dev</parameter>.) 44928 </para><para> 44929 44930 Drivers must assume that the clock source is not enabled. 44931 </para><para> 44932 44933 devm_clk_get should not be called from within interrupt context. 44934 </para><para> 44935 44936 The clock will automatically be freed when the device is unbound 44937 from the bus. 44938</para> 44939</refsect1> 44940</refentry> 44941 44942<refentry id="API-clk-enable"> 44943<refentryinfo> 44944 <title>LINUX</title> 44945 <productname>Kernel Hackers Manual</productname> 44946 <date>July 2017</date> 44947</refentryinfo> 44948<refmeta> 44949 <refentrytitle><phrase>clk_enable</phrase></refentrytitle> 44950 <manvolnum>9</manvolnum> 44951 <refmiscinfo class="version">4.1.27</refmiscinfo> 44952</refmeta> 44953<refnamediv> 44954 <refname>clk_enable</refname> 44955 <refpurpose> 44956 inform the system when the clock source should be running. 44957 </refpurpose> 44958</refnamediv> 44959<refsynopsisdiv> 44960 <title>Synopsis</title> 44961 <funcsynopsis><funcprototype> 44962 <funcdef>int <function>clk_enable </function></funcdef> 44963 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 44964 </funcprototype></funcsynopsis> 44965</refsynopsisdiv> 44966<refsect1> 44967 <title>Arguments</title> 44968 <variablelist> 44969 <varlistentry> 44970 <term><parameter>clk</parameter></term> 44971 <listitem> 44972 <para> 44973 clock source 44974 </para> 44975 </listitem> 44976 </varlistentry> 44977 </variablelist> 44978</refsect1> 44979<refsect1> 44980<title>Description</title> 44981<para> 44982 If the clock can not be enabled/disabled, this should return success. 44983 </para><para> 44984 44985 May be called from atomic contexts. 44986 </para><para> 44987 44988 Returns success (0) or negative errno. 44989</para> 44990</refsect1> 44991</refentry> 44992 44993<refentry id="API-clk-disable"> 44994<refentryinfo> 44995 <title>LINUX</title> 44996 <productname>Kernel Hackers Manual</productname> 44997 <date>July 2017</date> 44998</refentryinfo> 44999<refmeta> 45000 <refentrytitle><phrase>clk_disable</phrase></refentrytitle> 45001 <manvolnum>9</manvolnum> 45002 <refmiscinfo class="version">4.1.27</refmiscinfo> 45003</refmeta> 45004<refnamediv> 45005 <refname>clk_disable</refname> 45006 <refpurpose> 45007 inform the system when the clock source is no longer required. 45008 </refpurpose> 45009</refnamediv> 45010<refsynopsisdiv> 45011 <title>Synopsis</title> 45012 <funcsynopsis><funcprototype> 45013 <funcdef>void <function>clk_disable </function></funcdef> 45014 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 45015 </funcprototype></funcsynopsis> 45016</refsynopsisdiv> 45017<refsect1> 45018 <title>Arguments</title> 45019 <variablelist> 45020 <varlistentry> 45021 <term><parameter>clk</parameter></term> 45022 <listitem> 45023 <para> 45024 clock source 45025 </para> 45026 </listitem> 45027 </varlistentry> 45028 </variablelist> 45029</refsect1> 45030<refsect1> 45031<title>Description</title> 45032<para> 45033 Inform the system that a clock source is no longer required by 45034 a driver and may be shut down. 45035 </para><para> 45036 45037 May be called from atomic contexts. 45038</para> 45039</refsect1> 45040<refsect1> 45041<title>Implementation detail</title> 45042<para> 45043 if the clock source is shared between 45044 multiple drivers, <function>clk_enable</function> calls must be balanced by the 45045 same number of <function>clk_disable</function> calls for the clock source to be 45046 disabled. 45047</para> 45048</refsect1> 45049</refentry> 45050 45051<refentry id="API-clk-get-rate"> 45052<refentryinfo> 45053 <title>LINUX</title> 45054 <productname>Kernel Hackers Manual</productname> 45055 <date>July 2017</date> 45056</refentryinfo> 45057<refmeta> 45058 <refentrytitle><phrase>clk_get_rate</phrase></refentrytitle> 45059 <manvolnum>9</manvolnum> 45060 <refmiscinfo class="version">4.1.27</refmiscinfo> 45061</refmeta> 45062<refnamediv> 45063 <refname>clk_get_rate</refname> 45064 <refpurpose> 45065 obtain the current clock rate (in Hz) for a clock source. This is only valid once the clock source has been enabled. 45066 </refpurpose> 45067</refnamediv> 45068<refsynopsisdiv> 45069 <title>Synopsis</title> 45070 <funcsynopsis><funcprototype> 45071 <funcdef>unsigned long <function>clk_get_rate </function></funcdef> 45072 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 45073 </funcprototype></funcsynopsis> 45074</refsynopsisdiv> 45075<refsect1> 45076 <title>Arguments</title> 45077 <variablelist> 45078 <varlistentry> 45079 <term><parameter>clk</parameter></term> 45080 <listitem> 45081 <para> 45082 clock source 45083 </para> 45084 </listitem> 45085 </varlistentry> 45086 </variablelist> 45087</refsect1> 45088</refentry> 45089 45090<refentry id="API-clk-put"> 45091<refentryinfo> 45092 <title>LINUX</title> 45093 <productname>Kernel Hackers Manual</productname> 45094 <date>July 2017</date> 45095</refentryinfo> 45096<refmeta> 45097 <refentrytitle><phrase>clk_put</phrase></refentrytitle> 45098 <manvolnum>9</manvolnum> 45099 <refmiscinfo class="version">4.1.27</refmiscinfo> 45100</refmeta> 45101<refnamediv> 45102 <refname>clk_put</refname> 45103 <refpurpose> 45104 "free" the clock source 45105 </refpurpose> 45106</refnamediv> 45107<refsynopsisdiv> 45108 <title>Synopsis</title> 45109 <funcsynopsis><funcprototype> 45110 <funcdef>void <function>clk_put </function></funcdef> 45111 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 45112 </funcprototype></funcsynopsis> 45113</refsynopsisdiv> 45114<refsect1> 45115 <title>Arguments</title> 45116 <variablelist> 45117 <varlistentry> 45118 <term><parameter>clk</parameter></term> 45119 <listitem> 45120 <para> 45121 clock source 45122 </para> 45123 </listitem> 45124 </varlistentry> 45125 </variablelist> 45126</refsect1> 45127<refsect1> 45128<title>Note</title> 45129<para> 45130 drivers must ensure that all clk_enable calls made on this 45131 clock source are balanced by clk_disable calls prior to calling 45132 this function. 45133 </para><para> 45134 45135 clk_put should not be called from within interrupt context. 45136</para> 45137</refsect1> 45138</refentry> 45139 45140<refentry id="API-devm-clk-put"> 45141<refentryinfo> 45142 <title>LINUX</title> 45143 <productname>Kernel Hackers Manual</productname> 45144 <date>July 2017</date> 45145</refentryinfo> 45146<refmeta> 45147 <refentrytitle><phrase>devm_clk_put</phrase></refentrytitle> 45148 <manvolnum>9</manvolnum> 45149 <refmiscinfo class="version">4.1.27</refmiscinfo> 45150</refmeta> 45151<refnamediv> 45152 <refname>devm_clk_put</refname> 45153 <refpurpose> 45154 "free" a managed clock source 45155 </refpurpose> 45156</refnamediv> 45157<refsynopsisdiv> 45158 <title>Synopsis</title> 45159 <funcsynopsis><funcprototype> 45160 <funcdef>void <function>devm_clk_put </function></funcdef> 45161 <paramdef>struct device * <parameter>dev</parameter></paramdef> 45162 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 45163 </funcprototype></funcsynopsis> 45164</refsynopsisdiv> 45165<refsect1> 45166 <title>Arguments</title> 45167 <variablelist> 45168 <varlistentry> 45169 <term><parameter>dev</parameter></term> 45170 <listitem> 45171 <para> 45172 device used to acquire the clock 45173 </para> 45174 </listitem> 45175 </varlistentry> 45176 <varlistentry> 45177 <term><parameter>clk</parameter></term> 45178 <listitem> 45179 <para> 45180 clock source acquired with <function>devm_clk_get</function> 45181 </para> 45182 </listitem> 45183 </varlistentry> 45184 </variablelist> 45185</refsect1> 45186<refsect1> 45187<title>Note</title> 45188<para> 45189 drivers must ensure that all clk_enable calls made on this 45190 clock source are balanced by clk_disable calls prior to calling 45191 this function. 45192 </para><para> 45193 45194 clk_put should not be called from within interrupt context. 45195</para> 45196</refsect1> 45197</refentry> 45198 45199<refentry id="API-clk-round-rate"> 45200<refentryinfo> 45201 <title>LINUX</title> 45202 <productname>Kernel Hackers Manual</productname> 45203 <date>July 2017</date> 45204</refentryinfo> 45205<refmeta> 45206 <refentrytitle><phrase>clk_round_rate</phrase></refentrytitle> 45207 <manvolnum>9</manvolnum> 45208 <refmiscinfo class="version">4.1.27</refmiscinfo> 45209</refmeta> 45210<refnamediv> 45211 <refname>clk_round_rate</refname> 45212 <refpurpose> 45213 adjust a rate to the exact rate a clock can provide 45214 </refpurpose> 45215</refnamediv> 45216<refsynopsisdiv> 45217 <title>Synopsis</title> 45218 <funcsynopsis><funcprototype> 45219 <funcdef>long <function>clk_round_rate </function></funcdef> 45220 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 45221 <paramdef>unsigned long <parameter>rate</parameter></paramdef> 45222 </funcprototype></funcsynopsis> 45223</refsynopsisdiv> 45224<refsect1> 45225 <title>Arguments</title> 45226 <variablelist> 45227 <varlistentry> 45228 <term><parameter>clk</parameter></term> 45229 <listitem> 45230 <para> 45231 clock source 45232 </para> 45233 </listitem> 45234 </varlistentry> 45235 <varlistentry> 45236 <term><parameter>rate</parameter></term> 45237 <listitem> 45238 <para> 45239 desired clock rate in Hz 45240 </para> 45241 </listitem> 45242 </varlistentry> 45243 </variablelist> 45244</refsect1> 45245<refsect1> 45246<title>Description</title> 45247<para> 45248 Returns rounded clock rate in Hz, or negative errno. 45249</para> 45250</refsect1> 45251</refentry> 45252 45253<refentry id="API-clk-set-rate"> 45254<refentryinfo> 45255 <title>LINUX</title> 45256 <productname>Kernel Hackers Manual</productname> 45257 <date>July 2017</date> 45258</refentryinfo> 45259<refmeta> 45260 <refentrytitle><phrase>clk_set_rate</phrase></refentrytitle> 45261 <manvolnum>9</manvolnum> 45262 <refmiscinfo class="version">4.1.27</refmiscinfo> 45263</refmeta> 45264<refnamediv> 45265 <refname>clk_set_rate</refname> 45266 <refpurpose> 45267 set the clock rate for a clock source 45268 </refpurpose> 45269</refnamediv> 45270<refsynopsisdiv> 45271 <title>Synopsis</title> 45272 <funcsynopsis><funcprototype> 45273 <funcdef>int <function>clk_set_rate </function></funcdef> 45274 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 45275 <paramdef>unsigned long <parameter>rate</parameter></paramdef> 45276 </funcprototype></funcsynopsis> 45277</refsynopsisdiv> 45278<refsect1> 45279 <title>Arguments</title> 45280 <variablelist> 45281 <varlistentry> 45282 <term><parameter>clk</parameter></term> 45283 <listitem> 45284 <para> 45285 clock source 45286 </para> 45287 </listitem> 45288 </varlistentry> 45289 <varlistentry> 45290 <term><parameter>rate</parameter></term> 45291 <listitem> 45292 <para> 45293 desired clock rate in Hz 45294 </para> 45295 </listitem> 45296 </varlistentry> 45297 </variablelist> 45298</refsect1> 45299<refsect1> 45300<title>Description</title> 45301<para> 45302 Returns success (0) or negative errno. 45303</para> 45304</refsect1> 45305</refentry> 45306 45307<refentry id="API-clk-has-parent"> 45308<refentryinfo> 45309 <title>LINUX</title> 45310 <productname>Kernel Hackers Manual</productname> 45311 <date>July 2017</date> 45312</refentryinfo> 45313<refmeta> 45314 <refentrytitle><phrase>clk_has_parent</phrase></refentrytitle> 45315 <manvolnum>9</manvolnum> 45316 <refmiscinfo class="version">4.1.27</refmiscinfo> 45317</refmeta> 45318<refnamediv> 45319 <refname>clk_has_parent</refname> 45320 <refpurpose> 45321 check if a clock is a possible parent for another 45322 </refpurpose> 45323</refnamediv> 45324<refsynopsisdiv> 45325 <title>Synopsis</title> 45326 <funcsynopsis><funcprototype> 45327 <funcdef>bool <function>clk_has_parent </function></funcdef> 45328 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 45329 <paramdef>struct clk * <parameter>parent</parameter></paramdef> 45330 </funcprototype></funcsynopsis> 45331</refsynopsisdiv> 45332<refsect1> 45333 <title>Arguments</title> 45334 <variablelist> 45335 <varlistentry> 45336 <term><parameter>clk</parameter></term> 45337 <listitem> 45338 <para> 45339 clock source 45340 </para> 45341 </listitem> 45342 </varlistentry> 45343 <varlistentry> 45344 <term><parameter>parent</parameter></term> 45345 <listitem> 45346 <para> 45347 parent clock source 45348 </para> 45349 </listitem> 45350 </varlistentry> 45351 </variablelist> 45352</refsect1> 45353<refsect1> 45354<title>Description</title> 45355<para> 45356 This function can be used in drivers that need to check that a clock can be 45357 the parent of another without actually changing the parent. 45358 </para><para> 45359 45360 Returns true if <parameter>parent</parameter> is a possible parent for <parameter>clk</parameter>, false otherwise. 45361</para> 45362</refsect1> 45363</refentry> 45364 45365<refentry id="API-clk-set-rate-range"> 45366<refentryinfo> 45367 <title>LINUX</title> 45368 <productname>Kernel Hackers Manual</productname> 45369 <date>July 2017</date> 45370</refentryinfo> 45371<refmeta> 45372 <refentrytitle><phrase>clk_set_rate_range</phrase></refentrytitle> 45373 <manvolnum>9</manvolnum> 45374 <refmiscinfo class="version">4.1.27</refmiscinfo> 45375</refmeta> 45376<refnamediv> 45377 <refname>clk_set_rate_range</refname> 45378 <refpurpose> 45379 set a rate range for a clock source 45380 </refpurpose> 45381</refnamediv> 45382<refsynopsisdiv> 45383 <title>Synopsis</title> 45384 <funcsynopsis><funcprototype> 45385 <funcdef>int <function>clk_set_rate_range </function></funcdef> 45386 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 45387 <paramdef>unsigned long <parameter>min</parameter></paramdef> 45388 <paramdef>unsigned long <parameter>max</parameter></paramdef> 45389 </funcprototype></funcsynopsis> 45390</refsynopsisdiv> 45391<refsect1> 45392 <title>Arguments</title> 45393 <variablelist> 45394 <varlistentry> 45395 <term><parameter>clk</parameter></term> 45396 <listitem> 45397 <para> 45398 clock source 45399 </para> 45400 </listitem> 45401 </varlistentry> 45402 <varlistentry> 45403 <term><parameter>min</parameter></term> 45404 <listitem> 45405 <para> 45406 desired minimum clock rate in Hz, inclusive 45407 </para> 45408 </listitem> 45409 </varlistentry> 45410 <varlistentry> 45411 <term><parameter>max</parameter></term> 45412 <listitem> 45413 <para> 45414 desired maximum clock rate in Hz, inclusive 45415 </para> 45416 </listitem> 45417 </varlistentry> 45418 </variablelist> 45419</refsect1> 45420<refsect1> 45421<title>Description</title> 45422<para> 45423 Returns success (0) or negative errno. 45424</para> 45425</refsect1> 45426</refentry> 45427 45428<refentry id="API-clk-set-min-rate"> 45429<refentryinfo> 45430 <title>LINUX</title> 45431 <productname>Kernel Hackers Manual</productname> 45432 <date>July 2017</date> 45433</refentryinfo> 45434<refmeta> 45435 <refentrytitle><phrase>clk_set_min_rate</phrase></refentrytitle> 45436 <manvolnum>9</manvolnum> 45437 <refmiscinfo class="version">4.1.27</refmiscinfo> 45438</refmeta> 45439<refnamediv> 45440 <refname>clk_set_min_rate</refname> 45441 <refpurpose> 45442 set a minimum clock rate for a clock source 45443 </refpurpose> 45444</refnamediv> 45445<refsynopsisdiv> 45446 <title>Synopsis</title> 45447 <funcsynopsis><funcprototype> 45448 <funcdef>int <function>clk_set_min_rate </function></funcdef> 45449 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 45450 <paramdef>unsigned long <parameter>rate</parameter></paramdef> 45451 </funcprototype></funcsynopsis> 45452</refsynopsisdiv> 45453<refsect1> 45454 <title>Arguments</title> 45455 <variablelist> 45456 <varlistentry> 45457 <term><parameter>clk</parameter></term> 45458 <listitem> 45459 <para> 45460 clock source 45461 </para> 45462 </listitem> 45463 </varlistentry> 45464 <varlistentry> 45465 <term><parameter>rate</parameter></term> 45466 <listitem> 45467 <para> 45468 desired minimum clock rate in Hz, inclusive 45469 </para> 45470 </listitem> 45471 </varlistentry> 45472 </variablelist> 45473</refsect1> 45474<refsect1> 45475<title>Description</title> 45476<para> 45477 Returns success (0) or negative errno. 45478</para> 45479</refsect1> 45480</refentry> 45481 45482<refentry id="API-clk-set-max-rate"> 45483<refentryinfo> 45484 <title>LINUX</title> 45485 <productname>Kernel Hackers Manual</productname> 45486 <date>July 2017</date> 45487</refentryinfo> 45488<refmeta> 45489 <refentrytitle><phrase>clk_set_max_rate</phrase></refentrytitle> 45490 <manvolnum>9</manvolnum> 45491 <refmiscinfo class="version">4.1.27</refmiscinfo> 45492</refmeta> 45493<refnamediv> 45494 <refname>clk_set_max_rate</refname> 45495 <refpurpose> 45496 set a maximum clock rate for a clock source 45497 </refpurpose> 45498</refnamediv> 45499<refsynopsisdiv> 45500 <title>Synopsis</title> 45501 <funcsynopsis><funcprototype> 45502 <funcdef>int <function>clk_set_max_rate </function></funcdef> 45503 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 45504 <paramdef>unsigned long <parameter>rate</parameter></paramdef> 45505 </funcprototype></funcsynopsis> 45506</refsynopsisdiv> 45507<refsect1> 45508 <title>Arguments</title> 45509 <variablelist> 45510 <varlistentry> 45511 <term><parameter>clk</parameter></term> 45512 <listitem> 45513 <para> 45514 clock source 45515 </para> 45516 </listitem> 45517 </varlistentry> 45518 <varlistentry> 45519 <term><parameter>rate</parameter></term> 45520 <listitem> 45521 <para> 45522 desired maximum clock rate in Hz, inclusive 45523 </para> 45524 </listitem> 45525 </varlistentry> 45526 </variablelist> 45527</refsect1> 45528<refsect1> 45529<title>Description</title> 45530<para> 45531 Returns success (0) or negative errno. 45532</para> 45533</refsect1> 45534</refentry> 45535 45536<refentry id="API-clk-set-parent"> 45537<refentryinfo> 45538 <title>LINUX</title> 45539 <productname>Kernel Hackers Manual</productname> 45540 <date>July 2017</date> 45541</refentryinfo> 45542<refmeta> 45543 <refentrytitle><phrase>clk_set_parent</phrase></refentrytitle> 45544 <manvolnum>9</manvolnum> 45545 <refmiscinfo class="version">4.1.27</refmiscinfo> 45546</refmeta> 45547<refnamediv> 45548 <refname>clk_set_parent</refname> 45549 <refpurpose> 45550 set the parent clock source for this clock 45551 </refpurpose> 45552</refnamediv> 45553<refsynopsisdiv> 45554 <title>Synopsis</title> 45555 <funcsynopsis><funcprototype> 45556 <funcdef>int <function>clk_set_parent </function></funcdef> 45557 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 45558 <paramdef>struct clk * <parameter>parent</parameter></paramdef> 45559 </funcprototype></funcsynopsis> 45560</refsynopsisdiv> 45561<refsect1> 45562 <title>Arguments</title> 45563 <variablelist> 45564 <varlistentry> 45565 <term><parameter>clk</parameter></term> 45566 <listitem> 45567 <para> 45568 clock source 45569 </para> 45570 </listitem> 45571 </varlistentry> 45572 <varlistentry> 45573 <term><parameter>parent</parameter></term> 45574 <listitem> 45575 <para> 45576 parent clock source 45577 </para> 45578 </listitem> 45579 </varlistentry> 45580 </variablelist> 45581</refsect1> 45582<refsect1> 45583<title>Description</title> 45584<para> 45585 Returns success (0) or negative errno. 45586</para> 45587</refsect1> 45588</refentry> 45589 45590<refentry id="API-clk-get-parent"> 45591<refentryinfo> 45592 <title>LINUX</title> 45593 <productname>Kernel Hackers Manual</productname> 45594 <date>July 2017</date> 45595</refentryinfo> 45596<refmeta> 45597 <refentrytitle><phrase>clk_get_parent</phrase></refentrytitle> 45598 <manvolnum>9</manvolnum> 45599 <refmiscinfo class="version">4.1.27</refmiscinfo> 45600</refmeta> 45601<refnamediv> 45602 <refname>clk_get_parent</refname> 45603 <refpurpose> 45604 get the parent clock source for this clock 45605 </refpurpose> 45606</refnamediv> 45607<refsynopsisdiv> 45608 <title>Synopsis</title> 45609 <funcsynopsis><funcprototype> 45610 <funcdef>struct clk * <function>clk_get_parent </function></funcdef> 45611 <paramdef>struct clk * <parameter>clk</parameter></paramdef> 45612 </funcprototype></funcsynopsis> 45613</refsynopsisdiv> 45614<refsect1> 45615 <title>Arguments</title> 45616 <variablelist> 45617 <varlistentry> 45618 <term><parameter>clk</parameter></term> 45619 <listitem> 45620 <para> 45621 clock source 45622 </para> 45623 </listitem> 45624 </varlistentry> 45625 </variablelist> 45626</refsect1> 45627<refsect1> 45628<title>Description</title> 45629<para> 45630 Returns struct clk corresponding to parent clock source, or 45631 valid <function>IS_ERR</function> condition containing errno. 45632</para> 45633</refsect1> 45634</refentry> 45635 45636<refentry id="API-clk-get-sys"> 45637<refentryinfo> 45638 <title>LINUX</title> 45639 <productname>Kernel Hackers Manual</productname> 45640 <date>July 2017</date> 45641</refentryinfo> 45642<refmeta> 45643 <refentrytitle><phrase>clk_get_sys</phrase></refentrytitle> 45644 <manvolnum>9</manvolnum> 45645 <refmiscinfo class="version">4.1.27</refmiscinfo> 45646</refmeta> 45647<refnamediv> 45648 <refname>clk_get_sys</refname> 45649 <refpurpose> 45650 get a clock based upon the device name 45651 </refpurpose> 45652</refnamediv> 45653<refsynopsisdiv> 45654 <title>Synopsis</title> 45655 <funcsynopsis><funcprototype> 45656 <funcdef>struct clk * <function>clk_get_sys </function></funcdef> 45657 <paramdef>const char * <parameter>dev_id</parameter></paramdef> 45658 <paramdef>const char * <parameter>con_id</parameter></paramdef> 45659 </funcprototype></funcsynopsis> 45660</refsynopsisdiv> 45661<refsect1> 45662 <title>Arguments</title> 45663 <variablelist> 45664 <varlistentry> 45665 <term><parameter>dev_id</parameter></term> 45666 <listitem> 45667 <para> 45668 device name 45669 </para> 45670 </listitem> 45671 </varlistentry> 45672 <varlistentry> 45673 <term><parameter>con_id</parameter></term> 45674 <listitem> 45675 <para> 45676 connection ID 45677 </para> 45678 </listitem> 45679 </varlistentry> 45680 </variablelist> 45681</refsect1> 45682<refsect1> 45683<title>Description</title> 45684<para> 45685 Returns a struct clk corresponding to the clock producer, or 45686 valid <function>IS_ERR</function> condition containing errno. The implementation 45687 uses <parameter>dev_id</parameter> and <parameter>con_id</parameter> to determine the clock consumer, and 45688 thereby the clock producer. In contrast to <function>clk_get</function> this function 45689 takes the device name instead of the device itself for identification. 45690 </para><para> 45691 45692 Drivers must assume that the clock source is not enabled. 45693 </para><para> 45694 45695 clk_get_sys should not be called from within interrupt context. 45696</para> 45697</refsect1> 45698</refentry> 45699 45700<refentry id="API-clk-add-alias"> 45701<refentryinfo> 45702 <title>LINUX</title> 45703 <productname>Kernel Hackers Manual</productname> 45704 <date>July 2017</date> 45705</refentryinfo> 45706<refmeta> 45707 <refentrytitle><phrase>clk_add_alias</phrase></refentrytitle> 45708 <manvolnum>9</manvolnum> 45709 <refmiscinfo class="version">4.1.27</refmiscinfo> 45710</refmeta> 45711<refnamediv> 45712 <refname>clk_add_alias</refname> 45713 <refpurpose> 45714 add a new clock alias 45715 </refpurpose> 45716</refnamediv> 45717<refsynopsisdiv> 45718 <title>Synopsis</title> 45719 <funcsynopsis><funcprototype> 45720 <funcdef>int <function>clk_add_alias </function></funcdef> 45721 <paramdef>const char * <parameter>alias</parameter></paramdef> 45722 <paramdef>const char * <parameter>alias_dev_name</parameter></paramdef> 45723 <paramdef>char * <parameter>id</parameter></paramdef> 45724 <paramdef>struct device * <parameter>dev</parameter></paramdef> 45725 </funcprototype></funcsynopsis> 45726</refsynopsisdiv> 45727<refsect1> 45728 <title>Arguments</title> 45729 <variablelist> 45730 <varlistentry> 45731 <term><parameter>alias</parameter></term> 45732 <listitem> 45733 <para> 45734 name for clock alias 45735 </para> 45736 </listitem> 45737 </varlistentry> 45738 <varlistentry> 45739 <term><parameter>alias_dev_name</parameter></term> 45740 <listitem> 45741 <para> 45742 device name 45743 </para> 45744 </listitem> 45745 </varlistentry> 45746 <varlistentry> 45747 <term><parameter>id</parameter></term> 45748 <listitem> 45749 <para> 45750 platform specific clock name 45751 </para> 45752 </listitem> 45753 </varlistentry> 45754 <varlistentry> 45755 <term><parameter>dev</parameter></term> 45756 <listitem> 45757 <para> 45758 device 45759 </para> 45760 </listitem> 45761 </varlistentry> 45762 </variablelist> 45763</refsect1> 45764<refsect1> 45765<title>Description</title> 45766<para> 45767 Allows using generic clock names for drivers by adding a new alias. 45768 Assumes clkdev, see clkdev.h for more info. 45769</para> 45770</refsect1> 45771</refentry> 45772 45773 </chapter> 45774 45775</book> 45776