]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 16 Oct 2008 22:02:24 +0000 (15:02 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 16 Oct 2008 22:02:24 +0000 (15:02 -0700)
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6:
  firewire: Add more documentation to firewire-cdev.h
  firewire: fix ioctl() return code
  firewire: fix setting tag and sy in iso transmission
  firewire: fw-sbp2: fix another small generation access bug
  firewire: fw-sbp2: enforce s/g segment size limit
  firewire: fw_send_request_sync()
  ieee1394: survive a few seconds connection loss
  ieee1394: nodemgr clean up class iterators
  ieee1394: dv1394, video1394: remove unnecessary expressions
  ieee1394: raw1394: make write() thread-safe
  ieee1394: raw1394: narrow down the state_mutex protected region
  ieee1394: raw1394: replace BKL by local mutex, make ioctl() and mmap() thread-safe
  ieee1394: sbp2: enforce s/g segment size limit
  ieee1394: sbp2: check for DMA mapping failures
  ieee1394: sbp2: stricter dma_sync
  ieee1394: Use DIV_ROUND_UP

1  2 
drivers/ieee1394/dv1394.c
drivers/ieee1394/raw1394.c
drivers/ieee1394/video1394.c

index 9236c0d5a12242120e11a7bd95b6c10617d0b480,df70f51279d85db8d21b1731c9d7b3b96ca8e668..2f83543a9dfca95c797e42421055497fc1c6f2e0
@@@ -918,7 -918,7 +918,7 @@@ static int do_dv1394_init(struct video_
                /* default SYT offset is 3 cycles */
                init->syt_offset = 3;
  
-       if ( (init->channel > 63) || (init->channel < 0) )
+       if (init->channel > 63)
                init->channel = 63;
  
        chan_mask = (u64)1 << init->channel;
@@@ -2296,10 -2296,10 +2296,10 @@@ static void dv1394_add_host(struct hpsb
  
        ohci = (struct ti_ohci *)host->hostdata;
  
 -      device_create_drvdata(hpsb_protocol_class, NULL,
 -                            MKDEV(IEEE1394_MAJOR,
 -                                  IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), NULL,
 -                            "dv1394-%d", id);
 +      device_create(hpsb_protocol_class, NULL,
 +                    MKDEV(IEEE1394_MAJOR,
 +                          IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)),
 +                    NULL, "dv1394-%d", id);
  
        dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE);
        dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT);
index c7833bb37ae1e134eea46034e5cdda13765f49ab,2cf4ae75becaf92213c2af33056a3fb20e35be39..9f19ac492106a8107a0d9fc2f2af66d92908dfe0
@@@ -34,6 -34,7 +34,7 @@@
  #include <linux/fs.h>
  #include <linux/poll.h>
  #include <linux/module.h>
+ #include <linux/mutex.h>
  #include <linux/init.h>
  #include <linux/interrupt.h>
  #include <linux/vmalloc.h>
@@@ -2267,6 -2268,8 +2268,8 @@@ static ssize_t raw1394_write(struct fil
                return -EFAULT;
        }
  
+       mutex_lock(&fi->state_mutex);
        switch (fi->state) {
        case opened:
                retval = state_opened(fi, req);
                break;
        }
  
