aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartyn Welch <martyn.welch@ge.com>2013-11-08 06:58:34 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-03 14:15:58 -0500
commit978f47d64365fa1659178e54c5106154c315b595 (patch)
tree00df9ed48a7bd0d95ba9095134b7e21f3fdc682c
parent49cf10c67bfbd68bc646390cd1f4cbe77aea12d5 (diff)
VME: Provide access to VME bus enumeration and fix vme_user match function
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@ge.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--Documentation/vme_api.txt10
-rw-r--r--drivers/staging/vme/devices/vme_user.c13
-rw-r--r--drivers/vme/vme.c13
-rw-r--r--include/linux/vme.h1
4 files changed, 34 insertions, 3 deletions
diff --git a/Documentation/vme_api.txt b/Documentation/vme_api.txt
index 856efa35f6e3..126a1f1d5151 100644
--- a/Documentation/vme_api.txt
+++ b/Documentation/vme_api.txt
@@ -394,3 +394,13 @@ Slot Detection
394This function returns the slot ID of the provided bridge. 394This function returns the slot ID of the provided bridge.
395 395
396 int vme_slot_get(struct vme_dev *dev); 396 int vme_slot_get(struct vme_dev *dev);
397
398
399Bus Detection
400=============
401
402This function returns the bus ID of the provided bridge.
403
404 int vme_bus_num(struct vme_dev *dev);
405
406
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index daec15565a43..caee906f9b38 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -663,9 +663,16 @@ err_nocard:
663 663
664static int vme_user_match(struct vme_dev *vdev) 664static int vme_user_match(struct vme_dev *vdev)
665{ 665{
666 if (vdev->num >= VME_USER_BUS_MAX) 666 int i;
667 return 0; 667
668 return 1; 668 int cur_bus = vme_bus_num(vdev);
669 int cur_slot = vme_slot_get(vdev);
670
671 for (i = 0; i < bus_num; i++)
672 if ((cur_bus == bus[i]) && (cur_slot == vdev->num))
673 return 1;
674
675 return 0;
669} 676}
670 677
671/* 678/*
diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index f6856b427496..8df5e4efc1ca 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -1293,6 +1293,19 @@ int vme_slot_get(struct vme_dev *vdev)
1293} 1293}
1294EXPORT_SYMBOL(vme_slot_get); 1294EXPORT_SYMBOL(vme_slot_get);
1295 1295
1296int vme_bus_num(struct vme_dev *vdev)
1297{
1298 struct vme_bridge *bridge;
1299
1300 bridge = vdev->bridge;
1301 if (bridge == NULL) {
1302 pr_err("Can't find VME bus\n");
1303 return -EINVAL;
1304 }
1305
1306 return bridge->num;
1307}
1308EXPORT_SYMBOL(vme_bus_num);
1296 1309
1297/* - Bridge Registration --------------------------------------------------- */ 1310/* - Bridge Registration --------------------------------------------------- */
1298 1311
diff --git a/include/linux/vme.h b/include/linux/vme.h
index c9d65bf14cec..4eb42c8f097d 100644
--- a/include/linux/vme.h
+++ b/include/linux/vme.h
@@ -165,6 +165,7 @@ int vme_lm_detach(struct vme_resource *, int);
165void vme_lm_free(struct vme_resource *); 165void vme_lm_free(struct vme_resource *);
166 166
167int vme_slot_get(struct vme_dev *); 167int vme_slot_get(struct vme_dev *);
168int vme_bus_num(struct vme_dev *);
168 169
169int vme_register_driver(struct vme_driver *, unsigned int); 170int vme_register_driver(struct vme_driver *, unsigned int);
170void vme_unregister_driver(struct vme_driver *); 171void vme_unregister_driver(struct vme_driver *);