usb_get_status(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ usb_get_status β€” a Kernel API Manual moment, bestie πŸŽ€

Ok so we're diving into usb_get_status(9) today and honestly? It's giving "small function, big job" energy. This is the kernel API manual, and this lil baby issues a GET_STATUS call β€” that's the whole NAME, periodt. πŸ’…


✨ SYNOPSIS ✨

int usb_get_status (struct usb_device *dev , int recip , int type , int target , void *data );

Like, look at that signature. Five arguments. She's thorough and we respect it. 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • dev β€” the device whose status is being checked πŸ‘€ like, whose vibe are we checking exactly
  • recip β€” USB_RECIP_*; for device, interface, or endpoint. Basically "who's the recipient of this whole situation"
  • type β€” USB_STATUS_TYPE_*; for standard or PTM status types
  • target β€” zero (for device), else interface or endpoint number. So 0 means "the device itself", anything else is like "no babe, that specific interface or endpoint"
  • data β€” pointer to two bytes of bitmap data πŸ—ΊοΈ two whole bytes, that's the cargo

🌸 CONTEXT 🌸

task context, might sleep. 😴

No fr, that means you canNOT pull this in an interrupt context β€” she needs her nap time and that's non-negotiable.


πŸ’– DESCRIPTION πŸ’–

Returns device, interface, or endpoint status. That's the tea. β˜•

Normally only of interest to see if the device is self powered, or has enabled the remote wakeup facility; or whether a bulk or interrupt endpoint is halted ("stalled"). Those are literally the main character reasons you'd ever call this, iykyk.

Bits in these status bitmaps are set using the SET_FEATURE request, and cleared using the CLEAR_FEATURE request. So set-feature and clear-feature are the ones flipping the switches, bestie, not this function. πŸ”₯

The usb_clear_halt function should be used to clear halt ("stall") status. Like β€” do NOT try to DIY the un-stalling, that's not what we're here for. πŸ™ˆ

This call is synchronous, and may not be used in an interrupt context. Sleepy function, sleepy rules. πŸ’€

And the results? Returns 0 and the status value in *data (in host byte order) on success, or else the status code from the underlying usb_control_msg call. So 0 = slay, anything else = the actual error from the layer underneath. 🫑


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./drivers/usb/core/message.c β€” and honestly the whole friend group:


Sign-off time, bestie 🧚 this page lives in ./drivers/usb/core, it's dated October 2026, and it's filed under usb_get_status(9) in the Kernel API Manual. That's the whole vibe, we ate, no crumbs left. πŸ’œπŸŽ€βœ¨

πŸ“¦ where this page comes from