From: Brandon Niemczyk <brandon@snprogramming.com>
To: kernel-janitors@vger.kernel.org
Subject: [KJ] [PATCH] cli() cleanup in xircom_tulip_cp.c and fec.c
Date: Mon, 11 Jul 2005 22:32:12 +0000 [thread overview]
Message-ID: <1121121132.3554.50.camel@localhost> (raw)
[-- Attachment #1: Type: text/plain, Size: 5627 bytes --]
replaces calls to save_flags(); cli() with spinlocks, also fixes some unreadable spacing
in outl_CSR6()
Signed-off-by: Brandon Niemczyk <brandon@snprogramming.com>
diff -pruNX anti-cli/Documentation/dontdiff linux-pristine/drivers/net/fec.c anti-cli/drivers/net/fec.c
--- linux-pristine/drivers/net/fec.c 2005-06-17 15:48:29.000000000 -0400
+++ anti-cli/drivers/net/fec.c 2005-07-11 01:35:34.000000000 -0400
@@ -707,6 +707,7 @@ mii_queue(struct net_device *dev, int re
unsigned long flags;
mii_list_t *mip;
int retval;
+ static spinlock_t lock = SPIN_LOCK_UNLOCKED;
/* Add PHY address to register command.
*/
@@ -715,8 +716,7 @@ mii_queue(struct net_device *dev, int re
retval = 0;
- save_flags(flags);
- cli();
+ spin_lock_irqsave(&lock, flags);
if ((mip = mii_free) != NULL) {
mii_free = mip->mii_next;
@@ -736,7 +736,7 @@ mii_queue(struct net_device *dev, int re
retval = 1;
}
- restore_flags(flags);
+ spin_unlock_irqrestore(&lock, flags);
return(retval);
}
diff -pruNX anti-cli/Documentation/dontdiff linux-pristine/drivers/net/tulip/xircom_tulip_cb.c anti-cli/drivers/net/tulip/xircom_tulip_cb.c
--- linux-pristine/drivers/net/tulip/xircom_tulip_cb.c 2005-07-10 23:42:14.000000000 -0400
+++ anti-cli/drivers/net/tulip/xircom_tulip_cb.c 2005-07-11 18:22:58.000000000 -0400
@@ -358,46 +358,49 @@ static struct ethtool_ops ops;
static void outl_CSR6(u32 newcsr6, long ioaddr)
{
const int strict_bits =
- TxThresh10 | TxStoreForw | TxThreshMask | EnableTxRx | FullDuplexBit;
- int csr5, csr5_22_20, csr5_19_17, currcsr6, attempts = 200;
- unsigned long flags;
- save_flags(flags);
- cli();
+ TxThresh10 | TxStoreForw | TxThreshMask | EnableTxRx |
+ FullDuplexBit;
+ int csr5, csr5_22_20, csr5_19_17, currcsr6, attempts = 200;
+ unsigned long flags;
+ static spinlock_t lock = SPIN_LOCK_UNLOCKED;
+
+ spin_lock_irqsave(&lock, flags);
/* mask out the reserved bits that always read 0 on the Xircom cards */
newcsr6 &= ~ReservedZeroMask;
/* or in the reserved bits that always read 1 */
newcsr6 |= ReservedOneMask;
- currcsr6 = inl(ioaddr + CSR6);
- if (((newcsr6 & strict_bits) == (currcsr6 & strict_bits)) ||
- ((currcsr6 & ~EnableTxRx) == 0)) {
+ currcsr6 = inl(ioaddr + CSR6);
+ if (((newcsr6 & strict_bits) == (currcsr6 & strict_bits)) ||
+ ((currcsr6 & ~EnableTxRx) == 0)) {
outl(newcsr6, ioaddr + CSR6); /* safe */
- restore_flags(flags);
- return;
- }
- /* make sure the transmitter and receiver are stopped first */
- currcsr6 &= ~EnableTxRx;
- while (1) {
+ goto fini;
+ }
+ /* make sure the transmitter and receiver are stopped first */
+ currcsr6 &= ~EnableTxRx;
+ while (1) {
csr5 = inl(ioaddr + CSR5);
if (csr5 == 0xffffffff)
- break; /* cannot read csr5, card removed? */
+ break; /* cannot read csr5, card removed? */
csr5_22_20 = csr5 & 0x700000;
csr5_19_17 = csr5 & 0x0e0000;
if ((csr5_22_20 == 0 || csr5_22_20 == 0x600000) &&
- (csr5_19_17 == 0 || csr5_19_17 == 0x80000 || csr5_19_17 == 0xc0000))
- break; /* both are stopped or suspended */
+ (csr5_19_17 == 0 || csr5_19_17 == 0x80000
+ || csr5_19_17 == 0xc0000))
+ break; /* both are stopped or suspended */
if (!--attempts) {
- printk(KERN_INFO DRV_NAME ": outl_CSR6 too many attempts,"
- "csr5=0x%08x\n", csr5);
- outl(newcsr6, ioaddr + CSR6); /* unsafe but do it anyway */
- restore_flags(flags);
- return;
+ printk(KERN_INFO DRV_NAME
+ ": outl_CSR6 too many attempts," "csr5=0x%08x\n",
+ csr5);
+ outl(newcsr6, ioaddr + CSR6); /* unsafe but do it anyway */
+ goto fini;
}
outl(currcsr6, ioaddr + CSR6);
udelay(1);
- }
- /* now it is safe to change csr6 */
- outl(newcsr6, ioaddr + CSR6);
- restore_flags(flags);
+ }
+ /* now it is safe to change csr6 */
+ outl(newcsr6, ioaddr + CSR6);
+fini:
+ spin_unlock_irqrestore(&lock, flags);
}
@@ -1463,6 +1466,7 @@ static int xircom_ioctl(struct net_devic
u16 *data = (u16 *)&rq->ifr_ifru;
int phy = tp->phys[0] & 0x1f;
unsigned long flags;
+ static spinlock_t lock = SPIN_LOCK_UNLOCKED;
switch(cmd) {
/* Legacy mii-diag interface */
@@ -1473,16 +1477,14 @@ static int xircom_ioctl(struct net_devic
return -ENODEV;
return 0;
case SIOCGMIIREG: /* Read MII PHY register. */
- save_flags(flags);
- cli();
+ spin_lock_irqsave(&lock, flags);
data[3] = mdio_read(dev, data[0] & 0x1f, data[1] & 0x1f);
- restore_flags(flags);
+ spin_unlock_irqrestore(&lock, flags);
return 0;
case SIOCSMIIREG: /* Write MII PHY register. */
if (!capable(CAP_NET_ADMIN))
return -EPERM;
- save_flags(flags);
- cli();
+ spin_lock_irqsave(&lock, flags);
if (data[0] == tp->phys[0]) {
u16 value = data[2];
switch (data[1]) {
@@ -1502,7 +1504,7 @@ static int xircom_ioctl(struct net_devic
check_duplex(dev);
}
mdio_write(dev, data[0] & 0x1f, data[1] & 0x1f, data[2]);
- restore_flags(flags);
+ spin_unlock_irqrestore(&lock, flags);
return 0;
default:
return -EOPNOTSUPP;
@@ -1609,8 +1611,9 @@ static void set_rx_mode(struct net_devic
unsigned long flags;
unsigned int entry;
int dummy = -1;
+ static spinlock_t lock = SPIN_LOCK_UNLOCKED;
- save_flags(flags); cli();
+ spin_lock_irqsave(&lock, flags);
entry = tp->cur_tx++ % TX_RING_SIZE;
if (entry != 0) {
@@ -1637,7 +1640,7 @@ static void set_rx_mode(struct net_devic
}
if (dummy >= 0)
tp->tx_ring[dummy].status = Tx0DescOwned;
- restore_flags(flags);
+ spin_unlock_irqrestore(&lock, flags);
/* Trigger an immediate transmit demand. */
outl(0, ioaddr + CSR1);
}
[-- Attachment #2: Type: text/plain, Size: 168 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
next reply other threads:[~2005-07-11 22:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-11 22:32 Brandon Niemczyk [this message]
2005-07-12 1:37 ` [KJ] [PATCH] cli() cleanup in xircom_tulip_cp.c and fec.c Brandon Niemczyk
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=1121121132.3554.50.camel@localhost \
--to=brandon@snprogramming.com \
--cc=kernel-janitors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.