diff options
-rw-r--r-- | drivers/ata/libata-acpi.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index d14a48e75f1b..019d8ffdde50 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
@@ -34,6 +34,13 @@ struct taskfile_array { | |||
34 | u8 tfa[REGS_PER_GTF]; /* regs. 0x1f1 - 0x1f7 */ | 34 | u8 tfa[REGS_PER_GTF]; /* regs. 0x1f1 - 0x1f7 */ |
35 | }; | 35 | }; |
36 | 36 | ||
37 | /* | ||
38 | * Helper - belongs in the PCI layer somewhere eventually | ||
39 | */ | ||
40 | static int is_pci_dev(struct device *dev) | ||
41 | { | ||
42 | return (dev->bus == &pci_bus_type); | ||
43 | } | ||
37 | 44 | ||
38 | /** | 45 | /** |
39 | * sata_get_dev_handle - finds acpi_handle and PCI device.function | 46 | * sata_get_dev_handle - finds acpi_handle and PCI device.function |
@@ -53,6 +60,9 @@ static int sata_get_dev_handle(struct device *dev, acpi_handle *handle, | |||
53 | struct pci_dev *pci_dev; | 60 | struct pci_dev *pci_dev; |
54 | acpi_integer addr; | 61 | acpi_integer addr; |
55 | 62 | ||
63 | if (!is_pci_dev(dev)) | ||
64 | return -ENODEV; | ||
65 | |||
56 | pci_dev = to_pci_dev(dev); /* NOTE: PCI-specific */ | 66 | pci_dev = to_pci_dev(dev); /* NOTE: PCI-specific */ |
57 | /* Please refer to the ACPI spec for the syntax of _ADR. */ | 67 | /* Please refer to the ACPI spec for the syntax of _ADR. */ |
58 | addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn); | 68 | addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn); |
@@ -84,7 +94,12 @@ static int pata_get_dev_handle(struct device *dev, acpi_handle *handle, | |||
84 | acpi_status status; | 94 | acpi_status status; |
85 | struct acpi_device_info *dinfo = NULL; | 95 | struct acpi_device_info *dinfo = NULL; |
86 | int ret = -ENODEV; | 96 | int ret = -ENODEV; |
87 | struct pci_dev *pdev = to_pci_dev(dev); | 97 | struct pci_dev *pdev; |
98 | |||
99 | if (!is_pci_dev(dev)) | ||
100 | return -ENODEV; | ||
101 | |||
102 | pdev = to_pci_dev(dev); | ||
88 | 103 | ||
89 | bus = pdev->bus->number; | 104 | bus = pdev->bus->number; |
90 | devnum = PCI_SLOT(pdev->devfn); | 105 | devnum = PCI_SLOT(pdev->devfn); |