Skip to content

Commit

Permalink
usb: typec: ucsi: Remove struct ucsi_control
Browse files Browse the repository at this point in the history
That data structure was used for constructing the commands
before executing them, but it was never really useful. Using
the structure just complicated the driver. The commands are
64-bit wide, so it is enough to simply fill a u64 variable.
No data structures needed.

This simplifies the driver considerable and makes it much
easier to for example add support for big endian systems
later on.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Tested-by: Ajay Gupta <ajayg@nvidia.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20191104142435.29960-16-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Heikki Krogerus authored and Greg Kroah-Hartman committed Nov 4, 2019
1 parent 2ede554 commit 470ce43
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 300 deletions.
16 changes: 8 additions & 8 deletions drivers/usb/typec/ucsi/displayport.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static int ucsi_displayport_enter(struct typec_altmode *alt)
{
struct ucsi_dp *dp = typec_altmode_get_drvdata(alt);
struct ucsi *ucsi = dp->con->ucsi;
struct ucsi_control ctrl;
u64 command;
u8 cur = 0;
int ret;

Expand All @@ -64,7 +64,7 @@ static int ucsi_displayport_enter(struct typec_altmode *alt)
goto err_unlock;
}

UCSI_CMD_GET_CURRENT_CAM(ctrl, dp->con->num);
command = UCSI_GET_CURRENT_CAM | UCSI_CONNECTOR_NUMBER(dp->con->num);
ret = ucsi_send_command(ucsi, command, &cur, sizeof(cur));
if (ret < 0) {
if (ucsi->version > 0x0100)
Expand Down Expand Up @@ -101,7 +101,7 @@ static int ucsi_displayport_enter(struct typec_altmode *alt)
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);
Expand All @@ -115,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;

Expand Down Expand Up @@ -170,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,
Expand Down
11 changes: 0 additions & 11 deletions drivers/usb/typec/ucsi/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
50 changes: 7 additions & 43 deletions drivers/usb/typec/ucsi/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -66,13 +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)
TP_PROTO(u64 command, int ret),
TP_ARGS(command, ret)
);

DECLARE_EVENT_CLASS(ucsi_log_connector_status,
Expand Down
Loading

0 comments on commit 470ce43

Please sign in to comment.