Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8671211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:53:39+00:00 2026-06-12T18:53:39+00:00

In Linux if device drivers are built as loadable kernel modules, then upon inserting

  • 0

In Linux if device drivers are built as loadable kernel modules, then upon inserting the device driver kernel module, the kernel calls the init function of the device driver as pointed out by module_init() macro.

How does this work for device drivers that are statically compiled into the kernel ? How is their init function called ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:53:40+00:00Added an answer on June 12, 2026 at 6:53 pm

    The init routine of a built-in driver can still use the module_init() macro to declare that entry point. Or the driver can use device_initcall() when the driver would never be compiled as a loadable module. Or to move its initialization very early in the boot sequence, the driver could use subsys_initcall().

    In include/linux/init.h the sequence for invoking these init routines is described as:

    /* initcalls are now grouped by functionality into separate 
     * subsections. Ordering inside the subsections is determined
     * by link order. 
     * For backwards compatibility, initcall() puts the call in 
     * the device init subsection.
     *
     * The `id' arg to __define_initcall() is needed so that multiple initcalls
     * can point at the same handler without causing duplicate-symbol build errors.
     */
    

    I assume that these subsections for device drivers correspond to the subdirectories within the drivers directory of the Linux kernel source tree, and that the link order is recorded in the built-in.o file of each subdirectory in drivers. So during kernel boot the init routine of each built-in driver is eventually executed by do_initcalls() in init/main.c.

    The init routine of the device driver is responsible for probing the system to verify that the HW device actually exists. The driver should not allocate any resources or register any devices when the probe fails.

    UPDATE:
    Passing the option “initcall_debug” on the kernel command line will cause timing information to be printed to the console for each initcall. initcalls are used to initialize statically linked kernel drivers and subsystems and contribute a significant amount of time to the Linux boot process. The output looks like:

    calling  tty_class_init+0x0/0x44 @ 1
    initcall tty_class_init+0x0/0x44 returned 0 after 9765 usecs
    calling  spi_init+0x0/0x90 @ 1
    initcall spi_init+0x0/0x90 returned 0 after 9765 usecs
    

    Reference: http://elinux.org/Initcall_Debug

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to learn about device drivers on Linux Kernel, for that I've created
I'm writing a kernel object (.ko file, which is usually device driver) of Linux.
I'm writing an API as a kernel module that provides device drivers with various
I have started reading the book Essential Linux Device Drivers. I am following the
I am reading linux device driver book of rubini,corbet and hartmen.I have doubt regarding
I am rather new to Linux device driver programmring, but for debugging purposes, I
Recently, i began developing a driver of an embedded device running linux. Until now
I am writing a device driver for a DMA device in Linux. In Linux
I am following the Linux Device Drivers. When it introduces spinlocks, it gives the
I m bit confused by the following statement in linux device drivers book. http://www.linuxdriver.co.il/ldd3/

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.