[PATCH] VME: Provide access to VME bus enumeration and fix vme_user match function

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

 



The match function for vme_user is completely wrong. It will blindly bind
against the first VME slot on each bus (at this point that would be just the
first bus as the driver can only handle one bus).

The original intention (before some major subsystem changes) was that the
driver bind against the slot to which the bridge was attached in the VME
system and to the bus(es) provided via the "bus" module parameter.

To do this cleanly (i.e. without poking arround in the subsystems internal
stuctures) a functionality has been added to provide access to the bus
enumeration.

Signed-off-by: Martyn Welch <martyn.welch@xxxxxx>
---
 drivers/staging/vme/devices/vme_user.c |   13 ++++++++++---
 drivers/vme/vme.c                      |   13 +++++++++++++
 include/linux/vme.h                    |    1 +
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index e24a6f9..e2d2cfb 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -667,9 +667,16 @@ err_nocard:
 
 static int vme_user_match(struct vme_dev *vdev)
 {
-	if (vdev->num >= VME_USER_BUS_MAX)
-		return 0;
-	return 1;
+	int i;
+
+	int cur_bus = vme_bus_get(vdev);
+	int cur_slot = vme_slot_get(vdev);
+
+	for (i = 0; i < VME_USER_BUS_MAX; i++)
+		if ((cur_bus == bus[i]) && (cur_slot == vdev->num))
+			return 1;
+
+	return 0;
 }
 
 /*
diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 95a9f71..5e29639 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -1291,6 +1291,19 @@ int vme_slot_get(struct vme_dev *vdev)
 }
 EXPORT_SYMBOL(vme_slot_get);
 
+int vme_bus_get(struct vme_dev *vdev)
+{
+	struct vme_bridge *bridge;
+
+	bridge = vdev->bridge;
+	if (bridge == NULL) {
+		pr_err("Can't find VME bus\n");
+		return -EINVAL;
+	}
+
+	return bridge->num;
+}
+EXPORT_SYMBOL(vme_bus_get);
 
 /* - Bridge Registration --------------------------------------------------- */
 
diff --git a/include/linux/vme.h b/include/linux/vme.h
index c9d65bf..77d262d 100644
--- a/include/linux/vme.h
+++ b/include/linux/vme.h
@@ -165,6 +165,7 @@ int vme_lm_detach(struct vme_resource *, int);
 void vme_lm_free(struct vme_resource *);
 
 int vme_slot_get(struct vme_dev *);
+int vme_bus_get(struct vme_dev *);
 
 int vme_register_driver(struct vme_driver *, unsigned int);
 void vme_unregister_driver(struct vme_driver *);
-- 
1.7.0.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux