Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 22 Jul 2011 21:49:48 +0000 (14:49 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 22 Jul 2011 21:49:48 +0000 (14:49 -0700)
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6:
  firewire: document the sysfs ABIs
  firewire: cdev: ABI documentation enhancements
  firewire: cdev: prevent race between first get_info ioctl and bus reset event queuing
  firewire: cdev: return -ENOTTY for unimplemented ioctls, not -EINVAL
  firewire: ohci: skip soft reset retries after card ejection
  firewire: ohci: fix PHY reg access after card ejection
  firewire: ohci: add a comment on PHY reg access serialization
  firewire: ohci: reduce potential context_stop latency
  firewire: ohci: remove superfluous posted write flushes
  firewire: net: replacing deprecated __attribute__((packed)) with __packed

1  2 
drivers/firewire/net.c
drivers/firewire/ohci.c

diff --combined drivers/firewire/net.c
@@@ -7,6 -7,7 +7,7 @@@
   */
  
  #include <linux/bug.h>
+ #include <linux/compiler.h>
  #include <linux/delay.h>
  #include <linux/device.h>
  #include <linux/ethtool.h>
@@@ -73,7 -74,7 +74,7 @@@ struct rfc2734_arp 
        __be32 fifo_lo;         /* lo 32bits of sender's FIFO addr      */
        __be32 sip;             /* Sender's IP Address                  */
        __be32 tip;             /* IP Address of requested hw addr      */
- } __attribute__((packed));
+ } __packed;
  
  /* This header format is specific to this driver implementation. */
  #define FWNET_ALEN    8
