Commit 6f865c0a authored by Matthias Kaehlcke's avatar Matthias Kaehlcke Committed by John W. Linville

prism54: Convert acl->sem in a mutex

The semaphore acl->sem is used as mutex, convert it to the mutex API
Signed-off-by: default avatarMatthias Kaehlcke <matthias@kaehlcke.net>
Acked-by: default avatarLuis R. Rodriguez <mcgrof@winlab.rutgers.edu>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 5c05863d
...@@ -1780,7 +1780,7 @@ prism54_set_raw(struct net_device *ndev, struct iw_request_info *info, ...@@ -1780,7 +1780,7 @@ prism54_set_raw(struct net_device *ndev, struct iw_request_info *info,
void void
prism54_acl_init(struct islpci_acl *acl) prism54_acl_init(struct islpci_acl *acl)
{ {
sema_init(&acl->sem, 1); mutex_init(&acl->lock);
INIT_LIST_HEAD(&acl->mac_list); INIT_LIST_HEAD(&acl->mac_list);
acl->size = 0; acl->size = 0;
acl->policy = MAC_POLICY_OPEN; acl->policy = MAC_POLICY_OPEN;
...@@ -1792,10 +1792,10 @@ prism54_clear_mac(struct islpci_acl *acl) ...@@ -1792,10 +1792,10 @@ prism54_clear_mac(struct islpci_acl *acl)
struct list_head *ptr, *next; struct list_head *ptr, *next;
struct mac_entry *entry; struct mac_entry *entry;
down(&acl->sem); mutex_lock(&acl->lock);
if (acl->size == 0) { if (acl->size == 0) {
up(&acl->sem); mutex_unlock(&acl->lock);
return; return;
} }
...@@ -1806,7 +1806,7 @@ prism54_clear_mac(struct islpci_acl *acl) ...@@ -1806,7 +1806,7 @@ prism54_clear_mac(struct islpci_acl *acl)
kfree(entry); kfree(entry);
} }
acl->size = 0; acl->size = 0;
up(&acl->sem); mutex_unlock(&acl->lock);
} }
void void
...@@ -1833,13 +1833,13 @@ prism54_add_mac(struct net_device *ndev, struct iw_request_info *info, ...@@ -1833,13 +1833,13 @@ prism54_add_mac(struct net_device *ndev, struct iw_request_info *info,
memcpy(entry->addr, addr->sa_data, ETH_ALEN); memcpy(entry->addr, addr->sa_data, ETH_ALEN);
if (down_interruptible(&acl->sem)) { if (mutex_lock_interruptible(&acl->lock)) {
kfree(entry); kfree(entry);
return -ERESTARTSYS; return -ERESTARTSYS;
} }
list_add_tail(&entry->_list, &acl->mac_list); list_add_tail(&entry->_list, &acl->mac_list);
acl->size++; acl->size++;
up(&acl->sem); mutex_unlock(&acl->lock);
return 0; return 0;
} }
...@@ -1856,18 +1856,18 @@ prism54_del_mac(struct net_device *ndev, struct iw_request_info *info, ...@@ -1856,18 +1856,18 @@ prism54_del_mac(struct net_device *ndev, struct iw_request_info *info,
if (addr->sa_family != ARPHRD_ETHER) if (addr->sa_family != ARPHRD_ETHER)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (down_interruptible(&acl->sem)) if (mutex_lock_interruptible(&acl->lock))
return -ERESTARTSYS; return -ERESTARTSYS;
list_for_each_entry(entry, &acl->mac_list, _list) { list_for_each_entry(entry, &acl->mac_list, _list) {
if (memcmp(entry->addr, addr->sa_data, ETH_ALEN) == 0) { if (memcmp(entry->addr, addr->sa_data, ETH_ALEN) == 0) {
list_del(&entry->_list); list_del(&entry->_list);
acl->size--; acl->size--;
kfree(entry); kfree(entry);
up(&acl->sem); mutex_unlock(&acl->lock);
return 0; return 0;
} }
} }
up(&acl->sem); mutex_unlock(&acl->lock);
return -EINVAL; return -EINVAL;
} }
...@@ -1882,7 +1882,7 @@ prism54_get_mac(struct net_device *ndev, struct iw_request_info *info, ...@@ -1882,7 +1882,7 @@ prism54_get_mac(struct net_device *ndev, struct iw_request_info *info,
dwrq->length = 0; dwrq->length = 0;
if (down_interruptible(&acl->sem)) if (mutex_lock_interruptible(&acl->lock))
return -ERESTARTSYS; return -ERESTARTSYS;
list_for_each_entry(entry, &acl->mac_list, _list) { list_for_each_entry(entry, &acl->mac_list, _list) {
...@@ -1891,7 +1891,7 @@ prism54_get_mac(struct net_device *ndev, struct iw_request_info *info, ...@@ -1891,7 +1891,7 @@ prism54_get_mac(struct net_device *ndev, struct iw_request_info *info,
dwrq->length++; dwrq->length++;
dst++; dst++;
} }
up(&acl->sem); mutex_unlock(&acl->lock);
return 0; return 0;
} }
...@@ -1955,11 +1955,11 @@ prism54_mac_accept(struct islpci_acl *acl, char *mac) ...@@ -1955,11 +1955,11 @@ prism54_mac_accept(struct islpci_acl *acl, char *mac)
struct mac_entry *entry; struct mac_entry *entry;
int res = 0; int res = 0;
if (down_interruptible(&acl->sem)) if (mutex_lock_interruptible(&acl->lock))
return -ERESTARTSYS; return -ERESTARTSYS;
if (acl->policy == MAC_POLICY_OPEN) { if (acl->policy == MAC_POLICY_OPEN) {
up(&acl->sem); mutex_unlock(&acl->lock);
return 1; return 1;
} }
...@@ -1970,7 +1970,7 @@ prism54_mac_accept(struct islpci_acl *acl, char *mac) ...@@ -1970,7 +1970,7 @@ prism54_mac_accept(struct islpci_acl *acl, char *mac)
} }
} }
res = (acl->policy == MAC_POLICY_ACCEPT) ? !res : res; res = (acl->policy == MAC_POLICY_ACCEPT) ? !res : res;
up(&acl->sem); mutex_unlock(&acl->lock);
return res; return res;
} }
......
...@@ -55,7 +55,7 @@ struct islpci_acl { ...@@ -55,7 +55,7 @@ struct islpci_acl {
enum { MAC_POLICY_OPEN=0, MAC_POLICY_ACCEPT=1, MAC_POLICY_REJECT=2 } policy; enum { MAC_POLICY_OPEN=0, MAC_POLICY_ACCEPT=1, MAC_POLICY_REJECT=2 } policy;
struct list_head mac_list; /* a list of mac_entry */ struct list_head mac_list; /* a list of mac_entry */
int size; /* size of queue */ int size; /* size of queue */
struct semaphore sem; /* accessed in ioctls and trap_work */ struct mutex lock; /* accessed in ioctls and trap_work */
}; };
struct islpci_membuf { struct islpci_membuf {
......
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