summaryrefslogtreecommitdiffstats
path: root/sys/compat/linuxkpi/common/include/linux/pci.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat/linuxkpi/common/include/linux/pci.h')
-rw-r--r--sys/compat/linuxkpi/common/include/linux/pci.h34
1 files changed, 25 insertions, 9 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
index 54a9b2f..e7bf51f 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -2,7 +2,7 @@
* Copyright (c) 2010 Isilon Systems, Inc.
* Copyright (c) 2010 iX Systems, Inc.
* Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -121,9 +121,9 @@ struct pci_device_id {
#define PCI_EXP_LNKCAP2_SLS_5_0GB 0x04 /* Supported Link Speed 5.0GT/s */
#define PCI_EXP_LNKCAP2_SLS_8_0GB 0x08 /* Supported Link Speed 8.0GT/s */
-#define IORESOURCE_MEM SYS_RES_MEMORY
-#define IORESOURCE_IO SYS_RES_IOPORT
-#define IORESOURCE_IRQ SYS_RES_IRQ
+#define IORESOURCE_MEM (1 << SYS_RES_MEMORY)
+#define IORESOURCE_IO (1 << SYS_RES_IOPORT)
+#define IORESOURCE_IRQ (1 << SYS_RES_IRQ)
enum pci_bus_speed {
PCI_SPEED_UNKNOWN = -1,
@@ -230,17 +230,33 @@ pci_resource_len(struct pci_dev *pdev, int bar)
return rle->count;
}
+static inline int
+pci_resource_type(struct pci_dev *pdev, int bar)
+{
+ struct pci_map *pm;
+
+ pm = pci_find_bar(pdev->dev.bsddev, PCIR_BAR(bar));
+ if (!pm)
+ return (-1);
+
+ if (PCI_BAR_IO(pm->pm_value))
+ return (SYS_RES_IOPORT);
+ else
+ return (SYS_RES_MEMORY);
+}
+
/*
* All drivers just seem to want to inspect the type not flags.
*/
static inline int
pci_resource_flags(struct pci_dev *pdev, int bar)
{
- struct resource_list_entry *rle;
+ int type;
- if ((rle = _pci_get_bar(pdev, bar)) == NULL)
+ type = pci_resource_type(pdev, bar);
+ if (type < 0)
return (0);
- return rle->type;
+ return (1 << type);
}
static inline const char *
@@ -300,8 +316,8 @@ pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
int rid;
int type;
- type = pci_resource_flags(pdev, bar);
- if (type == 0)
+ type = pci_resource_type(pdev, bar);
+ if (type < 0)
return (-ENODEV);
rid = PCIR_BAR(bar);
if (bus_alloc_resource_any(pdev->dev.bsddev, type, &rid,
OpenPOWER on IntegriCloud