linux/Documentation/driver-model/bus.txt
<<
>>
Prefs
   1
   2Bus Types 
   3
   4Definition
   5~~~~~~~~~~
   6See the kerneldoc for the struct bus_type.
   7
   8int bus_register(struct bus_type * bus);
   9
  10
  11Declaration
  12~~~~~~~~~~~
  13
  14Each bus type in the kernel (PCI, USB, etc) should declare one static
  15object of this type. They must initialize the name field, and may
  16optionally initialize the match callback.
  17
  18struct bus_type pci_bus_type = {
  19       .name    = "pci",
  20       .match   = pci_bus_match,
  21};
  22
  23The structure should be exported to drivers in a header file:
  24
  25extern struct bus_type pci_bus_type;
  26
  27
  28Registration
  29~~~~~~~~~~~~
  30
  31When a bus driver is initialized, it calls bus_register. This
  32initializes the rest of the fields in the bus object and inserts it
  33into a global list of bus types. Once the bus object is registered, 
  34the fields in it are usable by the bus driver. 
  35
  36
  37Callbacks
  38~~~~~~~~~
  39
  40match(): Attaching Drivers to Devices
  41~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  42
  43The format of device ID structures and the semantics for comparing
  44them are inherently bus-specific. Drivers typically declare an array
  45of device IDs of devices they support that reside in a bus-specific
  46driver structure. 
  47
  48The purpose of the match callback is provide the bus an opportunity to
  49determine if a particular driver supports a particular device by
  50comparing the device IDs the driver supports with the device ID of a
  51particular device, without sacrificing bus-specific functionality or
  52type-safety. 
  53
  54When a driver is registered with the bus, the bus's list of devices is
  55iterated over, and the match callback is called for each device that
  56does not have a driver associated with it. 

  v2.6d="L38" class="xt#L54" id="L54ocntation/driver-model/bus.txt#L54" id="L5n72"v2.6.16.27"
	  >
  v2.6.16.27
us.txt#L38" id=4" class="line" name="L54">  54When a n 49d5termine if a particular5drive5odel/bus.txt#L40" id="L40" class="line" name="L40">6 50c6mparing the device IDs 6he dr60n/driver-moeach href= Lion/bus.txt#L55" id="L55" class="line" name="L55">6 51p6rticular device, withou6 sacr6~~~~~
6 52t6pe-safety. 
6 53
6a href="Documentation/d6iver-6es and thtion in a bus-speeachcumentattypicatendef="Doreplahref="DloDocbus.txt#L43" id="L43" class="line" name="L43">6 54W6en a driver is register6d wit6 the tion i="Docntalare spekeep, and mtypition in a="Docum bus-speeacbus.txt#L43" id="L43" class="line" name="L43">6 55i6erated over, and the ma6ch ca6566See  the kerneldoc for the sociat66the tion iapecificpleasuncblitconodeaptio.oDref="Doocumentatition/malar"bus.txt#L43" id="L43" class="line" name="L43">6 >
  v2.6d="L38" class="xt#L54" 6d="L56ocntane-spsarel/bus.txt#L53" id="L53" class="line" name="L53">66.27"
	 6>
  v2.6.16.276us.tx6#L38" id=4" class="line" name="L54">  54When a 6 49d6termine if a particular6drive69s and thLDMtcoypihref="Ds helpr-mon/driven/driv is cahrefd foion/drtion/bus.txt#L7" id="L7" class="line" name="L7">   7 50c7mparing the device IDs 7he dr7odel/bus.txt#L31" id="L31" class="line" name="L31">7 51p7rticular device, withou7 sacr71* bus);
7 52t7pe-safety. 
   7 53
7a href="Documentation/d7iver-7odel/bus.txt#L54" id="L54" class="line" name="L54">7 54W7en a driver is register7d wit74* bus);
7 55i7erated over, and the ma7ch ca75   76See7 the kerneldoc for the 7ociat7odel/bus.txt#L37" id="L37" class="line" name="L37">77
76.27"
	 7>
  v2.6.16.277us.tx7#L38"tation/driver-moo by
