Patch: linux-2.5.44/include/linux/pci.h - eliminate pci_dev.driver_data

From: Adam J. Richter (adam@yggdrasil.com)
Date: Sun Oct 27 2002 - 04:08:23 EST


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
adam@yggdrasil.com     \ /                  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."


- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Oct 31 2002 - 22:00:32 EST