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

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

Merge "usb: typec: ucsi: Optimise ucsi_unregister()"

parents cace7512 e4351849
Loading
Loading
Loading
Loading
+19 −21
Original line number Diff line number Diff line
@@ -48,7 +48,8 @@ struct ucsi_dp {
static int ucsi_displayport_enter(struct typec_altmode *alt)
{
	struct ucsi_dp *dp = typec_altmode_get_drvdata(alt);
	struct ucsi_control ctrl;
	struct ucsi *ucsi = dp->con->ucsi;
	u64 command;
	u8 cur = 0;
	int ret;

@@ -59,25 +60,21 @@ static int ucsi_displayport_enter(struct typec_altmode *alt)

		dev_warn(&p->dev,
			 "firmware doesn't support alternate mode overriding\n");
		mutex_unlock(&dp->con->lock);
		return -EOPNOTSUPP;
		ret = -EOPNOTSUPP;
		goto err_unlock;
	}

	UCSI_CMD_GET_CURRENT_CAM(ctrl, dp->con->num);
	ret = ucsi_send_command(dp->con->ucsi, &ctrl, &cur, sizeof(cur));
	command = UCSI_GET_CURRENT_CAM | UCSI_CONNECTOR_NUMBER(dp->con->num);
	ret = ucsi_send_command(ucsi, command, &cur, sizeof(cur));
	if (ret < 0) {
		if (dp->con->ucsi->ppm->data->version > 0x0100) {
			mutex_unlock(&dp->con->lock);
			return ret;
		}
		if (ucsi->version > 0x0100)
			goto err_unlock;
		cur = 0xff;
	}

	if (cur != 0xff) {
		mutex_unlock(&dp->con->lock);
		if (dp->con->port_altmode[cur] == alt)
			return 0;
		return -EBUSY;
		ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
		goto err_unlock;
	}

	/*
@@ -94,16 +91,17 @@ static int ucsi_displayport_enter(struct typec_altmode *alt)
	dp->vdo_size = 1;

	schedule_work(&dp->work);

	ret = 0;
err_unlock:
	mutex_unlock(&dp->con->lock);

	return 0;
	return ret;
}

static int ucsi_displayport_exit(struct typec_altmode *alt)
{
	struct ucsi_dp *dp = typec_altmode_get_drvdata(alt);
	struct ucsi_control ctrl;
	u64 command;
	int ret = 0;

	mutex_lock(&dp->con->lock);
@@ -117,8 +115,8 @@ static int ucsi_displayport_exit(struct typec_altmode *alt)
		goto out_unlock;
	}

	ctrl.raw_cmd = UCSI_CMD_SET_NEW_CAM(dp->con->num, 0, dp->offset, 0);
	ret = ucsi_send_command(dp->con->ucsi, &ctrl, NULL, 0);
	command = UCSI_CMD_SET_NEW_CAM(dp->con->num, 0, dp->offset, 0);
	ret = ucsi_send_command(dp->con->ucsi, command, NULL, 0);
	if (ret < 0)
		goto out_unlock;

@@ -172,14 +170,14 @@ static int ucsi_displayport_status_update(struct ucsi_dp *dp)
static int ucsi_displayport_configure(struct ucsi_dp *dp)
{
	u32 pins = DP_CONF_GET_PIN_ASSIGN(dp->data.conf);
	struct ucsi_control ctrl;
	u64 command;

	if (!dp->override)
		return 0;

	ctrl.raw_cmd = UCSI_CMD_SET_NEW_CAM(dp->con->num, 1, dp->offset, pins);
	command = UCSI_CMD_SET_NEW_CAM(dp->con->num, 1, dp->offset, pins);

	return ucsi_send_command(dp->con->ucsi, &ctrl, NULL, 0);
	return ucsi_send_command(dp->con->ucsi, command, NULL, 0);
}

static int ucsi_displayport_vdm(struct typec_altmode *alt,
+0 −11
Original line number Diff line number Diff line
@@ -33,17 +33,6 @@ const char *ucsi_cmd_str(u64 raw_cmd)
	return ucsi_cmd_strs[(cmd >= ARRAY_SIZE(ucsi_cmd_strs)) ? 0 : cmd];
}

static const char * const ucsi_ack_strs[] = {
	[0]				= "",
	[UCSI_ACK_EVENT]		= "event",
	[UCSI_ACK_CMD]			= "command",
};

const char *ucsi_ack_str(u8 ack)
{
	return ucsi_ack_strs[(ack >= ARRAY_SIZE(ucsi_ack_strs)) ? 0 : ack];
}

const char *ucsi_cci_str(u32 cci)
{
	if (cci & GENMASK(7, 0)) {
+13 −66
Original line number Diff line number Diff line
@@ -10,54 +10,18 @@
#include <linux/usb/typec_altmode.h>

const char *ucsi_cmd_str(u64 raw_cmd);
const char *ucsi_ack_str(u8 ack);
const char *ucsi_cci_str(u32 cci);
const char *ucsi_recipient_str(u8 recipient);

DECLARE_EVENT_CLASS(ucsi_log_ack,
	TP_PROTO(u8 ack),
	TP_ARGS(ack),
	TP_STRUCT__entry(
		__field(u8, ack)
	),
	TP_fast_assign(
		__entry->ack = ack;
	),
	TP_printk("ACK %s", ucsi_ack_str(__entry->ack))
);

DEFINE_EVENT(ucsi_log_ack, ucsi_ack,
	TP_PROTO(u8 ack),
	TP_ARGS(ack)
);

DECLARE_EVENT_CLASS(ucsi_log_control,
	TP_PROTO(struct ucsi_control *ctrl),
	TP_ARGS(ctrl),
	TP_STRUCT__entry(
		__field(u64, ctrl)
	),
	TP_fast_assign(
		__entry->ctrl = ctrl->raw_cmd;
	),
	TP_printk("control=%08llx (%s)", __entry->ctrl,
		ucsi_cmd_str(__entry->ctrl))
);

DEFINE_EVENT(ucsi_log_control, ucsi_command,
	TP_PROTO(struct ucsi_control *ctrl),
	TP_ARGS(ctrl)
);

DECLARE_EVENT_CLASS(ucsi_log_command,
	TP_PROTO(struct ucsi_control *ctrl, int ret),
	TP_ARGS(ctrl, ret),
	TP_PROTO(u64 command, int ret),
	TP_ARGS(command, ret),
	TP_STRUCT__entry(
		__field(u64, ctrl)
		__field(int, ret)
	),
	TP_fast_assign(
		__entry->ctrl = ctrl->raw_cmd;
		__entry->ctrl = command;
		__entry->ret = ret;
	),
	TP_printk("%s -> %s (err=%d)", ucsi_cmd_str(__entry->ctrl),
@@ -66,30 +30,13 @@ DECLARE_EVENT_CLASS(ucsi_log_command,
);

DEFINE_EVENT(ucsi_log_command, ucsi_run_command,
	TP_PROTO(struct ucsi_control *ctrl, int ret),
	TP_ARGS(ctrl, ret)
	TP_PROTO(u64 command, int ret),
	TP_ARGS(command, ret)
);

DEFINE_EVENT(ucsi_log_command, ucsi_reset_ppm,
	TP_PROTO(struct ucsi_control *ctrl, int ret),
	TP_ARGS(ctrl, ret)
);

DECLARE_EVENT_CLASS(ucsi_log_cci,
	TP_PROTO(u32 cci),
	TP_ARGS(cci),
	TP_STRUCT__entry(
		__field(u32, cci)
	),
	TP_fast_assign(
		__entry->cci = cci;
	),
	TP_printk("CCI=%08x %s", __entry->cci, ucsi_cci_str(__entry->cci))
);

DEFINE_EVENT(ucsi_log_cci, ucsi_notify,
	TP_PROTO(u32 cci),
	TP_ARGS(cci)
	TP_PROTO(u64 command, int ret),
	TP_ARGS(command, ret)
);

DECLARE_EVENT_CLASS(ucsi_log_connector_status,
@@ -109,13 +56,13 @@ DECLARE_EVENT_CLASS(ucsi_log_connector_status,
	TP_fast_assign(
		__entry->port = port - 1;
		__entry->change = status->change;
		__entry->opmode = status->pwr_op_mode;
		__entry->connected = status->connected;
		__entry->pwr_dir = status->pwr_dir;
		__entry->partner_flags = status->partner_flags;
		__entry->partner_type = status->partner_type;
		__entry->opmode = UCSI_CONSTAT_PWR_OPMODE(status->flags);
		__entry->connected = !!(status->flags & UCSI_CONSTAT_CONNECTED);
		__entry->pwr_dir = !!(status->flags & UCSI_CONSTAT_PWR_DIR);
		__entry->partner_flags = UCSI_CONSTAT_PARTNER_FLAGS(status->flags);
		__entry->partner_type = UCSI_CONSTAT_PARTNER_TYPE(status->flags);
		__entry->request_data_obj = status->request_data_obj;
		__entry->bc_status = status->bc_status;
		__entry->bc_status = UCSI_CONSTAT_BC_STATUS(status->pwr_status);
	),
	TP_printk("port%d status: change=%04x, opmode=%x, connected=%d, "
		"sourcing=%d, partner_flags=%x, partner_type=%x, "
Loading