check ret of lock and adjust return type

This commit is contained in:
JacobBarthelmeh
2021-03-06 14:21:44 +07:00
parent 6d0dbbe1c0
commit 2275c97602
3 changed files with 13 additions and 7 deletions

View File

@@ -89,7 +89,7 @@ int CAAM_SET_BASEADDR()
/* convert a virtual address to a physical address /* convert a virtual address to a physical address
* returns the physical address on success * returns the physical address on success
*/ */
unsigned int CAAM_ADR_TO_PHYSICAL(void* in, int inSz) CAAM_ADDRESS CAAM_ADR_TO_PHYSICAL(void* in, int inSz)
{ {
off64_t ofst = 0; off64_t ofst = 0;
int ret, count = 0;; int ret, count = 0;;
@@ -112,7 +112,7 @@ unsigned int CAAM_ADR_TO_PHYSICAL(void* in, int inSz)
count++; count++;
} while (ret != 0 && ret == -1 && count < 5); } while (ret != 0 && ret == -1 && count < 5);
return (int)ofst; return (CAAM_ADDRESS)ofst;
} }

View File

@@ -224,16 +224,19 @@ word32 wc_caamReadRegister(word32 reg)
return (word32)out; return (word32)out;
} }
void wc_caamWriteRegister(word32 reg, word32 value)
/* returns 0 on success */
int wc_caamWriteRegister(word32 reg, word32 value)
{ {
if (caam == NULLIODevice) { if (caam == NULLIODevice) {
WOLFSSL_MSG("Error CAAM IODevice not found! Bad password?"); WOLFSSL_MSG("Error CAAM IODevice not found! Bad password?");
return; return -1;
} }
if (WriteIODeviceRegister(caam, reg, value) != Success) { if (WriteIODeviceRegister(caam, reg, value) != Success) {
WOLFSSL_MSG("Error writing to register\n"); WOLFSSL_MSG("Error writing to register\n");
} }
return 0;
} }
#endif #endif

View File

@@ -328,9 +328,12 @@ int SynchronousSendRequest(int type, unsigned int args[4], CAAM_BUFFER *buf,
return -1; return -1;
} }
wc_LockMutex(&caamMutex); ret = wc_LockMutex(&caamMutex);
if (ret == 0) {
ret = devctlv(caamFd, cmd, inIdx, outIdx, in, out, NULL); ret = devctlv(caamFd, cmd, inIdx, outIdx, in, out, NULL);
wc_UnLockMutex(&caamMutex); wc_UnLockMutex(&caamMutex);
}
if (ret != 0) { if (ret != 0) {
if (ret == EFAULT) { if (ret == EFAULT) {
WOLFSSL_MSG("bad address on one of the in/out buffers"); WOLFSSL_MSG("bad address on one of the in/out buffers");