FAILED: patch "[PATCH] phy: ti: omap-usb2: fix device leak at unbind" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 64961557efa1b98f375c0579779e7eeda1a02c42
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025091752-daycare-art-9e78@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 64961557efa1b98f375c0579779e7eeda1a02c42 Mon Sep 17 00:00:00 2001
From: Johan Hovold <[email protected]>
Date: Thu, 24 Jul 2025 15:12:05 +0200
Subject: [PATCH] phy: ti: omap-usb2: fix device leak at unbind
Make sure to drop the reference to the control device taken by of_find_device_by_node() during probe when the driver is unbound.
drivers/phy/ti/phy-omap-usb2.c +13 -0
@@ -363,6 +363,13 @@ static void omap_usb2_init_errata(struct omap_usb *phy) phy->flags |=OMAP_USB2_DISABLE_CHRG_DET ; } +static void omap_usb2_put_device (void *_dev) +{ +struct device *dev = _dev; + +put_device (dev); +} +static int omap_usb2_probe (struct platform_device *pdev) {struct omap_usb *phy;
@@ -373,6 +380,7 @@ static int omap_usb2_probe(struct platform_device *pdev)struct device_node *control_node;struct platform_device *control_pdev;const struct usb_phy_data *phy_data; +int ret; phy_data =device_get_match_data (&pdev->dev);if (!phy_data)
@@ -423,6 +431,11 @@ static int omap_usb2_probe(struct platform_device *pdev)return -EINVAL ; } phy->control_dev = &control_pdev->dev; + + ret =devm_add_action_or_reset (&pdev->dev, omap_usb2_put_device, + phy->control_dev); +if (ret) +return ret; }else { if (of_property_read_u32_index(node, "syscon-phy-power", 1,
Sasha Levin
maintainerPATCH 1/6 phy: broadcom: convert to devm_platform_ioremap_resource(_byname)
From: Chunfeng Yun <[email protected]>
[ Upstream commit f669bc8b9f7beb6b1936882a2c3670dc1bd985ba ]
Use devm_platform_ioremap_resource(_byname) to simplify code
Stable-dep-of: 64961557efa1 ("phy: ti: omap-usb2: fix device leak at unbind")
--- drivers/phy/broadcom/phy-bcm-cygnus-pcie.c | 4 +--- drivers/phy/broadcom/phy-bcm-kona-usb2.c | 4 +--- drivers/phy/broadcom/phy-bcm-ns-usb2.c | 4 +--- drivers/phy/broadcom/phy-bcm-ns-usb3.c | 7 ++----- drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c | 13 ++++--------- drivers/phy/broadcom/phy-bcm-sr-pcie.c | 5 +---- drivers/phy/broadcom/phy-bcm-sr-usb.c | 4 +--- drivers/phy/broadcom/phy-brcm-sata.c | 8 ++------ 8 files changed, 13 insertions(+), 36 deletions(-)
drivers/phy/broadcom/phy-bcm-cygnus-pcie.c +1 -3
@@ -126,7 +126,6 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev)struct device_node *node = dev->of_node, *child;struct cygnus_pcie_phy_core *core;struct phy_provider *provider; -struct resource *res;unsigned cnt =0 ;int ret;
@@ -141,8 +140,7 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev) core->dev = dev; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - core->base =devm_ioremap_resource (dev, res); + core->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (core->base))return PTR_ERR (core->base);
drivers/phy/broadcom/phy-bcm-kona-usb2.c +1 -3
@@ -94,7 +94,6 @@ static int bcm_kona_usb2_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct bcm_kona_usb *phy; -struct resource *res;struct phy *gphy;struct phy_provider *phy_provider;
@@ -102,8 +101,7 @@ static int bcm_kona_usb2_probe(struct platform_device *pdev)if (!phy)return -ENOMEM ; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - phy->regs =devm_ioremap_resource (&pdev->dev, res); + phy->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (phy->regs))return PTR_ERR (phy->regs);
drivers/phy/broadcom/phy-bcm-ns-usb2.c +1 -3
@@ -83,7 +83,6 @@ static int bcm_ns_usb2_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct bcm_ns_usb2 *usb2; -struct resource *res;struct phy_provider *phy_provider; usb2 =devm_kzalloc (&pdev->dev,sizeof (*usb2),GFP_KERNEL );
@@ -91,8 +90,7 @@ static int bcm_ns_usb2_probe(struct platform_device *pdev)return -ENOMEM ; usb2->dev = dev; - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dmu" ); - usb2->dmu =devm_ioremap_resource (dev, res); + usb2->dmu =devm_platform_ioremap_resource_byname (pdev,"dmu" );if (IS_ERR (usb2->dmu)) {dev_err (dev,"Failed to map DMU regs\n" );return PTR_ERR (usb2->dmu);
drivers/phy/broadcom/phy-bcm-ns-usb3.c +2 -5
@@ -305,7 +305,6 @@ static int bcm_ns_usb3_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;const struct of_device_id *of_id;struct bcm_ns_usb3 *usb3; -struct resource *res;struct phy_provider *phy_provider; usb3 =devm_kzalloc (dev,sizeof (*usb3),GFP_KERNEL );
@@ -319,15 +318,13 @@ static int bcm_ns_usb3_probe(struct platform_device *pdev)return -EINVAL ; usb3->family = (enum bcm_ns_family )of_id->data; - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dmp" ); - usb3->dmp =devm_ioremap_resource (dev, res); + usb3->dmp =devm_platform_ioremap_resource_byname (pdev,"dmp" );if (IS_ERR (usb3->dmp)) {dev_err (dev,"Failed to map DMP regs\n" );return PTR_ERR (usb3->dmp); } - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"ccb-mii" ); - usb3->ccb_mii =devm_ioremap_resource (dev, res); + usb3->ccb_mii =devm_platform_ioremap_resource_byname (pdev,"ccb-mii" );if (IS_ERR (usb3->ccb_mii)) {dev_err (dev,"Failed to map ChipCommon B MII regs\n" );return PTR_ERR (usb3->ccb_mii);
drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c +4 -9
@@ -293,7 +293,6 @@ static int ns2_drd_phy_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct ns2_phy_driver *driver;struct ns2_phy_data *data; -struct resource *res;int ret;u32 val;
@@ -307,23 +306,19 @@ static int ns2_drd_phy_probe(struct platform_device *pdev)if (!driver->data)return -ENOMEM ; - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"icfg" ); - driver->icfgdrd_regs =devm_ioremap_resource (dev, res); + driver->icfgdrd_regs =devm_platform_ioremap_resource_byname (pdev,"icfg" );if (IS_ERR (driver->icfgdrd_regs))return PTR_ERR (driver->icfgdrd_regs); - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"rst-ctrl" ); - driver->idmdrd_rst_ctrl =devm_ioremap_resource (dev, res); + driver->idmdrd_rst_ctrl =devm_platform_ioremap_resource_byname (pdev,"rst-ctrl" );if (IS_ERR (driver->idmdrd_rst_ctrl))return PTR_ERR (driver->idmdrd_rst_ctrl); - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"crmu-ctrl" ); - driver->crmu_usb2_ctrl =devm_ioremap_resource (dev, res); + driver->crmu_usb2_ctrl =devm_platform_ioremap_resource_byname (pdev,"crmu-ctrl" );if (IS_ERR (driver->crmu_usb2_ctrl))return PTR_ERR (driver->crmu_usb2_ctrl); - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"usb2-strap" ); - driver->usb2h_strap_reg =devm_ioremap_resource (dev, res); + driver->usb2h_strap_reg =devm_platform_ioremap_resource_byname (pdev,"usb2-strap" );if (IS_ERR (driver->usb2h_strap_reg))return PTR_ERR (driver->usb2h_strap_reg);
drivers/phy/broadcom/phy-bcm-sr-pcie.c +1 -4
@@ -217,7 +217,6 @@ static int sr_pcie_phy_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct device_node *node = dev->of_node;struct sr_pcie_phy_core *core; -struct resource *res;struct phy_provider *provider;unsigned int phy_idx =0 ;
@@ -226,9 +225,7 @@ static int sr_pcie_phy_probe(struct platform_device *pdev)return -ENOMEM ; core->dev = dev; - - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - core->base =devm_ioremap_resource (core->dev, res); + core->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (core->base))return PTR_ERR (core->base);
drivers/phy/broadcom/phy-bcm-sr-usb.c +1 -3
@@ -300,14 +300,12 @@ static int bcm_usb_phy_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct device_node *dn = dev->of_node;const struct of_device_id *of_id; -struct resource *res;void __iomem *regs;int ret;enum bcm_usb_phy_version version;struct phy_provider *phy_provider; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - regs =devm_ioremap_resource (dev, res); + regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (regs))return PTR_ERR (regs);
drivers/phy/broadcom/phy-brcm-sata.c +2 -6
@@ -726,7 +726,6 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)struct device_node *dn = dev->of_node, *child;const struct of_device_id *of_id;struct brcm_sata_phy *priv; -struct resource *res;struct phy_provider *provider;int ret, count =0 ;
@@ -739,8 +738,7 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)dev_set_drvdata (dev, priv); priv->dev = dev; - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"phy" ); - priv->phy_base =devm_ioremap_resource (dev, res); + priv->phy_base =devm_platform_ioremap_resource_byname (pdev,"phy" );if (IS_ERR (priv->phy_base))return PTR_ERR (priv->phy_base);
@@ -751,9 +749,7 @@ static int brcm_sata_phy_probe(struct platform_device *pdev) priv->version =BRCM_SATA_PHY_STB_28NM ;if (priv->version ==BRCM_SATA_PHY_IPROC_NS2 ) { - res =platform_get_resource_byname (pdev,IORESOURCE_MEM , -"phy-ctrl" ); - priv->ctrl_base =devm_ioremap_resource (dev, res); + priv->ctrl_base =devm_platform_ioremap_resource_byname (pdev,"phy-ctrl" );if (IS_ERR (priv->ctrl_base))return PTR_ERR (priv->ctrl_base); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 2/6 phy: ti: convert to devm_platform_ioremap_resource(_byname)
From: Chunfeng Yun <[email protected]>
[ Upstream commit 79caf207d6699419e83ac150accc5c80c5719b47 ]
Use devm_platform_ioremap_resource(_byname) to simplify code
Stable-dep-of: 64961557efa1 ("phy: ti: omap-usb2: fix device leak at unbind")
--- drivers/phy/ti/phy-omap-control.c | 17 ++++++----------- drivers/phy/ti/phy-omap-usb2.c | 4 +--- drivers/phy/ti/phy-ti-pipe3.c | 15 ++++----------- 3 files changed, 11 insertions(+), 25 deletions(-)
drivers/phy/ti/phy-omap-control.c +6 -11
@@ -268,7 +268,6 @@ MODULE_DEVICE_TABLE(of, omap_control_phy_id_table);static int omap_control_phy_probe (struct platform_device *pdev) { -struct resource *res;const struct of_device_id *of_id;struct omap_control_phy *control_phy;
@@ -285,16 +284,13 @@ static int omap_control_phy_probe(struct platform_device *pdev) control_phy->type = *(enum omap_control_phy_type *)of_id->data;if (control_phy->type ==OMAP_CTRL_TYPE_OTGHS ) { - res =platform_get_resource_byname (pdev,IORESOURCE_MEM , -"otghs_control" ); - control_phy->otghs_control =devm_ioremap_resource ( - &pdev->dev, res); + control_phy->otghs_control = +devm_platform_ioremap_resource_byname (pdev,"otghs_control" );if (IS_ERR (control_phy->otghs_control))return PTR_ERR (control_phy->otghs_control); }else { - res =platform_get_resource_byname (pdev,IORESOURCE_MEM , -"power" ); - control_phy->power =devm_ioremap_resource (&pdev->dev, res); + control_phy->power = +devm_platform_ioremap_resource_byname (pdev,"power" );if (IS_ERR (control_phy->power)) {dev_err (&pdev->dev,"Couldn't get power register\n" );return PTR_ERR (control_phy->power);
@@ -312,9 +308,8 @@ static int omap_control_phy_probe(struct platform_device *pdev) }if (control_phy->type ==OMAP_CTRL_TYPE_PCIE ) { - res =platform_get_resource_byname (pdev,IORESOURCE_MEM , -"pcie_pcs" ); - control_phy->pcie_pcs =devm_ioremap_resource (&pdev->dev, res); + control_phy->pcie_pcs = +devm_platform_ioremap_resource_byname (pdev,"pcie_pcs" );if (IS_ERR (control_phy->pcie_pcs))return PTR_ERR (control_phy->pcie_pcs); }
drivers/phy/ti/phy-omap-usb2.c +1 -3
@@ -366,7 +366,6 @@ static int omap_usb2_probe(struct platform_device *pdev) {struct omap_usb *phy;struct phy *generic_phy; -struct resource *res;struct phy_provider *phy_provider;struct usb_otg *otg;struct device_node *node = pdev->dev.of_node;
@@ -403,8 +402,7 @@ static int omap_usb2_probe(struct platform_device *pdev)omap_usb2_init_errata (phy); - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - phy->phy_base =devm_ioremap_resource (&pdev->dev, res); + phy->phy_base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (phy->phy_base))return PTR_ERR (phy->phy_base);
drivers/phy/ti/phy-ti-pipe3.c +4 -11
@@ -745,35 +745,28 @@ static int ti_pipe3_get_sysctrl(struct ti_pipe3 *phy)static int ti_pipe3_get_tx_rx_base (struct ti_pipe3 *phy) { -struct resource *res;struct device *dev = phy->dev;struct platform_device *pdev =to_platform_device (dev); - res =platform_get_resource_byname (pdev,IORESOURCE_MEM , -"phy_rx" ); - phy->phy_rx =devm_ioremap_resource (dev, res); + phy->phy_rx =devm_platform_ioremap_resource_byname (pdev,"phy_rx" );if (IS_ERR (phy->phy_rx))return PTR_ERR (phy->phy_rx); - res =platform_get_resource_byname (pdev,IORESOURCE_MEM , -"phy_tx" ); - phy->phy_tx =devm_ioremap_resource (dev, res); + phy->phy_tx =devm_platform_ioremap_resource_byname (pdev,"phy_tx" );return PTR_ERR_OR_ZERO (phy->phy_tx); }static int ti_pipe3_get_pll_base (struct ti_pipe3 *phy) { -struct resource *res;struct device *dev = phy->dev;struct platform_device *pdev =to_platform_device (dev);if (phy->mode ==PIPE3_MODE_PCIE )return 0 ; - res =platform_get_resource_byname (pdev,IORESOURCE_MEM , -"pll_ctrl" ); - phy->pll_ctrl_base =devm_ioremap_resource (dev, res); + phy->pll_ctrl_base = +devm_platform_ioremap_resource_byname (pdev,"pll_ctrl" );return PTR_ERR_OR_ZERO (phy->pll_ctrl_base); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 3/6 phy: phy-bcm-ns-usb3: drop support for deprecated DT binding
In reply to Sasha LevinFrom: Rafał Miłecki <[email protected]>
[ Upstream commit 36a94760c98954e50ea621f7a9603fee3621deb7 ]
Initially this PHY driver was implementing MDIO access on its own. It was caused by lack of proper hardware design understanding.
It has been changed back in 2017. DT bindings were changed and driver was updated to use MDIO layer.
It should be really safe now to drop the old deprecated code. All Linux stored DT files don't use it for 3,5 year. There is close to 0 chance there is any bootloader with its own DTB using old the binding.
Stable-dep-of: 64961557efa1 ("phy: ti: omap-usb2: fix device leak at unbind")
--- drivers/phy/broadcom/phy-bcm-ns-usb3.c | 156 +------------------------ 1 file changed, 5 insertions(+), 151 deletions(-)
drivers/phy/broadcom/phy-bcm-ns-usb3.c +5 -151
@@ -22,8 +22,6 @@#include <linux/phy/phy.h> #include <linux/slab.h> -#define BCM_NS_USB3_MII_MNG_TIMEOUT_US 1000/* usecs */ -#define BCM_NS_USB3_PHY_BASE_ADDR_REG 0x1f#define BCM_NS_USB3_PHY_PLL30_BLOCK 0x8000#define BCM_NS_USB3_PHY_TX_PMD_BLOCK 0x8040
@@ -51,11 +49,8 @@ struct bcm_ns_usb3 {struct device *dev;enum bcm_ns_family family;void __iomem *dmp; -void __iomem *ccb_mii;struct mdio_device *mdiodev;struct phy *phy; - -int (*phy_write)(struct bcm_ns_usb3 *usb3,u16 reg,u16 value); };static const struct of_device_id bcm_ns_usb3_id_table[] = {
@@ -69,13 +64,9 @@ static const struct of_device_id bcm_ns_usb3_id_table[] = { }, {}, }; -MODULE_DEVICE_TABLE (of, bcm_ns_usb3_id_table);static int bcm_ns_usb3_mdio_phy_write (struct bcm_ns_usb3 *usb3,u16 reg, -u16 value) -{ -return usb3->phy_write (usb3, reg, value); -} +u16 value);static int bcm_ns_usb3_phy_init_ns_bx (struct bcm_ns_usb3 *usb3) {
@@ -187,8 +178,8 @@ static const struct phy_ops ops = {* MDIO driver code **************************************************/ -static int bcm_ns_usb3_mdiodev_phy_write (struct bcm_ns_usb3 *usb3,u16 reg, -u16 value) +static int bcm_ns_usb3_mdio_phy_write (struct bcm_ns_usb3 *usb3,u16 reg, +u16 value) {struct mdio_device *mdiodev = usb3->mdiodev;
@@ -229,8 +220,6 @@ static int bcm_ns_usb3_mdio_probe(struct mdio_device *mdiodev)return PTR_ERR (usb3->dmp); } - usb3->phy_write = bcm_ns_usb3_mdiodev_phy_write; - usb3->phy =devm_phy_create (dev,NULL , &ops);if (IS_ERR (usb3->phy)) {dev_err (dev,"Failed to create PHY\n" );
@@ -254,142 +243,7 @@ static struct mdio_driver bcm_ns_usb3_mdio_driver = { .probe = bcm_ns_usb3_mdio_probe, }; -/************************************************** -* Platform driver code -**************************************************/ - -static int bcm_ns_usb3_wait_reg (struct bcm_ns_usb3 *usb3,void __iomem *addr, -u32 mask,u32 value,int usec) -{ -u32 val; -int ret; - - ret =readl_poll_timeout_atomic (addr, val, ((val & mask) == value), -10 , usec); -if (ret) -dev_err (usb3->dev,"Timeout waiting for register %p\n" , addr); - -return ret; -} - -static inline int bcm_ns_usb3_mii_mng_wait_idle (struct bcm_ns_usb3 *usb3) -{ -return bcm_ns_usb3_wait_reg (usb3, usb3->ccb_mii +BCMA_CCB_MII_MNG_CTL , -0x0100 ,0x0000 , -BCM_NS_USB3_MII_MNG_TIMEOUT_US ); -} - -static int bcm_ns_usb3_platform_phy_write (struct bcm_ns_usb3 *usb3,u16 reg, -u16 value) -{ -u32 tmp =0 ; -int err; - - err =bcm_ns_usb3_mii_mng_wait_idle (usb3); -if (err <0 ) { -dev_err (usb3->dev,"Couldn't write 0x%08x value\n" , value); -return err; - } - -/* TODO: Use a proper MDIO bus layer */ - tmp |=0x58020000 ;/* Magic value for MDIO PHY write */ - tmp |= reg <<18 ; - tmp |= value; -writel (tmp, usb3->ccb_mii +BCMA_CCB_MII_MNG_CMD_DATA ); - -return bcm_ns_usb3_mii_mng_wait_idle (usb3); -} - -static int bcm_ns_usb3_probe (struct platform_device *pdev) -{ -struct device *dev = &pdev->dev; -const struct of_device_id *of_id; -struct bcm_ns_usb3 *usb3; -struct phy_provider *phy_provider; - - usb3 =devm_kzalloc (dev,sizeof (*usb3),GFP_KERNEL ); -if (!usb3) -return -ENOMEM ; - - usb3->dev = dev; - - of_id =of_match_device (bcm_ns_usb3_id_table, dev); -if (!of_id) -return -EINVAL ; - usb3->family = (enum bcm_ns_family )of_id->data; - - usb3->dmp =devm_platform_ioremap_resource_byname (pdev,"dmp" ); -if (IS_ERR (usb3->dmp)) { -dev_err (dev,"Failed to map DMP regs\n" ); -return PTR_ERR (usb3->dmp); - } - - usb3->ccb_mii =devm_platform_ioremap_resource_byname (pdev,"ccb-mii" ); -if (IS_ERR (usb3->ccb_mii)) { -dev_err (dev,"Failed to map ChipCommon B MII regs\n" ); -return PTR_ERR (usb3->ccb_mii); - } - -/* Enable MDIO. Setting MDCDIV as 26 */ -writel (0x0000009a , usb3->ccb_mii +BCMA_CCB_MII_MNG_CTL ); - -/* Wait for MDIO? */ -udelay (2 ); - - usb3->phy_write = bcm_ns_usb3_platform_phy_write; - - usb3->phy =devm_phy_create (dev,NULL , &ops); -if (IS_ERR (usb3->phy)) { -dev_err (dev,"Failed to create PHY\n" ); -return PTR_ERR (usb3->phy); - } - -phy_set_drvdata (usb3->phy, usb3); -platform_set_drvdata (pdev, usb3); - - phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); -if (!IS_ERR (phy_provider)) -dev_info (dev,"Registered Broadcom Northstar USB 3.0 PHY driver\n" ); - -return PTR_ERR_OR_ZERO (phy_provider); -} - -static struct platform_driver bcm_ns_usb3_driver = { - .probe = bcm_ns_usb3_probe, - .driver = { - .name ="bcm_ns_usb3" , - .of_match_table = bcm_ns_usb3_id_table, - }, -}; - -static int __init bcm_ns_usb3_module_init (void ) -{ -int err; - -/* -* For backward compatibility we register as MDIO and platform driver. -* After getting MDIO binding commonly used (e.g. switching all DT files -* to use it) we should deprecate the old binding and eventually drop -* support for it. -*/ - - err =mdio_driver_register (&bcm_ns_usb3_mdio_driver); -if (err) -return err; - - err =platform_driver_register (&bcm_ns_usb3_driver); -if (err) -mdio_driver_unregister (&bcm_ns_usb3_mdio_driver); - -return err; -} -module_init (bcm_ns_usb3_module_init); - -static void __exit bcm_ns_usb3_module_exit(void) -{ -platform_driver_unregister (&bcm_ns_usb3_driver); -mdio_driver_unregister (&bcm_ns_usb3_mdio_driver); -} -module_exit(bcm_ns_usb3_module_exit) +mdio_module_driver (bcm_ns_usb3_mdio_driver);MODULE_LICENSE ("GPL v2" ); +MODULE_DEVICE_TABLE (of, bcm_ns_usb3_id_table);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 4/6 phy: broadcom: ns-usb3: fix Wvoid-pointer-to-enum-cast warning
In reply to Sasha LevinFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit bd6e74a2f0a0c76dda8e44d26f9b91a797586c3b ]
'family' is an enum, thus cast of pointer on 64-bit compile test with W=1 causes:
drivers/phy/broadcom/phy-bcm-ns-usb3.c:209:17: error: cast to smaller integer type 'enum bcm_ns_family' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]
Stable-dep-of: 64961557efa1 ("phy: ti: omap-usb2: fix device leak at unbind")
--- drivers/phy/broadcom/phy-bcm-ns-usb3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/broadcom/phy-bcm-ns-usb3.c +1 -1
@@ -206,7 +206,7 @@ static int bcm_ns_usb3_mdio_probe(struct mdio_device *mdiodev) of_id =of_match_device (bcm_ns_usb3_id_table, dev);if (!of_id)return -EINVAL ; - usb3->family = (enum bcm_ns_family )of_id->data; + usb3->family = (uintptr_t )of_id->data; syscon_np =of_parse_phandle (dev->of_node,"usb3-dmp-syscon" ,0 ); err =of_address_to_resource (syscon_np,0 , &res);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 5/6 phy: Use device_get_match_data()
In reply to Sasha LevinFrom: Rob Herring <[email protected]>
[ Upstream commit 21bf6fc47a1e45031ba8a7084343b7cfd09ed1d3 ]
Use preferred device_get_match_data() instead of of_match_device() to get the driver match data. With this, adjust the includes to explicitly include the correct headers.
Stable-dep-of: 64961557efa1 ("phy: ti: omap-usb2: fix device leak at unbind")
--- drivers/phy/broadcom/phy-bcm-ns-usb3.c | 9 +++------ drivers/phy/marvell/phy-berlin-usb.c | 7 +++---- drivers/phy/ralink/phy-ralink-usb.c | 10 +++------- drivers/phy/rockchip/phy-rockchip-pcie.c | 11 ++++------- drivers/phy/rockchip/phy-rockchip-usb.c | 10 +++------- drivers/phy/ti/phy-omap-control.c | 9 ++------- drivers/phy/ti/phy-omap-usb2.c | 11 ++++------- drivers/phy/ti/phy-ti-pipe3.c | 14 ++++---------- 8 files changed, 26 insertions(+), 55 deletions(-)
drivers/phy/broadcom/phy-bcm-ns-usb3.c +3 -6
@@ -16,10 +16,11 @@#include <linux/iopoll.h> #include <linux/mdio.h> #include <linux/module.h> +#include <linux/of.h> #include <linux/of_address.h> -#include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/phy/phy.h> +#include <linux/property.h> #include <linux/slab.h> #define BCM_NS_USB3_PHY_BASE_ADDR_REG 0x1f
@@ -189,7 +190,6 @@ static int bcm_ns_usb3_mdio_phy_write(struct bcm_ns_usb3 *usb3, u16 reg,static int bcm_ns_usb3_mdio_probe (struct mdio_device *mdiodev) {struct device *dev = &mdiodev->dev; -const struct of_device_id *of_id;struct phy_provider *phy_provider;struct device_node *syscon_np;struct bcm_ns_usb3 *usb3;
@@ -203,10 +203,7 @@ static int bcm_ns_usb3_mdio_probe(struct mdio_device *mdiodev) usb3->dev = dev; usb3->mdiodev = mdiodev; - of_id =of_match_device (bcm_ns_usb3_id_table, dev); -if (!of_id) -return -EINVAL ; - usb3->family = (uintptr_t )of_id->data; + usb3->family = (enum bcm_ns_family )device_get_match_data (dev); syscon_np =of_parse_phandle (dev->of_node,"usb3-dmp-syscon" ,0 ); err =of_address_to_resource (syscon_np,0 , &res);
drivers/phy/marvell/phy-berlin-usb.c +3 -4
@@ -8,9 +8,10 @@#include <linux/io.h> #include <linux/module.h> -#include <linux/of_device.h> +#include <linux/of.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/reset.h> #define USB_PHY_PLL 0x04
@@ -162,8 +163,6 @@ MODULE_DEVICE_TABLE(of, phy_berlin_usb_of_match);static int phy_berlin_usb_probe (struct platform_device *pdev) { -const struct of_device_id *match = -of_match_device (phy_berlin_usb_of_match, &pdev->dev);struct phy_berlin_usb_priv *priv;struct resource *res;struct phy *phy;
@@ -182,7 +181,7 @@ static int phy_berlin_usb_probe(struct platform_device *pdev)if (IS_ERR (priv->rst_ctrl))return PTR_ERR (priv->rst_ctrl); - priv->pll_divider = *((u32 *)match->data); + priv->pll_divider = *((u32 *)device_get_match_data (&pdev->dev)); phy =devm_phy_create (&pdev->dev,NULL , &phy_berlin_usb_ops);if (IS_ERR (phy)) {
drivers/phy/ralink/phy-ralink-usb.c +3 -7
@@ -13,9 +13,10 @@#include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/mutex.h> -#include <linux/of_platform.h> +#include <linux/of.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/platform_device.h> #include <linux/regmap.h> #include <linux/reset.h>
@@ -172,18 +173,13 @@ static int ralink_usb_phy_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct resource *res;struct phy_provider *phy_provider; -const struct of_device_id *match;struct ralink_usb_phy *phy; - match =of_match_device (ralink_usb_phy_of_match, &pdev->dev); -if (!match) -return -ENODEV ; - phy =devm_kzalloc (dev,sizeof (*phy),GFP_KERNEL );if (!phy)return -ENOMEM ; - phy->clk = (uintptr_t )match->data; + phy->clk = (uintptr_t )device_get_match_data (&pdev->dev); phy->base =NULL ; phy->sysctl =syscon_regmap_lookup_by_phandle (dev->of_node,"ralink,sysctl" );
drivers/phy/rockchip/phy-rockchip-pcie.c +4 -7
@@ -12,10 +12,9 @@#include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/of.h> -#include <linux/of_address.h> -#include <linux/of_platform.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/regmap.h> #include <linux/reset.h>
@@ -63,7 +62,7 @@ struct rockchip_pcie_data { };struct rockchip_pcie_phy { -struct rockchip_pcie_data *phy_data; +const struct rockchip_pcie_data *phy_data;struct regmap *reg_base;struct phy_pcie_instance {struct phy *phy;
@@ -365,7 +364,6 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev)struct rockchip_pcie_phy *rk_phy;struct phy_provider *phy_provider;struct regmap *grf; -const struct of_device_id *of_id;int i;u32 phy_num;
@@ -379,11 +377,10 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev)if (!rk_phy)return -ENOMEM ; - of_id =of_match_device (rockchip_pcie_phy_dt_ids, &pdev->dev); -if (!of_id) + rk_phy->phy_data =device_get_match_data (&pdev->dev); +if (!rk_phy->phy_data)return -EINVAL ; - rk_phy->phy_data = (struct rockchip_pcie_data *)of_id->data; rk_phy->reg_base = grf;mutex_init (&rk_phy->pcie_mutex);
drivers/phy/rockchip/phy-rockchip-usb.c +3 -7
@@ -13,10 +13,9 @@#include <linux/module.h> #include <linux/mutex.h> #include <linux/of.h> -#include <linux/of_address.h> -#include <linux/of_platform.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/regulator/consumer.h> #include <linux/reset.h> #include <linux/regmap.h>
@@ -458,7 +457,6 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct rockchip_usb_phy_base *phy_base;struct phy_provider *phy_provider; -const struct of_device_id *match;struct device_node *child;int err;
@@ -466,14 +464,12 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)if (!phy_base)return -ENOMEM ; - match =of_match_device (dev->driver->of_match_table, dev); -if (!match || !match->data) { + phy_base->pdata =device_get_match_data (dev); +if (!phy_base->pdata) {dev_err (dev,"missing phy data\n" );return -EINVAL ; } - phy_base->pdata = match->data; - phy_base->dev = dev; phy_base->reg_base =ERR_PTR (-ENODEV );if (dev->parent && dev->parent->of_node)
drivers/phy/ti/phy-omap-control.c +2 -7
@@ -8,9 +8,9 @@#include <linux/module.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/of.h> -#include <linux/of_device.h> #include <linux/err.h> #include <linux/io.h> #include <linux/clk.h>
@@ -268,20 +268,15 @@ MODULE_DEVICE_TABLE(of, omap_control_phy_id_table);static int omap_control_phy_probe (struct platform_device *pdev) { -const struct of_device_id *of_id;struct omap_control_phy *control_phy; - of_id =of_match_device (omap_control_phy_id_table, &pdev->dev); -if (!of_id) -return -EINVAL ; - control_phy =devm_kzalloc (&pdev->dev,sizeof (*control_phy),GFP_KERNEL );if (!control_phy)return -ENOMEM ; control_phy->dev = &pdev->dev; - control_phy->type = *(enum omap_control_phy_type *)of_id->data; + control_phy->type = *(enum omap_control_phy_type *)device_get_match_data (&pdev->dev);if (control_phy->type ==OMAP_CTRL_TYPE_OTGHS ) { control_phy->otghs_control =
drivers/phy/ti/phy-omap-usb2.c +4 -7
@@ -19,6 +19,7 @@#include <linux/phy/phy.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/property.h> #include <linux/regmap.h> #include <linux/slab.h> #include <linux/sys_soc.h>
@@ -371,16 +372,12 @@ static int omap_usb2_probe(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;struct device_node *control_node;struct platform_device *control_pdev; -const struct of_device_id *of_id; -struct usb_phy_data *phy_data; +const struct usb_phy_data *phy_data; - of_id =of_match_device (omap_usb2_id_table, &pdev->dev); - -if (!of_id) + phy_data =device_get_match_data (&pdev->dev); +if (!phy_data)return -EINVAL ; - phy_data = (struct usb_phy_data *)of_id->data; - phy =devm_kzalloc (&pdev->dev,sizeof (*phy),GFP_KERNEL );if (!phy)return -ENOMEM ;
drivers/phy/ti/phy-ti-pipe3.c +4 -10
@@ -8,6 +8,7 @@#include <linux/module.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/phy/phy.h> #include <linux/of.h>
@@ -777,23 +778,16 @@ static int ti_pipe3_probe(struct platform_device *pdev)struct phy_provider *phy_provider;struct device *dev = &pdev->dev;int ret; -const struct of_device_id *match; -struct pipe3_data *data; +const struct pipe3_data *data; phy =devm_kzalloc (dev,sizeof (*phy),GFP_KERNEL );if (!phy)return -ENOMEM ; - match =of_match_device (ti_pipe3_id_table, dev); -if (!match) + data =device_get_match_data (dev); +if (!data)return -EINVAL ; - data = (struct pipe3_data *)match->data; -if (!data) { -dev_err (dev,"no driver data\n" ); -return -EINVAL ; - } - phy->dev = dev; phy->mode = data->mode; phy->dpll_map = data->dpll_map;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 6/6 phy: ti: omap-usb2: fix device leak at unbind
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
[ Upstream commit 64961557efa1b98f375c0579779e7eeda1a02c42 ]
Make sure to drop the reference to the control device taken by of_find_device_by_node() during probe when the driver is unbound.
--- drivers/phy/ti/phy-omap-usb2.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/phy/ti/phy-omap-usb2.c +13 -0
@@ -363,6 +363,13 @@ static void omap_usb2_init_errata(struct omap_usb *phy) phy->flags |=OMAP_USB2_DISABLE_CHRG_DET ; } +static void omap_usb2_put_device (void *_dev) +{ +struct device *dev = _dev; + +put_device (dev); +} +static int omap_usb2_probe (struct platform_device *pdev) {struct omap_usb *phy;
@@ -373,6 +380,7 @@ static int omap_usb2_probe(struct platform_device *pdev)struct device_node *control_node;struct platform_device *control_pdev;const struct usb_phy_data *phy_data; +int ret; phy_data =device_get_match_data (&pdev->dev);if (!phy_data)
@@ -423,6 +431,11 @@ static int omap_usb2_probe(struct platform_device *pdev)return -EINVAL ; } phy->control_dev = &control_pdev->dev; + + ret =devm_add_action_or_reset (&pdev->dev, omap_usb2_put_device, + phy->control_dev); +if (ret) +return ret; }else { if (of_property_read_u32_index(node, "syscon-phy-power", 1,
Signature · 1 line
2.51.0