Skip to content

Commit 4573240

Browse files
committed
xen/xenbus: eliminate xenbus_grant_ring()
There is no external user of xenbus_grant_ring() left, so merge it into the only caller xenbus_setup_ring(). Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Oleksandr Tyshchenko <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent 360dc89 commit 4573240

File tree

2 files changed

+19
-48
lines changed

2 files changed

+19
-48
lines changed

drivers/xen/xenbus/xenbus_client.c

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -363,50 +363,6 @@ static void xenbus_switch_fatal(struct xenbus_device *dev, int depth, int err,
363363
__xenbus_switch_state(dev, XenbusStateClosing, 1);
364364
}
365365

366-
/**
367-
* xenbus_grant_ring
368-
* @dev: xenbus device
369-
* @vaddr: starting virtual address of the ring
370-
* @nr_pages: number of pages to be granted
371-
* @grefs: grant reference array to be filled in
372-
*
373-
* Grant access to the given @vaddr to the peer of the given device.
374-
* Then fill in @grefs with grant references. Return 0 on success, or
375-
* -errno on error. On error, the device will switch to
376-
* XenbusStateClosing, and the error will be saved in the store.
377-
*/
378-
int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,
379-
unsigned int nr_pages, grant_ref_t *grefs)
380-
{
381-
int err;
382-
unsigned int i;
383-
grant_ref_t gref_head;
384-
385-
err = gnttab_alloc_grant_references(nr_pages, &gref_head);
386-
if (err) {
387-
xenbus_dev_fatal(dev, err, "granting access to ring page");
388-
return err;
389-
}
390-
391-
for (i = 0; i < nr_pages; i++) {
392-
unsigned long gfn;
393-
394-
if (is_vmalloc_addr(vaddr))
395-
gfn = pfn_to_gfn(vmalloc_to_pfn(vaddr));
396-
else
397-
gfn = virt_to_gfn(vaddr);
398-
399-
grefs[i] = gnttab_claim_grant_reference(&gref_head);
400-
gnttab_grant_foreign_access_ref(grefs[i], dev->otherend_id,
401-
gfn, 0);
402-
403-
vaddr = vaddr + XEN_PAGE_SIZE;
404-
}
405-
406-
return 0;
407-
}
408-
EXPORT_SYMBOL_GPL(xenbus_grant_ring);
409-
410366
/*
411367
* xenbus_setup_ring
412368
* @dev: xenbus device
@@ -424,6 +380,7 @@ int xenbus_setup_ring(struct xenbus_device *dev, gfp_t gfp, void **vaddr,
424380
unsigned int nr_pages, grant_ref_t *grefs)
425381
{
426382
unsigned long ring_size = nr_pages * XEN_PAGE_SIZE;
383+
grant_ref_t gref_head;
427384
unsigned int i;
428385
int ret;
429386

@@ -433,9 +390,25 @@ int xenbus_setup_ring(struct xenbus_device *dev, gfp_t gfp, void **vaddr,
433390
goto err;
434391
}
435392

436-
ret = xenbus_grant_ring(dev, *vaddr, nr_pages, grefs);
437-
if (ret)
393+
ret = gnttab_alloc_grant_references(nr_pages, &gref_head);
394+
if (ret) {
395+
xenbus_dev_fatal(dev, ret, "granting access to %u ring pages",
396+
nr_pages);
438397
goto err;
398+
}
399+
400+
for (i = 0; i < nr_pages; i++) {
401+
unsigned long gfn;
402+
403+
if (is_vmalloc_addr(*vaddr))
404+
gfn = pfn_to_gfn(vmalloc_to_pfn(vaddr[i]));
405+
else
406+
gfn = virt_to_gfn(vaddr[i]);
407+
408+
grefs[i] = gnttab_claim_grant_reference(&gref_head);
409+
gnttab_grant_foreign_access_ref(grefs[i], dev->otherend_id,
410+
gfn, 0);
411+
}
439412

440413
return 0;
441414

include/xen/xenbus.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,6 @@ int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch,
224224
const char *pathfmt, ...);
225225

226226
int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_state);
227-
int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,
228-
unsigned int nr_pages, grant_ref_t *grefs);
229227
int xenbus_setup_ring(struct xenbus_device *dev, gfp_t gfp, void **vaddr,
230228
unsigned int nr_pages, grant_ref_t *grefs);
231229
void xenbus_teardown_ring(void **vaddr, unsigned int nr_pages,

0 commit comments

Comments
 (0)