aboutsummaryrefslogtreecommitdiff
path: root/drivers/char
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2009-07-29 08:49:12 +0100
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-08-03 09:04:55 +0100
commit91b8e3056bf9107b688eb076c9b804171364db71 (patch)
tree0df6aded4e83ea84258f45d0187715be732408a9 /drivers/char
parentc2980d8c2961113f24863f70d8ad016f55224c81 (diff)
intel-agp: Move repeated sglist free into separate function
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/agp/intel-agp.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 148d7e38fdd..b9d9886ff3c 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -196,6 +196,18 @@ static void intel_agp_unmap_page(struct page *page, dma_addr_t dma)
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)
{
struct scatterlist *sg;
@@ -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->page_count, PCI_DMA_BIDIRECTIONAL);
- if (!mem->num_sg) {
- if (mem->sg_vmalloc_flag)
- vfree(mem->sg_list);
- else
- kfree(mem->sg_list);
- mem->sg_list = NULL;
- mem->sg_vmalloc_flag = 0;
+ if (unlikely(!mem->num_sg)) {
+ intel_agp_free_sglist(mem);
return -ENOMEM;
}
return 0;
@@ -242,13 +249,7 @@ static void intel_agp_unmap_memory(struct agp_memory *mem)
pci_unmap_sg(intel_private.pcidev, mem->sg_list,
mem->page_count, PCI_DMA_BIDIRECTIONAL);
- 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;
+ intel_agp_free_sglist(mem);
}
static void intel_agp_insert_sg_entries(struct agp_memory *mem,