[PATCH] libata-acpi: Try and stop all the non PCI devices crashing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>

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);
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux