提交 91b8e305 编写于 作者: D David Woodhouse

intel-agp: Move repeated sglist free into separate function

Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 c2980d8c
...@@ -196,6 +196,18 @@ static void intel_agp_unmap_page(struct page *page, dma_addr_t dma) ...@@ -196,6 +196,18 @@ static void intel_agp_unmap_page(struct page *page, dma_addr_t dma)
PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
} }
static void intel_agp_free_sglist(struct agp_memory *mem)
{
if (mem->sg_vmalloc_flag)
vfree(mem->sg_list);
else
kfree(mem->sg_list);
mem->sg_vmalloc_flag = 0;
mem->sg_list = NULL;
mem->num_sg = 0;
}
static int intel_agp_map_memory(struct agp_memory *mem) static int intel_agp_map_memory(struct agp_memory *mem)
{ {
struct scatterlist *sg; struct scatterlist *sg;
...@@ -224,13 +236,8 @@ static int intel_agp_map_memory(struct agp_memory *mem) ...@@ -224,13 +236,8 @@ static int intel_agp_map_memory(struct agp_memory *mem)
mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list, mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list,
mem->page_count, PCI_DMA_BIDIRECTIONAL); mem->page_count, PCI_DMA_BIDIRECTIONAL);
if (!mem->num_sg) { if (unlikely(!mem->num_sg)) {
if (mem->sg_vmalloc_flag) intel_agp_free_sglist(mem);
vfree(mem->sg_list);
else
kfree(mem->sg_list);
mem->sg_list = NULL;
mem->sg_vmalloc_flag = 0;
return -ENOMEM; return -ENOMEM;
} }
return 0; return 0;
...@@ -242,13 +249,7 @@ static void intel_agp_unmap_memory(struct agp_memory *mem) ...@@ -242,13 +249,7 @@ static void intel_agp_unmap_memory(struct agp_memory *mem)
pci_unmap_sg(intel_private.pcidev, mem->sg_list, pci_unmap_sg(intel_private.pcidev, mem->sg_list,
mem->page_count, PCI_DMA_BIDIRECTIONAL); mem->page_count, PCI_DMA_BIDIRECTIONAL);
if (mem->sg_vmalloc_flag) intel_agp_free_sglist(mem);
vfree(mem->sg_list);
else
kfree(mem->sg_list);
mem->sg_vmalloc_flag = 0;
mem->sg_list = NULL;
mem->num_sg = 0;
} }
static void intel_agp_insert_sg_entries(struct agp_memory *mem, static void intel_agp_insert_sg_entries(struct agp_memory *mem,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册