diff options
| author | Linux Build Service Account <lnxbuild@localhost> | 2016-12-30 06:27:19 -0800 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-12-30 06:27:19 -0800 |
| commit | 5ca83f157640b7d0eec452098052e4e4e3579899 (patch) | |
| tree | 405d35aca0624b6a360796c67b3265fb698d5dd3 | |
| parent | fa8941a5482d6c2a3d0c977f5782d81a6022c9ce (diff) | |
| parent | db1306a708582a3069c03e1c9de427fe805d122d (diff) | |
Merge "diag: Add sysfs parameter to control diag mask clear"
| -rw-r--r-- | drivers/char/diag/diag_usb.c | 4 | ||||
| -rw-r--r-- | drivers/char/diag/diagchar.h | 1 | ||||
| -rw-r--r-- | drivers/char/diag/diagchar_core.c | 16 | ||||
| -rw-r--r-- | drivers/char/diag/diagfwd.c | 22 |
4 files changed, 36 insertions, 7 deletions
diff --git a/drivers/char/diag/diag_usb.c b/drivers/char/diag/diag_usb.c index ca54b24ec604..0a0fc4400de5 100644 --- a/drivers/char/diag/diag_usb.c +++ b/drivers/char/diag/diag_usb.c @@ -14,6 +14,7 @@ #include <linux/init.h> #include <linux/module.h> #include <linux/device.h> +#include <linux/kernel.h> #include <linux/err.h> #include <linux/sched.h> #include <linux/ratelimit.h> @@ -218,7 +219,8 @@ static void usb_disconnect(struct diag_usb_info *ch) if (!ch) return; - if (!atomic_read(&ch->connected) && driver->usb_connected) + if (!atomic_read(&ch->connected) && + driver->usb_connected && diag_mask_param()) diag_clear_masks(NULL); if (ch && ch->ops && ch->ops->close) diff --git a/drivers/char/diag/diagchar.h b/drivers/char/diag/diagchar.h index 67db49badf21..1488f9dc4300 100644 --- a/drivers/char/diag/diagchar.h +++ b/drivers/char/diag/diagchar.h @@ -632,6 +632,7 @@ void diag_cmd_remove_reg(struct diag_cmd_reg_entry_t *entry, uint8_t proc); void diag_cmd_remove_reg_by_pid(int pid); void diag_cmd_remove_reg_by_proc(int proc); int diag_cmd_chk_polling(struct diag_cmd_reg_entry_t *entry); +int diag_mask_param(void); void diag_clear_masks(struct diag_md_session_t *info); void diag_record_stats(int type, int flag); diff --git a/drivers/char/diag/diagchar_core.c b/drivers/char/diag/diagchar_core.c index 76559633f387..9494314d18f0 100644 --- a/drivers/char/diag/diagchar_core.c +++ b/drivers/char/diag/diagchar_core.c @@ -144,6 +144,14 @@ module_param(max_clients, uint, 0); static struct timer_list drain_timer; static int timer_in_progress; +/* + * Diag Mask clear variable + * Used for clearing masks upon + * USB disconnection and stopping ODL + */ +static int diag_mask_clear_param = 1; +module_param(diag_mask_clear_param, int, 0644); + struct diag_apps_data_t { void *buf; uint32_t len; @@ -390,7 +398,10 @@ static uint32_t diag_translate_kernel_to_user_mask(uint32_t peripheral_mask) return ret; } - +int diag_mask_param(void) +{ + return diag_mask_clear_param; +} void diag_clear_masks(struct diag_md_session_t *info) { int ret; @@ -423,7 +434,8 @@ static void diag_close_logging_process(const int pid) if (!session_info) return; - diag_clear_masks(session_info); + if (diag_mask_clear_param) + diag_clear_masks(session_info); mutex_lock(&driver->diag_maskclear_mutex); driver->mask_clear = 1; diff --git a/drivers/char/diag/diagfwd.c b/drivers/char/diag/diagfwd.c index 876b455624b2..a7069bc0edf3 100644 --- a/drivers/char/diag/diagfwd.c +++ b/drivers/char/diag/diagfwd.c @@ -1232,6 +1232,8 @@ static int diagfwd_mux_open(int id, int mode) static int diagfwd_mux_close(int id, int mode) { + uint8_t i; + switch (mode) { case DIAG_USB_MODE: driver->usb_connected = 0; @@ -1252,10 +1254,22 @@ static int diagfwd_mux_close(int id, int mode) */ } else { /* - * With clearing of masks on ODL exit and - * USB disconnection, closing of the channel is - * not needed.This enables read and drop of stale packets. - */ + * With sysfs parameter to clear masks set, + * peripheral masks are cleared on ODL exit and + * USB disconnection and buffers are not marked busy. + * This enables read and drop of stale packets. + * + * With sysfs parameter to clear masks cleared, + * masks are not cleared and buffers are to be marked + * busy to ensure traffic generated by peripheral + * are not read + */ + if (!(diag_mask_param())) { + for (i = 0; i < NUM_PERIPHERALS; i++) { + diagfwd_close(i, TYPE_DATA); + diagfwd_close(i, TYPE_CMD); + } + } /* Re enable HDLC encoding */ pr_debug("diag: In %s, re-enabling HDLC encoding\n", __func__); |
