Commit 5e0afd8e authored by Juergen Gross's avatar Juergen Gross

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: default avatarJuergen Gross <jgross@suse.com>
parent 46e20d43
...@@ -253,20 +253,12 @@ static int setup_ring(struct xenbus_device *dev, struct tpm_private *priv) ...@@ -253,20 +253,12 @@ static int setup_ring(struct xenbus_device *dev, struct tpm_private *priv)
struct xenbus_transaction xbt; struct xenbus_transaction xbt;
const char *message = NULL; const char *message = NULL;
int rv; int rv;
grant_ref_t gref;
priv->shr = (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO); rv = xenbus_setup_ring(dev, GFP_KERNEL, (void **)&priv->shr, 1,
if (!priv->shr) { &priv->ring_ref);
xenbus_dev_fatal(dev, -ENOMEM, "allocating shared ring");
return -ENOMEM;
}
rv = xenbus_grant_ring(dev, priv->shr, 1, &gref);
if (rv < 0) if (rv < 0)
return rv; return rv;
priv->ring_ref = gref;
rv = xenbus_alloc_evtchn(dev, &priv->evtchn); rv = xenbus_alloc_evtchn(dev, &priv->evtchn);
if (rv) if (rv)
return rv; return rv;
...@@ -331,11 +323,7 @@ static void ring_free(struct tpm_private *priv) ...@@ -331,11 +323,7 @@ static void ring_free(struct tpm_private *priv)
if (!priv) if (!priv)
return; return;
if (priv->ring_ref) xenbus_teardown_ring((void **)&priv->shr, 1, &priv->ring_ref);
gnttab_end_foreign_access(priv->ring_ref,
(unsigned long)priv->shr);
else
free_page((unsigned long)priv->shr);
if (priv->irq) if (priv->irq)
unbind_from_irqhandler(priv->irq, priv); unbind_from_irqhandler(priv->irq, priv);
......
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