From: "Emilio G. Cota" <cota@braap.org>
To: Greg KH <greg@kroah.com>
Cc: Martyn Welch <martyn.welch@ge.com>,
LKML <linux-kernel@vger.kernel.org>,
Juan David Gonzalez Cobas <david.cobas@gmail.com>
Subject: [PATCH 28/30] staging/vme: convert vme_* users to vme_*_ng
Date: Fri, 22 Oct 2010 02:36:50 -0400 [thread overview]
Message-ID: <1287729412-24356-29-git-send-email-cota@braap.org> (raw)
In-Reply-To: <1287729412-24356-1-git-send-email-cota@braap.org>
From: Emilio G. Cota <cota@braap.org>
Only vme_user.c is calling the old functions.
Signed-off-by: Emilio G. Cota <cota@braap.org>
---
drivers/staging/vme/bridges/vme_ca91cx42.c | 7 +-
drivers/staging/vme/bridges/vme_tsi148.c | 5 +-
drivers/staging/vme/devices/vme_user.c | 100 ++++++++++++----------------
drivers/staging/vme/vme.c | 6 +-
4 files changed, 54 insertions(+), 64 deletions(-)
diff --git a/drivers/staging/vme/bridges/vme_ca91cx42.c b/drivers/staging/vme/bridges/vme_ca91cx42.c
index b91c130..0f7dd66 100644
--- a/drivers/staging/vme/bridges/vme_ca91cx42.c
+++ b/drivers/staging/vme/bridges/vme_ca91cx42.c
@@ -1599,6 +1599,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}
ca91cx42_bridge->driver_priv = ca91cx42_device;
+ ca91cx42_bridge->owner = THIS_MODULE;
ca91cx42_bridge->num = -1;
/* Enable the device */
@@ -1772,7 +1773,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
/* Need to save ca91cx42_bridge pointer locally in link list for use in
* ca91cx42_remove()
*/
- retval = vme_register_bridge(ca91cx42_bridge);
+ retval = vme_register_bridge_ng(ca91cx42_bridge);
if (retval != 0) {
dev_err(&pdev->dev, "Chip Registration failed.\n");
goto err_reg;
@@ -1782,7 +1783,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
return 0;
- vme_unregister_bridge(ca91cx42_bridge);
+ vme_unregister_bridge_ng(ca91cx42_bridge);
err_reg:
ca91cx42_crcsr_exit(ca91cx42_bridge, pdev);
err_lm:
@@ -1866,7 +1867,7 @@ static void ca91cx42_remove(struct pci_dev *pdev)
iowrite32(0x00F00000, bridge->base + VSI6_CTL);
iowrite32(0x00F00000, bridge->base + VSI7_CTL);
- vme_unregister_bridge(ca91cx42_bridge);
+ vme_unregister_bridge_ng(ca91cx42_bridge);
ca91cx42_crcsr_exit(ca91cx42_bridge, pdev);
diff --git a/drivers/staging/vme/bridges/vme_tsi148.c b/drivers/staging/vme/bridges/vme_tsi148.c
index 80a9829..b12d517 100644
--- a/drivers/staging/vme/bridges/vme_tsi148.c
+++ b/drivers/staging/vme/bridges/vme_tsi148.c
@@ -2248,6 +2248,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}
tsi148_bridge->driver_priv = tsi148_device;
+ tsi148_bridge->owner = THIS_MODULE;
tsi148_bridge->num = -1;
/* Enable the device */
@@ -2463,7 +2464,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto err_crcsr;
}
- retval = vme_register_bridge(tsi148_bridge);
+ retval = vme_register_bridge_ng(tsi148_bridge);
if (retval != 0) {
dev_err(&pdev->dev, "Chip Registration failed.\n");
goto err_reg;
@@ -2586,7 +2587,7 @@ static void tsi148_remove(struct pci_dev *pdev)
tsi148_irq_exit(tsi148_bridge, pdev);
- vme_unregister_bridge(tsi148_bridge);
+ vme_unregister_bridge_ng(tsi148_bridge);
tsi148_crcsr_exit(tsi148_bridge, pdev);
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index 75f6472..030f5ee 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -116,7 +116,8 @@ static driver_stats_t statistics;
static struct cdev *vme_user_cdev; /* Character device */
static struct class *vme_user_sysfs_class; /* Sysfs class */
-static struct device *vme_user_bridge; /* Pointer to the bridge device */
+static struct vme_bridge *bridges[USER_BUS_MAX];
+static int bus_registered;
static const int type[VME_DEVS] = { MASTER_MINOR, MASTER_MINOR,
@@ -134,8 +135,9 @@ static ssize_t vme_user_write(struct file *, const char __user *, size_t, loff_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 __devinit vme_user_probe(struct device *, int, int);
-static int __devexit vme_user_remove(struct device *, int, int);
+static int __devinit vme_user_match(struct device *, unsigned int, unsigned int);
+static int __devinit vme_user_probe(struct device *, unsigned int, unsigned int);
+static int __devexit vme_user_remove(struct device *, unsigned int, unsigned int);
static struct file_operations vme_user_fops = {
.open = vme_user_open,
@@ -146,6 +148,16 @@ static struct file_operations vme_user_fops = {
.unlocked_ioctl = vme_user_unlocked_ioctl,
};
+static int get_bus_index(unsigned int bus_id)
+{
+ int i;
+
+ for (i = 0; i < bus_num; i++) {
+ if (bus[i] == bus_id)
+ return i;
+ }
+ return -1;
+}
/*
* Reset all the statistic counters
@@ -590,8 +602,9 @@ static void buf_unalloc(int num)
}
}
-static struct vme_driver vme_user_driver = {
+static struct vme_driver_ng vme_user_driver_ng = {
.name = driver_name,
+ .match = vme_user_match,
.probe = vme_user_probe,
.remove = __devexit_p(vme_user_remove),
};
@@ -599,17 +612,12 @@ 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");
if (bus_num == 0) {
printk(KERN_ERR "%s: No cards, skipping registration\n",
driver_name);
- retval = -ENODEV;
- goto err_nocard;
+ return -ENODEV;
}
/* Let's start by supporting one bus, we can support more than one
@@ -621,41 +629,14 @@ static int __init vme_user_init(void)
bus_num = USER_BUS_MAX;
}
+ return vme_register_driver_ng(&vme_user_driver_ng, 1);
+}
- /* Dynamically create the bind table based on module parameters */
- ids = kmalloc(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;
- }
-
- memset(ids, 0, (sizeof(struct vme_device_id) * (bus_num + 1)));
-
- 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);
- if (retval != 0)
- goto err_reg;
-
- return retval;
-
-err_reg:
- kfree(ids);
-err_id:
-err_nocard:
- return retval;
+/* NOTE: This only supports one device per bus */
+static int __devinit
+vme_user_match(struct device *devp, unsigned int bus_id, unsigned int id)
+{
+ return get_bus_index(bus_id) >= 0 && id == 0 ? 1 : 0;
}
/*
@@ -663,19 +644,25 @@ err_nocard:
* as practical. We will therefore reserve the buffers and request the images
* here so that we don't have to do it later.
*/
-static int __devinit vme_user_probe(struct device *dev, int cur_bus, int cur_slot)
+static int __devinit
+vme_user_probe(struct device *dev, unsigned int bus_id, unsigned int id)
{
int i, err;
char name[12];
- /* Save pointer to the bridge device */
- if (vme_user_bridge != NULL) {
+ if (bus_registered) {
printk(KERN_ERR "%s: Driver can only be loaded for 1 device\n",
driver_name);
err = -EINVAL;
goto err_dev;
}
- vme_user_bridge = dev;
+ bus_registered = 1;
+
+ bridges[0] = vme_get_bridge(bus_id);
+ if (bridges[0] == NULL) {
+ err = -ENODEV;
+ goto err_get_bridge;
+ }
/* Initialise descriptors */
for (i = 0; i < VME_DEVS; i++) {
@@ -716,8 +703,7 @@ static int __devinit vme_user_probe(struct device *dev, int cur_bus, int cur_slo
* supporting A16 addressing, so we request A24 supported
* by all windows.
*/
- image[i].resource = vme_slave_request(vme_user_bridge,
- VME_A24, VME_SCT);
+ image[i].resource = vme_slave_request_ng(bridges[0], VME_A24, VME_SCT);
if (image[i].resource == NULL) {
printk(KERN_WARNING "Unable to allocate slave "
"resource\n");
@@ -742,8 +728,7 @@ static int __devinit vme_user_probe(struct device *dev, int cur_bus, int cur_slo
*/
for (i = MASTER_MINOR; i < (MASTER_MAX + 1); i++) {
/* XXX Need to properly request attributes */
- image[i].resource = vme_master_request(vme_user_bridge,
- VME_A32, VME_SCT, VME_D32);
+ image[i].resource = vme_master_request_ng(bridges[0], VME_A32, VME_SCT, VME_D32);
if (image[i].resource == NULL) {
printk(KERN_WARNING "Unable to allocate master "
"resource\n");
@@ -834,11 +819,14 @@ err_class:
err_char:
unregister_chrdev_region(MKDEV(VME_MAJOR, 0), VME_DEVS);
err_region:
+ vme_put_bridge(bridges[0]);
+err_get_bridge:
+ bus_registered = 0;
err_dev:
return err;
}
-static int __devexit vme_user_remove(struct device *dev, int cur_bus, int cur_slot)
+static int __devexit vme_user_remove(struct device *dev, unsigned int bus_id, unsigned int id)
{
int i;
@@ -863,14 +851,14 @@ static int __devexit vme_user_remove(struct device *dev, int cur_bus, int cur_sl
/* Unregiser the major and minor device numbers */
unregister_chrdev_region(MKDEV(VME_MAJOR, 0), VME_DEVS);
+ vme_put_bridge(bridges[0]);
+
return 0;
}
static void __exit vme_user_exit(void)
{
- vme_unregister_driver(&vme_user_driver);
-
- kfree(vme_user_driver.bind_table);
+ vme_unregister_driver_ng(&vme_user_driver_ng);
}
diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c
index 5ecfecc..88697aa 100644
--- a/drivers/staging/vme/vme.c
+++ b/drivers/staging/vme/vme.c
@@ -1812,9 +1812,9 @@ static int vme_bus_remove_ng(struct device *dev)
struct bus_type vme_bus_type = {
.name = "vme",
- .match = vme_bus_match,
- .probe = vme_bus_probe,
- .remove = vme_bus_remove,
+ .match = vme_bus_match_ng,
+ .probe = vme_bus_probe_ng,
+ .remove = vme_bus_remove_ng,
};
EXPORT_SYMBOL(vme_bus_type);
--
1.7.1
next prev parent reply other threads:[~2010-10-22 7:03 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-22 6:36 [-next] staging/vme: various fixes + new driver model for VME Emilio G. Cota
2010-10-22 6:36 ` [PATCH 01/30] staging/vme: style: convert '&(foo)' to '&foo' Emilio G. Cota
2010-10-22 6:36 ` [PATCH 02/30] staging/vme_user: return the appropriate error code when module_init fails Emilio G. Cota
2010-10-22 6:36 ` [PATCH 03/30] staging/vme_user: remove unreachable line Emilio G. Cota
2010-10-22 6:36 ` [PATCH 04/30] staging/vme: allow non-dynamic allocation of bus numbers Emilio G. Cota
2010-10-22 6:36 ` [PATCH 05/30] staging/vme: fix bogus clearing of the bus number in vme_free_bus_num Emilio G. Cota
2010-10-22 6:36 ` [PATCH 06/30] staging/vme/tsi148: use list_for_each_safe when deleting resources in .remove Emilio G. Cota
2010-10-22 6:36 ` [PATCH 07/30] staging/vme/tsi148: remove double freeing of the IRQ " Emilio G. Cota
2010-10-22 6:36 ` [PATCH 08/30] staging/vme/tsi148: fix warning in free_irq Emilio G. Cota
2010-10-22 6:36 ` [PATCH 09/30] staging/vme: fill in struct device's .release, even if it's a NOOP Emilio G. Cota
2010-10-22 6:36 ` [PATCH 10/30] staging/vme/tsi148: remove unreachable line Emilio G. Cota
2010-10-22 6:36 ` [PATCH 11/30] staging/vme/tsi148: declare static functions as such Emilio G. Cota
2010-10-22 6:36 ` [PATCH 12/30] staging/vme/ca91cx42: " Emilio G. Cota
2010-10-22 6:36 ` [PATCH 13/30] staging/vme_user: declare private variables as static Emilio G. Cota
2010-10-22 6:36 ` [PATCH 14/30] staging/vme_user: use an unsigned int for counting the number of kparams Emilio G. Cota
2010-10-22 6:36 ` [PATCH 15/30] staging/vme_user: remove __iomem marking from kern_buf and derivates Emilio G. Cota
2010-10-22 6:36 ` [PATCH 16/30] staging/vme_user: mark user-space buffers with __user Emilio G. Cota
2010-10-22 6:36 ` [PATCH 17/30] staging/vme: mark struct vme_master_resource's base address pointer as __iomem Emilio G. Cota
2010-10-22 6:36 ` [PATCH 18/30] staging/vme/tsi148: mark the registers' " Emilio G. Cota
2010-10-22 6:36 ` [PATCH 19/30] staging/vme/ca91cx42: " Emilio G. Cota
2010-10-22 6:36 ` [PATCH 20/30] staging/vme: trivial: rename vme_bus_num_mtx to vme_buses_lock Emilio G. Cota
2010-10-22 6:36 ` [PATCH 21/30] staging/vme: keep a list of registered buses (bridges) Emilio G. Cota
2010-10-22 6:36 ` [PATCH 22/30] staging/vme/vme_user: use __dev{init,exit} for .probe and .remove Emilio G. Cota
2010-10-22 6:36 ` [PATCH 23/30] staging/vme_user: fix usage of the slave resources after they've been freed Emilio G. Cota
2010-10-22 6:36 ` [PATCH 24/30] staging/vme_user: remove unnecessary call to vme_slave_set Emilio G. Cota
2010-10-22 6:36 ` [PATCH 25/30] staging/vme_user: add missing calls to vme_master_free calls in .remove Emilio G. Cota
2010-10-22 6:36 ` [PATCH 26/30] staging/vme: move all contents of vme_bridge.h to vme.h Emilio G. Cota
2010-10-22 6:36 ` [PATCH 27/30] staging/vme: rework the bus model Emilio G. Cota
2010-10-22 23:27 ` Emilio G. Cota
2010-10-25 11:24 ` Martyn Welch
2010-10-26 1:02 ` Emilio G. Cota
2010-10-27 9:16 ` Martyn Welch
2010-10-27 15:40 ` Emilio G. Cota
2010-10-22 6:36 ` Emilio G. Cota [this message]
2010-10-22 6:36 ` [PATCH 29/30] staging/vme: remove unused vme_* functions and related code Emilio G. Cota
2010-10-22 6:36 ` [PATCH 30/30] staging/vme: remove _ng suffixes Emilio G. Cota
2010-10-22 9:26 ` [-next] staging/vme: various fixes + new driver model for VME Martyn Welch
2010-10-22 23:03 ` Emilio G. Cota
2010-10-22 10:08 ` Martyn Welch
2010-10-22 23:04 ` Emilio G. Cota
2010-10-22 13:56 ` Greg KH
2010-10-22 22:56 ` Emilio G. Cota
2010-10-26 1:10 [re-send][-next] " Emilio G. Cota
2010-10-26 1:11 ` [PATCH 28/30] staging/vme: convert vme_* users to vme_*_ng Emilio G. Cota
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1287729412-24356-29-git-send-email-cota@braap.org \
--to=cota@braap.org \
--cc=david.cobas@gmail.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martyn.welch@ge.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®