Loading drivers/char/diag/diag_memorydevice.c +35 −3 Original line number Diff line number Diff line /* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -240,13 +240,19 @@ int diag_md_copy_to_user(char __user *buf, int *pret, size_t buf_size, if (!ch->md_info_inited) continue; for (j = 0; j < ch->num_tbl_entries && !err; j++) { spin_lock_irqsave(&ch->lock, flags); entry = &ch->tbl[j]; if (entry->len <= 0 || entry->buf == NULL) if (entry->len <= 0 || entry->buf == NULL) { spin_unlock_irqrestore(&ch->lock, flags); continue; } peripheral = diag_md_get_peripheral(entry->ctx); if (peripheral < 0) if (peripheral < 0) { spin_unlock_irqrestore(&ch->lock, flags); goto drop_data; } spin_unlock_irqrestore(&ch->lock, flags); session_info = diag_md_session_get_peripheral(peripheral); if (!session_info) Loading Loading @@ -388,6 +394,32 @@ int diag_md_close_peripheral(int id, uint8_t peripheral) return 0; } int diag_md_close_device(int id) { int i; uint8_t found = 0; unsigned long flags; struct diag_md_info *ch = NULL; struct diag_buf_tbl_t *entry = NULL; if (id < 0 || id >= NUM_DIAG_MD_DEV || id >= DIAG_NUM_PROC) return -EINVAL; ch = &diag_md[id]; if (!ch || !ch->md_info_inited) return -EINVAL; spin_lock_irqsave(&ch->lock, flags); for (i = 0; i < ch->num_tbl_entries && !found; i++) { entry = &ch->tbl[i]; entry->buf = NULL; entry->len = 0; entry->ctx = 0; } spin_unlock_irqrestore(&ch->lock, flags); return 0; } int diag_md_init(void) { int i, j; Loading drivers/char/diag/diag_memorydevice.h +3 −1 Original line number Diff line number Diff line /* Copyright (c) 2014-2015, 2017-2018 The Linux Foundation. All rights reserved. /* Copyright (c) 2014-2015, 2017-2019 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -56,4 +56,6 @@ int diag_md_close_peripheral(int id, uint8_t peripheral); int diag_md_write(int id, unsigned char *buf, int len, int ctx); int diag_md_copy_to_user(char __user *buf, int *pret, size_t buf_size, struct diag_md_session_t *info); int diag_md_close_device(int id); #endif drivers/char/diag/diag_mux.c +17 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,8 @@ static struct diag_logger_ops usb_log_ops = { .close = diag_usb_disconnect_all, .queue_read = diag_usb_queue_read, .write = diag_usb_write, .close_peripheral = NULL .close_peripheral = NULL, .close_device = NULL }; static struct diag_logger_ops md_log_ops = { Loading @@ -50,6 +51,7 @@ static struct diag_logger_ops md_log_ops = { .queue_read = NULL, .write = diag_md_write, .close_peripheral = diag_md_close_peripheral, .close_device = diag_md_close_device }; static struct diag_logger_ops pcie_log_ops = { Loading Loading @@ -279,6 +281,20 @@ int diag_mux_close_peripheral(int proc, uint8_t peripheral) return 0; } int diag_mux_close_device(int proc) { struct diag_logger_t *logger = NULL; if (!diag_mux) return -EIO; logger = diag_mux->logger; if (logger && logger->log_ops && logger->log_ops->close_device) return logger->log_ops->close_device(proc); return 0; } int diag_mux_switch_logging(int *req_mode, int *peripheral_mask) { unsigned int new_mask = 0; Loading drivers/char/diag/diag_mux.h +2 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ struct diag_logger_ops { int (*queue_read)(int id); int (*write)(int id, unsigned char *buf, int len, int ctx); int (*close_peripheral)(int id, uint8_t peripheral); int (*close_device)(int id); }; struct diag_logger_t { Loading @@ -71,6 +72,7 @@ int diag_mux_register(int proc, int ctx, struct diag_mux_ops *ops); int diag_mux_queue_read(int proc); int diag_mux_write(int proc, unsigned char *buf, int len, int ctx); int diag_mux_close_peripheral(int proc, uint8_t peripheral); int diag_mux_close_device(int proc); int diag_mux_open_all(struct diag_logger_t *logger); int diag_mux_close_all(void); int diag_mux_switch_logging(int *new_mode, int *peripheral_mask); Loading drivers/char/diag/diagfwd_bridge.c +4 −0 Original line number Diff line number Diff line Loading @@ -172,6 +172,10 @@ int diag_remote_dev_open(int id) void diag_remote_dev_close(int id) { if (id < 0 || id >= NUM_REMOTE_DEV) return; diag_mux_close_device(BRIDGE_TO_MUX(id)); } int diag_remote_dev_read_done(int id, unsigned char *buf, int len) Loading Loading
drivers/char/diag/diag_memorydevice.c +35 −3 Original line number Diff line number Diff line /* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -240,13 +240,19 @@ int diag_md_copy_to_user(char __user *buf, int *pret, size_t buf_size, if (!ch->md_info_inited) continue; for (j = 0; j < ch->num_tbl_entries && !err; j++) { spin_lock_irqsave(&ch->lock, flags); entry = &ch->tbl[j]; if (entry->len <= 0 || entry->buf == NULL) if (entry->len <= 0 || entry->buf == NULL) { spin_unlock_irqrestore(&ch->lock, flags); continue; } peripheral = diag_md_get_peripheral(entry->ctx); if (peripheral < 0) if (peripheral < 0) { spin_unlock_irqrestore(&ch->lock, flags); goto drop_data; } spin_unlock_irqrestore(&ch->lock, flags); session_info = diag_md_session_get_peripheral(peripheral); if (!session_info) Loading Loading @@ -388,6 +394,32 @@ int diag_md_close_peripheral(int id, uint8_t peripheral) return 0; } int diag_md_close_device(int id) { int i; uint8_t found = 0; unsigned long flags; struct diag_md_info *ch = NULL; struct diag_buf_tbl_t *entry = NULL; if (id < 0 || id >= NUM_DIAG_MD_DEV || id >= DIAG_NUM_PROC) return -EINVAL; ch = &diag_md[id]; if (!ch || !ch->md_info_inited) return -EINVAL; spin_lock_irqsave(&ch->lock, flags); for (i = 0; i < ch->num_tbl_entries && !found; i++) { entry = &ch->tbl[i]; entry->buf = NULL; entry->len = 0; entry->ctx = 0; } spin_unlock_irqrestore(&ch->lock, flags); return 0; } int diag_md_init(void) { int i, j; Loading
drivers/char/diag/diag_memorydevice.h +3 −1 Original line number Diff line number Diff line /* Copyright (c) 2014-2015, 2017-2018 The Linux Foundation. All rights reserved. /* Copyright (c) 2014-2015, 2017-2019 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -56,4 +56,6 @@ int diag_md_close_peripheral(int id, uint8_t peripheral); int diag_md_write(int id, unsigned char *buf, int len, int ctx); int diag_md_copy_to_user(char __user *buf, int *pret, size_t buf_size, struct diag_md_session_t *info); int diag_md_close_device(int id); #endif
drivers/char/diag/diag_mux.c +17 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,8 @@ static struct diag_logger_ops usb_log_ops = { .close = diag_usb_disconnect_all, .queue_read = diag_usb_queue_read, .write = diag_usb_write, .close_peripheral = NULL .close_peripheral = NULL, .close_device = NULL }; static struct diag_logger_ops md_log_ops = { Loading @@ -50,6 +51,7 @@ static struct diag_logger_ops md_log_ops = { .queue_read = NULL, .write = diag_md_write, .close_peripheral = diag_md_close_peripheral, .close_device = diag_md_close_device }; static struct diag_logger_ops pcie_log_ops = { Loading Loading @@ -279,6 +281,20 @@ int diag_mux_close_peripheral(int proc, uint8_t peripheral) return 0; } int diag_mux_close_device(int proc) { struct diag_logger_t *logger = NULL; if (!diag_mux) return -EIO; logger = diag_mux->logger; if (logger && logger->log_ops && logger->log_ops->close_device) return logger->log_ops->close_device(proc); return 0; } int diag_mux_switch_logging(int *req_mode, int *peripheral_mask) { unsigned int new_mask = 0; Loading
drivers/char/diag/diag_mux.h +2 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ struct diag_logger_ops { int (*queue_read)(int id); int (*write)(int id, unsigned char *buf, int len, int ctx); int (*close_peripheral)(int id, uint8_t peripheral); int (*close_device)(int id); }; struct diag_logger_t { Loading @@ -71,6 +72,7 @@ int diag_mux_register(int proc, int ctx, struct diag_mux_ops *ops); int diag_mux_queue_read(int proc); int diag_mux_write(int proc, unsigned char *buf, int len, int ctx); int diag_mux_close_peripheral(int proc, uint8_t peripheral); int diag_mux_close_device(int proc); int diag_mux_open_all(struct diag_logger_t *logger); int diag_mux_close_all(void); int diag_mux_switch_logging(int *new_mode, int *peripheral_mask); Loading
drivers/char/diag/diagfwd_bridge.c +4 −0 Original line number Diff line number Diff line Loading @@ -172,6 +172,10 @@ int diag_remote_dev_open(int id) void diag_remote_dev_close(int id) { if (id < 0 || id >= NUM_REMOTE_DEV) return; diag_mux_close_device(BRIDGE_TO_MUX(id)); } int diag_remote_dev_read_done(int id, unsigned char *buf, int len) Loading