typedef struct semaphore compat_mutex_t;
-# define compat_define_mutex(_mx) DECLARE_MUTEX(_mx)
-# define compat_mutex_init(_mx) init_MUTEX(_mx)
-# define compat_mutex_lock(_mx) down(_mx)
-# define compat_mutex_unlock(_mx) up(_mx)
+# define compat_define_mutex(_mx) DECLARE_MUTEX(_mx)
+# define compat_mutex_init(_mx) init_MUTEX(_mx)
+# define compat_mutex_lock(_mx) down(_mx)
+# define compat_mutex_lock_interruptible(_mx) down_interruptible(_mx)
+# define compat_mutex_unlock(_mx) up(_mx)
#else
typedef struct mutex compat_mutex_t;
-# define compat_define_mutex(_mx) DEFINE_MUTEX(_mx)
-# define compat_mutex_init(_mx) mutex_init(_mx)
-# define compat_mutex_lock(_mx) mutex_lock(_mx)
-# define compat_mutex_unlock(_mx) mutex_unlock(_mx)
+# define compat_define_mutex(_mx) DEFINE_MUTEX(_mx)
+# define compat_mutex_init(_mx) mutex_init(_mx)
+# define compat_mutex_lock(_mx) mutex_lock(_mx)
+# define compat_mutex_lock_interruptible(_mx) mutex_lock_interruptible(_mx)
+# define compat_mutex_unlock(_mx) mutex_unlock(_mx)
#endif
#include "compat_ioport.h"
#include "compat_interrupt.h"
#include "compat_page.h"
+#include "compat_mutex.h"
#include "vm_basic_types.h"
#include "vm_device_version.h"
#include "kernelStubs.h"
#define VMCI_DEVICE_MINOR_NUM 0
typedef struct vmci_device {
- struct semaphore lock;
+ compat_mutex_t lock;
unsigned int ioaddr;
unsigned int ioaddr_size;
printk("VMCI: Major device number is: %d\n", device_major_nr);
/* Initialize device data. */
- init_MUTEX(&vmci_dev.lock);
+ compat_mutex_init(&vmci_dev.lock);
spin_lock_init(&vmci_dev.dev_spinlock);
vmci_dev.enabled = FALSE;
outl(VMCI_CAPS_DATAGRAM, ioaddr + VMCI_CAPS_ADDR);
/* Device struct initialization. */
- down(&vmci_dev.lock);
+ compat_mutex_lock(&vmci_dev.lock);
if (vmci_dev.enabled) {
printk(KERN_ERR "VMCI device already enabled.\n");
goto unlock;
printk(KERN_INFO "Registered vmci device.\n");
- up(&vmci_dev.lock);
+ compat_mutex_unlock(&vmci_dev.lock);
/* Enable specific interrupt bits. */
outl(VMCI_IMR_DATAGRAM, vmci_dev.ioaddr + VMCI_IMR_ADDR);
VMCIEvent_Exit();
VMCIProcess_Exit();
unlock:
- up(&vmci_dev.lock);
+ compat_mutex_unlock(&vmci_dev.lock);
release:
release_region(ioaddr, ioaddr_size);
pci_disable:
//VMCIDatagram_Exit();
VMCIProcess_Exit();
- down(&dev->lock);
+ compat_mutex_lock(&dev->lock);
printk(KERN_INFO "Resetting vmci device\n");
outl(VMCI_CONTROL_RESET, vmci_dev.ioaddr + VMCI_CONTROL_ADDR);
free_irq(dev->irq, dev);
dev->enabled = FALSE;
printk(KERN_INFO "Unregistered vmci device.\n");
- up(&dev->lock);
+ compat_mutex_unlock(&dev->lock);
compat_pci_disable_device(pdev);
}
return -ENODEV;
}
- down(&vmci_dev.lock);
+ compat_mutex_lock(&vmci_dev.lock);
if (!vmci_dev.enabled) {
printk(KERN_INFO "Received open on uninitialized vmci device.\n");
errcode = -ENODEV;
devHndl->objType = VMCIOBJ_NOT_SET;
file->private_data = devHndl;
- up(&vmci_dev.lock);
+ compat_mutex_unlock(&vmci_dev.lock);
return 0;
unlock:
- up(&vmci_dev.lock);
+ compat_mutex_unlock(&vmci_dev.lock);
return errcode;
}
{
Bool retval;
- down(&vmci_dev.lock);
+ compat_mutex_lock(&vmci_dev.lock);
retval = vmci_dev.enabled;
- up(&vmci_dev.lock);
+ compat_mutex_unlock(&vmci_dev.lock);
return retval;
}
#include "compat_fs.h"
#include "compat_module.h"
#include "compat_namei.h"
-#include "compat_semaphore.h"
+#include "compat_mutex.h"
#include "compat_slab.h"
#include "compat_workqueue.h"
typedef struct VmSyncState {
struct list_head devices;
- struct semaphore lock;
+ compat_mutex_t lock;
compat_delayed_work thawTask;
} VmSyncState;
* Serializes freeze operations. Used to make sure that two different
* fds aren't allowed to freeze the same device.
*/
-static struct semaphore gFreezeLock;
+static compat_mutex_t gFreezeLock;
/* A global count of how many devices are currently frozen by the driver. */
static atomic_t gFreezeCount;
state = (VmSyncState *) _state;
- down(&state->lock);
+ compat_mutex_lock(&state->lock);
cancel_delayed_work(&state->thawTask);
list_for_each_safe(cur, tmp, &state->devices) {
dev = list_entry(cur, VmSyncBlockDevice, list);
list_del_init(&dev->list);
kmem_cache_free(gBlockDeviceCache, dev);
}
- up(&state->lock);
+ compat_mutex_unlock(&state->lock);
}
return PTR_ERR(paths);
}
- down(&gFreezeLock);
- down(&state->lock);
+ compat_mutex_lock(&gFreezeLock);
+ compat_mutex_lock(&state->lock);
/*
* First, try to add all paths to the list of paths to be frozen.
}
}
- up(&state->lock);
- up(&gFreezeLock);
+ compat_mutex_unlock(&state->lock);
+ compat_mutex_unlock(&gFreezeLock);
if (result == 0) {
compat_schedule_delayed_work(&state->thawTask, VMSYNC_THAW_TASK_DELAY);
INIT_LIST_HEAD(&state->devices);
COMPAT_INIT_DELAYED_WORK(&state->thawTask,
VmSyncThawDevicesCallback, state);
- init_MUTEX(&state->lock);
+ compat_mutex_init(&state->lock);
}
struct proc_dir_entry *controlProcEntry;
atomic_set(&gFreezeCount, 0);
- init_MUTEX(&gFreezeLock);
+ compat_mutex_init(&gFreezeLock);
/* Create the slab allocators for the module. */
gBlockDeviceCache = compat_kmem_cache_create("VmSyncBlockDeviceCache",
#include "compat_version.h"
#include "compat_workqueue.h"
#include "compat_list.h"
-#if defined(HAVE_COMPAT_IOCTL) || defined(HAVE_UNLOCKED_IOCTL)
-# include "compat_semaphore.h"
-#endif
+#include "compat_mutex.h"
#include "vmware.h"
VSockPacket pkt;
} VSockRecvPktInfo;
-static DECLARE_MUTEX(registrationMutex);
+static compat_define_mutex(registrationMutex);
static int devOpenCount = 0;
static int vsockVmciSocketCount = 0;
static int vsockVmciKernClientCount = 0;
{
int afvalue;
- down(®istrationMutex);
+ compat_mutex_lock(®istrationMutex);
/*
* Kernel clients are required to explicitly register themselves before they
afvalue = VSockVmciGetAFValue();
exit:
- up(®istrationMutex);
+ compat_mutex_unlock(®istrationMutex);
return afvalue;
}
EXPORT_SYMBOL(VMCISock_GetAFValue);
{
int cid;
- down(®istrationMutex);
+ compat_mutex_lock(®istrationMutex);
/*
* Kernel clients are required to explicitly register themselves before they
cid = VMCI_GetContextID();
exit:
- up(®istrationMutex);
+ compat_mutex_unlock(®istrationMutex);
return cid;
}
EXPORT_SYMBOL(VMCISock_GetLocalCID);
void
VMCISock_KernelRegister(void)
{
- down(®istrationMutex);
+ compat_mutex_lock(®istrationMutex);
vsockVmciKernClientCount++;
- up(®istrationMutex);
+ compat_mutex_unlock(®istrationMutex);
}
EXPORT_SYMBOL(VMCISock_KernelRegister);
void
VMCISock_KernelDeregister(void)
{
- down(®istrationMutex);
+ compat_mutex_lock(®istrationMutex);
vsockVmciKernClientCount--;
VSockVmciTestUnregister();
- up(®istrationMutex);
+ compat_mutex_unlock(®istrationMutex);
}
EXPORT_SYMBOL(VMCISock_KernelDeregister);
{
int afvalue;
- down(®istrationMutex);
+ compat_mutex_lock(®istrationMutex);
afvalue = VSockVmciGetAFValue();
- up(®istrationMutex);
+ compat_mutex_unlock(®istrationMutex);
return afvalue;
}
void *clientData) // IN
{
int err;
- down(®istrationMutex);
+ compat_mutex_lock(®istrationMutex);
if (!VMCI_HANDLE_INVALID(vmciStreamHandle)) {
VMCIDatagram_DestroyHnd(vmciStreamHandle);
Warning("Unable to create datagram handle. (%d)\n", err);
}
- up(®istrationMutex);
+ compat_mutex_unlock(®istrationMutex);
}
* If we go this far, we know the socket family is registered, so there's no
* need to register it now.
*/
- down(®istrationMutex);
+ compat_mutex_lock(®istrationMutex);
vsockVmciSocketCount++;
- up(®istrationMutex);
+ compat_mutex_unlock(®istrationMutex);
sock_init_data(sock, sk);
NOTIFYCALL(vsk, socketDestruct, sk);
- down(®istrationMutex);
+ compat_mutex_lock(®istrationMutex);
vsockVmciSocketCount--;
VSockVmciTestUnregister();
- up(®istrationMutex);
+ compat_mutex_unlock(®istrationMutex);
VSOCK_STATS_CTLPKT_DUMP_ALL();
VSockVmciDevOpen(struct inode *inode, // IN
struct file *file) // IN
{
- down(®istrationMutex);
+ compat_mutex_lock(®istrationMutex);
devOpenCount++;
- up(®istrationMutex);
+ compat_mutex_unlock(®istrationMutex);
return 0;
}
VSockVmciDevRelease(struct inode *inode, // IN
struct file *file) // IN
{
- down(®istrationMutex);
+ compat_mutex_lock(®istrationMutex);
devOpenCount--;
VSockVmciTestUnregister();
- up(®istrationMutex);
+ compat_mutex_unlock(®istrationMutex);
return 0;
}
{
unregister_ioctl32_handlers();
misc_deregister(&vsockVmciDevice);
- down(®istrationMutex);
+ compat_mutex_lock(®istrationMutex);
VSockVmciUnregisterAddressFamily();
- up(®istrationMutex);
+ compat_mutex_unlock(®istrationMutex);
VSockVmciUnregisterProto();
}