Commit 2b3daf08 authored by Juergen Gross's avatar Juergen Gross

xen/usbfront: use xenbus_setup_ring() and xenbus_teardown_ring()

Simplify xen-hcd's ring creation and removal via xenbus_setup_ring()
and xenbus_teardown_ring().
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
parent caa427d2
......@@ -1098,19 +1098,10 @@ static void xenhcd_destroy_rings(struct xenhcd_info *info)
unbind_from_irqhandler(info->irq, info);
info->irq = 0;
if (info->urb_ring_ref != INVALID_GRANT_REF) {
gnttab_end_foreign_access(info->urb_ring_ref,
(unsigned long)info->urb_ring.sring);
info->urb_ring_ref = INVALID_GRANT_REF;
}
info->urb_ring.sring = NULL;
if (info->conn_ring_ref != INVALID_GRANT_REF) {
gnttab_end_foreign_access(info->conn_ring_ref,
(unsigned long)info->conn_ring.sring);
info->conn_ring_ref = INVALID_GRANT_REF;
}
info->conn_ring.sring = NULL;
xenbus_teardown_ring((void **)&info->urb_ring.sring, 1,
&info->urb_ring_ref);
xenbus_teardown_ring((void **)&info->conn_ring.sring, 1,
&info->conn_ring_ref);
}
static int xenhcd_setup_rings(struct xenbus_device *dev,
......@@ -1118,46 +1109,24 @@ static int xenhcd_setup_rings(struct xenbus_device *dev,
{
struct xenusb_urb_sring *urb_sring;
struct xenusb_conn_sring *conn_sring;
grant_ref_t gref;
int err;
info->urb_ring_ref = INVALID_GRANT_REF;
info->conn_ring_ref = INVALID_GRANT_REF;
urb_sring = (struct xenusb_urb_sring *)get_zeroed_page(
GFP_NOIO | __GFP_HIGH);
if (!urb_sring) {
xenbus_dev_fatal(dev, -ENOMEM, "allocating urb ring");
return -ENOMEM;
}
SHARED_RING_INIT(urb_sring);
FRONT_RING_INIT(&info->urb_ring, urb_sring, PAGE_SIZE);
err = xenbus_grant_ring(dev, urb_sring, 1, &gref);
if (err < 0) {
free_page((unsigned long)urb_sring);
info->urb_ring.sring = NULL;
goto fail;
}
info->urb_ring_ref = gref;
conn_sring = (struct xenusb_conn_sring *)get_zeroed_page(
GFP_NOIO | __GFP_HIGH);
if (!conn_sring) {
xenbus_dev_fatal(dev, -ENOMEM, "allocating conn ring");
err = -ENOMEM;
goto fail;
err = xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH,
(void **)&urb_sring, 1, &info->urb_ring_ref);
if (err) {
xenbus_dev_fatal(dev, err, "allocating urb ring");
return err;
}
SHARED_RING_INIT(conn_sring);
FRONT_RING_INIT(&info->conn_ring, conn_sring, PAGE_SIZE);
XEN_FRONT_RING_INIT(&info->urb_ring, urb_sring, PAGE_SIZE);
err = xenbus_grant_ring(dev, conn_sring, 1, &gref);
if (err < 0) {
free_page((unsigned long)conn_sring);
info->conn_ring.sring = NULL;
err = xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH,
(void **)&conn_sring, 1, &info->conn_ring_ref);
if (err) {
xenbus_dev_fatal(dev, err, "allocating conn ring");
goto fail;
}
info->conn_ring_ref = gref;
XEN_FRONT_RING_INIT(&info->conn_ring, conn_sring, PAGE_SIZE);
err = xenbus_alloc_evtchn(dev, &info->evtchn);
if (err) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment