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

Commit a2ebf03e authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "wigig_sensing: fix driver state machine"

parents 9ba050d8 f92a7e71
Loading
Loading
Loading
Loading
+26 −11
Original line number Diff line number Diff line
@@ -454,9 +454,11 @@ static int wigig_sensing_change_state(struct wigig_sensing_ctx *ctx,

	/*
	 * Moving from INITIALIZED state is allowed only to READY_STOPPED state
	 * and only when spi_ready is set
	 */
	else if (curr_state == WIGIG_SENSING_STATE_INITIALIZED &&
	    new_state != WIGIG_SENSING_STATE_READY_STOPPED) {
		 (new_state != WIGIG_SENSING_STATE_READY_STOPPED ||
		  !ctx->stm.spi_ready)) {
		transition_allowed = false;
		rc = -EFAULT;
	}
@@ -514,22 +516,25 @@ static int wigig_sensing_ioc_get_mode(struct wigig_sensing_ctx *ctx)
}

static int wigig_sensing_ioc_change_mode(struct wigig_sensing_ctx *ctx,
					 struct wigig_sensing_change_mode req)
					 struct wigig_sensing_change_mode *req)
{
	struct wigig_sensing_stm sim_state;
	int rc;
	u32 ch;

	if (req == NULL)
		return -EINVAL;

	pr_info("mode = %d, channel = %d, has_channel = %d\n",
		req.mode, req.channel, req.has_channel);
		req->mode, req->channel, req->has_channel);
	if (!ctx)
		return -EINVAL;

	/* Save the request for later use */
	ctx->stm.mode_request = req.mode;
	ctx->stm.mode_request = req->mode;

	/* Simulate a state change */
	ctx->stm.state_request = convert_mode_to_state(req.mode);
	ctx->stm.state_request = convert_mode_to_state(req->mode);
	sim_state = ctx->stm;
	rc = wigig_sensing_change_state(ctx, &sim_state,
					ctx->stm.state_request);
@@ -541,11 +546,11 @@ static int wigig_sensing_ioc_change_mode(struct wigig_sensing_ctx *ctx,
	/* Send command to FW */
	mutex_lock(&ctx->dri_lock);
	ctx->stm.change_mode_in_progress = true;
	ch = req.has_channel ? req.channel : 0;
	ch = req->has_channel ? req->channel : 0;
	ctx->stm.channel_request = ch;
	ctx->stm.burst_size_ready = false;
	/* Change mode command must not be called during DRI processing */
	rc = wigig_sensing_send_change_mode_command(ctx, req.mode, ch);
	rc = wigig_sensing_send_change_mode_command(ctx, req->mode, ch);
	mutex_unlock(&ctx->dri_lock);
	if (rc) {
		pr_err("wigig_sensing_send_change_mode_command() failed, err %d\n",
@@ -585,7 +590,9 @@ static int wigig_sensing_ioc_change_mode(struct wigig_sensing_ctx *ctx,
	ctx->stm.state_request = WIGIG_SENSING_STATE_MIN;
	ctx->stm.channel_request = 0;
	ctx->stm.mode_request = WIGIG_SENSING_MODE_STOP;
	return (rc == 0) ? ctx->stm.burst_size : rc;
	req->burst_size = ctx->stm.burst_size;

	return rc;
}

static int wigig_sensing_ioc_clear_data(struct wigig_sensing_ctx *ctx)
@@ -808,7 +815,11 @@ static long wigig_sensing_ioctl(struct file *file, unsigned int cmd,
		if (copy_from_user(&req, (void *)arg, sizeof(req)))
			return -EFAULT;

		rc = wigig_sensing_ioc_change_mode(ctx, req);
		rc = wigig_sensing_ioc_change_mode(ctx, &req);

		if (copy_to_user((void *)arg, &req, sizeof(req)))
			return -EFAULT;

		break;
	}
	case WIGIG_SENSING_IOCTL_CLEAR_DATA:
@@ -1246,9 +1257,11 @@ static irqreturn_t wigig_sensing_dri_isr_thread(int irq, void *cookie)
			}

			ctx->stm.spi_malfunction = false;
			if (ctx->stm.state == WIGIG_SENSING_STATE_INITIALIZED)
			if (ctx->stm.state == WIGIG_SENSING_STATE_INITIALIZED) {
				wigig_sensing_change_state(ctx, &ctx->stm,
					WIGIG_SENSING_STATE_READY_STOPPED);
				ctx->stm.spi_ready = true;
			}
		}

		pr_debug("Reading SANITY register\n");
@@ -1304,6 +1317,7 @@ static irqreturn_t wigig_sensing_dri_isr_thread(int irq, void *cookie)
						 WIGIG_SENSING_EVENT_RESET);

		ctx->stm.spi_malfunction = true;
		ctx->stm.spi_ready = false;
		memset(&ctx->inb_cmd, 0, sizeof(ctx->inb_cmd));
		spi_status.v &= ~INT_SYSASSERT;
		goto deassert_and_bail_out;
@@ -1483,10 +1497,11 @@ static int wigig_sensing_remove(struct spi_device *spi)
		.mode = WIGIG_SENSING_MODE_STOP,
		.has_channel = false,
		.channel = 0,
		.burst_size = 0,
	};

	/* Make sure that FW is in STOP mode */
	wigig_sensing_ioc_change_mode(ctx, req);
	wigig_sensing_ioc_change_mode(ctx, &req);

	device_destroy(ctx->class, ctx->wigig_sensing_dev);
	unregister_chrdev_region(ctx->wigig_sensing_dev, 1);
+1 −0
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ struct wigig_sensing_stm {
	bool auto_recovery;
	bool fw_is_ready;
	bool spi_malfunction;
	bool spi_ready;
	bool waiting_for_deep_sleep_exit;
	bool waiting_for_deep_sleep_exit_first_pass;
	bool burst_size_ready;
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ struct wigig_sensing_change_mode {
	enum wigig_sensing_mode mode;
	bool has_channel;
	uint32_t channel;
	uint32_t burst_size;
};

enum wigig_sensing_event {