Skip to contentSkip to conversation

How to determine whether a device is PCI or not

parisc-linux Greg KH 3 participants 3 messages Oct 30, 2004 4 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Greg KH

author
#3 lore raw
Quoted 10 lines · Matthew Wilcox
Quoted 9 lines · Joel Soete
(quoted diff) +4 -0
 	while (dev != &root) {
+#ifdef CONFIG_PCI
 		if (dev->bus == &pci_bus_type) {
 			unsigned int devfn = to_pci_dev(dev)->devfn;
 			path->bc[i--] = PCI_SLOT(devfn) | (PCI_FUNC(devfn)<< 5);
 		} else if (dev->bus == &parisc_bus_type) {
+#else
+		if (dev->bus == &parisc_bus_type) {
+#endif
Quoted 8 lines

Review

Quoted 3 lines
(quoted diff) +0 -0
 			path->bc[i--] = to_parisc_device(dev)->hw_path;
 		}
 		dev = dev->parent;

The problem here is that pci_bus_type is declared inside an #ifdef CONFIG_PCI. What we *actually* want to know is "is this device a pci_dev?" and this isn't the best way to ask this question. How about we add exactly that question to <linux/pci.h>, something like:

Ick, no. Devices do not "show" their type, you have to explicitly know what type they are in order to use them.

Why are you wanting to know this? What are you trying to do with a generic struct device * where you don't know exactly what type it is?

thanks,

greg k-h

p.s. bonus points to the first person who finds in the kernel where I myself have violated the second sentance in this response :)
_______________________________________________
parisc-linux mailing list [email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

#4 lore raw
Quoted 5 lines · Greg KH

Ick, no. Devices do not "show" their type, you have to explicitly know what type they are in order to use them.

Why are you wanting to know this? What are you trying to do with a generic struct device * where you don't know exactly what type it is?

In order to communicate with PA-RISC firmware, you have to know the path to a device. It's typically represented as something like [10/8/4/5/0]. This device can be PCI, GSC or EISA. There's some moderately arcane rules for turning a device into a path that you really don't care about, but we need the devfn for PCI devices and the hw_path for GSC devices.

So what we want to do is, given a struct device, determine its path; and given a path, turn it into a struct device. The device model lets us do this quite nicely -- much better than having duplicated routines for starting with a pci_dev or a parisc_device.

If you prefer to keep this out of linux/pci.h, that's fine, we can keep it private to arch/parisc. I thought this might be something other architectures might want to use (maybe for openfirmware?)

Signature · 10 lines
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 8 lines · Greg KH
Quoted 4 lines · Matthew Wilcox

If you prefer to keep this out of linux/pci.h, that's fine, we can keep it private to arch/parisc. I thought this might be something other architectures might want to use (maybe for openfirmware?)

Let's keep it private for now. If openfirmware ever moves to the device tree properly, we can deal with it then :)

The EDD sysfs symlinks would like something like this, not only for PCI (it does this today by calling pci_find_slot() with the values BIOS tells it), but doesn't have the infrastructure for making symlinks to the underlying ATA, SCSI, SAS (coming), ... devices. I removed the horrible hacks I put in to try to guess what a device is, and don't create the symlink from the EDD device to the actual disk device. But it would be nice to have a generic method to do it so I can add that back in.

Thanks,
Matt

Signature · 8 lines
Matt Domsch
Sr. Software Engineer, Lead Engineer
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux