msm: qti_sdio_client: Return error number in diag callback

Return error number in the diag callback to handle it in calback's
error handling sequence. This potentially fixes a memory leak when
device is reenumerated multiple times such as during SSR.

Change-Id: I841d07dfa2f3231e54c5145f27dda977fa8c9f97
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
This commit is contained in:
Amandeep Singh 2019-09-12 15:14:37 +05:30
parent e53bd39000
commit a08ceb359a

View file

@ -88,9 +88,9 @@ static DEFINE_MUTEX(work_lock);
static spinlock_t list_lock;
#define qlog(qsb, _msg, ...) do { \
if (to_console) \
pr_err("[%s] " _msg, __func__, ##__VA_ARGS__); \
if (ipc_log) \
if (!qsb ? 1 : to_console) \
pr_err("[%s] " _msg, __func__, ##__VA_ARGS__); \
if (qsb && ipc_log) \
ipc_log_string(qsb->ipc_log_ctxt, "[%s] " _msg, __func__, \
##__VA_ARGS__); \
} while (0)
@ -438,8 +438,10 @@ int qti_client_read(int id, char *buf, size_t count)
wait_event(qsb->wait_q, qsb->data_avail ||
atomic_read(&qsb->is_client_closing));
if (atomic_read(&qsb->is_client_closing))
return count;
if (atomic_read(&qsb->is_client_closing)) {
ret = -ENODEV;
goto out;
}
bytes = qsb->data_avail;
@ -484,7 +486,7 @@ out:
if (id == QCN_SDIO_CLI_ID_DIAG && qsb->ops &&
qsb->ops->read_complete_cb) {
qsb->ops->read_complete_cb((void *)(uintptr_t)0, buf, count,
count);
ret < 0 ? ret : count);
}
if (!qsb->data_remain) {
@ -593,8 +595,10 @@ int qti_client_write(int id, char *buf, size_t count)
wait_event(qsb->wait_q, qsb->tx_ready ||
atomic_read(&qsb->is_client_closing));
if (atomic_read(&qsb->is_client_closing))
return count;
if (atomic_read(&qsb->is_client_closing)) {
ret = -ENODEV;
goto out;
}
if (qsb->mode) {
reinit_completion(&tx_complete);
@ -627,10 +631,11 @@ int qti_client_write(int id, char *buf, size_t count)
buffer = buffer + temp_count;
}
out:
if (id == QCN_SDIO_CLI_ID_DIAG && qsb->ops &&
qsb->ops->write_complete_cb) {
qsb->ops->write_complete_cb((void *)(uintptr_t)0, buf, count,
count);
ret < 0 ? ret : count);
}
return count;