usb: typec: qcom-pmic-typec: fix arguments of qcom_pmic_typec_pdphy_set_roles
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Sat, 13 Jan 2024 20:55:49 +0000 (22:55 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 28 Jan 2024 01:46:19 +0000 (17:46 -0800)
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>
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.h

index 1a2b4bddaa97e86da87b18ae5174413e3238af6a..a243648abb4a590d41c9567df56801ddab4a17c7 100644 (file)
@@ -123,7 +123,7 @@ static int qcom_pmic_typec_set_roles(struct tcpc_dev *tcpc, bool attached,
        struct pmic_typec *tcpm = tcpc_to_tcpm(tcpc);
 
        return qcom_pmic_typec_pdphy_set_roles(tcpm->pmic_typec_pdphy,
-                                              data_role, power_role);
+                                              power_role, data_role);
 }
 
 static int qcom_pmic_typec_set_pd_rx(struct tcpc_dev *tcpc, bool on)
index a3154085ae32ee3259f4c944f7d7bc20131792eb..e977f98b7d61b6806cdbfc9860ec47feef02080a 100644 (file)
@@ -354,7 +354,8 @@ int qcom_pmic_typec_pdphy_set_pd_rx(struct pmic_typec_pdphy *pmic_typec_pdphy, b
 }
 
 int qcom_pmic_typec_pdphy_set_roles(struct pmic_typec_pdphy *pmic_typec_pdphy,
-                                   bool data_role_host, bool power_role_src)
+                                   enum typec_role power_role,
+                                   enum typec_data_role data_role)
 {
        struct device *dev = pmic_typec_pdphy->dev;
        unsigned long flags;
@@ -366,12 +367,13 @@ int qcom_pmic_typec_pdphy_set_roles(struct pmic_typec_pdphy *pmic_typec_pdphy,
                                 pmic_typec_pdphy->base + USB_PDPHY_MSG_CONFIG_REG,
                                 MSG_CONFIG_PORT_DATA_ROLE |
                                 MSG_CONFIG_PORT_POWER_ROLE,
-                                data_role_host << 3 | power_role_src << 2);
+                                (data_role == TYPEC_HOST ? MSG_CONFIG_PORT_DATA_ROLE : 0) |
+                                (power_role == TYPEC_SOURCE ? MSG_CONFIG_PORT_POWER_ROLE : 0));
 
        spin_unlock_irqrestore(&pmic_typec_pdphy->lock, flags);
 
        dev_dbg(dev, "pdphy_set_roles: data_role_host=%d power_role_src=%d\n",
-               data_role_host, power_role_src);
+               data_role, power_role);
 
        return ret;
 }
index e67954e31b149cd086c40cc44ca34ea51613bcc3..070822dc6f1772946045af1de28b802e3ce4a030 100644 (file)
@@ -107,7 +107,8 @@ int qcom_pmic_typec_pdphy_start(struct pmic_typec_pdphy *pmic_typec_pdphy,
 void qcom_pmic_typec_pdphy_stop(struct pmic_typec_pdphy *pmic_typec_pdphy);
 
 int qcom_pmic_typec_pdphy_set_roles(struct pmic_typec_pdphy *pmic_typec_pdphy,
-                                   bool power_role_src, bool data_role_host);
+                                   enum typec_role power_role,
+                                   enum typec_data_role data_role);
 
 int qcom_pmic_typec_pdphy_set_pd_rx(struct pmic_typec_pdphy *pmic_typec_pdphy, bool on);