Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Diff of /arch/powerpc/platforms/embedded6xx/starlet-stm.c [3f1531] .. [aa2218] Maximize Restore

  Switch to side-by-side view

--- a/arch/powerpc/platforms/embedded6xx/starlet-stm.c
+++ b/arch/powerpc/platforms/embedded6xx/starlet-stm.c
@@ -27,6 +27,8 @@
 #define STARLET_STM_HOTRESET	0x2001
 #define STARLET_STM_SHUTDOWN	0x2003
 
+#define STARLET_STM_TIMEOUT	1000000	/* usecs */
+
 #define STARLET_DEV_STM_IMMEDIATE	"/dev/stm/immediate"
 
 #define drv_printk(level, format, arg...) \
@@ -44,17 +46,22 @@
  */
 static void starlet_stm_common_restart(int request, u32 value)
 {
+	static int already_in_restart;
 	u32 *buf = starlet_stm_buf;
 	size_t len = sizeof(starlet_stm_buf);
 	int fd;
 	int error;
 
-	/* REVISIT, use polled ipc calls here */
-
+	if (already_in_restart) {
+		drv_printk(KERN_ERR, "previous restart attempt failed,"
+			   " halting\n");
+		goto halt;
+	}
 
 	drv_printk(KERN_INFO, "trying IPC restart...\n");
+	already_in_restart = 1;
 
-	fd = starlet_open(dev_stm_immediate, 0);
+	fd = starlet_open_polled(dev_stm_immediate, 0, STARLET_STM_TIMEOUT);
 	if (fd < 0) {
 		drv_printk(KERN_ERR, "failed to open %s\n", dev_stm_immediate);
 		error = fd;
@@ -62,10 +69,16 @@
 	}
 
 	*buf = value;
-	error = starlet_ioctl(fd, request, buf, len, buf, len);
-	if (error < 0)
+	error = starlet_ioctl_polled(fd, request, buf, len, buf, len,
+				     STARLET_STM_TIMEOUT);
+	if (error < 0) {
 		drv_printk(KERN_ERR, "ioctl %d failed\n", request);
-	starlet_close(fd);
+		starlet_close_polled(fd, STARLET_STM_TIMEOUT);
+	} else {
+halt:
+		for(;;)
+			cpu_relax();
+	}
 
 done:
 	if (error < 0)