spcom: print error message on lock ion failure

Locking ION buffer should not fail, print error message if it happens.

Signed-off-by: Amir Samuelov <amirs@codeaurora.org>
Change-Id: Ic67f69daa646712dd814f29d5aa0fc68386177e1
This commit is contained in:
Amir Samuelov 2017-02-05 14:08:58 +02:00 committed by Gerrit - the friendly Code Review server
parent 2e47ba9a64
commit edd2fc9348

View file

@ -316,6 +316,10 @@ static int spcom_create_predefined_channels_chardev(void)
{
int i;
int ret;
static bool is_predefined_created;
if (is_predefined_created)
return 0;
for (i = 0; i < SPCOM_MAX_CHANNELS; i++) {
const char *name = spcom_dev->predefined_ch_name[i];
@ -330,6 +334,8 @@ static int spcom_create_predefined_channels_chardev(void)
}
}
is_predefined_created = true;
return 0;
}
@ -1633,12 +1639,13 @@ static int spcom_handle_lock_ion_buf_command(struct spcom_channel *ch,
pr_err("fail to get ion handle.\n");
return -EINVAL;
}
pr_debug("ion handle ok.\n");
/* Check if this ION buffer is already locked */
for (i = 0 ; i < ARRAY_SIZE(ch->ion_handle_table) ; i++) {
if (ch->ion_handle_table[i] == ion_handle) {
pr_debug("fd [%d] ion buf is already locked.\n", fd);
pr_err("fd [%d] ion buf is already locked.\n", fd);
/* decrement back the ref count */
ion_free(spcom_dev->ion_client, ion_handle);
return -EINVAL;
@ -1650,11 +1657,14 @@ static int spcom_handle_lock_ion_buf_command(struct spcom_channel *ch,
if (ch->ion_handle_table[i] == NULL) {
ch->ion_handle_table[i] = ion_handle;
ch->ion_fd_table[i] = fd;
pr_debug("locked ion buf#[%d], fd [%d].\n", i, fd);
pr_debug("ch [%s] locked ion buf #%d, fd [%d].\n",
ch->name, i, fd);
return 0;
}
}
pr_err("fd [%d] ion buf not found.\n", fd);
return -EFAULT;
}
@ -1684,20 +1694,22 @@ static int spcom_unlock_ion_buf(struct spcom_channel *ch, int fd)
/* unlock all ION buf */
for (i = 0 ; i < ARRAY_SIZE(ch->ion_handle_table) ; i++) {
if (ch->ion_handle_table[i] != NULL) {
pr_debug("unlocked ion buf #%d fd [%d].\n",
i, ch->ion_fd_table[i]);
ion_free(ion_client, ch->ion_handle_table[i]);
ch->ion_handle_table[i] = NULL;
ch->ion_fd_table[i] = -1;
pr_debug("unlocked ion buf#[%d].\n", i);
}
}
} else {
/* unlock specific ION buf */
for (i = 0 ; i < ARRAY_SIZE(ch->ion_handle_table) ; i++) {
if (ch->ion_fd_table[i] == fd) {
pr_debug("unlocked ion buf #%d fd [%d].\n",
i, ch->ion_fd_table[i]);
ion_free(ion_client, ch->ion_handle_table[i]);
ch->ion_handle_table[i] = NULL;
ch->ion_fd_table[i] = -1;
pr_debug("unlocked ion buf#[%d].\n", i);
found = true;
break;
}