All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libata-acpi: Try and stop all the non PCI devices crashing
@ 2007-03-08 23:13 Alan Cox
  0 siblings, 0 replies; only message in thread
From: Alan Cox @ 2007-03-08 23:13 UTC (permalink / raw)
  To: akpm, torvalds, linux-ide, jgarzik

For 2.6.20 it mostly used to just not work, for 2.6.21-rc it crashes, this
seems to be down to luck (bad or good). The libata-acpi code needs to
avoid doing PCI work on non-PCI devices. This is one hack although it's
not pretty and perhaps there is a "right" way to check if a struct device
* is PCI ?

Signed-off-by: Alan Cox <alan@redhat.com>

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.21-rc3-mm2/drivers/ata/libata-acpi.c linux-2.6.21-rc3-mm2/drivers/ata/libata-acpi.c
--- linux.vanilla-2.6.21-rc3-mm2/drivers/ata/libata-acpi.c	2007-03-08 15:59:20.000000000 +0000
+++ linux-2.6.21-rc3-mm2/drivers/ata/libata-acpi.c	2007-03-08 16:44:25.000000000 +0000
@@ -34,6 +34,16 @@
 	u8	tfa[REGS_PER_GTF];	/* regs. 0x1f1 - 0x1f7 */
 };
 
+/*
+ *	Helper - belongs in the PCI layer somewhere eventually
+ */
+ 
+static int is_pci_dev(struct device *dev)
+{
+	if (dev->bus == &pci_bus_type)
+		return 1;
+	return 0;
+}
 
 /**
  * sata_get_dev_handle - finds acpi_handle and PCI device.function
@@ -52,6 +62,9 @@
 {
 	struct pci_dev	*pci_dev;
 	acpi_integer	addr;
+	
+	if (!is_pci_dev(dev))
+		return -ENODEV;
 
 	pci_dev = to_pci_dev(dev);	/* NOTE: PCI-specific */
 	/* Please refer to the ACPI spec for the syntax of _ADR. */
@@ -84,7 +97,12 @@
 	acpi_status status;
 	struct acpi_device_info	*dinfo = NULL;
 	int ret = -ENODEV;
-	struct pci_dev *pdev = to_pci_dev(dev);
+	struct pci_dev *pdev;
+
+	if (!is_pci_dev(dev))
+		return -ENODEV;
+
+	pdev = to_pci_dev(dev);
 
 	bus = pdev->bus->number;
 	devnum = PCI_SLOT(pdev->devfn);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-03-08 22:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-08 23:13 [PATCH] libata-acpi: Try and stop all the non PCI devices crashing Alan Cox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.