diff options
Diffstat (limited to 'drivers/xen/xen-pciback/xenbus.c')
-rw-r--r-- | drivers/xen/xen-pciback/xenbus.c | 128 |
1 files changed, 65 insertions, 63 deletions
diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c index 70030c40921..1e5ba85c0d3 100644 --- a/drivers/xen/xen-pciback/xenbus.c +++ b/drivers/xen/xen-pciback/xenbus.c @@ -14,14 +14,15 @@ #include <linux/workqueue.h> #include "pciback.h" +#define DRV_NAME "xen-pciback" #define INVALID_EVTCHN_IRQ (-1) -struct workqueue_struct *pciback_wq; +struct workqueue_struct *xen_pcibk_wq; -static struct pciback_device *alloc_pdev(struct xenbus_device *xdev) +static struct xen_pcibk_device *alloc_pdev(struct xenbus_device *xdev) { - struct pciback_device *pdev; + struct xen_pcibk_device *pdev; - pdev = kzalloc(sizeof(struct pciback_device), GFP_KERNEL); + pdev = kzalloc(sizeof(struct xen_pcibk_device), GFP_KERNEL); if (pdev == NULL) goto out; dev_dbg(&xdev->dev, "allocated pdev @ 0x%p\n", pdev); @@ -35,9 +36,9 @@ static struct pciback_device *alloc_pdev(struct xenbus_device *xdev) pdev->evtchn_irq = INVALID_EVTCHN_IRQ; pdev->be_watching = 0; - INIT_WORK(&pdev->op_work, pciback_do_op); + INIT_WORK(&pdev->op_work, xen_pcibk_do_op); - if (pciback_init_devices(pdev)) { + if (xen_pcibk_init_devices(pdev)) { kfree(pdev); pdev = NULL; } @@ -45,7 +46,7 @@ out: return pdev; } -static void pciback_disconnect(struct pciback_device *pdev) +static void xen_pcibk_disconnect(struct xen_pcibk_device *pdev) { spin_lock(&pdev->dev_lock); @@ -60,7 +61,7 @@ static void pciback_disconnect(struct pciback_device *pdev) * before releasing the shared memory */ /* Note, the workqueue does not use spinlocks at all.*/ - flush_workqueue(pciback_wq); + flush_workqueue(xen_pcibk_wq); spin_lock(&pdev->dev_lock); if (pdev->sh_info != NULL) { @@ -71,16 +72,16 @@ static void pciback_disconnect(struct pciback_device *pdev) } -static void free_pdev(struct pciback_device *pdev) +static void free_pdev(struct xen_pcibk_device *pdev) { if (pdev->be_watching) { unregister_xenbus_watch(&pdev->be_watch); pdev->be_watching = 0; } - pciback_disconnect(pdev); + xen_pcibk_disconnect(pdev); - pciback_release_devices(pdev); + xen_pcibk_release_devices(pdev); dev_set_drvdata(&pdev->xdev->dev, NULL); pdev->xdev = NULL; @@ -88,7 +89,7 @@ static void free_pdev(struct pciback_device *pdev) kfree(pdev); } -static int pciback_do_attach(struct pciback_device *pdev, int gnt_ref, +static int xen_pcibk_do_attach(struct xen_pcibk_device *pdev, int gnt_ref, int remote_evtchn) { int err = 0; @@ -110,8 +111,8 @@ static int pciback_do_attach(struct pciback_device *pdev, int gnt_ref, spin_unlock(&pdev->dev_lock); err = bind_interdomain_evtchn_to_irqhandler( - pdev->xdev->otherend_id, remote_evtchn, pciback_handle_event, - 0, "pciback", pdev); + pdev->xdev->otherend_id, remote_evtchn, xen_pcibk_handle_event, + 0, DRV_NAME, pdev); if (err < 0) { xenbus_dev_fatal(pdev->xdev, err, "Error binding event channel to IRQ"); @@ -128,7 +129,7 @@ out: return err; } -static int pciback_attach(struct pciback_device *pdev) +static int xen_pcibk_attach(struct xen_pcibk_device *pdev) { int err = 0; int gnt_ref, remote_evtchn; @@ -161,12 +162,12 @@ static int pciback_attach(struct pciback_device *pdev) if (magic == NULL || strcmp(magic, XEN_PCI_MAGIC) != 0) { xenbus_dev_fatal(pdev->xdev, -EFAULT, "version mismatch (%s/%s) with pcifront - " - "halting pciback", + "halting xen_pcibk", magic, XEN_PCI_MAGIC); goto out; } - err = pciback_do_attach(pdev, gnt_ref, remote_evtchn); + err = xen_pcibk_do_attach(pdev, gnt_ref, remote_evtchn); if (err) goto out; @@ -185,7 +186,7 @@ out: return err; } -static int pciback_publish_pci_dev(struct pciback_device *pdev, +static int xen_pcibk_publish_pci_dev(struct xen_pcibk_device *pdev, unsigned int domain, unsigned int bus, unsigned int devfn, unsigned int devid) { @@ -207,7 +208,7 @@ out: return err; } -static int pciback_export_device(struct pciback_device *pdev, +static int xen_pcibk_export_device(struct xen_pcibk_device *pdev, int domain, int bus, int slot, int func, int devid) { @@ -228,7 +229,8 @@ static int pciback_export_device(struct pciback_device *pdev, goto out; } - err = pciback_add_pci_dev(pdev, dev, devid, pciback_publish_pci_dev); + err = xen_pcibk_add_pci_dev(pdev, dev, devid, + xen_pcibk_publish_pci_dev); if (err) goto out; @@ -253,7 +255,7 @@ out: return err; } -static int pciback_remove_device(struct pciback_device *pdev, +static int xen_pcibk_remove_device(struct xen_pcibk_device *pdev, int domain, int bus, int slot, int func) { int err = 0; @@ -262,7 +264,7 @@ static int pciback_remove_device(struct pciback_device *pdev, dev_dbg(&pdev->xdev->dev, "removing dom %x bus %x slot %x func %x\n", domain, bus, slot, func); - dev = pciback_get_pci_dev(pdev, domain, bus, PCI_DEVFN(slot, func)); + dev = xen_pcibk_get_pci_dev(pdev, domain, bus, PCI_DEVFN(slot, func)); if (!dev) { err = -EINVAL; dev_dbg(&pdev->xdev->dev, "Couldn't locate PCI device " @@ -274,13 +276,13 @@ static int pciback_remove_device(struct pciback_device *pdev, dev_dbg(&dev->dev, "unregistering for %d\n", pdev->xdev->otherend_id); xen_unregister_device_domain_owner(dev); - pciback_release_pci_dev(pdev, dev); + xen_pcibk_release_pci_dev(pdev, dev); out: return err; } -static int pciback_publish_pci_root(struct pciback_device *pdev, +static int xen_pcibk_publish_pci_root(struct xen_pcibk_device *pdev, unsigned int domain, unsigned int bus) { unsigned int d, b; @@ -340,7 +342,7 @@ out: return err; } -static int pciback_reconfigure(struct pciback_device *pdev) +static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev) { int err = 0; int num_devs; @@ -411,14 +413,14 @@ static int pciback_reconfigure(struct pciback_device *pdev) goto out; } - err = pciback_export_device(pdev, domain, bus, slot, + err = xen_pcibk_export_device(pdev, domain, bus, slot, func, i); if (err) goto out; /* Publish pci roots. */ - err = pciback_publish_pci_roots(pdev, - pciback_publish_pci_root); + err = xen_pcibk_publish_pci_roots(pdev, + xen_pcibk_publish_pci_root); if (err) { xenbus_dev_fatal(pdev->xdev, err, "Error while publish PCI root" @@ -465,7 +467,7 @@ static int pciback_reconfigure(struct pciback_device *pdev) goto out; } - err = pciback_remove_device(pdev, domain, bus, slot, + err = xen_pcibk_remove_device(pdev, domain, bus, slot, func); if (err) goto out; @@ -493,20 +495,20 @@ out: return 0; } -static void pciback_frontend_changed(struct xenbus_device *xdev, +static void xen_pcibk_frontend_changed(struct xenbus_device *xdev, enum xenbus_state fe_state) { - struct pciback_device *pdev = dev_get_drvdata(&xdev->dev); + struct xen_pcibk_device *pdev = dev_get_drvdata(&xdev->dev); dev_dbg(&xdev->dev, "fe state changed %d\n", fe_state); switch (fe_state) { case XenbusStateInitialised: - pciback_attach(pdev); + xen_pcibk_attach(pdev); break; case XenbusStateReconfiguring: - pciback_reconfigure(pdev); + xen_pcibk_reconfigure(pdev); break; case XenbusStateConnected: @@ -517,12 +519,12 @@ static void pciback_frontend_changed(struct xenbus_device *xdev, break; case XenbusStateClosing: - pciback_disconnect(pdev); + xen_pcibk_disconnect(pdev); xenbus_switch_state(xdev, XenbusStateClosing); break; case XenbusStateClosed: - pciback_disconnect(pdev); + xen_pcibk_disconnect(pdev); xenbus_switch_state(xdev, XenbusStateClosed); if (xenbus_dev_is_online(xdev)) break; @@ -537,7 +539,7 @@ static void pciback_frontend_changed(struct xenbus_device *xdev, } } -static int pciback_setup_backend(struct pciback_device *pdev) +static int xen_pcibk_setup_backend(struct xen_pcibk_device *pdev) { /* Get configuration from xend (if available now) */ int domain, bus, slot, func; @@ -590,7 +592,7 @@ static int pciback_setup_backend(struct pciback_device *pdev) goto out; } - err = pciback_export_device(pdev, domain, bus, slot, func, i); + err = xen_pcibk_export_device(pdev, domain, bus, slot, func, i); if (err) goto out; @@ -612,7 +614,7 @@ static int pciback_setup_backend(struct pciback_device *pdev) } } - err = pciback_publish_pci_roots(pdev, pciback_publish_pci_root); + err = xen_pcibk_publish_pci_roots(pdev, xen_pcibk_publish_pci_root); if (err) { xenbus_dev_fatal(pdev->xdev, err, "Error while publish PCI root buses " @@ -628,20 +630,20 @@ static int pciback_setup_backend(struct pciback_device *pdev) out: if (!err) /* see if pcifront is already configured (if not, we'll wait) */ - pciback_attach(pdev); + xen_pcibk_attach(pdev); return err; } -static void pciback_be_watch(struct xenbus_watch *watch, +static void xen_pcibk_be_watch(struct xenbus_watch *watch, const char **vec, unsigned int len) { - struct pciback_device *pdev = - container_of(watch, struct pciback_device, be_watch); + struct xen_pcibk_device *pdev = + container_of(watch, struct xen_pcibk_device, be_watch); switch (xenbus_read_driver_state(pdev->xdev->nodename)) { case XenbusStateInitWait: - pciback_setup_backend(pdev); + xen_pcibk_setup_backend(pdev); break; default: @@ -649,16 +651,16 @@ static void pciback_be_watch(struct xenbus_watch *watch, } } -static int pciback_xenbus_probe(struct xenbus_device *dev, +static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err = 0; - struct pciback_device *pdev = alloc_pdev(dev); + struct xen_pcibk_device *pdev = alloc_pdev(dev); if (pdev == NULL) { err = -ENOMEM; xenbus_dev_fatal(dev, err, - "Error allocating pciback_device struct"); + "Error allocating xen_pcibk_device struct"); goto out; } @@ -669,7 +671,7 @@ static int pciback_xenbus_probe(struct xenbus_device *dev, /* watch the backend node for backend configuration information */ err = xenbus_watch_path(dev, dev->nodename, &pdev->be_watch, - pciback_be_watch); + xen_pcibk_be_watch); if (err) goto out; @@ -678,15 +680,15 @@ static int pciback_xenbus_probe(struct xenbus_device *dev, /* We need to force a call to our callback here in case * xend already configured us! */ - pciback_be_watch(&pdev->be_watch, NULL, 0); + xen_pcibk_be_watch(&pdev->be_watch, NULL, 0); out: return err; } -static int pciback_xenbus_remove(struct xenbus_device *dev) +static int xen_pcibk_xenbus_remove(struct xenbus_device *dev) { - struct pciback_device *pdev = dev_get_drvdata(&dev->dev); + struct xen_pcibk_device *pdev = dev_get_drvdata(&dev->dev); if (pdev != NULL) free_pdev(pdev); @@ -699,28 +701,28 @@ static const struct xenbus_device_id xenpci_ids[] = { {""}, }; -static struct xenbus_driver xenbus_pciback_driver = { - .name = "pciback", +static struct xenbus_driver xenbus_xen_pcibk_driver = { + .name = DRV_NAME, .owner = THIS_MODULE, .ids = xenpci_ids, - .probe = pciback_xenbus_probe, - .remove = pciback_xenbus_remove, - .otherend_changed = pciback_frontend_changed, + .probe = xen_pcibk_xenbus_probe, + .remove = xen_pcibk_xenbus_remove, + .otherend_changed = xen_pcibk_frontend_changed, }; -int __init pciback_xenbus_register(void) +int __init xen_pcibk_xenbus_register(void) { - pciback_wq = create_workqueue("pciback_workqueue"); - if (!pciback_wq) { + xen_pcibk_wq = create_workqueue("xen_pciback_workqueue"); + if (!xen_pcibk_wq) { printk(KERN_ERR "%s: create" - "pciback_workqueue failed\n", __func__); + "xen_pciback_workqueue failed\n", __func__); return -EFAULT; } - return xenbus_register_backend(&xenbus_pciback_driver); + return xenbus_register_backend(&xenbus_xen_pcibk_driver); } -void __exit pciback_xenbus_unregister(void) +void __exit xen_pcibk_xenbus_unregister(void) { - destroy_workqueue(pciback_wq); - xenbus_unregister_driver(&xenbus_pciback_driver); + destroy_workqueue(xen_pcibk_wq); + xenbus_unregister_driver(&xenbus_xen_pcibk_driver); } |