Skip to content

Commit 5e0afd8

Browse files
committed
xen/tpmfront: use xenbus_setup_ring() and xenbus_teardown_ring()
Simplify tpmfront's ring creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(), which are provided exactly for the use pattern as seen in this driver. Signed-off-by: Juergen Gross <[email protected]>
1 parent 46e20d4 commit 5e0afd8

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

drivers/char/tpm/xen-tpmfront.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -253,20 +253,12 @@ static int setup_ring(struct xenbus_device *dev, struct tpm_private *priv)
253253
struct xenbus_transaction xbt;
254254
const char *message = NULL;
255255
int rv;
256-
grant_ref_t gref;
257256

258-
priv->shr = (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
259-
if (!priv->shr) {
260-
xenbus_dev_fatal(dev, -ENOMEM, "allocating shared ring");
261-
return -ENOMEM;
262-
}
263-
264-
rv = xenbus_grant_ring(dev, priv->shr, 1, &gref);
257+
rv = xenbus_setup_ring(dev, GFP_KERNEL, (void **)&priv->shr, 1,
258+
&priv->ring_ref);
265259
if (rv < 0)
266260
return rv;
267261

268-
priv->ring_ref = gref;
269-
270262
rv = xenbus_alloc_evtchn(dev, &priv->evtchn);
271263
if (rv)
272264
return rv;
@@ -331,11 +323,7 @@ static void ring_free(struct tpm_private *priv)
331323
if (!priv)
332324
return;
333325

334-
if (priv->ring_ref)
335-
gnttab_end_foreign_access(priv->ring_ref,
336-
(unsigned long)priv->shr);
337-
else
338-
free_page((unsigned long)priv->shr);
326+
xenbus_teardown_ring((void **)&priv->shr, 1, &priv->ring_ref);
339327

340328
if (priv->irq)
341329
unbind_from_irqhandler(priv->irq, priv);

0 commit comments

Comments
 (0)