aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2009-07-29 03:49:12 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-08-03 04:04:55 -0400
commit91b8e3056bf9107b688eb076c9b804171364db71 (patch)
tree0df6aded4e83ea84258f45d0187715be732408a9
parentc2980d8c2961113f24863f70d8ad016f55224c81 (diff)
intel-agp: Move repeated sglist free into separate function
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-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 148d7e38fddf..b9d9886ff3c3 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)
196 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); 196 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
197} 197}
198 198
199static void intel_agp_free_sglist(struct agp_memory *mem)
200{
201
202 if (mem->sg_vmalloc_flag)
203 vfree(mem->sg_list);
204 else
205 kfree(mem->sg_list);
206 mem->sg_vmalloc_flag = 0;
207 mem->sg_list = NULL;
208 mem->num_sg = 0;
209}
210
199static int intel_agp_map_memory(struct agp_memory *mem) 211static int intel_agp_map_memory(struct agp_memory *mem)
200{ 212{
201 struct scatterlist *sg; 213 struct scatterlist *sg;
@@ -224,13 +236,8 @@ static int intel_agp_map_memory(struct agp_memory *mem)
224 236
225 mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list, 237 mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list,
226 mem->page_count, PCI_DMA_BIDIRECTIONAL); 238 mem->page_count, PCI_DMA_BIDIRECTIONAL);
227 if (!mem->num_sg) { 239 if (unlikely(!mem->num_sg)) {
228 if (mem->sg_vmalloc_flag) 240 intel_agp_free_sglist(mem);
229 vfree(mem->sg_list);
230 else
231 kfree(mem->sg_list);
232 mem->sg_list = NULL;
233 mem->sg_vmalloc_flag = 0;
234 return -ENOMEM; 241 return -ENOMEM;
235 } 242 }
236 return 0; 243 return 0;
@@ -242,13 +249,7 @@ static void intel_agp_unmap_memory(struct agp_memory *mem)
242 249
243 pci_unmap_sg(intel_private.pcidev, mem->sg_list, 250 pci_unmap_sg(intel_private.pcidev, mem->sg_list,
244 mem->page_count, PCI_DMA_BIDIRECTIONAL); 251 mem->page_count, PCI_DMA_BIDIRECTIONAL);
245 if (mem->sg_vmalloc_flag) 252 intel_agp_free_sglist(mem);
246 vfree(mem->sg_list);
247 else
248 kfree(mem->sg_list);
249 mem->sg_vmalloc_flag = 0;
250 mem->sg_list = NULL;
251 mem->num_sg = 0;
252} 253}
253 254
254static void intel_agp_insert_sg_entries(struct agp_memory *mem, 255static void intel_agp_insert_sg_entries(struct agp_memory *mem,