X-Git-Url: https://git.kernelconcepts.de/?a=blobdiff_plain;f=drivers%2Fstaging%2Fmost%2Faim-cdev%2Fcdev.c;h=dc3fb25b52aab246ba9c2d14cf7ca940be3e9e54;hb=25912ee10d64eba7f267b475afcf5d6ad4249ab3;hp=16be88e2b454b32f833ffb8026faf489354848bd;hpb=b981da12513469324a18ae8250bca2848f8bf787;p=karo-tx-linux.git diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index 16be88e2b454..dc3fb25b52aa 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -32,7 +32,6 @@ static struct most_aim cdev_aim; struct aim_channel { wait_queue_head_t wq; - wait_queue_head_t poll_wq; struct cdev cdev; struct device *dev; struct mutex io_mutex; @@ -47,6 +46,7 @@ struct aim_channel { atomic_t access_ref; struct list_head list; }; + #define to_channel(d) container_of(d, struct aim_channel, cdev) static struct list_head channel_list; static spinlock_t ch_list_lock; @@ -87,8 +87,8 @@ static int aim_open(struct inode *inode, struct file *filp) filp->private_data = channel; if (((channel->cfg->direction == MOST_CH_RX) && - ((filp->f_flags & O_ACCMODE) != O_RDONLY)) - || ((channel->cfg->direction == MOST_CH_TX) && + ((filp->f_flags & O_ACCMODE) != O_RDONLY)) || + ((channel->cfg->direction == MOST_CH_TX) && ((filp->f_flags & O_ACCMODE) != O_WRONLY))) { pr_info("WARN: Access flags mismatch\n"); return -EACCES; @@ -100,7 +100,7 @@ static int aim_open(struct inode *inode, struct file *filp) } ret = most_start_channel(channel->iface, channel->channel_id, - &cdev_aim); + &cdev_aim); if (ret) atomic_dec(&channel->access_ref); return ret; @@ -134,7 +134,7 @@ static int aim_close(struct inode *inode, struct file *filp) } mutex_unlock(&channel->io_mutex); - while (0 != kfifo_out((struct kfifo *)&channel->fifo, &mbo, 1)) + while (kfifo_out((struct kfifo *)&channel->fifo, &mbo, 1)) most_put_mbo(mbo); if (channel->keep_mbo) most_put_mbo(channel->stacked_mbo); @@ -208,8 +208,7 @@ static ssize_t aim_write(struct file *filp, const char __user *buf, } return actual_len - retval; error: - if (mbo) - most_put_mbo(mbo); + most_put_mbo(mbo); return err; } @@ -233,8 +232,7 @@ aim_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) channel->keep_mbo = false; goto start_copy; } - while ((0 == kfifo_out(&channel->fifo, &mbo, 1)) - && (channel->dev)) { + while ((!kfifo_out(&channel->fifo, &mbo, 1)) && (channel->dev)) { if (filp->f_flags & O_NONBLOCK) return -EAGAIN; if (wait_event_interruptible(channel->wq, @@ -284,7 +282,7 @@ static unsigned int aim_poll(struct file *filp, poll_table *wait) struct aim_channel *c = filp->private_data; unsigned int mask = 0; - poll_wait(filp, &c->poll_wq, wait); + poll_wait(filp, &c->wq, wait); if (c->cfg->direction == MOST_CH_RX) { if (!kfifo_is_empty(&c->fifo)) @@ -460,7 +458,6 @@ static int aim_probe(struct most_interface *iface, int channel_id, goto error_alloc_kfifo; } init_waitqueue_head(&channel->wq); - init_waitqueue_head(&channel->poll_wq); mutex_init(&channel->io_mutex); spin_lock_irqsave(&ch_list_lock, cl_flags); list_add_tail(&channel->list, &channel_list);