From 585172558c656b819b5e75179bfb4633650ebf94 Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Wed, 15 Nov 2023 20:53:29 +0800 Subject: [PATCH] rockchip: motorcomm: simplify redundant code Signed-off-by: Tianling Shen (cherry picked from commit 6b5ec5a5eeadc14cb4f28daf41e2a62df6b0f198) --- ...-use-3.0-clock-when-operating-in-2.0.patch | 2 +- ...omm-add-LED-configuration-for-yt85xx.patch | 72 +++++++++---------- 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/target/linux/rockchip/patches-5.15/008-0017-v5.18-usb-dwc3-core-do-not-use-3.0-clock-when-operating-in-2.0.patch b/target/linux/rockchip/patches-5.15/008-0017-v5.18-usb-dwc3-core-do-not-use-3.0-clock-when-operating-in-2.0.patch index 66b9a33e14..2c6cbb16fa 100644 --- a/target/linux/rockchip/patches-5.15/008-0017-v5.18-usb-dwc3-core-do-not-use-3.0-clock-when-operating-in-2.0.patch +++ b/target/linux/rockchip/patches-5.15/008-0017-v5.18-usb-dwc3-core-do-not-use-3.0-clock-when-operating-in-2.0.patch @@ -22,7 +22,7 @@ Signed-off-by: Greg Kroah-Hartman --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c -@@ -1090,6 +1090,11 @@ static int dwc3_core_init(struct dwc3 *d +@@ -1127,6 +1127,11 @@ static int dwc3_core_init(struct dwc3 *d if (dwc->parkmode_disable_ss_quirk) reg |= DWC3_GUCTL1_PARKMODE_DISABLE_SS; diff --git a/target/linux/rockchip/patches-5.15/601-net-phy-motorcomm-add-LED-configuration-for-yt85xx.patch b/target/linux/rockchip/patches-5.15/601-net-phy-motorcomm-add-LED-configuration-for-yt85xx.patch index 6e38648183..d175abe3b1 100644 --- a/target/linux/rockchip/patches-5.15/601-net-phy-motorcomm-add-LED-configuration-for-yt85xx.patch +++ b/target/linux/rockchip/patches-5.15/601-net-phy-motorcomm-add-LED-configuration-for-yt85xx.patch @@ -13,53 +13,51 @@ /* 2b00 84ms * 2b01 168ms *default* * 2b10 336ms -@@ -1459,6 +1465,7 @@ static int yt8521_resume(struct phy_devi - static int yt8521_config_init(struct phy_device *phydev) - { - struct device_node *node = phydev->mdio.dev.of_node; -+ u32 led_data[YTPHY_LED_NUM_CONFIG]; - int old_page; - int ret = 0; +@@ -1450,6 +1456,27 @@ static int yt8521_resume(struct phy_devi + return yt8521_modify_utp_fiber_bmcr(phydev, BMCR_PDOWN, 0); + } -@@ -1488,6 +1495,16 @@ static int yt8521_config_init(struct phy ++static int ytphy_config_led(struct phy_device *phydev) ++{ ++ struct device_node *node = phydev->mdio.dev.of_node; ++ u32 led_data[YTPHY_LED_NUM_CONFIG]; ++ int ret; ++ ++ ret = of_property_read_u32_array(node, "motorcomm,led-data", ++ led_data, YTPHY_LED_NUM_CONFIG); ++ if (ret) ++ return 0; ++ ++ for (int i = 0; i < YTPHY_LED_NUM_CONFIG; i++) { ++ ret = ytphy_write_ext(phydev, YTPHY_LED_CONFIG_REG(i), ++ led_data[i]); ++ if (ret < 0) ++ return ret; ++ } ++ ++ return 0; ++} ++ + /** + * yt8521_config_init() - called to initialize the PHY + * @phydev: a pointer to a &struct phy_device +@@ -1488,6 +1515,10 @@ static int yt8521_config_init(struct phy if (ret < 0) goto err_restore_page; } + -+ if (!of_property_read_u32_array(node, "motorcomm,led-data", -+ led_data, YTPHY_LED_NUM_CONFIG)) { -+ for (int i = 0; i < YTPHY_LED_NUM_CONFIG; i++) { -+ ret = ytphy_write_ext(phydev, YTPHY_LED_CONFIG_REG(i), -+ led_data[i]); -+ if (ret < 0) -+ goto err_restore_page; -+ } -+ } ++ ret = ytphy_config_led(phydev); ++ if (ret < 0) ++ goto err_restore_page; err_restore_page: return phy_restore_page(phydev, old_page, ret); } -@@ -1495,6 +1512,7 @@ err_restore_page: - static int yt8531_config_init(struct phy_device *phydev) - { - struct device_node *node = phydev->mdio.dev.of_node; -+ u32 led_data[YTPHY_LED_NUM_CONFIG]; - int ret; - - ret = ytphy_rgmii_clk_delay_config_with_lock(phydev); -@@ -1519,6 +1537,16 @@ static int yt8531_config_init(struct phy +@@ -1519,7 +1550,7 @@ static int yt8531_config_init(struct phy return ret; } -+ if (!of_property_read_u32_array(node, "motorcomm,led-data", -+ led_data, YTPHY_LED_NUM_CONFIG)) { -+ for (int i = 0; i < YTPHY_LED_NUM_CONFIG; i++) { -+ ret = ytphy_write_ext(phydev, YTPHY_LED_CONFIG_REG(i), -+ led_data[i]); -+ if (ret < 0) -+ return ret; -+ } -+ } -+ - return 0; +- return 0; ++ return ytphy_config_led(phydev); } + /**