Pull vector-domain into release branch
[sfrench/cifs-2.6.git] / drivers / firewire / fw-sbp2.c
index f488ff8903fc55651e325f4629c61c033ce19a75..fc984474162c3c493cc78c06f9fe43a3071e634e 100644 (file)
@@ -416,21 +416,11 @@ sbp2_send_management_orb(struct fw_unit *unit, int node_id, int generation,
        if (orb == NULL)
                return -ENOMEM;
 
-       /*
-        * The sbp2 device is going to send a block read request to
-        * read out the request from host memory, so map it for dma.
-        */
-       orb->base.request_bus =
-               dma_map_single(device->card->device, &orb->request,
-                              sizeof(orb->request), DMA_TO_DEVICE);
-       if (dma_mapping_error(orb->base.request_bus))
-               goto out;
-
        orb->response_bus =
                dma_map_single(device->card->device, &orb->response,
                               sizeof(orb->response), DMA_FROM_DEVICE);
        if (dma_mapping_error(orb->response_bus))
-               goto out;
+               goto fail_mapping_response;
 
        orb->request.response.high    = 0;
        orb->request.response.low     = orb->response_bus;
@@ -456,6 +446,12 @@ sbp2_send_management_orb(struct fw_unit *unit, int node_id, int generation,
        init_completion(&orb->done);
        orb->base.callback = complete_management_orb;
 
+       orb->base.request_bus =
+               dma_map_single(device->card->device, &orb->request,
+                              sizeof(orb->request), DMA_TO_DEVICE);
+       if (dma_mapping_error(orb->base.request_bus))
+               goto fail_mapping_request;
+
        sbp2_send_orb(&orb->base, unit,
                      node_id, generation, sd->management_agent_address);
 
@@ -487,9 +483,10 @@ sbp2_send_management_orb(struct fw_unit *unit, int node_id, int generation,
  out:
        dma_unmap_single(device->card->device, orb->base.request_bus,
                         sizeof(orb->request), DMA_TO_DEVICE);
+ fail_mapping_request:
        dma_unmap_single(device->card->device, orb->response_bus,
                         sizeof(orb->response), DMA_FROM_DEVICE);
-
+ fail_mapping_response:
        if (response)
                fw_memcpy_from_be32(response,
                                    orb->response, sizeof(orb->response));
@@ -843,7 +840,6 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
                container_of(base_orb, struct sbp2_command_orb, base);
        struct fw_unit *unit = orb->unit;
        struct fw_device *device = fw_device(unit->device.parent);
-       struct scatterlist *sg;
        int result;
 
        if (status != NULL) {
@@ -879,11 +875,10 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
        dma_unmap_single(device->card->device, orb->base.request_bus,
                         sizeof(orb->request), DMA_TO_DEVICE);
 
-       if (orb->cmd->use_sg > 0) {
-               sg = (struct scatterlist *)orb->cmd->request_buffer;
-               dma_unmap_sg(device->card->device, sg, orb->cmd->use_sg,
+       if (scsi_sg_count(orb->cmd) > 0)
+               dma_unmap_sg(device->card->device, scsi_sglist(orb->cmd),
+                            scsi_sg_count(orb->cmd),
                             orb->cmd->sc_data_direction);
-       }
 
        if (orb->page_table_bus != 0)
                dma_unmap_single(device->card->device, orb->page_table_bus,
@@ -904,8 +899,8 @@ static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb)
        int sg_len, l, i, j, count;
        dma_addr_t sg_addr;
 
-       sg = (struct scatterlist *)orb->cmd->request_buffer;
-       count = dma_map_sg(device->card->device, sg, orb->cmd->use_sg,
+       sg = scsi_sglist(orb->cmd);
+       count = dma_map_sg(device->card->device, sg, scsi_sg_count(orb->cmd),
                           orb->cmd->sc_data_direction);
        if (count == 0)
                goto fail;
@@ -974,7 +969,7 @@ static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb)
        return 0;
 
  fail_page_table:
-       dma_unmap_sg(device->card->device, sg, orb->cmd->use_sg,
+       dma_unmap_sg(device->card->device, sg, scsi_sg_count(orb->cmd),
                     orb->cmd->sc_data_direction);
  fail:
        return -ENOMEM;
@@ -1034,7 +1029,7 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
                orb->request.misc |=
                        COMMAND_ORB_DIRECTION(SBP2_DIRECTION_TO_MEDIA);
 
-       if (cmd->use_sg && sbp2_command_orb_map_scatterlist(orb) < 0)
+       if (scsi_sg_count(cmd) && sbp2_command_orb_map_scatterlist(orb) < 0)
                goto fail_mapping;
 
        fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request));