示例#1
0
/*
* @brief Open the specified channel for communication
*	- Send the OPEN_CONN command to the modem
*	- Return the operation status
*
* @param ch_ctx : The channel context to consider
*
* @return 0 when OK, error value otherwise
*/
int dlp_ctrl_open_channel(struct dlp_channel *ch_ctx)
{
	int ret = 0;
	unsigned char param1 = PARAM1(ch_ctx->tx.pdu_size);
	unsigned char param2 = PARAM2(ch_ctx->tx.pdu_size);
	struct dlp_ctrl_context *ctrl_ctx = DLP_CTRL_CTX;

	/* Send the OPEN_CONN command */
	ret = dlp_ctrl_cmd_send(ch_ctx,
				DLP_CMD_OPEN_CONN, DLP_CMD_ACK,
				DLP_CH_STATE_OPENING, DLP_CH_STATE_NONE,
				param1, param2, 0);

	/* Channel correctly opened ? */
	if (ret == 0) {
		unsigned long flags;

		spin_lock_irqsave(&ctrl_ctx->open_lock, flags);
		dlp_ctrl_set_channel_state(ch_ctx->hsi_channel,
				DLP_CH_STATE_OPENED);
		spin_unlock_irqrestore(&ctrl_ctx->open_lock, flags);

		/* Check if we have any waiting OPEN_CONN */
		ret = dlp_ctrl_send_ack_nack(ch_ctx);
	}

	return ret;
}
示例#2
0
/*
* @brief Close the specified channel
*	- Send the CLOSE_CONN command to the modem
*	- Return the operation status
*
* @param ch_ctx : The channel context to consider
*
* @return 0 when OK, error value otherwise
*/
int dlp_ctrl_close_channel(struct dlp_channel *ch_ctx)
{
	int state, ret = 0;
	unsigned char param3 = PARAM1(DLP_DIR_TRANSMIT_AND_RECEIVE);

	/* Reset the credits counter */
	ch_ctx->credits = 0;

	/* Reset the RX/TX seq_num */
	ch_ctx->rx.seq_num = 0;
	ch_ctx->tx.seq_num = 0;

	/* Check if the channel was correctly opened */
	state = dlp_ctrl_get_channel_state(ch_ctx->hsi_channel);
	if (state == DLP_CH_STATE_OPENED) {
		/* Send the command */
		ret = dlp_ctrl_cmd_send(ch_ctx,
				DLP_CMD_CLOSE_CONN, DLP_CMD_ACK,
				DLP_CH_STATE_CLOSING, DLP_CH_STATE_CLOSED,
				0, 0, param3);
	} else {
		pr_warn(DRVNAME ": Can't close CH%d (HSI CH%d) => invalid state: %d\n",
				ch_ctx->ch_id, ch_ctx->hsi_channel, state);
	}

	return ret;
}
示例#3
0
文件: w99685.c 项目: LucidOne/Rovio
void CommandDump(CmdReq_t *reqp, CmdParameters_t * paramp)
{
#ifdef COMMAND_DUMP	
	CmdParameters_t *cmdparamp = paramp;
	
	printk("subcmd: %4x, flag: %d\n", reqp->subcmd, reqp->flag);
	if(cmdparamp) {
		printk("param1: %2x, param2: %2x, param3: %2x, param4: %2x\n", PARAM1(cmdparamp), \
				PARAM2(cmdparamp), PARAM3(cmdparamp), PARAM4(cmdparamp));	
	}
#endif
}
示例#4
0
/*
* @brief Send the NOP command
*
* @param ch_ctx : The channel context to consider
*
* @return 0 when OK, error value otherwise
*/
int dlp_ctrl_send_nop(struct dlp_channel *ch_ctx)
{
	int ret;
	unsigned char param1, param2, param3;

	param1 = PARAM1(DLP_NOP_CMD_CHECKSUM);
	param2 = PARAM2(DLP_NOP_CMD_CHECKSUM);
	param3 = PARAM3(DLP_NOP_CMD_CHECKSUM);

	/* Send the NOP command */
	ret = dlp_ctrl_cmd_send(ch_ctx,
			DLP_CMD_NOP, DLP_CMD_NONE,
			DLP_CH_STATE_NONE, DLP_CH_STATE_NONE,
			param1, param2, param3);

	return ret;
}