Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Juergen Gross <jgross@suse.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Juergen Gross <jgross@suse.com>

+15 -46
+15 -46
drivers/usb/host/xen-hcd.c
··· 1098 1098 unbind_from_irqhandler(info->irq, info); 1099 1099 info->irq = 0; 1100 1100 1101 - if (info->urb_ring_ref != INVALID_GRANT_REF) { 1102 - gnttab_end_foreign_access(info->urb_ring_ref, 1103 - (unsigned long)info->urb_ring.sring); 1104 - info->urb_ring_ref = INVALID_GRANT_REF; 1105 - } 1106 - info->urb_ring.sring = NULL; 1107 - 1108 - if (info->conn_ring_ref != INVALID_GRANT_REF) { 1109 - gnttab_end_foreign_access(info->conn_ring_ref, 1110 - (unsigned long)info->conn_ring.sring); 1111 - info->conn_ring_ref = INVALID_GRANT_REF; 1112 - } 1113 - info->conn_ring.sring = NULL; 1101 + xenbus_teardown_ring((void **)&info->urb_ring.sring, 1, 1102 + &info->urb_ring_ref); 1103 + xenbus_teardown_ring((void **)&info->conn_ring.sring, 1, 1104 + &info->conn_ring_ref); 1114 1105 } 1115 1106 1116 1107 static int xenhcd_setup_rings(struct xenbus_device *dev, ··· 1109 1118 { 1110 1119 struct xenusb_urb_sring *urb_sring; 1111 1120 struct xenusb_conn_sring *conn_sring; 1112 - grant_ref_t gref; 1113 1121 int err; 1114 1122 1115 - info->urb_ring_ref = INVALID_GRANT_REF; 1116 1123 info->conn_ring_ref = INVALID_GRANT_REF; 1117 - 1118 - urb_sring = (struct xenusb_urb_sring *)get_zeroed_page( 1119 - GFP_NOIO | __GFP_HIGH); 1120 - if (!urb_sring) { 1121 - xenbus_dev_fatal(dev, -ENOMEM, "allocating urb ring"); 1122 - return -ENOMEM; 1124 + err = xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, 1125 + (void **)&urb_sring, 1, &info->urb_ring_ref); 1126 + if (err) { 1127 + xenbus_dev_fatal(dev, err, "allocating urb ring"); 1128 + return err; 1123 1129 } 1124 - SHARED_RING_INIT(urb_sring); 1125 - FRONT_RING_INIT(&info->urb_ring, urb_sring, PAGE_SIZE); 1130 + XEN_FRONT_RING_INIT(&info->urb_ring, urb_sring, PAGE_SIZE); 1126 1131 1127 - err = xenbus_grant_ring(dev, urb_sring, 1, &gref); 1128 - if (err < 0) { 1129 - free_page((unsigned long)urb_sring); 1130 - info->urb_ring.sring = NULL; 1132 + err = xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, 1133 + (void **)&conn_sring, 1, &info->conn_ring_ref); 1134 + if (err) { 1135 + xenbus_dev_fatal(dev, err, "allocating conn ring"); 1131 1136 goto fail; 1132 1137 } 1133 - info->urb_ring_ref = gref; 1134 - 1135 - conn_sring = (struct xenusb_conn_sring *)get_zeroed_page( 1136 - GFP_NOIO | __GFP_HIGH); 1137 - if (!conn_sring) { 1138 - xenbus_dev_fatal(dev, -ENOMEM, "allocating conn ring"); 1139 - err = -ENOMEM; 1140 - goto fail; 1141 - } 1142 - SHARED_RING_INIT(conn_sring); 1143 - FRONT_RING_INIT(&info->conn_ring, conn_sring, PAGE_SIZE); 1144 - 1145 - err = xenbus_grant_ring(dev, conn_sring, 1, &gref); 1146 - if (err < 0) { 1147 - free_page((unsigned long)conn_sring); 1148 - info->conn_ring.sring = NULL; 1149 - goto fail; 1150 - } 1151 - info->conn_ring_ref = gref; 1138 + XEN_FRONT_RING_INIT(&info->conn_ring, conn_sring, PAGE_SIZE); 1152 1139 1153 1140 err = xenbus_alloc_evtchn(dev, &info->evtchn); 1154 1141 if (err) {