Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b68a890f authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller
Browse files

[SCSI] pluto: Use wait_for_completion_timeout.

parent c420bc9f
Loading
Loading
Loading
Loading
+4 −14
Original line number Original line Diff line number Diff line
@@ -4,6 +4,7 @@
 *
 *
 */
 */


#include <linux/completion.h>
#include <linux/kernel.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/delay.h>
#include <linux/types.h>
#include <linux/types.h>
@@ -50,16 +51,10 @@ static struct ctrl_inquiry {
} *fcs __initdata;
} *fcs __initdata;
static int fcscount __initdata = 0;
static int fcscount __initdata = 0;
static atomic_t fcss __initdata = ATOMIC_INIT(0);
static atomic_t fcss __initdata = ATOMIC_INIT(0);
DECLARE_MUTEX_LOCKED(fc_sem);
static DECLARE_COMPLETION(fc_detect_complete);


static int pluto_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd);
static int pluto_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd);


static void __init pluto_detect_timeout(unsigned long data)
{
	PLND(("Timeout\n"))
	up(&fc_sem);
}

static void __init pluto_detect_done(Scsi_Cmnd *SCpnt)
static void __init pluto_detect_done(Scsi_Cmnd *SCpnt)
{
{
	/* Do nothing */
	/* Do nothing */
@@ -69,7 +64,7 @@ static void __init pluto_detect_scsi_done(Scsi_Cmnd *SCpnt)
{
{
	PLND(("Detect done %08lx\n", (long)SCpnt))
	PLND(("Detect done %08lx\n", (long)SCpnt))
	if (atomic_dec_and_test (&fcss))
	if (atomic_dec_and_test (&fcss))
		up(&fc_sem);
		complete(&fc_detect_complete);
}
}


int pluto_slave_configure(struct scsi_device *device)
int pluto_slave_configure(struct scsi_device *device)
@@ -96,7 +91,6 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
	int i, retry, nplutos;
	int i, retry, nplutos;
	fc_channel *fc;
	fc_channel *fc;
	struct scsi_device dev;
	struct scsi_device dev;
	DEFINE_TIMER(fc_timer, pluto_detect_timeout, 0, 0);


	tpnt->proc_name = "pluto";
	tpnt->proc_name = "pluto";
	fcscount = 0;
	fcscount = 0;
@@ -187,15 +181,11 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
			}
			}
		}
		}
	    
	    
		fc_timer.expires = jiffies + 10 * HZ;
		wait_for_completion_timeout(&fc_detect_complete, 10 * HZ);
		add_timer(&fc_timer);
		
		down(&fc_sem);
		PLND(("Woken up\n"))
		PLND(("Woken up\n"))
		if (!atomic_read(&fcss))
		if (!atomic_read(&fcss))
			break; /* All fc channels have answered us */
			break; /* All fc channels have answered us */
	}
	}
	del_timer_sync(&fc_timer);


	PLND(("Finished search\n"))
	PLND(("Finished search\n"))
	for (i = 0, nplutos = 0; i < fcscount; i++) {
	for (i = 0, nplutos = 0; i < fcscount; i++) {