2002-10-27 09:02:15

by Adam J. Richter

[permalink] [raw]
Subject: Patch: linux-2.5.44/include/linux/pci.h - eliminate pci_dev.driver_data

Hi Martin,

In 2.5.44 (don't know when it first appeared), the generic
struct device has a "void *driver_data" field. The following patch
eliminates pci_dev.driver_data, using pci_dev.dev.driver_data instead.

The immediate benefits are small but pretty clear:

1. Shrinks all struct pci_dev's by 4 (or 8) bytes.
2. Shrinks include/linux/pci.h by 1 line.
3. Avoids potential bugs by programmers getting conufsed between
the two.
4. Prevents anyone from writing drivers that use both pointers
separately, which would make it harder to make this change
in the future. This is a reason to make the change now.

Only six driver files in 2.5.44 attempted to reference
pci_dev.driver_data directly, and I have submitted patches
to make them use pci_{get,set}_drvdata to their maintainers
(cc'ed to linux-kernel).

I am sending this email from a machine running this patch.

By the way, there is an additional future benefit that I
envision. In the future, I would like to add an optional
device_driver.devpriv_size field that could eliminate some initial
memory allocation, error branch and memory deallocation in about a
hundred drivers (well, at least after allocation of network, SCSI, USB
interfaces is done by filling in a pointer to a structure rather than
having a routine that does its own kmalloc).

--
Adam J. Richter __ ______________ 575 Oroville Road
[email protected] \ / Milpitas, California 95035
+1 408 309-6081 | g g d r a s i l United States of America
"Free Software For The Rest Of Us."


Attachments:
(No filename) (1.56 kB)
pci.diff (802.00 B)
Download all attachments