diff --git a/drivers/soc/qcom/spcom.c b/drivers/soc/qcom/spcom.c index 9b71083e4f27..d91daa6a3456 100644 --- a/drivers/soc/qcom/spcom.c +++ b/drivers/soc/qcom/spcom.c @@ -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; }