Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Oct 2016 11:34:51 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r306950 - stable/10/sys/ofed/include/linux
Message-ID:  <201610101134.u9ABYpAk044450@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon Oct 10 11:34:51 2016
New Revision: 306950
URL: https://svnweb.freebsd.org/changeset/base/306950

Log:
  MFC r306451:
  The IORESOURCE_XXX defines should resemble a bitmask while SYS_RES_XXX
  are not bitmasks. Fix return value of pci_resource_flags() to reflect
  this change.
  
  Sponsored by:	Mellanox Technologies

Modified:
  stable/10/sys/ofed/include/linux/pci.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/ofed/include/linux/pci.h
==============================================================================
--- stable/10/sys/ofed/include/linux/pci.h	Mon Oct 10 11:30:35 2016	(r306949)
+++ stable/10/sys/ofed/include/linux/pci.h	Mon Oct 10 11:34:51 2016	(r306950)
@@ -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
@@ -115,9 +115,9 @@ struct pci_device_id {
 #define	PCI_EXP_TYPE_RC_EC	PCIEM_TYPE_ROOT_EC		/* Root Complex Event Collector */
 
 
-#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)
 
 struct pci_dev;
 
@@ -213,17 +213,28 @@ pci_resource_len(struct pci_dev *pdev, i
 	return rle->count;
 }
 
+static inline int
+pci_resource_type(struct pci_dev *pdev, int bar)
+{
+	struct resource_list_entry *rle;
+
+	if ((rle = _pci_get_bar(pdev, bar)) == NULL)
+		return (-1);
+	return (rle->type);
+}
+
 /*
  * 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 *
@@ -283,8 +294,8 @@ pci_request_region(struct pci_dev *pdev,
 	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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201610101134.u9ABYpAk044450>