]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
VME: Provide access to VME bus enumeration and fix vme_user match function
authorMartyn Welch <martyn.welch@ge.com>
Fri, 8 Nov 2013 11:58:34 +0000 (11:58 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 Dec 2013 19:15:58 +0000 (11:15 -0800)
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>
Documentation/vme_api.txt
drivers/staging/vme/devices/vme_user.c
drivers/vme/vme.c
include/linux/vme.h

index 856efa35f6e3c582b612a154ef07f0d4b66a393f..126a1f1d5151529a14b8e153fb65b2fe3480d3b1 100644 (file)
@@ -394,3 +394,13 @@ Slot Detection
 This function returns the slot ID of the provided bridge.
 
        int vme_slot_get(struct vme_dev *dev);
+
+
+Bus Detection
+=============
+
+This function returns the bus ID of the provided bridge.
+
+       int vme_bus_num(struct vme_dev *dev);
+
+
index daec15565a43098c37e6d1ac8d50f56ae99acd88..caee906f9b387cce70fff74ed1942c47ec0c27c9 100644 (file)
@@ -663,9 +663,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_num(vdev);
+       int cur_slot = vme_slot_get(vdev);
+
+       for (i = 0; i < bus_num; i++)
+               if ((cur_bus == bus[i]) && (cur_slot == vdev->num))
+                       return 1;
+
+       return 0;
 }
 
 /*
index f6856b42749655f3730e99c3bdb45891efb1d0b9..8df5e4efc1cadcbba8ee6f8412920c0406be6114 100644 (file)
@@ -1293,6 +1293,19 @@ int vme_slot_get(struct vme_dev *vdev)
 }
 EXPORT_SYMBOL(vme_slot_get);
 
+int vme_bus_num(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_num);
 
 /* - Bridge Registration --------------------------------------------------- */
 
index c9d65bf14cecd44dc922806f505ceddd85165fa0..4eb42c8f097d0d5eadc468d2ff8dac5bd5032f48 100644 (file)
@@ -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_num(struct vme_dev *);
 
 int vme_register_driver(struct vme_driver *, unsigned int);
 void vme_unregister_driver(struct vme_driver *);