€•@Œ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Œ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”…””}”(hhñhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hhîhž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:”…””}”(hhÿhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h Khhîhž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, };”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1j hŸh¶h Khhîhž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:”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h KhhîhžhubhÉ)”}”(hŒ$extern struct bus_type pci_bus_type;”h]”hŒ$extern struct bus_type pci_bus_type;”…””}”(hj-hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h Khhîhžhubeh}”(h]”Œ declaration”ah ]”h"]”Œ declaration”ah$]”h&]”uh1h¡hh£hžhhŸh¶h K ubh¢)”}”(hhh]”(h§)”}”(hŒ Registration”h]”hŒ Registration”…””}”(hjFhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjChž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.”…””}”(hjThžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K hjChžhubeh}”(h]”Œ registration”ah ]”h"]”Œ registration”ah$]”h&]”uh1h¡hh£hžhhŸh¶h Kubh¢)”}”(hhh]”h§)”}”(hŒ Callbacks”h]”hŒ Callbacks”…””}”(hjmhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjjhž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 *));”…””}”hjósbah}”(h]”h ]”h"]”h$]”h&]”jjuh1j 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”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjhž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 KYhjhž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:”…””}”(hj6hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K[hjhžhubj)”}”(hŒ%/sys/bus/pci/ |-- devices `-- drivers”h]”hŒ%/sys/bus/pci/ |-- devices `-- drivers”…””}”hjDsbah}”(h]”h ]”h"]”h$]”h&]”jjuh1j hŸh¶h K^hjhž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:”…””}”(hjRhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h Kbhjhž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”…””}”hj`sbah}”(h]”h ]”h"]”h$]”h&]”jjuh1j hŸh¶h Kehjhž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:”…””}”(hjnhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h Kmhjhž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”…””}”hj|sbah}”(h]”h ]”h"]”h$]”h&]”jjuh1j hŸh¶h Kqhjhž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&]”jjuh1j 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&]”jjuh1j 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&]”jjuh1j 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&]”jjuh1j 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”j8Œ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”}”(jjhëhèj@j=jgjdj€j}jÃjÀjjjjŒj juŒ nametypes”}”(j‰hë‰j@‰jg‰j€‰jÉj‰j‰j ‰uh}”(jh£hèh·j=hîjdjCj}jjjÀjƒjjÆjŒjjj’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.