Skip to content

Commit

Permalink
prism54: Convert acl->sem in a mutex
Browse files Browse the repository at this point in the history
The semaphore acl->sem is used as mutex, convert it to the mutex API

Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
Acked-by: Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Matthias Kaehlcke authored and John W. Linville committed Feb 29, 2008
1 parent 5c05863 commit 6f865c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions drivers/net/wireless/prism54/isl_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -1806,7 +1806,7 @@ prism54_clear_mac(struct islpci_acl *acl)
kfree(entry);
}
acl->size = 0;
up(&acl->sem);
mutex_unlock(&acl->lock);
}

void
Expand All @@ -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;
}
Expand All @@ -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;
}

Expand All @@ -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) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/prism54/islpci_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6f865c0

Please sign in to comment.