From: "Paulo Andre'" <fscked@netvisao.pt>
To: linux-kernel@vger.kernel.org
Cc: jgarzik@redhat.com, alan@redhat.com, Philip.Blundell@pobox.com
Subject: [PATCH] Make 3c505.c use spinlocks instead of cli/sti
Date: Thu, 31 Oct 2002 02:15:58 +0000 [thread overview]
Message-ID: <20021031021558.38763ed7.fscked@netvisao.pt> (raw)
Hi,
This patch does some cleanup on the 3c505.c driver by making use of
spinlocks instead of the deprecated cli()/sti() scheme. Note that even
though it compiles fine, I don't have the specific hardware to test
this.
Patch is against 2.5.45.
-- Paulo Andre'
PS - This is my first patch ever. I'm scared. I'm shaking. Take that
into account, please.
--- drivers/net/3c505.c.orig 2002-10-31 00:33:46.000000000 +0000
+++ drivers/net/3c505.c 2002-10-31 00:55:35.000000000 +0000
@@ -274,9 +274,12 @@
static inline void set_hsf(struct net_device *dev, int hsf)
{
- cli();
+ elp_device *adapter = dev->priv;
+ unsigned long flags;
+
+ spin_lock_irqsave(&adapter->lock, flags);
outb_control((HCR_VAL(dev) & ~HSF_PCB_MASK) | hsf, dev);
- sti();
+ spin_unlock_irqrestore(&adapter->lock, flags);
}
static int start_receive(struct net_device *, pcb_struct *);
@@ -325,8 +328,7 @@
if (adapter->dmaing && time_after(jiffies, adapter->current_dma.start_time + 10)) {
unsigned long flags, f;
printk("%s: DMA %s timed out, %d bytes left\n", dev->name, adapter->current_dma.direction ? "download" : "upload", get_dma_residue(dev->dma));
- save_flags(flags);
- cli();
+ spin_lock_irqsave(&adapter->lock, flags);
adapter->dmaing = 0;
adapter->busy = 0;
@@ -337,7 +339,7 @@
if (adapter->rx_active)
adapter->rx_active--;
outb_control(adapter->hcr_val & ~(DMAE | TCEN | DIR), dev);
- restore_flags(flags);
+ spin_unlock_irqrestore(&adapter->lock, flags);
}
}
@@ -405,6 +407,7 @@
int i;
int timeout;
elp_device *adapter = dev->priv;
+ unsigned long flags;
check_3c505_dma(dev);
@@ -428,7 +431,7 @@
if (send_pcb_slow(dev->base_addr, pcb->command))
goto abort;
- cli();
+ spin_lock_irqsave(&adapter->lock, flags);
if (send_pcb_fast(dev->base_addr, pcb->length))
goto sti_abort;
@@ -442,7 +445,7 @@
outb_command(2 + pcb->length, dev->base_addr);
/* now wait for the acknowledgement */
- sti();
+ spin_unlock_irqrestore(&adapter->lock, flags);
for (timeout = jiffies + 5*HZ/100; time_before(jiffies, timeout);) {
switch (GET_ASF(dev->base_addr)) {
@@ -463,7 +466,7 @@
printk("%s: timeout waiting for PCB acknowledge (status %02x)\n", dev->name, inb_status(dev->base_addr));
sti_abort:
- sti();
+ spin_unlock_irqrestore(&adapter->lock, flags);
abort:
adapter->send_pcb_semaphore = 0;
return FALSE;
@@ -489,6 +492,7 @@
int total_length;
int stat;
int timeout;
+ unsigned long flags;
elp_device *adapter = dev->priv;
@@ -519,7 +523,7 @@
return FALSE;
}
/* read the data */
- cli();
+ spin_lock_irqsave(&adapter->lock, flags);
i = 0;
do {
j = 0;
@@ -528,7 +532,7 @@
if (i > MAX_PCB_DATA)
INVALID_PCB_MSG(i);
} while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000);
- sti();
+ spin_unlock_irqrestore(&adapter->lock, flags);
if (j >= 20000) {
TIMEOUT_MSG(__LINE__);
return FALSE;
next reply other threads:[~2002-11-01 2:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-31 2:15 Paulo Andre' [this message]
2002-11-01 8:31 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021031021558.38763ed7.fscked@netvisao.pt \
--to=fscked@netvisao.pt \
--cc=Philip.Blundell@pobox.com \
--cc=alan@redhat.com \
--cc=jgarzik@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®