+       mutex_unlock(&fi->state_mutex);
        if (retval < 0) {
                free_pending_request(req);
        } else {
@@@ -2541,109 -2546,120 +2546,120 @@@ static int raw1394_read_cycle_timer(str
  static int raw1394_mmap(struct file *file, struct vm_area_struct *vma)
  {
        struct file_info *fi = file->private_data;
+       int ret;
+       mutex_lock(&fi->state_mutex);
  
        if (fi->iso_state == RAW1394_ISO_INACTIVE)
-               return -EINVAL;
+               ret = -EINVAL;
+       else
+               ret = dma_region_mmap(&fi->iso_handle->data_buf, file, vma);
+       mutex_unlock(&fi->state_mutex);
  
-       return dma_region_mmap(&fi->iso_handle->data_buf, file, vma);
+       return ret;
  }
  
- /* ioctl is only used for rawiso operations */
- static long do_raw1394_ioctl(struct file *file, unsigned int cmd,
-                                                       unsigned long arg)
+ static long raw1394_ioctl_inactive(struct file_info *fi, unsigned int cmd,
+                                  void __user *argp)
+ {
+       switch (cmd) {
+       case RAW1394_IOC_ISO_XMIT_INIT:
+               return raw1394_iso_xmit_init(fi, argp);
+       case RAW1394_IOC_ISO_RECV_INIT:
+               return raw1394_iso_recv_init(fi, argp);
+       default:
+               return -EINVAL;
+       }
+ }
+ static long raw1394_ioctl_recv(struct file_info *fi, unsigned int cmd,
+                              unsigned long arg)
  {
-       struct file_info *fi = file->private_data;
        void __user *argp = (void __user *)arg;
  
-       switch (fi->iso_state) {
-       case RAW1394_ISO_INACTIVE:
-               switch (cmd) {
-               case RAW1394_IOC_ISO_XMIT_INIT:
-                       return raw1394_iso_xmit_init(fi, argp);
-               case RAW1394_IOC_ISO_RECV_INIT:
-                       return raw1394_iso_recv_init(fi, argp);
-               default:
-                       break;
+       switch (cmd) {
+       case RAW1394_IOC_ISO_RECV_START:{
+                       int args[3];
+                       if (copy_from_user(&args[0], argp, sizeof(args)))
+                               return -EFAULT;
+                       return hpsb_iso_recv_start(fi->iso_handle,
+                                                  args[0], args[1], args[2]);
                }
-               break;
-       case RAW1394_ISO_RECV:
-               switch (cmd) {
-               case RAW1394_IOC_ISO_RECV_START:{
-                               /* copy args from user-space */
-                               int args[3];
-                               if (copy_from_user
-                                   (&args[0], argp, sizeof(args)))
-                                       return -EFAULT;
-                               return hpsb_iso_recv_start(fi->iso_handle,
-                                                          args[0], args[1],
-                                                          args[2]);
-                       }
-               case RAW1394_IOC_ISO_XMIT_RECV_STOP:
-                       hpsb_iso_stop(fi->iso_handle);
-                       return 0;
-               case RAW1394_IOC_ISO_RECV_LISTEN_CHANNEL:
-                       return hpsb_iso_recv_listen_channel(fi->iso_handle,
-                                                           arg);
-               case RAW1394_IOC_ISO_RECV_UNLISTEN_CHANNEL:
-                       return hpsb_iso_recv_unlisten_channel(fi->iso_handle,
-                                                             arg);
-               case RAW1394_IOC_ISO_RECV_SET_CHANNEL_MASK:{
-                               /* copy the u64 from user-space */
-                               u64 mask;
-                               if (copy_from_user(&mask, argp, sizeof(mask)))
-                                       return -EFAULT;
-                               return hpsb_iso_recv_set_channel_mask(fi->
-                                                                     iso_handle,
-                                                                     mask);
-                       }
-               case RAW1394_IOC_ISO_GET_STATUS:
-                       return raw1394_iso_get_status(fi, argp);
-               case RAW1394_IOC_ISO_RECV_PACKETS:
-                       return raw1394_iso_recv_packets(fi, argp);
-               case RAW1394_IOC_ISO_RECV_RELEASE_PACKETS:
-                       return hpsb_iso_recv_release_packets(fi->iso_handle,
-                                                            arg);
-               case RAW1394_IOC_ISO_RECV_FLUSH:
-                       return hpsb_iso_recv_flush(fi->iso_handle);
-               case RAW1394_IOC_ISO_SHUTDOWN:
-                       raw1394_iso_shutdown(fi);
-                       return 0;
-               case RAW1394_IOC_ISO_QUEUE_ACTIVITY:
-                       queue_rawiso_event(fi);
-                       return 0;
+       case RAW1394_IOC_ISO_XMIT_RECV_STOP:
+               hpsb_iso_stop(fi->iso_handle);
+               return 0;
+       case RAW1394_IOC_ISO_RECV_LISTEN_CHANNEL:
+               return hpsb_iso_recv_listen_channel(fi->iso_handle, arg);
+       case RAW1394_IOC_ISO_RECV_UNLISTEN_CHANNEL:
+               return hpsb_iso_recv_unlisten_channel(fi->iso_handle, arg);
+       case RAW1394_IOC_ISO_RECV_SET_CHANNEL_MASK:{
+                       u64 mask;
+                       if (copy_from_user(&mask, argp, sizeof(mask)))
+                               return -EFAULT;
+                       return hpsb_iso_recv_set_channel_mask(fi->iso_handle,
+                                                             mask);
                }
-               break;
-       case RAW1394_ISO_XMIT:
-               switch (cmd) {
-               case RAW1394_IOC_ISO_XMIT_START:{
-                               /* copy two ints from user-space */
-                               int args[2];
-                               if (copy_from_user
-                                   (&args[0], argp, sizeof(args)))
-                                       return -EFAULT;
-                               return hpsb_iso_xmit_start(fi->iso_handle,
-                                                          args[0], args[1]);
-                       }
-               case RAW1394_IOC_ISO_XMIT_SYNC:
-                       return hpsb_iso_xmit_sync(fi->iso_handle);
-               case RAW1394_IOC_ISO_XMIT_RECV_STOP:
-                       hpsb_iso_stop(fi->iso_handle);
-                       return 0;
-               case RAW1394_IOC_ISO_GET_STATUS:
-                       return raw1394_iso_get_status(fi, argp);
-               case RAW1394_IOC_ISO_XMIT_PACKETS:
-                       return raw1394_iso_send_packets(fi, argp);
-               case RAW1394_IOC_ISO_SHUTDOWN:
-                       raw1394_iso_shutdown(fi);
-                       return 0;
-               case RAW1394_IOC_ISO_QUEUE_ACTIVITY:
-                       queue_rawiso_event(fi);
-                       return 0;
+       case RAW1394_IOC_ISO_GET_STATUS:
+               return raw1394_iso_get_status(fi, argp);
+       case RAW1394_IOC_ISO_RECV_PACKETS:
+               return raw1394_iso_recv_packets(fi, argp);
+       case RAW1394_IOC_ISO_RECV_RELEASE_PACKETS:
+               return hpsb_iso_recv_release_packets(fi->iso_handle, arg);
+       case RAW1394_IOC_ISO_RECV_FLUSH:
+               return hpsb_iso_recv_flush(fi->iso_handle);
+       case RAW1394_IOC_ISO_SHUTDOWN:
+               raw1394_iso_shutdown(fi);
+               return 0;
+       case RAW1394_IOC_ISO_QUEUE_ACTIVITY:
+               queue_rawiso_event(fi);
+               return 0;
+       default:
+               return -EINVAL;
+       }
+ }
+ static long raw1394_ioctl_xmit(struct file_info *fi, unsigned int cmd,
+                              void __user *argp)
+ {
+       switch (cmd) {
+       case RAW1394_IOC_ISO_XMIT_START:{
+                       int args[2];
+                       if (copy_from_user(&args[0], argp, sizeof(args)))
+                               return -EFAULT;
+                       return hpsb_iso_xmit_start(fi->iso_handle,
+                                                  args[0], args[1]);
                }
-               break;
+       case RAW1394_IOC_ISO_XMIT_SYNC:
+               return hpsb_iso_xmit_sync(fi->iso_handle);
+       case RAW1394_IOC_ISO_XMIT_RECV_STOP:
+               hpsb_iso_stop(fi->iso_handle);
+               return 0;
+       case RAW1394_IOC_ISO_GET_STATUS:
+               return raw1394_iso_get_status(fi, argp);
+       case RAW1394_IOC_ISO_XMIT_PACKETS:
+               return raw1394_iso_send_packets(fi, argp);
+       case RAW1394_IOC_ISO_SHUTDOWN:
+               raw1394_iso_shutdown(fi);
+               return 0;
+       case RAW1394_IOC_ISO_QUEUE_ACTIVITY:
+               queue_rawiso_event(fi);
+               return 0;
        default:
-               break;
+               return -EINVAL;
        }
+ }
+ /* ioctl is only used for rawiso operations */
+ static long raw1394_ioctl(struct file *file, unsigned int cmd,
+                         unsigned long arg)
+ {
+       struct file_info *fi = file->private_data;
+       void __user *argp = (void __user *)arg;
+       long ret;
  
        /* state-independent commands */
        switch(cmd) {
                break;
        }
  
-       return -EINVAL;
- }
+       mutex_lock(&fi->state_mutex);
+       switch (fi->iso_state) {
+       case RAW1394_ISO_INACTIVE:
+               ret = raw1394_ioctl_inactive(fi, cmd, argp);
+               break;
+       case RAW1394_ISO_RECV:
+               ret = raw1394_ioctl_recv(fi, cmd, arg);
+               break;
+       case RAW1394_ISO_XMIT:
+               ret = raw1394_ioctl_xmit(fi, cmd, argp);
+               break;
+       default:
+               ret = -EINVAL;
+               break;
+       }
+       mutex_unlock(&fi->state_mutex);
  
- static long raw1394_ioctl(struct file *file, unsigned int cmd,
-                                                       unsigned long arg)
- {
-       long ret;
-       lock_kernel();
-       ret = do_raw1394_ioctl(file, cmd, arg);
-       unlock_kernel();
        return ret;
  }
  
@@@ -2700,7 -2725,7 +2725,7 @@@ static long raw1394_iso_xmit_recv_packe
            !copy_from_user(&infos32, &arg->infos, sizeof infos32)) {
                infos = compat_ptr(infos32);
                if (!copy_to_user(&dst->infos, &infos, sizeof infos))
-                       err = do_raw1394_ioctl(file, cmd, (unsigned long)dst);
+                       err = raw1394_ioctl(file, cmd, (unsigned long)dst);
        }
        return err;
  }
@@@ -2724,7 -2749,6 +2749,6 @@@ static long raw1394_compat_ioctl(struc
        void __user *argp = (void __user *)arg;
        long err;
  
-       lock_kernel();
        switch (cmd) {
        /* These requests have same format as long as 'int' has same size. */
        case RAW1394_IOC_ISO_RECV_INIT:
        case RAW1394_IOC_ISO_GET_STATUS:
        case RAW1394_IOC_ISO_SHUTDOWN:
        case RAW1394_IOC_ISO_QUEUE_ACTIVITY:
-               err = do_raw1394_ioctl(file, cmd, arg);
+               err = raw1394_ioctl(file, cmd, arg);
                break;
        /* These request have different format. */
        case RAW1394_IOC_ISO_RECV_PACKETS32:
                err = -EINVAL;
                break;
        }
-       unlock_kernel();
  
        return err;
  }
@@@ -2791,6 -2814,7 +2814,7 @@@ static int raw1394_open(struct inode *i
        fi->notification = (u8) RAW1394_NOTIFY_ON;      /* busreset notification */
  
        INIT_LIST_HEAD(&fi->list);
+       mutex_init(&fi->state_mutex);
        fi->state = opened;
        INIT_LIST_HEAD(&fi->req_pending);
        INIT_LIST_HEAD(&fi->req_complete);
@@@ -3010,10 -3034,10 +3034,10 @@@ static int __init init_raw1394(void
        hpsb_register_highlevel(&raw1394_highlevel);
  
        if (IS_ERR
 -          (device_create_drvdata(
 -            hpsb_protocol_class, NULL,
 -            MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
 -            NULL, RAW1394_DEVICE_NAME))) {
 +          (device_create(hpsb_protocol_class, NULL,
 +                         MKDEV(IEEE1394_MAJOR,
 +                               IEEE1394_MINOR_BLOCK_RAW1394 * 16),
 +                         NULL, RAW1394_DEVICE_NAME))) {
                ret = -EFAULT;
                goto out_unreg;
        }
index 6e73b06eed4f3afdb7e39342c64b8d82c2cc5a2c,fa9e7d8b51fe9d3c5b1175aa17fa7a504b750dd2..679a918a5cc76eae41500b458eef93cc2c06992a
@@@ -893,7 -893,7 +893,7 @@@ static long video1394_ioctl(struct fil
                if (unlikely(d == NULL))
                        return -EFAULT;
  
-               if (unlikely((v.buffer<0) || (v.buffer>=d->num_desc - 1))) {
+               if (unlikely(v.buffer >= d->num_desc - 1)) {
                        PRINT(KERN_ERR, ohci->host->id,
                              "Buffer %d out of range",v.buffer);
                        return -EINVAL;
                if (unlikely(d == NULL))
                        return -EFAULT;
  
-               if (unlikely((v.buffer<0) || (v.buffer>d->num_desc - 1))) {
+               if (unlikely(v.buffer > d->num_desc - 1)) {
                        PRINT(KERN_ERR, ohci->host->id,
                              "Buffer %d out of range",v.buffer);
                        return -EINVAL;
                d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel);
                if (d == NULL) return -EFAULT;
  
-               if ((v.buffer<0) || (v.buffer>=d->num_desc - 1)) {
+               if (v.buffer >= d->num_desc - 1) {
                        PRINT(KERN_ERR, ohci->host->id,
                              "Buffer %d out of range",v.buffer);
                        return -EINVAL;
                d = find_ctx(&ctx->context_list, OHCI_ISO_TRANSMIT, v.channel);
                if (d == NULL) return -EFAULT;
  
-               if ((v.buffer<0) || (v.buffer>=d->num_desc-1)) {
+               if (v.buffer >= d->num_desc - 1) {
                        PRINT(KERN_ERR, ohci->host->id,
                              "Buffer %d out of range",v.buffer);
                        return -EINVAL;
@@@ -1341,8 -1341,9 +1341,8 @@@ static void video1394_add_host (struct 
        hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id);
  
        minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id;
 -      device_create_drvdata(hpsb_protocol_class, NULL,
 -                            MKDEV(IEEE1394_MAJOR, minor), NULL,
 -                            "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
 +      device_create(hpsb_protocol_class, NULL, MKDEV(IEEE1394_MAJOR, minor),
 +                    NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
  }