diag: Add Subsystem restart support
DIAG char driver maintains registrations for remote processors in a table.
When the remote processor goes down, the registrations should be cleaned
up. This change adds the clean up process in event of a restart.
Change-Id: I191099242bb9997efe5612a8b02ca3dc17f096ff
CRs-Fixed: 311580
Signed-off-by: Shalabh Jain <shalabhj@codeaurora.org>
diff --git a/drivers/char/diag/diagchar_core.c b/drivers/char/diag/diagchar_core.c
index 6fa043c..eabdb4f 100644
--- a/drivers/char/diag/diagchar_core.c
+++ b/drivers/char/diag/diagchar_core.c
@@ -253,7 +253,18 @@
return -ENOMEM;
}
-void diag_fill_reg_table(int j, struct bindpkt_params *params,
+void diag_clear_reg(int proc_num)
+{
+ int i;
+
+ for (i = 0; i < diag_max_registration; i++) {
+ if (driver->table[i].client_id == proc_num) {
+ driver->table[i].process_id = 0;
+ }
+ }
+}
+
+void diag_add_reg(int j, struct bindpkt_params *params,
int *success, int *count_entries)
{
*success = 1;
@@ -284,7 +295,7 @@
mutex_lock(&driver->diagchar_mutex);
for (i = 0; i < diag_max_registration; i++) {
if (driver->table[i].process_id == 0) {
- diag_fill_reg_table(i, pkt_params->params,
+ diag_add_reg(i, pkt_params->params,
&success, &count_entries);
if (pkt_params->count > count_entries) {
pkt_params->params++;
@@ -315,7 +326,7 @@
driver->table = temp_buf;
}
for (j = i; j < diag_max_registration; j++) {
- diag_fill_reg_table(j, pkt_params->params,
+ diag_add_reg(j, pkt_params->params,
&success, &count_entries);
if (pkt_params->count > count_entries) {
pkt_params->params++;
diff --git a/drivers/char/diag/diagfwd.c b/drivers/char/diag/diagfwd.c
index e49d57c..226e5b5 100644
--- a/drivers/char/diag/diagfwd.c
+++ b/drivers/char/diag/diagfwd.c
@@ -1129,7 +1129,11 @@
static void diag_smd_notify(void *ctxt, unsigned event)
{
- queue_work(driver->diag_wq, &(driver->diag_read_smd_work));
+ if (event == SMD_EVENT_CLOSE) {
+ pr_info("diag: clean modem registration\n");
+ diag_clear_reg(MODEM_PROC);
+ } else
+ queue_work(driver->diag_wq, &(driver->diag_read_smd_work));
}
#if defined(CONFIG_MSM_N_WAY_SMD)
diff --git a/drivers/char/diag/diagfwd.h b/drivers/char/diag/diagfwd.h
index cc24cbc..0a271dd 100644
--- a/drivers/char/diag/diagfwd.h
+++ b/drivers/char/diag/diagfwd.h
@@ -27,6 +27,7 @@
int diag_device_write(void *, int, struct diag_request *);
int mask_request_validate(unsigned char mask_buf[]);
int chk_config_get_id(void);
+void diag_clear_reg(int);
/* State for diag forwarding */
#ifdef CONFIG_DIAG_OVER_USB
int diagfwd_connect(void);