Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/ieee1394/dv1394.c    |   11 +---
 25-akpm/drivers/ieee1394/eth1394.c   |    2 
 25-akpm/drivers/ieee1394/nodemgr.c   |    2 
 25-akpm/drivers/ieee1394/ohci1394.c  |   84 +++++++++++++++++++++--------------
 25-akpm/drivers/ieee1394/pcilynx.c   |    4 -
 25-akpm/drivers/ieee1394/raw1394.c   |    5 +-
 25-akpm/drivers/ieee1394/sbp2.c      |   10 ++--
 25-akpm/drivers/ieee1394/video1394.c |   51 ++++++++-------------
 8 files changed, 91 insertions(+), 78 deletions(-)

diff -puN drivers/ieee1394/dv1394.c~bk-ieee1394 drivers/ieee1394/dv1394.c
--- 25/drivers/ieee1394/dv1394.c~bk-ieee1394	2005-03-23 21:04:32.000000000 -0800
+++ 25-akpm/drivers/ieee1394/dv1394.c	2005-03-23 21:04:32.000000000 -0800
@@ -2531,7 +2531,7 @@ static int handle_dv1394_init(struct fil
 	mm_segment_t old_fs;
 	int ret;
 
-	if (file->f_op->ioctl != dv1394_ioctl)
+	if (file->f_op->unlocked_ioctl != dv1394_ioctl)
 		return -EFAULT;
 
 	if (copy_from_user(&dv32, (void __user *)arg, sizeof(dv32)))
@@ -2547,8 +2547,7 @@ static int handle_dv1394_init(struct fil
 
 	old_fs = get_fs();
 	set_fs(KERNEL_DS);
-	ret = dv1394_ioctl(file,
-			   DV1394_IOC_INIT, (unsigned long)&dv);
+	ret = dv1394_ioctl(file, DV1394_IOC_INIT, (unsigned long)&dv);
 	set_fs(old_fs);
 
 	return ret;
@@ -2561,13 +2560,12 @@ static int handle_dv1394_get_status(stru
 	mm_segment_t old_fs;
 	int ret;
 
-	if (file->f_op->ioctl != dv1394_ioctl)
+	if (file->f_op->unlocked_ioctl != dv1394_ioctl)
 		return -EFAULT;
 
 	old_fs = get_fs();
 	set_fs(KERNEL_DS);
-	ret = dv1394_ioctl(file,
-			   DV1394_IOC_GET_STATUS, (unsigned long)&dv);
+	ret = dv1394_ioctl(file, DV1394_IOC_GET_STATUS, (unsigned long)&dv);
 	set_fs(old_fs);
 
 	if (!ret) {
@@ -2595,7 +2593,6 @@ static int handle_dv1394_get_status(stru
 static long dv1394_compat_ioctl(struct file *file, unsigned int cmd,
 			       unsigned long arg)
 {
-	int err;
 	switch (cmd) {
 	case DV1394_IOC_SHUTDOWN:
 	case DV1394_IOC_SUBMIT_FRAMES:
diff -puN drivers/ieee1394/eth1394.c~bk-ieee1394 drivers/ieee1394/eth1394.c
--- 25/drivers/ieee1394/eth1394.c~bk-ieee1394	2005-03-23 21:04:32.000000000 -0800
+++ 25-akpm/drivers/ieee1394/eth1394.c	2005-03-23 21:04:32.000000000 -0800
@@ -625,7 +625,7 @@ static void ether1394_add_host (struct h
 		goto out;
 	}
 
-	ETH1394_PRINT (KERN_ERR, dev->name, "IEEE-1394 IPv4 over 1394 Ethernet (fw-host%d)\n",
+	ETH1394_PRINT (KERN_INFO, dev->name, "IEEE-1394 IPv4 over 1394 Ethernet (fw-host%d)\n",
 		       host->id);
 
 	hi->host = host;
diff -puN drivers/ieee1394/nodemgr.c~bk-ieee1394 drivers/ieee1394/nodemgr.c
--- 25/drivers/ieee1394/nodemgr.c~bk-ieee1394	2005-03-23 21:04:32.000000000 -0800
+++ 25-akpm/drivers/ieee1394/nodemgr.c	2005-03-23 21:04:32.000000000 -0800
@@ -1284,7 +1284,7 @@ static void nodemgr_suspend_ne(struct no
 
 		if (ud->device.driver &&
 		    (!ud->device.driver->suspend ||
-		      ud->device.driver->suspend(&ud->device, 0, 0)))
+		      ud->device.driver->suspend(&ud->device, PMSG_SUSPEND, 0)))
 			device_release_driver(&ud->device);
 	}
 	up_write(&ne->device.bus->subsys.rwsem);
diff -puN drivers/ieee1394/ohci1394.c~bk-ieee1394 drivers/ieee1394/ohci1394.c
--- 25/drivers/ieee1394/ohci1394.c~bk-ieee1394	2005-03-23 21:04:32.000000000 -0800
+++ 25-akpm/drivers/ieee1394/ohci1394.c	2005-03-23 21:04:32.000000000 -0800
@@ -538,6 +538,11 @@ static void ohci_initialize(struct ti_oh
 	/* Initialize AT dma */
 	initialize_dma_trm_ctx(&ohci->at_req_context);
 	initialize_dma_trm_ctx(&ohci->at_resp_context);
+	
+	/* Initialize IR Legacy DMA */
+	ohci->ir_legacy_channels = 0;
+	initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1);
+	DBGMSG("ISO receive legacy context activated");
 
 	/*
 	 * Accept AT requests from all nodes. This probably
@@ -1035,22 +1040,6 @@ static int ohci_devctl(struct hpsb_host 
 			return -EFAULT;
 		}
 
-		/* activate the legacy IR context */
-		if (ohci->ir_legacy_context.ohci == NULL) {
-			if (alloc_dma_rcv_ctx(ohci, &ohci->ir_legacy_context,
-					      DMA_CTX_ISO, 0, IR_NUM_DESC,
-					      IR_BUF_SIZE, IR_SPLIT_BUF_SIZE,
-					      OHCI1394_IsoRcvContextBase) < 0) {
-				PRINT(KERN_ERR, "%s: failed to allocate an IR context",
-				      __FUNCTION__);
-				return -ENOMEM;
-			}
-			ohci->ir_legacy_channels = 0;
-			initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1);
-
-			DBGMSG("ISO receive legacy context activated");
-		}
-
 		mask = (u64)0x1<<arg;
 
                 spin_lock_irqsave(&ohci->IR_channel_lock, flags);
@@ -1112,12 +1101,6 @@ static int ohci_devctl(struct hpsb_host 
 
                 spin_unlock_irqrestore(&ohci->IR_channel_lock, flags);
                 DBGMSG("Listening disabled on channel %d", arg);
-
-		if (ohci->ir_legacy_channels == 0) {
-			stop_dma_rcv_ctx(&ohci->ir_legacy_context);
-			free_dma_rcv_ctx(&ohci->ir_legacy_context);
-			DBGMSG("ISO receive legacy context deactivated");
-		}
                 break;
         }
 	default:
@@ -2921,7 +2904,9 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, 
 		  enum context_type type, int ctx, int num_desc,
 		  int buf_size, int split_buf_size, int context_base)
 {
-	int i;
+	int i, len;
+	static int num_allocs;
+	static char pool_name[20];
 
 	d->ohci = ohci;
 	d->type = type;
@@ -2965,9 +2950,19 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, 
 		free_dma_rcv_ctx(d);
 		return -ENOMEM;
 	}
-
-	d->prg_pool = pci_pool_create("ohci1394 rcv prg", ohci->dev,
+	
+	len = sprintf(pool_name, "ohci1394_rcv_prg");
+	sprintf(pool_name+len, "%d", num_allocs);
+	d->prg_pool = pci_pool_create(pool_name, ohci->dev,
 				sizeof(struct dma_cmd), 4, 0);
+	if(d->prg_pool == NULL)
+	{
+		PRINT(KERN_ERR, "pci_pool_create failed for %s", pool_name);
+		free_dma_rcv_ctx(d);
+		return -ENOMEM;
+	}
+	num_allocs++;
+
 	OHCI_DMA_ALLOC("dma_rcv prg pool");
 
 	for (i=0; i<d->num_desc; i++) {
@@ -3060,7 +3055,9 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, 
 		  enum context_type type, int ctx, int num_desc,
 		  int context_base)
 {
-	int i;
+	int i, len;
+	static char pool_name[20];
+	static int num_allocs=0;
 
 	d->ohci = ohci;
 	d->type = type;
@@ -3082,8 +3079,17 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, 
 	memset(d->prg_cpu, 0, d->num_desc * sizeof(struct at_dma_prg*));
 	memset(d->prg_bus, 0, d->num_desc * sizeof(dma_addr_t));
 
-	d->prg_pool = pci_pool_create("ohci1394 trm prg", ohci->dev,
+	len = sprintf(pool_name, "ohci1394_trm_prg");
+	sprintf(pool_name+len, "%d", num_allocs);
+	d->prg_pool = pci_pool_create(pool_name, ohci->dev,
 				sizeof(struct at_dma_prg), 4, 0);
+	if (d->prg_pool == NULL) {
+		PRINT(KERN_ERR, "pci_pool_create failed for %s", pool_name);
+		free_dma_trm_ctx(d);
+		return -ENOMEM;
+	}
+	num_allocs++;
+
 	OHCI_DMA_ALLOC("dma_rcv prg pool");
 
 	for (i = 0; i < d->num_desc; i++) {
@@ -3355,10 +3361,19 @@ static int __devinit ohci1394_pci_probe(
 	ohci->ISO_channel_usage = 0;
         spin_lock_init(&ohci->IR_channel_lock);
 
-	/* the IR DMA context is allocated on-demand; mark it inactive */
-	ohci->ir_legacy_context.ohci = NULL;
+	/* Allocate the IR DMA context right here so we don't have
+	 * to do it in interrupt path - note that this doesn't
+	 * waste much memory and avoids the jugglery required to
+	 * allocate it in IRQ path. */
+	if (alloc_dma_rcv_ctx(ohci, &ohci->ir_legacy_context,
+			      DMA_CTX_ISO, 0, IR_NUM_DESC,
+			      IR_BUF_SIZE, IR_SPLIT_BUF_SIZE,
+			      OHCI1394_IsoRcvContextBase) < 0) {
+		FAIL(-ENOMEM, "Cannot allocate IR Legacy DMA context");
+	}
 
-	/* same for the IT DMA context */
+	/* We hopefully don't have to pre-allocate IT DMA like we did
+	 * for IR DMA above. Allocate it on-demand and mark inactive. */
 	ohci->it_legacy_context.ohci = NULL;
 
 	if (request_irq(dev->irq, ohci_irq_handler, SA_SHIRQ,
@@ -3398,6 +3413,7 @@ static void ohci1394_pci_remove(struct p
 
 	switch (ohci->init_state) {
 	case OHCI_INIT_DONE:
+		stop_dma_rcv_ctx(&ohci->ir_legacy_context);
 		hpsb_remove_host(ohci->host);
 
 		/* Clear out BUS Options */
@@ -3447,6 +3463,10 @@ static void ohci1394_pci_remove(struct p
 		/* Free IT dma */
 		free_dma_trm_ctx(&ohci->it_legacy_context);
 
+		/* Free IR legacy dma */
+		free_dma_rcv_ctx(&ohci->ir_legacy_context);
+
+
 	case OHCI_INIT_HAVE_SELFID_BUFFER:
 		pci_free_consistent(ohci->dev, OHCI1394_SI_DMA_BUF_SIZE,
 				    ohci->selfid_buf_cpu,
@@ -3512,7 +3532,7 @@ static int ohci1394_pci_resume (struct p
 }
 
 
-static int ohci1394_pci_suspend (struct pci_dev *pdev, u32 state)
+static int ohci1394_pci_suspend (struct pci_dev *pdev, pm_message_t state)
 {
 #ifdef CONFIG_PMAC_PBOOK
 	{
@@ -3678,7 +3698,7 @@ static void __exit ohci1394_cleanup (voi
 
 static int __init ohci1394_init(void)
 {
-	return pci_module_init(&ohci1394_pci_driver);
+	return pci_register_driver(&ohci1394_pci_driver);
 }
 
 module_init(ohci1394_init);
diff -puN drivers/ieee1394/pcilynx.c~bk-ieee1394 drivers/ieee1394/pcilynx.c
--- 25/drivers/ieee1394/pcilynx.c~bk-ieee1394	2005-03-23 21:04:32.000000000 -0800
+++ 25-akpm/drivers/ieee1394/pcilynx.c	2005-03-23 21:04:32.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * ti_pcilynx.c - Texas Instruments PCILynx driver
+ * pcilynx.c - Texas Instruments PCILynx driver
  * Copyright (C) 1999,2000 Andreas Bombe <andreas.bombe@munich.netsurf.de>,
  *                         Stephan Linz <linz@mazet.de>
  *                         Manfred Weihs <weihs@ict.tuwien.ac.at>
@@ -1952,7 +1952,7 @@ static int __init pcilynx_init(void)
         }
 #endif
 
-        ret = pci_module_init(&lynx_pci_driver);
+        ret = pci_register_driver(&lynx_pci_driver);
         if (ret < 0) {
                 PRINT_G(KERN_ERR, "PCI module init failed");
                 goto free_char_dev;
diff -puN drivers/ieee1394/raw1394.c~bk-ieee1394 drivers/ieee1394/raw1394.c
--- 25/drivers/ieee1394/raw1394.c~bk-ieee1394	2005-03-23 21:04:32.000000000 -0800
+++ 25-akpm/drivers/ieee1394/raw1394.c	2005-03-23 21:04:45.000000000 -0800
@@ -2737,7 +2737,8 @@ static int raw1394_release(struct inode 
 						    list) {
 					entry = fi_hlp->addr_list.next;
 					while (entry != &(fi_hlp->addr_list)) {
-						arm_addr = list_entry(entry, struct
+						arm_addr = list_entry(entry,
+								      struct
 								      arm_addr,
 								      addr_list);
 						if (arm_addr->start ==
@@ -2945,10 +2946,10 @@ static void __exit cleanup_raw1394(void)
 {
 	class_device_destroy(hpsb_protocol_class,
 		MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16));
-	hpsb_unregister_protocol(&raw1394_driver);
 	cdev_del(&raw1394_cdev);
 	devfs_remove(RAW1394_DEVICE_NAME);
 	hpsb_unregister_highlevel(&raw1394_highlevel);
+	hpsb_unregister_protocol(&raw1394_driver);
 }
 
 module_init(init_raw1394);
diff -puN drivers/ieee1394/sbp2.c~bk-ieee1394 drivers/ieee1394/sbp2.c
--- 25/drivers/ieee1394/sbp2.c~bk-ieee1394	2005-03-23 21:04:32.000000000 -0800
+++ 25-akpm/drivers/ieee1394/sbp2.c	2005-03-23 21:04:32.000000000 -0800
@@ -905,9 +905,13 @@ alloc_fail:
 	 * connected to the sbp2 device being removed. That host would
 	 * have a certain amount of time to relogin before the sbp2 device
 	 * allows someone else to login instead. One second makes sense. */
-	set_current_state(TASK_INTERRUPTIBLE);
-	schedule_timeout(HZ);
-
+	msleep_interruptible(1000);
+	if (signal_pending(current)) {
+		SBP2_WARN("aborting sbp2_start_device due to event");
+		sbp2_remove_device(scsi_id);
+		return -EINTR;
+	}
+	
 	/*
 	 * Login to the sbp-2 device
 	 */
diff -puN drivers/ieee1394/video1394.c~bk-ieee1394 drivers/ieee1394/video1394.c
--- 25/drivers/ieee1394/video1394.c~bk-ieee1394	2005-03-23 21:04:32.000000000 -0800
+++ 25-akpm/drivers/ieee1394/video1394.c	2005-03-23 21:04:32.000000000 -0800
@@ -710,6 +710,17 @@ static void initialize_dma_it_ctx(struct
 	reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, 1<<d->ctx);
 }
 
+static inline unsigned video1394_buffer_state(struct dma_iso_ctx *d,
+					      unsigned int buffer)
+{
+	unsigned long flags;
+	unsigned int ret;
+	spin_lock_irqsave(&d->lock, flags);
+	ret = d->buffer_status[buffer];
+	spin_unlock_irqrestore(&d->lock, flags);
+	return ret;
+}
+
 static int __video1394_ioctl(struct file *file,
 			     unsigned int cmd, unsigned long arg)
 {
@@ -970,24 +981,13 @@ static int __video1394_ioctl(struct file
 			    return -EINTR;
 			}
 
-#if 1
-			while (d->buffer_status[v.buffer]!=
-			      VIDEO1394_BUFFER_READY) {
-				spin_unlock_irqrestore(&d->lock, flags);
-				interruptible_sleep_on(&d->waitq);
-				spin_lock_irqsave(&d->lock, flags);
-				if (signal_pending(current)) {
-					spin_unlock_irqrestore(&d->lock,flags);
-					return -EINTR;
-				}
-			}
-#else
-			if (wait_event_interruptible(d->waitq,
-						     d->buffer_status[v.buffer]
-						     == VIDEO1394_BUFFER_READY)
-			    == -ERESTARTSYS)
-				return -EINTR;
-#endif
+			spin_unlock_irqrestore(&d->lock, flags);
+			wait_event_interruptible(d->waitq,
+					video1394_buffer_state(d, v.buffer) ==
+					 VIDEO1394_BUFFER_READY);
+			if (signal_pending(current))
+                                return -EINTR;
+			spin_lock_irqsave(&d->lock, flags);
 			d->buffer_status[v.buffer]=VIDEO1394_BUFFER_FREE;
 			break;
 		default:
@@ -1144,19 +1144,10 @@ static int __video1394_ioctl(struct file
 			d->buffer_status[v.buffer]=VIDEO1394_BUFFER_FREE;
 			return 0;
 		case VIDEO1394_BUFFER_QUEUED:
-#if 1
-			while (d->buffer_status[v.buffer]!=
-			      VIDEO1394_BUFFER_READY) {
-				interruptible_sleep_on(&d->waitq);
-				if (signal_pending(current)) return -EINTR;
-			}
-#else
-			if (wait_event_interruptible(d->waitq,
-						     d->buffer_status[v.buffer]
-						     == VIDEO1394_BUFFER_READY)
-			    == -ERESTARTSYS)
+			wait_event_interruptible(d->waitq,
+					(d->buffer_status[v.buffer] == VIDEO1394_BUFFER_READY));
+			if (signal_pending(current))
 				return -EINTR;
-#endif
 			d->buffer_status[v.buffer]=VIDEO1394_BUFFER_FREE;
 			return 0;
 		default:
_