phy: st: miphy28lp: use _poll_timeout functions for waits
Subsystems (2)
Sasha Levin
maintainerPATCH 1/2 phy: st: miphy28lp: use _poll_timeout functions for waits
From: Alain Volmat <[email protected]>
[ Upstream commit e3be4dd2c8d8aabfd2c3127d0e2e5754d3ae82d6 ]
This commit introduces _poll_timeout functions usage instead of wait loops waiting for a status bit.
Signed-off-by Alain Volmat <[email protected]>
Reviewed-by Patrice Chotard <[email protected]>
Signed-off-by Vinod Koul <[email protected]>
Signed-off-by Sasha Levin <[email protected]>
--- drivers/phy/st/phy-miphy28lp.c | 42 ++++++++-------------------------- 1 file changed, 10 insertions(+), 32 deletions(-)
drivers/phy/st/phy-miphy28lp.c +10 -32
@@ -13,6 +13,7 @@#include <linux/platform_device.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h>
@@ -488,19 +489,11 @@ static inline void miphy28lp_pcie_config_gen(struct miphy28lp_phy *miphy_phy)static inline int miphy28lp_wait_compensation (struct miphy28lp_phy *miphy_phy) { -unsigned long finish = jiffies +5 *HZ ;u8 val;/* Waiting for Compensation to complete */ -do { - val =readb_relaxed (miphy_phy->base +MIPHY_COMP_FSM_6 ); - -if (time_after_eq (jiffies, finish)) -return -EBUSY ; -cpu_relax (); - }while (!(val &COMP_DONE )); - -return 0 ; +return readb_relaxed_poll_timeout (miphy_phy->base +MIPHY_COMP_FSM_6 , + val, val &COMP_DONE ,1 ,5 *USEC_PER_SEC ); }
@@ -809,7 +802,6 @@ static inline void miphy28lp_configure_usb3(struct miphy28lp_phy *miphy_phy)static inline int miphy_is_ready (struct miphy28lp_phy *miphy_phy) { -unsigned long finish = jiffies +5 *HZ ;u8 mask =HFC_PLL |HFC_RDY ;u8 val;
@@ -820,21 +812,14 @@ static inline int miphy_is_ready(struct miphy28lp_phy *miphy_phy)if (miphy_phy->type ==PHY_TYPE_SATA ) mask |=PHY_RDY ; -do { - val =readb_relaxed (miphy_phy->base +MIPHY_STATUS_1 ); -if ((val & mask) != mask) -cpu_relax (); -else -return 0 ; - }while (!time_after_eq (jiffies, finish)); - -return -EBUSY ; +return readb_relaxed_poll_timeout (miphy_phy->base +MIPHY_STATUS_1 , + val, (val & mask) == mask,1 , +5 *USEC_PER_SEC ); }static int miphy_osc_is_ready (struct miphy28lp_phy *miphy_phy) {struct miphy28lp_dev *miphy_dev = miphy_phy->phydev; -unsigned long finish = jiffies +5 *HZ ;u32 val;if (!miphy_phy->osc_rdy)
@@ -843,17 +828,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)if (!miphy_phy->syscfg_reg[SYSCFG_STATUS ])return -EINVAL ; -do { -regmap_read (miphy_dev->regmap, - miphy_phy->syscfg_reg[SYSCFG_STATUS ], &val); - -if ((val &MIPHY_OSC_RDY ) !=MIPHY_OSC_RDY ) -cpu_relax (); -else -return 0 ; - }while (!time_after_eq (jiffies, finish)); - -return -EBUSY ; +return regmap_read_poll_timeout (miphy_dev->regmap, + miphy_phy->syscfg_reg[SYSCFG_STATUS ], + val, val &MIPHY_OSC_RDY ,1 , +5 *USEC_PER_SEC ); } static int miphy28lp_get_resource_byname(struct device_node *child,
Signature · 7 lines
2.39.2 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Sasha Levin
maintainerPATCH 2/2 mfd: dln2: Fix memory leak in dln2_probe()
From: Qiang Ning <[email protected]>
[ Upstream commit 96da8f148396329ba769246cb8ceaa35f1ddfc48 ]
When dln2_setup_rx_urbs() in dln2_probe() fails, error out_free forgets to call usb_put_dev() to decrease the refcount of dln2->usb_dev.
Fix this by adding usb_put_dev() in the error handling code of dln2_probe().
Signed-off-by Qiang Ning <[email protected]>
Signed-off-by Lee Jones <[email protected]>
Signed-off-by Sasha Levin <[email protected]>
--- drivers/mfd/dln2.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/dln2.c +1 -0
@@ -800,6 +800,7 @@ static int dln2_probe(struct usb_interface *interface,dln2_stop_rx_urbs (dln2); out_free: +usb_put_dev (dln2->usb_dev);dln2_free (dln2);return ret;
Signature · 1 line
2.39.2