Merge tag 'v2.6.39-rc7'
authorStefan Richter <stefanr@s5r6.in-berlin.de>
Tue, 10 May 2011 18:52:07 +0000 (20:52 +0200)
committerStefan Richter <stefanr@s5r6.in-berlin.de>
Tue, 10 May 2011 20:50:41 +0000 (22:50 +0200)
in order to pull in changes in drivers/media/dvb/firewire/ and
sound/firewire/.

1  2 
drivers/firewire/ohci.c

diff --combined drivers/firewire/ohci.c
@@@ -1006,12 -1006,13 +1006,12 @@@ static void ar_context_run(struct ar_co
  
  static struct descriptor *find_branch_descriptor(struct descriptor *d, int z)
  {
 -      int b, key;
 +      __le16 branch;
  
 -      b   = (le16_to_cpu(d->control) & DESCRIPTOR_BRANCH_ALWAYS) >> 2;
 -      key = (le16_to_cpu(d->control) & DESCRIPTOR_KEY_IMMEDIATE) >> 8;
 +      branch = d->control & cpu_to_le16(DESCRIPTOR_BRANCH_ALWAYS);
  
        /* figure out which descriptor the branch address goes in */
 -      if (z == 2 && (b == 3 || key == 2))
 +      if (z == 2 && branch == cpu_to_le16(DESCRIPTOR_BRANCH_ALWAYS))
                return d;
        else
                return d + z - 1;
@@@ -1217,7 -1218,6 +1217,7 @@@ static void context_stop(struct contex
  }
  
  struct driver_data {
 +      u8 inline_data[8];
        struct fw_packet *packet;
  };
  
@@@ -1301,28 -1301,20 +1301,28 @@@ static int at_context_queue_packet(stru
                return -1;
        }
  
 +      BUILD_BUG_ON(sizeof(struct driver_data) > sizeof(struct descriptor));
        driver_data = (struct driver_data *) &d[3];
        driver_data->packet = packet;
        packet->driver_data = driver_data;
  
        if (packet->payload_length > 0) {
 -              payload_bus =
 -                      dma_map_single(ohci->card.device, packet->payload,
 -                                     packet->payload_length, DMA_TO_DEVICE);
 -              if (dma_mapping_error(ohci->card.device, payload_bus)) {
 -                      packet->ack = RCODE_SEND_ERROR;
 -                      return -1;
 +              if (packet->payload_length > sizeof(driver_data->inline_data)) {
 +                      payload_bus = dma_map_single(ohci->card.device,
 +                                                   packet->payload,
 +                                                   packet->payload_length,
 +                                                   DMA_TO_DEVICE);
 +                      if (dma_mapping_error(ohci->card.device, payload_bus)) {
 +                              packet->ack = RCODE_SEND_ERROR;
 +                              return -1;
 +                      }
 +                      packet->payload_bus     = payload_bus;
 +                      packet->payload_mapped  = true;
 +              } else {
 +                      memcpy(driver_data->inline_data, packet->payload,
 +                             packet->payload_length);
 +                      payload_bus = d_bus + 3 * sizeof(*d);
                }
 -              packet->payload_bus     = payload_bus;
 -              packet->payload_mapped  = true;
  
                d[2].req_count    = cpu_to_le16(packet->payload_length);
                d[2].data_address = cpu_to_le32(payload_bus);
@@@ -2074,6 -2066,8 +2074,6 @@@ static int ohci_enable(struct fw_card *
  
        reg_write(ohci, OHCI1394_SelfIDBuffer, ohci->self_id_bus);
        reg_write(ohci, OHCI1394_LinkControlSet,
 -                OHCI1394_LinkControl_rcvSelfID |
 -                OHCI1394_LinkControl_rcvPhyPkt |
                  OHCI1394_LinkControl_cycleTimerEnable |
                  OHCI1394_LinkControl_cycleMaster);
  
        reg_write(ohci, OHCI1394_FairnessControl, 0);
        card->priority_budget_implemented = ohci->pri_req_max != 0;
  
 -      ar_context_run(&ohci->ar_request_ctx);
 -      ar_context_run(&ohci->ar_response_ctx);
 -
        reg_write(ohci, OHCI1394_PhyUpperBound, 0x00010000);
        reg_write(ohci, OHCI1394_IntEventClear, ~0);
        reg_write(ohci, OHCI1394_IntMaskClear, ~0);
        reg_write(ohci, OHCI1394_HCControlSet,
                  OHCI1394_HCControl_linkEnable |
                  OHCI1394_HCControl_BIBimageValid);
 -      flush_writes(ohci);
 +
 +      reg_write(ohci, OHCI1394_LinkControlSet,
 +                OHCI1394_LinkControl_rcvSelfID |
 +                OHCI1394_LinkControl_rcvPhyPkt);
 +
 +      ar_context_run(&ohci->ar_request_ctx);
 +      ar_context_run(&ohci->ar_response_ctx); /* also flushes writes */
  
        /* We are ready to go, reset bus to finish initialization. */
        fw_schedule_bus_reset(&ohci->card, false, true);
@@@ -2208,7 -2199,6 +2208,6 @@@ static int ohci_set_config_rom(struct f
  {
        struct fw_ohci *ohci;
        unsigned long flags;
-       int ret = -EBUSY;
        __be32 *next_config_rom;
        dma_addr_t uninitialized_var(next_config_rom_bus);
  
  
        spin_lock_irqsave(&ohci->lock, flags);
  
+       /*
+        * If there is not an already pending config_rom update,
+        * push our new allocation into the ohci->next_config_rom
+        * and then mark the local variable as null so that we
+        * won't deallocate the new buffer.
+        *
+        * OTOH, if there is a pending config_rom update, just
+        * use that buffer with the new config_rom data, and
+        * let this routine free the unused DMA allocation.
+        */
        if (ohci->next_config_rom == NULL) {
                ohci->next_config_rom = next_config_rom;
                ohci->next_config_rom_bus = next_config_rom_bus;
+               next_config_rom = NULL;
+       }
  
-               copy_config_rom(ohci->next_config_rom, config_rom, length);
+       copy_config_rom(ohci->next_config_rom, config_rom, length);
  
-               ohci->next_header = config_rom[0];
-               ohci->next_config_rom[0] = 0;
+       ohci->next_header = config_rom[0];
+       ohci->next_config_rom[0] = 0;
  
-               reg_write(ohci, OHCI1394_ConfigROMmap,
-                         ohci->next_config_rom_bus);
-               ret = 0;
-       }
+       reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus);
  
        spin_unlock_irqrestore(&ohci->lock, flags);
  
+       /* If we didn't use the DMA allocation, delete it. */
+       if (next_config_rom != NULL)
+               dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE,
+                                 next_config_rom, next_config_rom_bus);
        /*
         * Now initiate a bus reset to have the changes take
         * effect. We clean up the old config rom memory and DMA
         * controller could need to access it before the bus reset
         * takes effect.
         */
-       if (ret == 0)
-               fw_schedule_bus_reset(&ohci->card, true, true);
-       else
-               dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE,
-                                 next_config_rom, next_config_rom_bus);
  
-       return ret;
+       fw_schedule_bus_reset(&ohci->card, true, true);
+       return 0;
  }
  
  static void ohci_send_request(struct fw_card *card, struct fw_packet *packet)