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 6635257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:01:54+00:00 2026-05-25T23:01:54+00:00

In a project I am involved in we have the following hardware setup: Linux

  • 0

In a project I am involved in we have the following hardware setup:

     Linux PC ------> "Router" +----> "Device A"
                               |
                               +----> "Device B"

Linux PC is a standard X86 PC.

“Router” is a piece of hardware we developed that is connected to other pieces of hardware in our system. In this example “Device A”. The “Router” is connected to the Linux PC using USB.

“Device A” and “Device B” are pieces of hardware in the system. They are connected to the “Router” hardware via some communication channel (unimportant in this case).

My task is to write a Linux device driver for “Device A” (and later other devices as well).

I have already constructed a general purpose USB driver that talks to “Router” and this works fine. My plan was to have a driver stack that would look like this:

+----------+----------+
| dev_A.ko | dev_B.ko |
+----------+----------+
|     router.ko       |
+---------------------+
|   Linux USB driver  |
+---------------------+

That is: The device drivers communicate with their hardware using the “router.ko” kernel module which in turn is built on the standard Linux USB driver core.

My problem is that to the Linux PC, there is only one physical device: The “Router” hardware connected via USB, which means the device drivers become some sort of virtual devices.

I could compile teh device drivers and the Router device driver into one big kernel module, but it does not seem like the best solution.

Also, since “Device A” has previously been connected directly to a Linux PC there already exists a driver for it with a well defined userspace-interface which must be kept since there are already applications in production that need to speak to it.

My question more or less boils down to this:

Given the hardware scenario above, how would you structure the Linux kernel modules?

  • 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-05-25T23:01:55+00:00Added an answer on May 25, 2026 at 11:01 pm

    I don’t see any problem with your proposed solution of having one router.ko module that talks to the actual hardware, and submodules dev_A.ko and dev_B.ko that talk to router.ko. You just need to have router.ko export a “my_register_driver” function, analogous to the existing pci_register_driver function. You would pass in a structure that has an “id” member and a “add_device” function pointer; dev_A.ko would pass in id=”A” and add_device=dev_A_add, and similarly for dev_B.ko.

    Then when router.ko comes up, it discovers the hardware and creates virtual devices (your own context structure) for A and B. Then when a submodule comes along, router.ko just calls the appropriate add_device methods with the appropriate virtual device. router.ko should also export methods that the dev_A and dev_B modules can use to access the underlying hardware.

    For an example of what I have in mind, you can look at the mlx4_core, mlx4_ib and mlx4_en modules in the upstream kernel (I wrote them so I choose this example :). The idea with them is that there is one PCI device that can be used as both an InfiniBand and Ethernet device; so mlx4_ib and mlx4_en both use mlx4_core to discover and access the underlying PCI device. The small bit of code that the sub-drivers use to ask for which devices exist is in drivers/net/mlx4/intf.c.

    Also, as far as the existing “Device A” userspace interface, that shouldn’t be a problem. You can just implement the same ABI in your dev_A.ko, unless there is some complication you didn’t mention.

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

Sidebar

Related Questions

I have a project that involves polling a hardware switch each update and converting
I've been working on a project where I have been using LinqToSQL that involved
I have a Problem. I'm involved in a Windows CE Software Project that runs
I have a Java application that is managed using Maven. The project involves the
I spent the last year working on a project that involved mostly java for
the project that i am involved in has a lot of small modules that
I'm involved in a project which is able to connect to different hardware devices
Soon I will be involved in a project that will be using the agile
I have a project that involves three frontend developers. We're going to use backbone
I am currently working on a project that involves splitting a url. I have

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.