Skip to contentSkip to conversation

cleanup of linux-2.5/drivers/block/swim3.c

PATCH Jasper Spaans 4 participants 4 messages Jul 4, 2003 – Jul 12, 2003 Block layer

lore
Share & tools
lore
#0 lore raw

Hello,

Attached is a patch which should solve compilation issues related to the new irqhandler interface, and the deprecation of cli()/sti() for the swim3-driver.

Can you take a look, and possibly, apply this? (I don't have any hardware to test this on, however it compiles)

VrGr,
--
Jasper Spaans [not on the linuxppc-dev list, so please Cc me]

<== ``Got no clue? Too bad for you'' ==>
<== ==>

drivers/block/swim3.c-new renamed from drivers/block/swim3.c +22 -21
@@ -26,6 +26,9 @@
 #include <linux/ioctl.h>
 #include <linux/blk.h>
 #include <linux/devfs_fs_kernel.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+
 #include <asm/io.h>
 #include <asm/dbdma.h>
 #include <asm/prom.h>
@@ -234,7 +237,7 @@
 static void scan_timeout(unsigned long data);
 static void seek_timeout(unsigned long data);
 static void xfer_timeout(unsigned long data);
-static void swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 /*static void fd_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs);*/
 static int grab_drive(struct floppy_state *fs, enum swim_state state,
 		      int interruptible);
@@ -300,7 +303,6 @@
 			continue;
 		start_request(&floppy_states[i]);
 	}
-	sti();
 }
 
 static void start_request(struct floppy_state *fs)
@@ -359,9 +361,7 @@
 static void set_timeout(struct floppy_state *fs, int nticks,
 			void (*proc)(unsigned long))
 {
-	unsigned long flags;
-
-	save_flags(flags); cli();
+	spin_lock_irq(&swim3_lock);
 	if (fs->timeout_pending)
 		del_timer(&fs->timeout);
 	fs->timeout.expires = jiffies + nticks;
@@ -369,7 +369,7 @@
 	fs->timeout.data = (unsigned long) fs;
 	add_timer(&fs->timeout);
 	fs->timeout_pending = 1;
-	restore_flags(flags);
+	spin_unlock_irq(&swim3_lock);
 }
 
 static inline void scan_track(struct floppy_state *fs)
@@ -605,7 +605,7 @@
 	start_request(fs);
 }
 
-static void swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct floppy_state *fs = (struct floppy_state *) dev_id;
 	volatile struct swim3 *sw = fs->swim3;
@@ -613,6 +613,9 @@
 	int stat, resid;
 	struct dbdma_regs *dr;
 	struct dbdma_cmd *cp;
+	unsigned long flags;
+
+	spin_lock_irqsave(&swim3_lock, flags);
 
 	err = in_8(&sw->error);
 	intr = in_8(&sw->intr);
@@ -742,7 +745,13 @@
 		break;
 	default:
 		printk(KERN_ERR "swim3: don't know what to do in state %d\n", fs->state);
+#if 0
+		spin_unlock_irqrestore(&swim3_lock, flags);
+		return IRQ_NONE;
+#endif
 	}
+	spin_unlock_irqrestore(&swim3_lock, flags);
+	return IRQ_HANDLED;
 }
 
 /*
@@ -754,16 +763,14 @@
 static int grab_drive(struct floppy_state *fs, enum swim_state state,
 		      int interruptible)
 {
-	unsigned long flags;
-
-	save_flags(flags);
-	cli();
+	spin_lock_irq(&swim3_lock);
+
 	if (fs->state != idle) {
 		++fs->wanted;
 		while (fs->state != available) {
 			if (interruptible && signal_pending(current)) {
 				--fs->wanted;
-				restore_flags(flags);
+				spin_unlock_irq(&swim3_lock);
 				return -EINTR;
 			}
 			interruptible_sleep_on(&fs->wait);
@@ -771,19 +778,17 @@
 		--fs->wanted;
 	}
 	fs->state = state;
-	restore_flags(flags);
+	spin_unlock_irq(&swim3_lock);
 	return 0;
 }
 
 static void release_drive(struct floppy_state *fs)
 {
-	unsigned long flags;
+	spin_lock_irq(&swim3_lock);
 
-	save_flags(flags);
-	cli();
 	fs->state = idle;
 	start_request(fs);
-	restore_flags(flags);
+	spin_unlock_irq(&swim3_lock);
 }
 
 static int fd_eject(struct floppy_state *fs)
@@ -959,10 +964,6 @@
 	return ret;
 }
 
-static void floppy_off(unsigned int nr)
-{
-}
-
 static struct block_device_operations floppy_fops = {
 	.open		= floppy_open,
 	.release	= floppy_release,
#1 lore raw
Quoted 3 lines · Jasper Spaans

Attached is a patch which should solve compilation issues related to the new irqhandler interface, and the deprecation of cli()/sti() for the swim3-driver.

Have you audited the driver with respect to changes in the block device layer? I haven't, but I think it needs to be done. It's possible that the necessary changes have already been done but I'm not sure. And I don't want to send Linus a patch that would change it from broken and non-compiling to broken but compiling.

Paul.

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#2 lore raw
In reply to Jasper Spaans
Quoted 8 lines · Jasper Spaans

Hello,

Attached is a patch which should solve compilation issues related to the new irqhandler interface, and the deprecation of cli()/sti() for the swim3-driver.

Can you take a look, and possibly, apply this? (I don't have any hardware to test this on, however it compiles)

I'll take a look, but swim3 need more drastic updates for the new BIO stuff, the new macio device interface, etc... It's on my list once I'm done with a few other things.

Ben.

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#3 lore raw
In reply to Jasper Spaans
Quoted 8 lines · Jasper Spaans

Hello,

Attached is a patch which should solve compilation issues related to the new irqhandler interface, and the deprecation of cli()/sti() for the swim3-driver.

Can you take a look, and possibly, apply this? (I don't have any hardware to test this on, however it compiles)

You did not take into account the changes made to swim3 driver in 2.4 kernel (fixing write operation) made by Paul.

I will try to merge the two and update BIO stuff. I'm not so sure about the new macio device interface..should be fun :)

--

Boris

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/