]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
drivers: ufs: ufs-mediatek: fix phy handling
authorJulien Stephan <jstephan@baylibre.com>
Wed, 18 Mar 2026 16:50:58 +0000 (17:50 +0100)
committerDavid Lechner <dlechner@baylibre.com>
Fri, 17 Apr 2026 22:05:54 +0000 (17:05 -0500)
Currently mphy is declared as a pointer inside ufs_mtk_host struct, but
it is never initialized.

Fix this by using a struct phy directly in ufs_mtk_host struct instead
of a struct phy*. Update all call to mphy accordingly.

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
Link: https://patch.msgid.link/20260318-mt8195-add-ufs-support-v2-6-f18eeeeb0e72@baylibre.com
Signed-off-by: David Lechner <dlechner@baylibre.com>
drivers/ufs/ufs-mediatek.c
drivers/ufs/ufs-mediatek.h

index e860d765eea5fbd0c8b8119f8d8d0f77db44d1a0..5d882904c842d31a142fc5ae47f229fd9e934dbc 100644 (file)
@@ -182,19 +182,15 @@ static int ufs_mtk_bind_mphy(struct ufs_hba *hba)
        struct ufs_mtk_host *host = dev_get_priv(hba->dev);
        int err = 0;
 
-       err = generic_phy_get_by_index(hba->dev, 0, host->mphy);
+       err = generic_phy_get_by_index(hba->dev, 0, &host->mphy);
 
-       if (IS_ERR(host->mphy)) {
-               err = PTR_ERR(host->mphy);
-               if (err != -ENODEV) {
-                       dev_info(hba->dev, "%s: Could NOT get a valid PHY %d\n", __func__,
-                                err);
-               }
+       if (err) {
+               if (err == -ENOENT)
+                       return 0; /* no PHY, nothing to do */
+               dev_err(hba->dev, "Failed to get PHY: %d.\n", err);
+               return err;
        }
 
-       if (err)
-               host->mphy = NULL;
-
        return err;
 }
 
@@ -323,7 +319,7 @@ static int ufs_mtk_init(struct ufs_hba *hba)
 
        // TODO: Clocking
 
-       err = generic_phy_power_on(priv->mphy);
+       err = generic_phy_power_on(&priv->mphy);
        if (err) {
                dev_err(hba->dev, "%s: phy init failed, err = %d\n",
                        __func__, err);
index 11a83d34c5b93ce173575eb8bee895f6f70af2d6..0ffd0483eff31fd36bc56fb99b1d33a4d8634eb0 100644 (file)
@@ -154,7 +154,7 @@ struct ufs_mtk_mcq_intr_info {
 };
 
 struct ufs_mtk_host {
-       struct phy *mphy;
+       struct phy mphy;
        struct reset_ctl *unipro_reset;
        struct reset_ctl *crypto_reset;
        struct reset_ctl *hci_reset;