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

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

Simplify pcifront's shared page creation and removal via
xenbus_setup_ring() and xenbus_teardown_ring().

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Juergen Gross <jgross@suse.com>

+3 -16
+3 -16
drivers/pci/xen-pcifront.c
··· 709 709 if (pdev == NULL) 710 710 goto out; 711 711 712 - pdev->sh_info = 713 - (struct xen_pci_sharedinfo *)__get_free_page(GFP_KERNEL); 714 - if (pdev->sh_info == NULL) { 712 + if (xenbus_setup_ring(xdev, GFP_KERNEL, (void **)&pdev->sh_info, 1, 713 + &pdev->gnt_ref)) { 715 714 kfree(pdev); 716 715 pdev = NULL; 717 716 goto out; ··· 728 729 spin_lock_init(&pdev->sh_info_lock); 729 730 730 731 pdev->evtchn = INVALID_EVTCHN; 731 - pdev->gnt_ref = INVALID_GRANT_REF; 732 732 pdev->irq = -1; 733 733 734 734 INIT_WORK(&pdev->op_work, pcifront_do_aer); ··· 752 754 if (pdev->evtchn != INVALID_EVTCHN) 753 755 xenbus_free_evtchn(pdev->xdev, pdev->evtchn); 754 756 755 - if (pdev->gnt_ref != INVALID_GRANT_REF) 756 - gnttab_end_foreign_access(pdev->gnt_ref, 757 - (unsigned long)pdev->sh_info); 758 - else 759 - free_page((unsigned long)pdev->sh_info); 757 + xenbus_teardown_ring((void **)&pdev->sh_info, 1, &pdev->gnt_ref); 760 758 761 759 dev_set_drvdata(&pdev->xdev->dev, NULL); 762 760 ··· 763 769 { 764 770 int err = 0; 765 771 struct xenbus_transaction trans; 766 - grant_ref_t gref; 767 - 768 - err = xenbus_grant_ring(pdev->xdev, pdev->sh_info, 1, &gref); 769 - if (err < 0) 770 - goto out; 771 - 772 - pdev->gnt_ref = gref; 773 772 774 773 err = xenbus_alloc_evtchn(pdev->xdev, &pdev->evtchn); 775 774 if (err)