7 49d7termine if a particular7drive79s ansynchronhreftatioaks with t"Documentatohre(reachDury decl), and anfly dcpbus.txt#L37" id="L37" class="line" name="L37">8 50c8mparing the device IDs 8he dr8ver supu);
tioon/drentationef="Dotionr. Thicred="Leftaefoypiect at
8 51p8rticular device, withou8 sacr81* buDocume; hre. Tdecred="Leftaftfoiect nextrentatiohapebes, obtavicd, andbus.txt#L55" id="L55" class="line" name="L55">8 52t8pe-safety. 
8 53
8a href="Documentation/d8iver-8odel/bus.txt#L54" id="L54" class="line" name="L54">8 54W8en a driver is register8d wit8odel/bus.txt#L25" id="L25" class="line" name="L25">8 55i8erated over, and the ma8ch ca8586See8 the kerneldoc for the 8ociat86~~~~
87
   88int  bus_register(struct busus.tx8#L38" id=4" class="line" name="L54">  54When a 8 49d8termine if a particular8drive89 USB, etc) shgecumendiratioryaref="Documediratioryr elo wieviceswoTdefaul/bus.txt#L56" id="L56" class="line" name="L56">9 50c9mparing the device IDs 9he dr9ver sdiratiories/bus.txt#L24" id="L24" class="line" name="L24">9 51p9rticular device, withou9 sacr9odel/bus.txt#L2" id="L2" class="line" name="L2">   9 52t9pe-safety. 
   9 53
9a href="Documentation/d9iver-93   9 54W9en a driver is register9d wit94   9 55i9erated over, and the ma9ch ca9odel/bus.txt#L36" id="L36" class="line" name="L36">96See9 the kerneldoc for the 9ociat96~~~~ href="Ds list of devices is
   97
98int9 bus_register(struct bu9us.tx9#L38" id=4" class="line" name="L54">  54When a 99
   10 10
   10 11De0claration
   10 12~~0~~~~~~~~~
   10 13
<0a href="Documentation/dr03e dri310 14Ea0ch bus type in the kerne04e dri410 15ob0ject of this type. They 05e dri510 16op0tionally initialize the 06e driodel/bus.txt#L37" id="L37" class="line" name="L37">10 17
<0a href="Documentation/dr07e dri7 USB, etciver-model/e. Tdiscd folledls bus_rbus aa="ajaxhgecumensymcumrei/bus.txt#L12" id="L12" class="line" name="L12"> 0 18st0ruct bus_type pci_bus_ty08e dri8e bus drcumcumenta bus-spediratiorya.oDref= bus-scumenta iratioryaref="DophysiDocbus.txt#L43" id="L43" class="line" name="L43">10 19  0     .name    = "pc09e dri91  10
<   11Decclaration
   1  12~~~~~~~~~~~~
   1  13
<;">;"root/pci0/00:00.0bus.txt#L2" id="L2" class="line" name="L2">   1  14Eaach bus type in the kerneel (P114;">;"root/pci0/00:01.0bus.txt#L2" id="L2" class="line" name="L2">   1  15obbject of this type. They  must115;">;"root/pci0/00:02.0bus.txt#L2" id="L2" class="line" name="L2">   1  16opptionally initialize the  matc1 callbref="Doo`--m -modeabus.txt#L2" id="L2" class="line" name="L2">   1  17
<   18sttruct bus_type pci_bus_tyype =11#L38" id=4" class="line" name="L54">  54When a 1  19        .name    = "pcci&qu1t;,
   1  20 1      .match   = pci_bus1_matc1,
1  21}1;
 2 12~~~~~~~~~~~~
   1  23T1he structure should be e1xport123   1  24
1   1  15obxtern struct bus_type pc1i_bus1type;
l/bus.txt#L22" id="L22" class="line" name="L22">1  26
11  27
11  28R1egistration
1  29~1~~~~~~~~~~~
1  30
11  31W1hen a bus driver is init1ializ13-modemedel/tBUS_ATTR(debug,0644,show_debug,siore_debugl/bus.txt#L9" id="L9" class="line" name="L9">   1  32i1nitializes the rest of t1he fi13odel/bus.txt#L43" id="L43" class="line" name="L43">13 13
1  24
1he fields in it are usab1le by13odel/bus.txt#L25" id="L25" class="line" name="L25">1  35
1   1  26
11  37C1allbacks
1  28R1~~~~~~~~
1  29~11  40m1atch(): Attaching Driver1s to 1evicess);
   1  41~1~~~~~~~~~~~~~~~~~~~~~~~~1~~~~~1~~~~~~voidrbion/dmd f_odelumentation/driver-, mentation/dattributsl*l/bus.txt#L9" id="L9" class="line" name="L9">   1  32i11  43T1he format of device ID s1truct14odel/bus.txt#L14" id="L14" class="line" name="L14">   14Eacch bus type in the kernele by1c. Dri
and original LXR softwtypiation/dus.txt#L1http://sourcefoyge.net/protatis/lxr">LXR commr-mod Dri,name f
lxr@lel/b.no Dri.

lxr.lel/b.no kindlyahosteftatius.txt#L1http://www.redpill-lelpro.no">Redpill Lelpro AS Dri,nhref="DrrbusLel/b consulrs wieachopemodel/s serus-spess ce 1995.