From d1afa1b101aef9dfb9640bcad1ac21ef8c372cb3 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Wed, 18 Jun 2014 13:03:42 -0500 Subject: [PATCH] oct612x: Implement the SerializationObject callbacks. When originally implemented, the octasic calls where protected by the big kernel lock. This change now allows the octasic library to control it's synchronization as originally intended. It would still be worthwhile to completely make the oct612x library kernel-compliant. Signed-off-by: Shaun Ruffell Signed-off-by: Russ Meyerriecks --- .../include/oct6100api/oct6100_apiud.h | 2 +- drivers/dahdi/oct612x/oct612x-user.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/dahdi/oct612x/include/oct6100api/oct6100_apiud.h b/drivers/dahdi/oct612x/include/oct6100api/oct6100_apiud.h index feff93e..8bee548 100644 --- a/drivers/dahdi/oct612x/include/oct6100api/oct6100_apiud.h +++ b/drivers/dahdi/oct612x/include/oct6100api/oct6100_apiud.h @@ -129,7 +129,7 @@ $Octasic_Revision: 16 $ /***************************** TYPES ***************************************/ /*Change this type if your platform uses 64bits semaphores/locks */ -typedef UINT32 tOCT6100_USER_SERIAL_OBJECT; +typedef void* tOCT6100_USER_SERIAL_OBJECT; typedef struct _OCT6100_GET_TIME_ { diff --git a/drivers/dahdi/oct612x/oct612x-user.c b/drivers/dahdi/oct612x/oct612x-user.c index b5a845a..4ee5981 100644 --- a/drivers/dahdi/oct612x/oct612x-user.c +++ b/drivers/dahdi/oct612x/oct612x-user.c @@ -59,29 +59,38 @@ UINT32 Oct6100UserMemCopy(PVOID f_pDestination, const void *f_pSource, UINT32 Oct6100UserCreateSerializeObject( tPOCT6100_CREATE_SERIALIZE_OBJECT f_pCreate) { + struct oct612x_context *context = f_pCreate->pProcessContext; + struct mutex *lock = kzalloc(sizeof(*lock), GFP_KERNEL); + if (!lock) { + dev_err(context->dev, "Out of memory in %s.\n", __func__); + return cOCT6100_ERR_BASE; + } + mutex_init(lock); + f_pCreate->ulSerialObjHndl = lock; return cOCT6100_ERR_OK; } UINT32 Oct6100UserDestroySerializeObject( tPOCT6100_DESTROY_SERIALIZE_OBJECT f_pDestroy) { -#ifdef OCTASIC_DEBUG - pr_debug("I should never be called! (destroy serialize object)\n"); -#endif + struct mutex *lock = f_pDestroy->ulSerialObjHndl; + kfree(lock); return cOCT6100_ERR_OK; } UINT32 Oct6100UserSeizeSerializeObject( tPOCT6100_SEIZE_SERIALIZE_OBJECT f_pSeize) { - /* Not needed */ + struct mutex *lock = f_pSeize->ulSerialObjHndl; + mutex_lock(lock); return cOCT6100_ERR_OK; } UINT32 Oct6100UserReleaseSerializeObject( tPOCT6100_RELEASE_SERIALIZE_OBJECT f_pRelease) { - /* Not needed */ + struct mutex *lock = f_pRelease->ulSerialObjHndl; + mutex_unlock(lock); return cOCT6100_ERR_OK; }