From 4bcef711d14b12fbb950579c3d3841b761c1530b Mon Sep 17 00:00:00 2001 From: Jack Pham Date: Tue, 1 Aug 2017 17:36:50 -0700 Subject: [PATCH] usb: pd: rename enum pd_msg_type to pd_sop_type This enum is used to specify what packet type (SOP, SOP', SOP'') to the PD PHY when sending and receiving messages. To avoid confusion with the message type field of a message header (e.g. MSG_REQUEST, MSG_ACCEPT, etc), rename the enum to pd_sop_type and change the parameter name from 'type' to 'sop'. Also change the enum pd_sig_type parameter name to 'sig' for similar clarity. This patch is cosmetic, no functional changes. Change-Id: Idf74f7635ec5afee3538815f2efd9bc032ee6d89 Signed-off-by: Jack Pham --- drivers/usb/pd/policy_engine.c | 20 ++++++++++---------- drivers/usb/pd/qpnp-pdphy.c | 20 ++++++++++---------- drivers/usb/pd/usbpd.h | 12 ++++++------ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/usb/pd/policy_engine.c b/drivers/usb/pd/policy_engine.c index 0cbe95304417..a8610b152e33 100644 --- a/drivers/usb/pd/policy_engine.c +++ b/drivers/usb/pd/policy_engine.c @@ -481,15 +481,15 @@ static inline void pd_reset_protocol(struct usbpd *pd) pd->send_dr_swap = false; } -static int pd_send_msg(struct usbpd *pd, u8 hdr_type, const u32 *data, - size_t num_data, enum pd_msg_type type) +static int pd_send_msg(struct usbpd *pd, u8 msg_type, const u32 *data, + size_t num_data, enum pd_sop_type sop) { int ret; u16 hdr; - hdr = PD_MSG_HDR(hdr_type, pd->current_dr, pd->current_pr, + hdr = PD_MSG_HDR(msg_type, pd->current_dr, pd->current_pr, pd->tx_msgid, num_data, pd->spec_rev); - ret = pd_phy_write(hdr, (u8 *)data, num_data * sizeof(u32), type, 15); + ret = pd_phy_write(hdr, (u8 *)data, num_data * sizeof(u32), sop, 15); /* TODO figure out timeout. based on tReceive=1.1ms x nRetryCount? */ if (ret < 0) @@ -612,12 +612,12 @@ static void kick_sm(struct usbpd *pd, int ms) queue_work(pd->wq, &pd->sm_work); } -static void phy_sig_received(struct usbpd *pd, enum pd_sig_type type) +static void phy_sig_received(struct usbpd *pd, enum pd_sig_type sig) { union power_supply_propval val = {1}; - if (type != HARD_RESET_SIG) { - usbpd_err(&pd->dev, "invalid signal (%d) received\n", type); + if (sig != HARD_RESET_SIG) { + usbpd_err(&pd->dev, "invalid signal (%d) received\n", sig); return; } @@ -632,16 +632,16 @@ static void phy_sig_received(struct usbpd *pd, enum pd_sig_type type) kick_sm(pd, 0); } -static void phy_msg_received(struct usbpd *pd, enum pd_msg_type type, +static void phy_msg_received(struct usbpd *pd, enum pd_sop_type sop, u8 *buf, size_t len) { struct rx_msg *rx_msg; unsigned long flags; u16 header; - if (type != SOP_MSG) { + if (sop != SOP_MSG) { usbpd_err(&pd->dev, "invalid msg type (%d) received; only SOP supported\n", - type); + sop); return; } diff --git a/drivers/usb/pd/qpnp-pdphy.c b/drivers/usb/pd/qpnp-pdphy.c index e200c25bc23a..f30261e543ba 100644 --- a/drivers/usb/pd/qpnp-pdphy.c +++ b/drivers/usb/pd/qpnp-pdphy.c @@ -96,8 +96,8 @@ struct usb_pdphy { int msg_tx_discarded_irq; int msg_rx_discarded_irq; - void (*signal_cb)(struct usbpd *pd, enum pd_sig_type type); - void (*msg_rx_cb)(struct usbpd *pd, enum pd_msg_type type, + void (*signal_cb)(struct usbpd *pd, enum pd_sig_type sig); + void (*msg_rx_cb)(struct usbpd *pd, enum pd_sop_type sop, u8 *buf, size_t len); void (*shutdown_cb)(struct usbpd *pd); @@ -401,13 +401,13 @@ int pd_phy_open(struct pd_phy_params *params) } EXPORT_SYMBOL(pd_phy_open); -int pd_phy_signal(enum pd_sig_type type, unsigned int timeout_ms) +int pd_phy_signal(enum pd_sig_type sig, unsigned int timeout_ms) { u8 val; int ret; struct usb_pdphy *pdphy = __pdphy; - dev_dbg(pdphy->dev, "%s: type %d timeout %u\n", __func__, type, + dev_dbg(pdphy->dev, "%s: type %d timeout %u\n", __func__, sig, timeout_ms); if (!pdphy) { @@ -428,7 +428,7 @@ int pd_phy_signal(enum pd_sig_type type, unsigned int timeout_ms) usleep_range(2, 3); - val = (type == CABLE_RESET_SIG ? TX_CONTROL_FRAME_TYPE_CABLE_RESET : 0) + val = (sig == CABLE_RESET_SIG ? TX_CONTROL_FRAME_TYPE_CABLE_RESET : 0) | TX_CONTROL_SEND_SIGNAL; ret = pdphy_reg_write(pdphy, USB_PDPHY_TX_CONTROL, val); @@ -447,7 +447,7 @@ int pd_phy_signal(enum pd_sig_type type, unsigned int timeout_ms) if (pdphy->tx_status) return pdphy->tx_status; - if (type == HARD_RESET_SIG) + if (sig == HARD_RESET_SIG) /* Frame filter is reconfigured in pd_phy_open() */ return pdphy_reg_write(pdphy, USB_PDPHY_FRAME_FILTER, 0); @@ -456,15 +456,15 @@ int pd_phy_signal(enum pd_sig_type type, unsigned int timeout_ms) EXPORT_SYMBOL(pd_phy_signal); int pd_phy_write(u16 hdr, const u8 *data, size_t data_len, - enum pd_msg_type type, unsigned int timeout_ms) + enum pd_sop_type sop, unsigned int timeout_ms) { u8 val; int ret; size_t total_len = data_len + USB_PDPHY_MSG_HDR_LEN; struct usb_pdphy *pdphy = __pdphy; - dev_dbg(pdphy->dev, "%s: hdr %x frame type %d timeout %u\n", - __func__, hdr, type, timeout_ms); + dev_dbg(pdphy->dev, "%s: hdr %x frame sop_type %d timeout %u\n", + __func__, hdr, sop, timeout_ms); if (data && data_len) print_hex_dump_debug("tx data obj:", DUMP_PREFIX_NONE, 32, 4, @@ -518,7 +518,7 @@ int pd_phy_write(u16 hdr, const u8 *data, size_t data_len, usleep_range(2, 3); - val = TX_CONTROL_RETRY_COUNT | (type << 2) | TX_CONTROL_SEND_MSG; + val = TX_CONTROL_RETRY_COUNT | (sop << 2) | TX_CONTROL_SEND_MSG; ret = pdphy_reg_write(pdphy, USB_PDPHY_TX_CONTROL, val); if (ret) diff --git a/drivers/usb/pd/usbpd.h b/drivers/usb/pd/usbpd.h index 108701739f89..6b323e238aad 100644 --- a/drivers/usb/pd/usbpd.h +++ b/drivers/usb/pd/usbpd.h @@ -45,7 +45,7 @@ enum pd_sig_type { CABLE_RESET_SIG, }; -enum pd_msg_type { +enum pd_sop_type { SOP_MSG = 0, SOPI_MSG, SOPII_MSG, @@ -61,8 +61,8 @@ enum pd_spec_rev { #define FRAME_FILTER_EN_HARD_RESET BIT(5) struct pd_phy_params { - void (*signal_cb)(struct usbpd *pd, enum pd_sig_type type); - void (*msg_rx_cb)(struct usbpd *pd, enum pd_msg_type type, + void (*signal_cb)(struct usbpd *pd, enum pd_sig_type sig); + void (*msg_rx_cb)(struct usbpd *pd, enum pd_sop_type sop, u8 *buf, size_t len); void (*shutdown_cb)(struct usbpd *pd); enum data_role data_role; @@ -72,9 +72,9 @@ struct pd_phy_params { #if IS_ENABLED(CONFIG_QPNP_USB_PDPHY) int pd_phy_open(struct pd_phy_params *params); -int pd_phy_signal(enum pd_sig_type type, unsigned int timeout_ms); +int pd_phy_signal(enum pd_sig_type sig, unsigned int timeout_ms); int pd_phy_write(u16 hdr, const u8 *data, size_t data_len, - enum pd_msg_type type, unsigned int timeout_ms); + enum pd_sop_type sop, unsigned int timeout_ms); int pd_phy_update_roles(enum data_role dr, enum power_role pr); void pd_phy_close(void); #else @@ -89,7 +89,7 @@ static inline int pd_phy_signal(enum pd_sig_type type, unsigned int timeout_ms) } static inline int pd_phy_write(u16 hdr, const u8 *data, size_t data_len, - enum pd_msg_type type, unsigned int timeout_ms) + enum pd_sop_type sop, unsigned int timeout_ms) { return -ENODEV; }