firewire: Use dma_mapping_error() for checking for DMA mapping errors.
Pointed out by Pete Zaitcev.
Signed-off-by: Kristian Høgsberg <krh@redhat.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index e6fa349..4512edb 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -431,7 +431,7 @@
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 @@
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 @@
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 @@
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)