Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ccbf71d authored by Katish Paran's avatar Katish Paran Committed by Ravi Aravamudhan
Browse files

diag: Check for feature mask status before sending any command



Currently, APPS diag may send commands to peripherals even before
forwarding feature mask. This patch adds new check which ensures
that any command is sent to peripheral only after forwarding
feature mask.

Change-Id: I024ad6d3bcb2636f6f7d82a3744f034110ec1eb6
Signed-off-by: default avatarKatish Paran <kparan@codeaurora.org>
parent 58d6bfbe
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ static ssize_t diag_dbgfs_read_status(struct file *file, char __user *ubuf,

	for (i = 0; i < NUM_PERIPHERALS; i++) {
		ret += scnprintf(buf+ret, buf_size-ret,
			"p: %s Feature: %02x %02x |%c%c%c%c%c%c%c|\n",
			"p: %s Feature: %02x %02x |%c%c%c%c%c%c%c%c|\n",
			PERIPHERAL_STRING(i),
			driver->feature[i].feature_mask[0],
			driver->feature[i].feature_mask[1],
@@ -89,7 +89,8 @@ static ssize_t diag_dbgfs_read_status(struct file *file, char __user *ubuf,
			driver->feature[i].peripheral_buffering ? 'B':'b',
			driver->feature[i].mask_centralization ? 'M':'m',
			driver->feature[i].stm_support ? 'Q':'q',
			driver->feature[i].sockets_enabled ? 'S':'s');
			driver->feature[i].sockets_enabled ? 'S':'s',
			driver->feature[i].sent_feature_mask ? 'T':'t');
	}

#ifdef CONFIG_DIAG_OVER_USB
+3 −0
Original line number Diff line number Diff line
@@ -386,7 +386,10 @@ static void diag_send_feature_mask_update(uint8_t peripheral)
		pr_err("diag: In %s, unable to write to peripheral: %d, type: %d, len: %d, err: %d\n",
		       __func__, peripheral, TYPE_CNTL,
		       total_len, err);
		mutex_unlock(&driver->diag_cntl_mutex);
		return;
	}
	driver->feature[peripheral].sent_feature_mask = 1;
	mutex_unlock(&driver->diag_cntl_mutex);
}

+1 −0
Original line number Diff line number Diff line
@@ -378,6 +378,7 @@ struct diag_feature_t {
	uint8_t mask_centralization;
	uint8_t stm_support;
	uint8_t sockets_enabled;
	uint8_t sent_feature_mask;
};

struct diagchar_dev {
+1 −0
Original line number Diff line number Diff line
@@ -1357,6 +1357,7 @@ int diagfwd_init(void)
		driver->feature[i].encode_hdlc = 0;
		driver->feature[i].mask_centralization = 0;
		driver->feature[i].log_on_demand = 0;
		driver->feature[i].sent_feature_mask = 0;
		driver->buffering_mode[i].peripheral = i;
		driver->buffering_mode[i].mode = DIAG_BUFFERING_MODE_STREAMING;
		driver->buffering_mode[i].high_wm_val = DEFAULT_HIGH_WM_VAL;
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ void diag_cntl_channel_close(struct diagfwd_info *p_info)
	driver->feature[peripheral].rcvd_feature_mask = 0;
	driver->feature[peripheral].stm_support = DISABLE_STM;
	driver->feature[peripheral].log_on_demand = 0;
	driver->feature[peripheral].sent_feature_mask = 0;
	driver->stm_state[peripheral] = DISABLE_STM;
	driver->stm_state_requested[peripheral] = DISABLE_STM;
	reg_dirty ^= PERIPHERAL_MASK(peripheral);
Loading