€•õ@Œsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ//translations/zh_CN/driver-api/driver-model/bus”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ//translations/zh_TW/driver-api/driver-model/bus”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ//translations/it_IT/driver-api/driver-model/bus”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ//translations/ja_JP/driver-api/driver-model/bus”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ//translations/ko_KR/driver-api/driver-model/bus”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ//translations/pt_BR/driver-api/driver-model/bus”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ//translations/sp_SP/driver-api/driver-model/bus”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ Bus Types”h]”hŒ Bus Types”…””}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³ŒI/var/lib/git/docbuild/linux/Documentation/driver-api/driver-model/bus.rst”h´Kubh¶)”}”(hhh]”(h»)”}”(hŒ Definition”h]”hŒ Definition”…””}”(hhÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhhËh²hh³hÊh´KubhŒ paragraph”“”)”}”(hŒ*See the kerneldoc for the struct bus_type.”h]”hŒ*See the kerneldoc for the struct bus_type.”…””}”(hhÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KhhËh²hubhÝ)”}”(hŒ(int bus_register(struct bus_type * bus);”h]”hŒ(int bus_register(struct bus_type * bus);”…””}”(hhìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K hhËh²hubeh}”(h]”Œ definition”ah ]”h"]”Œ definition”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)”}”(hhh]”(h»)”}”(hŒ Declaration”h]”hŒ Declaration”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´K ubhÝ)”}”(hŒ²Each bus type in the kernel (PCI, USB, etc) should declare one static object of this type. They must initialize the name field, and may optionally initialize the match callback::”h]”hŒ±Each bus type in the kernel (PCI, USB, etc) should declare one static object of this type. They must initialize the name field, and may optionally initialize the match callback:”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Khjh²hubhŒ literal_block”“”)”}”(hŒ_struct bus_type pci_bus_type = { .name = "pci", .match = pci_bus_match, };”h]”hŒ_struct bus_type pci_bus_type = { .name = "pci", .match = pci_bus_match, };”…””}”hj#sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1j!h³hÊh´Khjh²hubhÝ)”}”(hŒ=The structure should be exported to drivers in a header file:”h]”hŒ=The structure should be exported to drivers in a header file:”…””}”(hj3h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Khjh²hubhÝ)”}”(hŒ$extern struct bus_type pci_bus_type;”h]”hŒ$extern struct bus_type pci_bus_type;”…””}”(hjAh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Khjh²hubeh}”(h]”Œ declaration”ah ]”h"]”Œ declaration”ah$]”h&]”uh1hµhh·h²hh³hÊh´K ubh¶)”}”(hhh]”(h»)”}”(hŒ Registration”h]”hŒ Registration”…””}”(hjZh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjWh²hh³hÊh´KubhÝ)”}”(hŒôWhen a bus driver is initialized, it calls bus_register. This initializes the rest of the fields in the bus object and inserts it into a global list of bus types. Once the bus object is registered, the fields in it are usable by the bus driver.”h]”hŒôWhen a bus driver is initialized, it calls bus_register. This initializes the rest of the fields in the bus object and inserts it into a global list of bus types. Once the bus object is registered, the fields in it are usable by the bus driver.”…””}”(hjhh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K hjWh²hubeh}”(h]”Œ registration”ah ]”h"]”Œ registration”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)”}”(hhh]”h»)”}”(hŒ Callbacks”h]”hŒ Callbacks”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj~h²hh³hÊh´K'ubah}”(h]”Œ callbacks”ah ]”h"]”Œ callbacks”ah$]”h&]”uh1hµhh·h²hh³hÊh´K'ubh¶)”}”(hhh]”(h»)”}”(hŒ%match(): Attaching Drivers to Devices”h]”hŒ%match(): Attaching Drivers to Devices”…””}”(hjšh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj—h²hh³hÊh´K*ubhÝ)”}”(hŒÝThe format of device ID structures and the semantics for comparing them are inherently bus-specific. Drivers typically declare an array of device IDs of devices they support that reside in a bus-specific driver structure.”h]”hŒÝThe format of device ID structures and the semantics for comparing them are inherently bus-specific. Drivers typically declare an array of device IDs of devices they support that reside in a bus-specific driver structure.”…””}”(hj¨h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K,hj—h²hubhÝ)”}”(hXThe purpose of the match callback is to give the bus an opportunity to determine if a particular driver supports a particular device by comparing the device IDs the driver supports with the device ID of a particular device, without sacrificing bus-specific functionality or type-safety.”h]”hXThe purpose of the match callback is to give the bus an opportunity to determine if a particular driver supports a particular device by comparing the device IDs the driver supports with the device ID of a particular device, without sacrificing bus-specific functionality or type-safety.”…””}”(hj¶h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K1hj—h²hubhÝ)”}”(hŒ¶When a driver is registered with the bus, the bus's list of devices is iterated over, and the match callback is called for each device that does not have a driver associated with it.”h]”hŒ¸When a driver is registered with the bus, the bus’s list of devices is iterated over, and the match callback is called for each device that does not have a driver associated with it.”…””}”(hjÄh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K7hj—h²hubeh}”(h]”Œ"match-attaching-drivers-to-devices”ah ]”h"]”Œ%match(): attaching drivers to devices”ah$]”h&]”uh1hµhh·h²hh³hÊh´K*ubh¶)”}”(hhh]”(h»)”}”(hŒDevice and Driver Lists”h]”hŒDevice and Driver Lists”…””}”(hjÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjÚh²hh³hÊh´K>ubhÝ)”}”(hXThe lists of devices and drivers are intended to replace the local lists that many buses keep. They are lists of struct devices and struct device_drivers, respectively. Bus drivers are free to use the lists as they please, but conversion to the bus-specific type may be necessary.”h]”hXThe lists of devices and drivers are intended to replace the local lists that many buses keep. They are lists of struct devices and struct device_drivers, respectively. Bus drivers are free to use the lists as they please, but conversion to the bus-specific type may be necessary.”…””}”(hjëh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K@hjÚh²hubhÝ)”}”(hŒEThe LDM core provides helper functions for iterating over each list::”h]”hŒDThe LDM core provides helper functions for iterating over each list:”…””}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KFhjÚh²hubj")”}”(hX7int bus_for_each_dev(struct bus_type * bus, struct device * start, void * data, int (*fn)(struct device *, void *)); int bus_for_each_drv(struct bus_type * bus, struct device_driver * start, void * data, int (*fn)(struct device_driver *, void *));”h]”hX7int bus_for_each_dev(struct bus_type * bus, struct device * start, void * data, int (*fn)(struct device *, void *)); int bus_for_each_drv(struct bus_type * bus, struct device_driver * start, void * data, int (*fn)(struct device_driver *, void *));”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”j1j2uh1j!h³hÊh´KHhjÚh²hubhÝ)”}”(hX‚These helpers iterate over the respective list, and call the callback for each device or driver in the list. All list accesses are synchronized by taking the bus's lock (read currently). The reference count on each object in the list is incremented before the callback is called; it is decremented after the next object has been obtained. The lock is not held when calling the callback.”h]”hX„These helpers iterate over the respective list, and call the callback for each device or driver in the list. All list accesses are synchronized by taking the bus’s lock (read currently). The reference count on each object in the list is incremented before the callback is called; it is decremented after the next object has been obtained. The lock is not held when calling the callback.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KOhjÚh²hubeh}”(h]”Œdevice-and-driver-lists”ah ]”h"]”Œdevice and driver lists”ah$]”h&]”uh1hµhh·h²hh³hÊh´K>ubh¶)”}”(hhh]”(h»)”}”(hŒsysfs”h]”hŒsysfs”…””}”(hj.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj+h²hh³hÊh´KXubhÝ)”}”(hŒ+There is a top-level directory named 'bus'.”h]”hŒ/There is a top-level directory named ‘bus’.”…””}”(hj<h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KYhj+h²hubhÝ)”}”(hŒTEach bus gets a directory in the bus directory, along with two default directories::”h]”hŒSEach bus gets a directory in the bus directory, along with two default directories:”…””}”(hjJh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K[hj+h²hubj")”}”(hŒ%/sys/bus/pci/ |-- devices `-- drivers”h]”hŒ%/sys/bus/pci/ |-- devices `-- drivers”…””}”hjXsbah}”(h]”h ]”h"]”h$]”h&]”j1j2uh1j!h³hÊh´K^hj+h²hubhÝ)”}”(hŒPDrivers registered with the bus get a directory in the bus's drivers directory::”h]”hŒQDrivers registered with the bus get a directory in the bus’s drivers directory:”…””}”(hjfh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kbhj+h²hubj")”}”(hŒo/sys/bus/pci/ |-- devices `-- drivers |-- Intel ICH |-- Intel ICH Joystick |-- agpgart `-- e100”h]”hŒo/sys/bus/pci/ |-- devices `-- drivers |-- Intel ICH |-- Intel ICH Joystick |-- agpgart `-- e100”…””}”hjtsbah}”(h]”h ]”h"]”h$]”h&]”j1j2uh1j!h³hÊh´Kehj+h²hubhÝ)”}”(hŒ˜Each device that is discovered on a bus of that type gets a symlink in the bus's devices directory to the device's directory in the physical hierarchy::”h]”hŒ›Each device that is discovered on a bus of that type gets a symlink in the bus’s devices directory to the device’s directory in the physical hierarchy:”…””}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kmhj+h²hubj")”}”(hŒ¯/sys/bus/pci/ |-- devices | |-- 00:00.0 -> ../../../root/pci0/00:00.0 | |-- 00:01.0 -> ../../../root/pci0/00:01.0 | `-- 00:02.0 -> ../../../root/pci0/00:02.0 `-- drivers”h]”hŒ¯/sys/bus/pci/ |-- devices | |-- 00:00.0 -> ../../../root/pci0/00:00.0 | |-- 00:01.0 -> ../../../root/pci0/00:01.0 | `-- 00:02.0 -> ../../../root/pci0/00:02.0 `-- drivers”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”j1j2uh1j!h³hÊh´Kqhj+h²hubeh}”(h]”Œsysfs”ah ]”h"]”Œsysfs”ah$]”h&]”uh1hµhh·h²hh³hÊh´KXubh¶)”}”(hhh]”(h»)”}”(hŒExporting Attributes”h]”hŒExporting Attributes”…””}”(hj©h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj¦h²hh³hÊh´Kzubj")”}”(hŒÊstruct bus_attribute { struct attribute attr; ssize_t (*show)(const struct bus_type *, char * buf); ssize_t (*store)(const struct bus_type *, const char * buf, size_t count); };”h]”hŒÊstruct bus_attribute { struct attribute attr; ssize_t (*show)(const struct bus_type *, char * buf); ssize_t (*store)(const struct bus_type *, const char * buf, size_t count); };”…””}”hj·sbah}”(h]”h ]”h"]”h$]”h&]”j1j2uh1j!h³hÊh´K~hj¦h²hubhÝ)”}”(hŒ¡Bus drivers can export attributes using the BUS_ATTR_RW macro that works similarly to the DEVICE_ATTR_RW macro for devices. For example, a definition like this::”h]”hŒ Bus drivers can export attributes using the BUS_ATTR_RW macro that works similarly to the DEVICE_ATTR_RW macro for devices. For example, a definition like this:”…””}”(hjÅh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K„hj¦h²hubj")”}”(hŒstatic BUS_ATTR_RW(debug);”h]”hŒstatic BUS_ATTR_RW(debug);”…””}”hjÓsbah}”(h]”h ]”h"]”h$]”h&]”j1j2uh1j!h³hÊh´Kˆhj¦h²hubhÝ)”}”(hŒis equivalent to declaring::”h]”hŒis equivalent to declaring:”…””}”(hjáh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KŠhj¦h²hubj")”}”(hŒ$static bus_attribute bus_attr_debug;”h]”hŒ$static bus_attribute bus_attr_debug;”…””}”hjïsbah}”(h]”h ]”h"]”h$]”h&]”j1j2uh1j!h³hÊh´KŒhj¦h²hubhÝ)”}”(hŒ\This can then be used to add and remove the attribute from the bus's sysfs directory using::”h]”hŒ]This can then be used to add and remove the attribute from the bus’s sysfs directory using:”…””}”(hjýh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KŽhj¦h²hubj")”}”(hŒ€int bus_create_file(struct bus_type *, struct bus_attribute *); void bus_remove_file(struct bus_type *, struct bus_attribute *);”h]”hŒ€int bus_create_file(struct bus_type *, struct bus_attribute *); void bus_remove_file(struct bus_type *, struct bus_attribute *);”…””}”hj sbah}”(h]”h ]”h"]”h$]”h&]”j1j2uh1j!h³hÊh´K‘hj¦h²hubeh}”(h]”Œexporting-attributes”ah ]”h"]”Œexporting attributes”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kzubeh}”(h]”Œ bus-types”ah ]”h"]”Œ bus types”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jLŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(j&j#hÿhüjTjQj{jxj”j‘j×jÔj(j%j£j jjuŒ nametypes”}”(j&‰hÿ‰jT‰j{‰j”‰j׉j(‰j£‰j‰uh}”(j#h·hühËjQjjxjWj‘j~jÔj—j%jÚj j+jj¦uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.