Commit b3c9f3c5 authored by Christian Gromm's avatar Christian Gromm Committed by Greg Kroah-Hartman

staging: most: change type of access_ref

This patch changes the type of the access reference from atomit_t to int.
It is needed, because the reference variable is secured by synchronization
locks and does not need to be atomic anymore.
Signed-off-by: default avatarChristian Gromm <christian.gromm@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fa96b8ed
...@@ -43,7 +43,7 @@ struct aim_channel { ...@@ -43,7 +43,7 @@ struct aim_channel {
size_t mbo_offs; size_t mbo_offs;
struct mbo *stacked_mbo; struct mbo *stacked_mbo;
DECLARE_KFIFO_PTR(fifo, typeof(struct mbo *)); DECLARE_KFIFO_PTR(fifo, typeof(struct mbo *));
atomic_t access_ref; int access_ref;
struct list_head list; struct list_head list;
}; };
...@@ -137,16 +137,15 @@ static int aim_open(struct inode *inode, struct file *filp) ...@@ -137,16 +137,15 @@ static int aim_open(struct inode *inode, struct file *filp)
return -EBUSY; return -EBUSY;
} }
if (!atomic_inc_and_test(&c->access_ref)) { if (c->access_ref) {
pr_info("WARN: Device is busy\n"); pr_info("WARN: Device is busy\n");
atomic_dec(&c->access_ref);
mutex_unlock(&c->io_mutex); mutex_unlock(&c->io_mutex);
return -EBUSY; return -EBUSY;
} }
ret = most_start_channel(c->iface, c->channel_id, &cdev_aim); ret = most_start_channel(c->iface, c->channel_id, &cdev_aim);
if (ret) if (!ret)
atomic_dec(&c->access_ref); c->access_ref = 1;
mutex_unlock(&c->io_mutex); mutex_unlock(&c->io_mutex);
return ret; return ret;
} }
...@@ -164,7 +163,7 @@ static int aim_close(struct inode *inode, struct file *filp) ...@@ -164,7 +163,7 @@ static int aim_close(struct inode *inode, struct file *filp)
mutex_lock(&c->io_mutex); mutex_lock(&c->io_mutex);
spin_lock(&c->unlink); spin_lock(&c->unlink);
atomic_dec(&c->access_ref); c->access_ref = 0;
spin_unlock(&c->unlink); spin_unlock(&c->unlink);
if (c->dev) { if (c->dev) {
stop_channel(c); stop_channel(c);
...@@ -347,7 +346,7 @@ static int aim_disconnect_channel(struct most_interface *iface, int channel_id) ...@@ -347,7 +346,7 @@ static int aim_disconnect_channel(struct most_interface *iface, int channel_id)
spin_lock(&c->unlink); spin_lock(&c->unlink);
c->dev = NULL; c->dev = NULL;
spin_unlock(&c->unlink); spin_unlock(&c->unlink);
if (!atomic_read(&c->access_ref)) { if (c->access_ref) {
stop_channel(c); stop_channel(c);
wake_up_interruptible(&c->wq); wake_up_interruptible(&c->wq);
mutex_unlock(&c->io_mutex); mutex_unlock(&c->io_mutex);
...@@ -378,7 +377,7 @@ static int aim_rx_completion(struct mbo *mbo) ...@@ -378,7 +377,7 @@ static int aim_rx_completion(struct mbo *mbo)
return -ENXIO; return -ENXIO;
spin_lock(&c->unlink); spin_lock(&c->unlink);
if (atomic_read(&c->access_ref) || !c->dev) { if (!c->access_ref || !c->dev) {
spin_unlock(&c->unlink); spin_unlock(&c->unlink);
return -EFAULT; return -EFAULT;
} }
...@@ -468,7 +467,7 @@ static int aim_probe(struct most_interface *iface, int channel_id, ...@@ -468,7 +467,7 @@ static int aim_probe(struct most_interface *iface, int channel_id,
c->cfg = cfg; c->cfg = cfg;
c->channel_id = channel_id; c->channel_id = channel_id;
c->mbo_offs = 0; c->mbo_offs = 0;
atomic_set(&c->access_ref, -1); c->access_ref = 0;
spin_lock_init(&c->unlink); spin_lock_init(&c->unlink);
INIT_KFIFO(c->fifo); INIT_KFIFO(c->fifo);
retval = kfifo_alloc(&c->fifo, cfg->num_buffers, GFP_KERNEL); retval = kfifo_alloc(&c->fifo, cfg->num_buffers, GFP_KERNEL);
......
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