0

I'm learning driver development and according to the book I read, all Linux devices of same type have same major number are controlled by same driver so for example if we have a computer with multiple UART physical ports all of them will have same major number but different minor number which the driver will interpret as different physical ports. My question is that according to this link misc devices (major number 10) are many and my PC confirms this, so my question is that how can one driver control all these different devices(there are many of them virtual). Is there one level of redirection in which when i open a device the Kernel have registered this major number already and according to minor number the kernel registered driver calls the driver responsible to this minor number(the one I wrote), or when I open the device file my registered driver will be the one called directly.

1 Answer 1

1

Yes, there is a level of indirection. The misc driver is registered as the driver for all device nodes with the corresponding major; it maintains a list of registered drivers. When a device is opened, the first handler is misc_open, which looks for a matching driver in the list and passes control to it.

3
  • thanks a lot but does this situation also applies for all other Linux static assigned major numbers
    – KMG
    Commented Jul 28, 2021 at 17:09
  • As a general rule yes: each major has one registered driver, if different minors have different drivers there has to be some indirection handled in the driver registered for the major. Commented Jul 28, 2021 at 17:12
  • thanks a lot got it now
    – KMG
    Commented Jul 28, 2021 at 17:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .