Multiple Device driver from single device driver????
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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/
Linux kernel module global variables are all in one namespace, no?
Quote:
Originally Posted by shishir
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.