Commit f794d623 authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[PATCH] cli_sti in drivers_net_hamradio_bpqether.c

From:  Chris Wilson <chris@qwirx.com>

  As part of the Linux Kernel Janitors project, I would like to submit my
  patch for bpqether.c.

  The document Documentation/cli-sti-removal.txt says that cli() should no
  longer be used to disable interrupts. This patch removes all references to
  cli() and {save,restore}_flags.

  - added a static spinlock to protect bpq_devices
  - changed cli/sti and {save,restore}_flags to taking the spinlock and
    disabling interrupts with spin_lock_irqsave
  - included my previous patch for proc_net_create, but as a separate hunk,
    so if you've already applied then just ignore the rejected hunk.

  I have verified that the patched driver compiles without warnings, but
  since I don't have the hardware I can't test it. Please treat with
  caution.
parent a48fa850
...@@ -159,6 +159,8 @@ static inline int dev_is_ethdev(struct net_device *dev) ...@@ -159,6 +159,8 @@ static inline int dev_is_ethdev(struct net_device *dev)
); );
} }
static spinlock_t bpq_lock = SPIN_LOCK_UNLOCKED;
/* /*
* Sanity check: remove all devices that ceased to exists and * Sanity check: remove all devices that ceased to exists and
* return '1' if the given BPQ device was affected. * return '1' if the given BPQ device was affected.
...@@ -169,8 +171,7 @@ static int bpq_check_devices(struct net_device *dev) ...@@ -169,8 +171,7 @@ static int bpq_check_devices(struct net_device *dev)
int result = 0; int result = 0;
unsigned long flags; unsigned long flags;
save_flags(flags); spin_lock_irqsave(&bpq_lock, flags);
cli();
bpq_prev = NULL; bpq_prev = NULL;
...@@ -196,7 +197,7 @@ static int bpq_check_devices(struct net_device *dev) ...@@ -196,7 +197,7 @@ static int bpq_check_devices(struct net_device *dev)
bpq_prev = bpq; bpq_prev = bpq;
} }
restore_flags(flags); spin_unlock_irqrestore(&bpq_lock, flags);
return result; return result;
} }
...@@ -446,8 +447,9 @@ static int bpq_get_info(char *buffer, char **start, off_t offset, int length) ...@@ -446,8 +447,9 @@ static int bpq_get_info(char *buffer, char **start, off_t offset, int length)
int len = 0; int len = 0;
off_t pos = 0; off_t pos = 0;
off_t begin = 0; off_t begin = 0;
unsigned long flags;
cli(); spin_lock_irqsave(&bpq_lock, flags);
len += sprintf(buffer, "dev ether destination accept from\n"); len += sprintf(buffer, "dev ether destination accept from\n");
...@@ -470,7 +472,7 @@ static int bpq_get_info(char *buffer, char **start, off_t offset, int length) ...@@ -470,7 +472,7 @@ static int bpq_get_info(char *buffer, char **start, off_t offset, int length)
break; break;
} }
sti(); spin_unlock_irqrestore(&bpq_lock, flags);
*start = buffer + (offset - begin); *start = buffer + (offset - begin);
len -= (offset - begin); len -= (offset - begin);
...@@ -491,6 +493,7 @@ static int bpq_new_device(struct net_device *dev) ...@@ -491,6 +493,7 @@ static int bpq_new_device(struct net_device *dev)
{ {
int k; int k;
struct bpqdev *bpq, *bpq2; struct bpqdev *bpq, *bpq2;
unsigned long flags;
if ((bpq = kmalloc(sizeof(struct bpqdev), GFP_KERNEL)) == NULL) if ((bpq = kmalloc(sizeof(struct bpqdev), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -553,7 +556,7 @@ static int bpq_new_device(struct net_device *dev) ...@@ -553,7 +556,7 @@ static int bpq_new_device(struct net_device *dev)
dev->mtu = AX25_DEF_PACLEN; dev->mtu = AX25_DEF_PACLEN;
dev->addr_len = AX25_ADDR_LEN; dev->addr_len = AX25_ADDR_LEN;
cli(); spin_lock_irqsave(&bpq_lock, flags);
if (bpq_devices == NULL) { if (bpq_devices == NULL) {
bpq_devices = bpq; bpq_devices = bpq;
...@@ -562,7 +565,7 @@ static int bpq_new_device(struct net_device *dev) ...@@ -562,7 +565,7 @@ static int bpq_new_device(struct net_device *dev)
bpq2->next = bpq; bpq2->next = bpq;
} }
sti(); spin_unlock_irqrestore(&bpq_lock, flags);
return 0; return 0;
} }
...@@ -615,7 +618,13 @@ static int __init bpq_init_driver(void) ...@@ -615,7 +618,13 @@ static int __init bpq_init_driver(void)
printk(banner); printk(banner);
proc_net_create("bpqether", 0, bpq_get_info); if (!proc_net_create("bpqether", 0, bpq_get_info)) {
printk(KERN_ERR
"bpq: cannot create /proc/net/bpqether entry.\n");
unregister_netdevice_notifier(&bpq_dev_notifier);
dev_remove_pack(&bpq_packet_type);
return -ENOENT;
}
read_lock_bh(&dev_base_lock); read_lock_bh(&dev_base_lock);
for (dev = dev_base; dev != NULL; dev = dev->next) { for (dev = dev_base; dev != NULL; dev = dev->next) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment