STRUCT BUS_TYPE(9)
π struct bus_type(9) β the bus type of the device β¨
okay so this is a page straight outta the Kernel API Manual, and before we get into it: hi bestie, welcome, you're gonna do great π«Ά
π NAME π
struct bus_type β literally just: the bus type of the device. that's the whole vibe. that's what it is. π
π SYNOPSIS π
struct bus_type {
const char *name;
const char *dev_name;
const struct attribute_group *const *bus_groups;
const struct attribute_group *const *dev_groups;
const struct attribute_group *const *drv_groups;
int (*match)(struct device *dev, const struct device_driver *drv);
int (*uevent)(const struct device *dev, struct kobj_uevent_env *env);
int (*probe)(struct device *dev);
void (*sync_state)(struct device *dev);
void (*remove)(struct device *dev);
void (*shutdown)(struct device *dev);
const struct cpumask *(*irq_get_affinity)(struct device *dev, unsigned int irq_vec);
int (*online)(struct device *dev);
int (*offline)(struct device *dev);
int (*suspend)(struct device *dev, pm_message_t state);
int (*resume)(struct device *dev);
int (*num_vf)(struct device *dev);
int (*dma_configure)(struct device *dev);
void (*dma_cleanup)(struct device *dev);
const struct dev_pm_ops *pm;
bool driver_override;
bool need_parent_lock;
};
look at all those function pointers, she's iconic π
πΈ Members (the main characters) πΈ
okay so this is the whole cast, let's meet them one by one π
nameβ the name of the bus. that's it. that's her name. πdev_nameβ used for subsystems to enumerate devices like("foou", dev->id). yes the manual literally saysfoou. iykyk. πbus_groupsβ the default attributes of the bus itself.dev_groupsβ the default attributes of the devices on the bus.drv_groupsβ the default attributes of the device drivers on the bus.matchβ called, perhaps multiple times, whenever a new device or driver is added for this bus. she should return a positive value if the given device can be handled by the given driver, and zero otherwise. she may also return an error code if determining that the driver supports the device is not possible. and in the case of-EPROBE_DEFERshe'll queue the device for deferred probing. she's doing a lot, ngl πueventβ called when a device is added, removed, or a few other things that generate uevents, to add the environment variables.probeβ called when a new device or driver add to this bus, and callback the specific driver'sprobeto initial the matched device. (yes bestie, that's the original wording, i'm not touching it π«Ά)sync_stateβ called to sync device state to software state after all the state tracking consumers linked to this device (present at the time oflate_initcall) have successfully bound to a driver. if the device has no consumers, this function will be called atlate_initcall_synclevel. and if the device has consumers that are never bound to a driver, this function will never get called until they do. literally never. the suspense. πremoveβ called when a device removed from this bus. bye bestie πshutdownβ called at shut-down time to quiesce the device. quiet down queen, it's bedtime πirq_get_affinityβ get the IRQ affinity mask for the device on this bus.onlineβ called to put the device back online (after offlining it). welcome back πofflineβ called to put the device offline for hot-removal. may fail. πsuspendβ called when a device on this bus wants to go to sleep mode. goodnight π΄resumeβ called to bring a device on this bus out of sleep mode. rise and grind βοΈnum_vfβ called to find out how many virtual functions a device on this bus supports. counting era π’dma_configureβ called to setup DMA configuration on a device on this bus.dma_cleanupβ called to cleanup DMA configuration on a device on this bus. we love a tidy queen π§Ήpmβ power management operations of this bus, callback the specific device driver's pm-ops.driver_overrideβ set totrueif this bus supports thedriver_overridemechanism, which allows userspace to force a specific driver to bind to a device via a sysfs attribute. forcing it. main character energy fr fr πneed_parent_lockβ when probing or removing a device on this bus, the device core should lock the device's parent. protective parent vibes, we respect it π«Ά
β οΈ Note β οΈ
this callback may be invoked with or without the device lock held. yes, either way. prepare accordingly bestie π
π¦ Description π¦
so like, what even is a bus? a bus is a channel between the processor and one or more devices. β¨
for the purposes of the device model, all devices are connected via a bus β even if it's an internal, virtual, "platform" bus. no exceptions, everyone's on a bus, we're all connected π
buses can plug into each other. a USB controller is usually a PCI device, for example. it's giving nesting dolls, it's giving lore π§
the device model represents the actual connections between buses and the devices they control. and a bus is represented by the bus_type structure. she contains the name, the default attributes, the bus' methods, PM operations, and the driver core's private data. full package, no notes π
π SEE ALSO π
kernel file ./include/linux/device/bus.h, plus the whole friend group:
bus_find_device_by_name(9)bus_find_device_by_of_node(9)bus_find_device_by_fwnode(9)bus_find_device_by_devt(9)bus_find_next_device(9)bus_find_device_by_acpi_dev(9)enum bus_notifier_event(9)
go read them, they're all slay π₯
and that's the page babes!! brought to you by the fine folks at ./include/linux/device, from the October 2026 drop π mwah, go forth and enumerate your devices πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms