Skip to contentSkip to conversation

Untested port of parisc_device to generic device interface

parisc-linux Adam J. Richter 1 participant 1 message Nov 10, 2002

lore
Share & tools
lore
#0 lore raw
Quoted 10 lines · Grant Grundler

Documentation/driver-model/overview.txt:

| Note also that it is at the _end_ of struct pci_dev. This is
| to make people think about what they're doing when switching between the bus
| driver and the global driver; and to prevent against mindless casts between
| the two.

Until this changes, I don't see this as a useful replacement for either PCI or parisc devices. The "mindless casts" can be fixed. But without the ability to easily go from generic device type to bus specific type, people will just get lost in the maze of pointers.

linux-2.5.46/include/linux/kernel.h already defines
container_of(ptr_to_element, parent_struct, element_name).

Quoted 1 line

From <linux/pci.h>:

#define to_pci_dev(n) container_of(n, struct pci_dev, dev)

Quoted 1 line

From <linux/usb.h>:

#define to_usb_device(d) container_of(d, struct usb_device, dev)

Quoted 1 line

From <asm-parisc/hardware.h> with my parisc device patch:

static inline struct parisc_device *to_parisc_dev(struct device *dev)

{
        return container_of(dev, struct parisc_device, device);
}
Adam J. Richter     __     ______________   575 Oroville Road
[email protected]     \ /                  Miplitas, 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."