LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 04-15-2008, 10:28 PM   #1
rickhg12hs
LQ Newbie
 
Registered: Apr 2008
Distribution: RHEL, Fedora, Ubuntu
Posts: 13

Rep: Reputation: 1
Question Multiple Device driver from single device driver????


Goal:

Use multiple PCI cards in a system when the provided device driver assumes only one card will be present.

Background:

A reference design provides a device driver for a mini-PCI card. This device driver spans several loadable kernel modules (addressing different logical portions of the hardware) and each kernel module has dozens of source files. The device driver was written assuming _only_ one card would be present in the system at a time resulting in hardware/driver "state" variables sprinkled throughout all the source files.

Solution?:

Obviously the device driver could be completely rewritten by aggregating all of the state variables into some sort of structure and then kmalloc'ing a number of them at kernel module load/init time (array or linked list, etc.). This looks to be rather hard (the state variables are everywhere and the chances of missing some are high) and tedious (> 100k LOC).

Is there another option by perhaps wrapping the device driver in a way to allow multiple cards?

Is there a smart _and_ lazy way to accomplish the goal?
 
Old 05-14-2008, 04:15 PM   #2
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
You could load multiple instances of the same driver? using modprobe options like -o. you can see how it is done at this location which talks about bonding drivers : http://lwn.net/Articles/258538/

Hope this helped.
 
Old 05-24-2008, 11:37 PM   #3
rickhg12hs
LQ Newbie
 
Registered: Apr 2008
Distribution: RHEL, Fedora, Ubuntu
Posts: 13

Original Poster
Rep: Reputation: 1
Linux kernel module global variables are all in one namespace, no?

Quote:
Originally Posted by shishir View Post
You could load multiple instances of the same driver? using modprobe options like -o. you can see how it is done at this location which talks about bonding drivers : http://lwn.net/Articles/258538/
Since Linux has a monolithic kernel, won't all the non-static global variables clash when the second re-named module is loaded/linked?

How can this be prevented easily without a module rewrite?
 
Old 05-25-2008, 01:11 AM   #4
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
The way it works is kernel gives each modules its own namespace, as long as you are not exporting symbols from the modules, you should be fine.
 
  


Reply

Tags
devicedrivers, kernelmodule


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
uclinux custom device driver not loading, possibly multiple problems godzilla Linux - Kernel 12 09-10-2007 07:39 PM
help in device driver jaepi Linux - Newbie 2 05-01-2007 10:46 PM
single device - multiple icons on desktop pringle1944 Linux - Newbie 1 03-17-2006 07:09 PM
single ext3 journal device multiple journaled file systems? reelwylde Linux - General 4 09-08-2005 04:00 PM
assigning multiple device aliases to single drive cerealdaemon Linux - General 5 07-26-2005 12:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 12:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration