From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 078BD1C0BE0 for ; Tue, 22 Dec 2015 09:54:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 019A2330B5 for ; Tue, 22 Dec 2015 09:54:50 +0000 (UTC) Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WdTaG91SeLtO for ; Tue, 22 Dec 2015 09:54:49 +0000 (UTC) Received: from email.microchip.com (exsmtp03.microchip.com [198.175.253.49]) by silver.osuosl.org (Postfix) with ESMTPS id 2F46933006 for ; Tue, 22 Dec 2015 09:54:49 +0000 (UTC) From: Christian Gromm Subject: [PATCH 24/28] staging: most: change type of access_ref Date: Tue, 22 Dec 2015 10:53:05 +0100 Message-ID: <1450777989-5551-25-git-send-email-christian.gromm@microchip.com> In-Reply-To: <1450777989-5551-1-git-send-email-christian.gromm@microchip.com> References: <1450777989-5551-1-git-send-email-christian.gromm@microchip.com> MIME-Version: 1.0 List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" To: gregkh@linuxfoundation.org Cc: Christian Gromm , driverdev-devel@linuxdriverproject.org 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: Christian Gromm --- This patch has been resent on behalf of Greg Kroah-Hartman drivers/staging/most/aim-cdev/cdev.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index ade7808..d9c3f56 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -43,7 +43,7 @@ struct aim_channel { size_t mbo_offs; struct mbo *stacked_mbo; DECLARE_KFIFO_PTR(fifo, typeof(struct mbo *)); - atomic_t access_ref; + int access_ref; struct list_head list; }; @@ -137,16 +137,15 @@ static int aim_open(struct inode *inode, struct file *filp) return -EBUSY; } - if (!atomic_inc_and_test(&c->access_ref)) { + if (c->access_ref) { pr_info("WARN: Device is busy\n"); - atomic_dec(&c->access_ref); mutex_unlock(&c->io_mutex); return -EBUSY; } ret = most_start_channel(c->iface, c->channel_id, &cdev_aim); - if (ret) - atomic_dec(&c->access_ref); + if (!ret) + c->access_ref = 1; mutex_unlock(&c->io_mutex); return ret; } @@ -164,7 +163,7 @@ static int aim_close(struct inode *inode, struct file *filp) mutex_lock(&c->io_mutex); spin_lock(&c->unlink); - atomic_dec(&c->access_ref); + c->access_ref = 0; spin_unlock(&c->unlink); if (c->dev) { stop_channel(c); @@ -347,7 +346,7 @@ static int aim_disconnect_channel(struct most_interface *iface, int channel_id) spin_lock(&c->unlink); c->dev = NULL; spin_unlock(&c->unlink); - if (!atomic_read(&c->access_ref)) { + if (c->access_ref) { stop_channel(c); wake_up_interruptible(&c->wq); mutex_unlock(&c->io_mutex); @@ -378,7 +377,7 @@ static int aim_rx_completion(struct mbo *mbo) return -ENXIO; spin_lock(&c->unlink); - if (atomic_read(&c->access_ref) || !c->dev) { + if (!c->access_ref || !c->dev) { spin_unlock(&c->unlink); return -EFAULT; } @@ -468,7 +467,7 @@ static int aim_probe(struct most_interface *iface, int channel_id, c->cfg = cfg; c->channel_id = channel_id; c->mbo_offs = 0; - atomic_set(&c->access_ref, -1); + c->access_ref = 0; spin_lock_init(&c->unlink); INIT_KFIFO(c->fifo); retval = kfifo_alloc(&c->fifo, cfg->num_buffers, GFP_KERNEL); -- 1.7.9.5 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel