platform_get_irq(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ platform_get_irq(9) ✨

okay so bestie, welcome to the platform_get_irq page πŸ’… this is from the Kernel API Manual, section 9, and it's genuinely one of the most useful little functions you'll ever meet 🫢


🌸 SYNOPSIS 🌸

int platform_get_irq (struct platform_device *dev , unsigned int num );

like, that's the whole thing. short king πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

  • dev β€” the platform device 🧚 your main character, the one you want an IRQ for
  • num β€” the IRQ number index πŸ”’ like which IRQ you're asking for, by index

πŸ’– DESCRIPTION πŸ’–

so this function gets an IRQ for a platform device β€” and the iconic part? it also prints an error message if finding the IRQ fails 😭 it's literally telling on itself so you don't have to guess.

the important bit, no cap: device drivers should check the return value for errors so as to not pass a negative integer value to the request_irq APIs πŸ”₯ like please. check it. that negative int wandering into request_irq is giving chaos.

their example, verbatim, because it's iconic:

int irq = platform_get_irq(pdev, 0);
if (irq < 0)
        return irq;

see? check it, bail out, slay πŸ’…


⭐ RETURN ⭐

  • non-zero IRQ number on success πŸ‘‘
  • negative error number on failure πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹

lil family tree moment, and yes the whole thing, we're not skipping anyone 🫢

Kernel file ./drivers/base/platform.c platform_get_resource(9), devm_platform_get_and_ioremap_resource(9), devm_platform_ioremap_resource(9), devm_platform_ioremap_resource_byname(9), platform_get_irq_affinity(9), platform_get_irq_optional(9), platform_irq_count(9), devm_platform_get_irqs_affinity(9), platform_get_resource_byname(9), platform_get_irq_byname(9), platform_get_irq_byname_optional(9), platform_add_devices(9), platform_device_put(9), platform_device_alloc(9), platform_device_add_resources(9), platform_device_add_data(9), platform_device_set_of_node(9), platform_device_set_fwnode(9), platform_device_set_of_node_from_dev(9), platform_device_add(9), platform_device_del(9), platform_device_register(9), platform_device_unregister(9), platform_device_register_full(9), __platform_driver_register(9), platform_driver_unregister(9), __platform_driver_probe(9), __platform_create_bundle(9), __platform_register_drivers(9), platform_unregister_drivers(9), platform_match(9), platform_find_device_by_driver(9)


and that's the whole vibe bestie 🌈 this one lives in ./drivers/base and the manual's dated October 2026 β€” go forth and check your return values, ily, bye πŸŽ€βœ¨

πŸ“¦ where this page comes from