@@@ -81,7 -82,7 +82,7 @@@
  struct fwnet_header {
        u8 h_dest[FWNET_ALEN];  /* destination address */
        __be16 h_proto;         /* packet type ID field */
- } __attribute__((packed));
+ } __packed;
  
  /* IPv4 and IPv6 encapsulation header */
  struct rfc2734_header {
@@@ -261,16 -262,16 +262,16 @@@ static int fwnet_header_rebuild(struct 
  }
  
  static int fwnet_header_cache(const struct neighbour *neigh,
 -                            struct hh_cache *hh)
 +                            struct hh_cache *hh, __be16 type)
  {
        struct net_device *net;
        struct fwnet_header *h;
  
 -      if (hh->hh_type == cpu_to_be16(ETH_P_802_3))
 +      if (type == cpu_to_be16(ETH_P_802_3))
                return -1;
        net = neigh->dev;
        h = (struct fwnet_header *)((u8 *)hh->hh_data + 16 - sizeof(*h));
 -      h->h_proto = hh->hh_type;
 +      h->h_proto = type;
        memcpy(h->h_dest, neigh->ha, net->addr_len);
        hh->hh_len = FWNET_HLEN;
  
diff --combined drivers/firewire/ohci.c
@@@ -253,7 -253,6 +253,6 @@@ static inline struct fw_ohci *fw_ohci(s
  #define OHCI1394_MAX_PHYS_RESP_RETRIES        0x8
  
  #define OHCI1394_REGISTER_SIZE                0x800
- #define OHCI_LOOP_COUNT                       500
  #define OHCI1394_PCI_HCI_Control      0x40
  #define SELF_ID_BUF_SIZE              0x800
  #define OHCI_TCODE_PHY_PACKET         0x0e
@@@ -264,7 -263,6 +263,7 @@@ static char ohci_driver_name[] = KBUILD
  #define PCI_DEVICE_ID_AGERE_FW643     0x5901
  #define PCI_DEVICE_ID_JMICRON_JMB38X_FW       0x2380
  #define PCI_DEVICE_ID_TI_TSB12LV22    0x8009
 +#define PCI_VENDOR_ID_PINNACLE_SYSTEMS        0x11bd
  
  #define QUIRK_CYCLE_TIMER             1
  #define QUIRK_RESET_PACKET            2
@@@ -514,6 -512,12 +513,12 @@@ static inline void flush_writes(const s
        reg_read(ohci, OHCI1394_Version);
  }
  
+ /*
+  * Beware!  read_phy_reg(), write_phy_reg(), update_phy_reg(), and
+  * read_paged_phy_reg() require the caller to hold ohci->phy_reg_mutex.
+  * In other words, only use ohci_read_phy_reg() and ohci_update_phy_reg()
+  * directly.  Exceptions are intrinsically serialized contexts like pci_probe.
+  */
  static int read_phy_reg(struct fw_ohci *ohci, int addr)
  {
        u32 val;
        reg_write(ohci, OHCI1394_PhyControl, OHCI1394_PhyControl_Read(addr));
        for (i = 0; i < 3 + 100; i++) {
                val = reg_read(ohci, OHCI1394_PhyControl);
+               if (!~val)
+                       return -ENODEV; /* Card was ejected. */
                if (val & OHCI1394_PhyControl_ReadDone)
                        return OHCI1394_PhyControl_ReadData(val);
  
@@@ -545,6 -552,9 +553,9 @@@ static int write_phy_reg(const struct f
                  OHCI1394_PhyControl_Write(addr, val));
        for (i = 0; i < 3 + 100; i++) {
                val = reg_read(ohci, OHCI1394_PhyControl);
+               if (!~val)
+                       return -ENODEV; /* Card was ejected. */
                if (!(val & OHCI1394_PhyControl_WritePending))
                        return 0;
  
@@@ -630,7 -640,6 +641,6 @@@ static void ar_context_link_page(struc
        ctx->last_buffer_index = index;
  
        reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_WAKE);
-       flush_writes(ctx->ohci);
  }
  
  static void ar_context_release(struct ar_context *ctx)
@@@ -1002,7 -1011,6 +1012,6 @@@ static void ar_context_run(struct ar_co
  
        reg_write(ctx->ohci, COMMAND_PTR(ctx->regs), ctx->descriptors_bus | 1);
        reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_RUN);
-       flush_writes(ctx->ohci);
  }
  
  static struct descriptor *find_branch_descriptor(struct descriptor *d, int z)
@@@ -1202,14 -1210,14 +1211,14 @@@ static void context_stop(struct contex
  
        reg_write(ctx->ohci, CONTROL_CLEAR(ctx->regs), CONTEXT_RUN);
        ctx->running = false;
-       flush_writes(ctx->ohci);
  
-       for (i = 0; i < 10; i++) {
+       for (i = 0; i < 1000; i++) {
                reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs));
                if ((reg & CONTEXT_ACTIVE) == 0)
                        return;
  
-               mdelay(1);
+               if (i)
+                       udelay(10);
        }
        fw_error("Error: DMA context still active (0x%08x)\n", reg);
  }
@@@ -1346,12 -1354,10 +1355,10 @@@ static int at_context_queue_packet(stru
  
        context_append(ctx, d, z, 4 - z);
  
-       if (ctx->running) {
+       if (ctx->running)
                reg_write(ohci, CONTROL_SET(ctx->regs), CONTEXT_WAKE);
-               flush_writes(ohci);
-       } else {
+       else
                context_run(ctx, 0);
-       }
  
        return 0;
  }
@@@ -1960,14 -1966,18 +1967,18 @@@ static irqreturn_t irq_handler(int irq
  
  static int software_reset(struct fw_ohci *ohci)
  {
+       u32 val;
        int i;
  
        reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_softReset);
+       for (i = 0; i < 500; i++) {
+               val = reg_read(ohci, OHCI1394_HCControlSet);
+               if (!~val)
+                       return -ENODEV; /* Card was ejected. */
  
-       for (i = 0; i < OHCI_LOOP_COUNT; i++) {
-               if ((reg_read(ohci, OHCI1394_HCControlSet) &
-                    OHCI1394_HCControl_softReset) == 0)
+               if (!(val & OHCI1394_HCControl_softReset))
                        return 0;
                msleep(1);
        }
  
@@@ -2197,7 -2207,9 +2208,9 @@@ static int ohci_enable(struct fw_card *
                  OHCI1394_LinkControl_rcvPhyPkt);
  
        ar_context_run(&ohci->ar_request_ctx);
-       ar_context_run(&ohci->ar_response_ctx); /* also flushes writes */
+       ar_context_run(&ohci->ar_response_ctx);
+       flush_writes(ohci);
  
        /* We are ready to go, reset bus to finish initialization. */
        fw_schedule_bus_reset(&ohci->card, false, true);
@@@ -3129,7 -3141,6 +3142,6 @@@ static void ohci_flush_queue_iso(struc
                        &container_of(base, struct iso_context, base)->context;
  
        reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_WAKE);
-       flush_writes(ctx->ohci);
  }
  
  static const struct fw_card_driver ohci_driver = {
@@@ -3191,11 -3202,6 +3203,11 @@@ static int __devinit pci_probe(struct p
        int i, err;
        size_t size;
  
 +      if (dev->vendor == PCI_VENDOR_ID_PINNACLE_SYSTEMS) {
 +              dev_err(&dev->dev, "Pinnacle MovieBoard is not yet supported\n");
 +              return -ENOSYS;
 +      }
 +
        ohci = kzalloc(sizeof(*ohci), GFP_KERNEL);
        if (ohci == NULL) {
                err = -ENOMEM;