summaryrefslogtreecommitdiff
path: root/drivers/staging/vme/devices/vme_user.c
diff options
context:
space:
mode:
authorManohar Vanga <manohar.vanga@cern.ch>2011-09-26 09:27:16 (GMT)
committerGreg Kroah-Hartman <gregkh@suse.de>2011-10-17 22:43:13 (GMT)
commit5d6abf379d73efe390488e8edba972af4e93cb1c (patch)
tree428bff86b71eeec6e24504221574092ab14c1cf1 /drivers/staging/vme/devices/vme_user.c
parent8f966dc444b11adff6011a1d1fce424abdd876d8 (diff)
downloadlinux-5d6abf379d73efe390488e8edba972af4e93cb1c.tar.xz
staging: vme: make match() driver specific to improve non-VME64x support
For jumper based boards (non VME64x), there is no mechanism for detecting the card that is plugged into a specific slot. This leads to issues in non-autodiscovery crates/cards when a card is plugged into a slot that is "claimed" by a different driver. In reality, there is no problem, but the driver rejects such a configuration due to its dependence on the concept of slots. This patch makes the concept of slots less critical and pushes the driver match() to individual drivers (similar to what happens in the ISA bus in driver/base/isa.c). This allows drivers to register the number of devices that they expect without any restrictions. Devices in this new model are now formatted as $driver_name-$bus_id.$device_id (as compared to the earlier vme-$bus_id.$slot_number). This model also makes the device model more logical as devices are only registered when they actually exist whereas earlier, a set of devices were being created automatically regardless of them actually being there. Another change introduced in this patch is that devices are now created within the VME driver structure rather than in the VME bridge structure. This way, things don't go haywire if the bridge driver is removed while a driver is using it. Signed-off-by: Manohar Vanga <manohar.vanga@cern.ch> Cc: Martyn Welch <martyn.welch@ge.com> Reviewed-by: Emilio G. Cota <cota@braap.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/vme/devices/vme_user.c')
-rw-r--r--drivers/staging/vme/devices/vme_user.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index bb33dc2..c658ce9 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -135,6 +135,7 @@ static ssize_t vme_user_write(struct file *, const char __user *, size_t,
static loff_t vme_user_llseek(struct file *, loff_t, int);
static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned long);
+static int vme_user_match(struct vme_dev *);
static int __devinit vme_user_probe(struct vme_dev *);
static int __devexit vme_user_remove(struct vme_dev *);
@@ -620,6 +621,7 @@ static void buf_unalloc(int num)
static struct vme_driver vme_user_driver = {
.name = driver_name,
+ .match = vme_user_match,
.probe = vme_user_probe,
.remove = __devexit_p(vme_user_remove),
};
@@ -628,8 +630,6 @@ static struct vme_driver vme_user_driver = {
static int __init vme_user_init(void)
{
int retval = 0;
- int i;
- struct vme_device_id *ids;
printk(KERN_INFO "VME User Space Access Driver\n");
@@ -649,41 +649,30 @@ static int __init vme_user_init(void)
bus_num = USER_BUS_MAX;
}
-
- /* Dynamically create the bind table based on module parameters */
- ids = kzalloc(sizeof(struct vme_device_id) * (bus_num + 1), GFP_KERNEL);
- if (ids == NULL) {
- printk(KERN_ERR "%s: Unable to allocate ID table\n",
- driver_name);
- retval = -ENOMEM;
- goto err_id;
- }
-
- for (i = 0; i < bus_num; i++) {
- ids[i].bus = bus[i];
- /*
- * We register the driver against the slot occupied by *this*
- * card, since it's really a low level way of controlling
- * the VME bridge
- */
- ids[i].slot = VME_SLOT_CURRENT;
- }
-
- vme_user_driver.bind_table = ids;
-
- retval = vme_register_driver(&vme_user_driver);
+ /*
+ * Here we just register the maximum number of devices we can and
+ * leave vme_user_match() to allow only 1 to go through to probe().
+ * This way, if we later want to allow multiple user access devices,
+ * we just change the code in vme_user_match().
+ */
+ retval = vme_register_driver(&vme_user_driver, VME_MAX_SLOTS);
if (retval != 0)
goto err_reg;
return retval;
err_reg:
- kfree(ids);
-err_id:
err_nocard:
return retval;
}
+static int vme_user_match(struct vme_dev *vdev)
+{
+ if (vdev->id.num >= USER_BUS_MAX)
+ return 0;
+ return 1;
+}
+
/*
* In this simple access driver, the old behaviour is being preserved as much
* as practical. We will therefore reserve the buffers and request the images
@@ -896,8 +885,6 @@ static int __devexit vme_user_remove(struct vme_dev *dev)
static void __exit vme_user_exit(void)
{
vme_unregister_driver(&vme_user_driver);
-
- kfree(vme_user_driver.bind_table);
}