Skip to content

Commit 65145a0

Browse files
lumaggregkh
authored andcommitted
usb: typec: qcom-pmic-typec: fix arguments of qcom_pmic_typec_pdphy_set_roles
The function qcom_pmic_typec_set_roles() passes enum values as boolean values to qcom_pmic_typec_pdphy_set_roles(), which then interprets them as bit values. Be more explicit about it, pass enum values directly and compute corresponding bit masks in qcom_pmic_typec_pdphy_set_roles(). Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Link: https://lore.kernel.org/r/20240113-pmi632-typec-v2-6-182d9aa0a5b3@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 43a0297 commit 65145a0

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static int qcom_pmic_typec_set_roles(struct tcpc_dev *tcpc, bool attached,
123123
struct pmic_typec *tcpm = tcpc_to_tcpm(tcpc);
124124

125125
return qcom_pmic_typec_pdphy_set_roles(tcpm->pmic_typec_pdphy,
126-
data_role, power_role);
126+
power_role, data_role);
127127
}
128128

129129
static int qcom_pmic_typec_set_pd_rx(struct tcpc_dev *tcpc, bool on)

drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ int qcom_pmic_typec_pdphy_set_pd_rx(struct pmic_typec_pdphy *pmic_typec_pdphy, b
354354
}
355355

356356
int qcom_pmic_typec_pdphy_set_roles(struct pmic_typec_pdphy *pmic_typec_pdphy,
357-
bool data_role_host, bool power_role_src)
357+
enum typec_role power_role,
358+
enum typec_data_role data_role)
358359
{
359360
struct device *dev = pmic_typec_pdphy->dev;
360361
unsigned long flags;
@@ -366,12 +367,13 @@ int qcom_pmic_typec_pdphy_set_roles(struct pmic_typec_pdphy *pmic_typec_pdphy,
366367
pmic_typec_pdphy->base + USB_PDPHY_MSG_CONFIG_REG,
367368
MSG_CONFIG_PORT_DATA_ROLE |
368369
MSG_CONFIG_PORT_POWER_ROLE,
369-
data_role_host << 3 | power_role_src << 2);
370+
(data_role == TYPEC_HOST ? MSG_CONFIG_PORT_DATA_ROLE : 0) |
371+
(power_role == TYPEC_SOURCE ? MSG_CONFIG_PORT_POWER_ROLE : 0));
370372

371373
spin_unlock_irqrestore(&pmic_typec_pdphy->lock, flags);
372374

373375
dev_dbg(dev, "pdphy_set_roles: data_role_host=%d power_role_src=%d\n",
374-
data_role_host, power_role_src);
376+
data_role, power_role);
375377

376378
return ret;
377379
}

drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ int qcom_pmic_typec_pdphy_start(struct pmic_typec_pdphy *pmic_typec_pdphy,
107107
void qcom_pmic_typec_pdphy_stop(struct pmic_typec_pdphy *pmic_typec_pdphy);
108108

109109
int qcom_pmic_typec_pdphy_set_roles(struct pmic_typec_pdphy *pmic_typec_pdphy,
110-
bool power_role_src, bool data_role_host);
110+
enum typec_role power_role,
111+
enum typec_data_role data_role);
111112

112113
int qcom_pmic_typec_pdphy_set_pd_rx(struct pmic_typec_pdphy *pmic_typec_pdphy, bool on);
113114

0 commit comments

Comments
 (0)