Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754409AbbBZPxt (ORCPT ); Thu, 26 Feb 2015 10:53:49 -0500 Received: from mail-wg0-f42.google.com ([74.125.82.42]:46179 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754386AbbBZPxq (ORCPT ); Thu, 26 Feb 2015 10:53:46 -0500 From: Dmitry Kalinkin To: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Martyn Welch , Manohar Vanga , Greg Kroah-Hartman , Igor Alekseev , Dmitry Kalinkin Subject: [PATCHv2 1/3] staging: vme: use image mutex for ioctl() Date: Thu, 26 Feb 2015 18:53:09 +0300 Message-Id: <1424965991-27242-2-git-send-email-dmitry.kalinkin@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1424965991-27242-1-git-send-email-dmitry.kalinkin@gmail.com> References: <20141115075133.GP6749@mwanda> <1424965991-27242-1-git-send-email-dmitry.kalinkin@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1531 Lines: 48 This implements more granular locking in vme_user_ioctl() by using separate locks for each devfs device. This also provides a synchronization between vme_user_read(), vme_user_write() and vme_user_ioctl(). Signed-off-by: Dmitry Kalinkin Cc: Igor Alekseev --- drivers/staging/vme/devices/vme_user.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 8b1f533..8731838 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -41,7 +41,6 @@ #include "vme_user.h" -static DEFINE_MUTEX(vme_user_mutex); static const char driver_name[] = "vme_user"; static int bus[VME_USER_BUS_MAX]; @@ -555,10 +554,12 @@ static long vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int ret; + struct inode *inode = file_inode(file); + unsigned int minor = MINOR(inode->i_rdev); - mutex_lock(&vme_user_mutex); - ret = vme_user_ioctl(file_inode(file), file, cmd, arg); - mutex_unlock(&vme_user_mutex); + mutex_lock(&image[minor].mutex); + ret = vme_user_ioctl(inode, file, cmd, arg); + mutex_unlock(&image[minor].mutex); return ret; } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/