From 82eff9db7dc5d8f78898d5051975d14f48be2028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 6 Feb 2007 14:49:40 -0500 Subject: firewire: Use dma_mapping_error() for checking for DMA mapping errors. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pointed out by Pete Zaitcev. Signed-off-by: Kristian Høgsberg Signed-off-by: Stefan Richter --- drivers/firewire/fw-ohci.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'drivers/firewire/fw-ohci.c') diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c index e6fa3496183..4512edba6cb 100644 --- a/drivers/firewire/fw-ohci.c +++ b/drivers/firewire/fw-ohci.c @@ -431,7 +431,7 @@ at_context_setup_packet(struct at_context *ctx, struct list_head *list) packet->payload, packet->payload_length, DMA_TO_DEVICE); - if (packet->payload_bus == 0) { + if (dma_mapping_error(packet->payload_bus)) { complete_transmission(packet, RCODE_SEND_ERROR, list); return; } @@ -590,7 +590,7 @@ at_context_init(struct at_context *ctx, struct fw_ohci *ohci, u32 regs) ctx->descriptor_bus = dma_map_single(ohci->card.device, &ctx->d, sizeof ctx->d, DMA_TO_DEVICE); - if (ctx->descriptor_bus == 0) + if (dma_mapping_error(ctx->descriptor_bus)) return -ENOMEM; ctx->regs = regs; @@ -1159,16 +1159,14 @@ static struct fw_iso_context *ohci_allocate_iso_context(struct fw_card *card, tasklet_init(&ctx->tasklet, tasklet, (unsigned long)ctx); ctx->buffer = kmalloc(ISO_BUFFER_SIZE, GFP_KERNEL); - if (ctx->buffer == NULL) { - spin_lock_irqsave(&ohci->lock, flags); - *mask |= 1 << index; - spin_unlock_irqrestore(&ohci->lock, flags); - return ERR_PTR(-ENOMEM); - } + if (ctx->buffer == NULL) + goto buffer_alloc_failed; ctx->buffer_bus = dma_map_single(card->device, ctx->buffer, ISO_BUFFER_SIZE, DMA_TO_DEVICE); + if (dma_mapping_error(ctx->buffer_bus)) + goto buffer_map_failed; ctx->head_descriptor = ctx->buffer; ctx->prev_descriptor = ctx->buffer; @@ -1187,6 +1185,15 @@ static struct fw_iso_context *ohci_allocate_iso_context(struct fw_card *card, ctx->head_descriptor++; return &ctx->base; + + buffer_map_failed: + kfree(ctx->buffer); + buffer_alloc_failed: + spin_lock_irqsave(&ohci->lock, flags); + *mask |= 1 << index; + spin_unlock_irqrestore(&ohci->lock, flags); + + return ERR_PTR(-ENOMEM); } static int ohci_send_iso(struct fw_iso_context *base, s32 cycle) -- cgit v1.2.3