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,
void
prism54_acl_init(struct islpci_acl *acl)
{
sema_init(&acl->sem, 1);
mutex_init(&acl->lock);
INIT_LIST_HEAD(&acl->mac_list);
acl->size = 0;
acl->policy = MAC_POLICY_OPEN;
......@@ -1792,10 +1792,10 @@ prism54_clear_mac(struct islpci_acl *acl)
struct list_head *ptr, *next;
struct mac_entry *entry;
down(&acl->sem);
mutex_lock(&acl->lock);
if (acl->size == 0) {
up(&acl->sem);
mutex_unlock(&acl->lock);
return;
}
......@@ -1806,7 +1806,7 @@ prism54_clear_mac(struct islpci_acl *acl)
kfree(entry);
}
acl->size = 0;
up(&acl->sem);
mutex_unlock(&acl->lock);
}
void
......@@ -1833,13 +1833,13 @@ prism54_add_mac(struct net_device *ndev, struct iw_request_info *info,
memcpy(entry->addr, addr->sa_data, ETH_ALEN);
if (down_interruptible(&acl->sem)) {
if (mutex_lock_interruptible(&acl->lock)) {
kfree(entry);
return -ERESTARTSYS;
}
list_add_tail(&entry->_list, &acl->mac_list);
acl->size++;
up(&acl->sem);
mutex_unlock(&acl->lock);
return 0;
}
......@@ -1856,18 +1856,18 @@ prism54_del_mac(struct net_device *ndev, struct iw_request_info *info,
if (addr->sa_family != ARPHRD_ETHER)
return -EOPNOTSUPP;
if (down_interruptible(&acl->sem))
if (mutex_lock_interruptible(&acl->lock))
return -ERESTARTSYS;
list_for_each_entry(entry, &acl->mac_list, _list) {
if (memcmp(entry->addr, addr->sa_data, ETH_ALEN) == 0) {
list_del(&entry->_list);
acl->size--;
kfree(entry);
up(&acl->sem);
mutex_unlock(&acl->lock);
return 0;
}
}
up(&acl->sem);
mutex_unlock(&acl->lock);
return -EINVAL;
}
......@@ -1882,7 +1882,7 @@ prism54_get_mac(struct net_device *ndev, struct iw_request_info *info,
dwrq->length = 0;
if (down_interruptible(&acl->sem))
if (mutex_lock_interruptible(&acl->lock))
return -ERESTARTSYS;
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,
dwrq->length++;
dst++;
}
up(&acl->sem);
mutex_unlock(&acl->lock);
return 0;
}
......@@ -1955,11 +1955,11 @@ prism54_mac_accept(struct islpci_acl *acl, char *mac)
struct mac_entry *entry;
int res = 0;
if (down_interruptible(&acl->sem))
if (mutex_lock_interruptible(&acl->lock))
return -ERESTARTSYS;
if (acl->policy == MAC_POLICY_OPEN) {
up(&acl->sem);
mutex_unlock(&acl->lock);
return 1;
}
......@@ -1970,7 +1970,7 @@ prism54_mac_accept(struct islpci_acl *acl, char *mac)
}
}
res = (acl->policy == MAC_POLICY_ACCEPT) ? !res : res;
up(&acl->sem);
mutex_unlock(&acl->lock);
return res;
}
......
......@@ -55,7 +55,7 @@ struct islpci_acl {
enum { MAC_POLICY_OPEN=0, MAC_POLICY_ACCEPT=1, MAC_POLICY_REJECT=2 } policy;
struct list_head mac_list; /* a list of mac_entry */
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 {
......
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