phy: Set missing .owner = THIS_MODULE in phy_ops
Subsystems (12)
cover phy: Set missing .owner = THIS_MODULE in phy_ops
phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while a PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Ten modular drivers under drivers/phy/ omit .owner = THIS_MODULE in their const struct phy_ops definitions, leaving phy->ops->owner NULL.
Split per driver to simplify per-vendor review and stable backporting.
Tooling note: Found using Clang's require_explicit_initialization attribute; an AI coding assistant helped audit call sites, verify Fixes commits, and draft the changelogs. All ten drivers were build-tested as modules (-DMODULE) with LLVM=1.
Ian Rogers (10):
phy: allwinner: phy-sun6i-mipi-dphy: Set .owner = THIS_MODULE
phy: cadence: cdns-dphy-rx: Set .owner = THIS_MODULE
phy: cadence: cdns-dphy: Set .owner = THIS_MODULE
phy: eyeq5-eth: Set .owner = THIS_MODULE
phy: google: usb: Set .owner = THIS_MODULE
phy: qcom: ipq4019-usb: Set .owner = THIS_MODULE
phy: renesas: r8a779f0-ether-serdes: Set .owner = THIS_MODULE
phy: starfive: jh7110-dphy-rx: Set .owner = THIS_MODULE
phy: sunplus: usb2: Set .owner = THIS_MODULE
phy: tegra: mphy: Set .owner = THIS_MODULE
drivers/phy/allwinner/phy-sun6i-mipi-dphy.c | 1 + drivers/phy/cadence/cdns-dphy-rx.c | 1 + drivers/phy/cadence/cdns-dphy.c | 1 + drivers/phy/phy-eyeq5-eth.c | 1 + drivers/phy/phy-google-usb.c | 2 ++ drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c | 2 ++ drivers/phy/renesas/r8a779f0-ether-serdes.c | 1 + drivers/phy/starfive/phy-jh7110-dphy-rx.c | 1 + drivers/phy/sunplus/phy-sunplus-usb2.c | 1 + drivers/phy/tegra/phy-tegra-mphy.c | 2 ++ 10 files changed, 13 insertions(+)
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
Signature · 1 line
2.56.1.839.g22a8290db9-goog
PATCH 1/10 phy: allwinner: phy-sun6i-mipi-dphy: Set .owner = THIS_MODULE
phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.
Set .owner = THIS_MODULE in sun6i_dphy_ops, found with Clang's require_explicit_initialization attribute.
--- drivers/phy/allwinner/phy-sun6i-mipi-dphy.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/allwinner/phy-sun6i-mipi-dphy.c +1 -0
@@ -535,6 +535,7 @@ static const struct phy_ops sun6i_dphy_ops = { .power_off = sun6i_dphy_power_off, .init = sun6i_dphy_init, .exit = sun6i_dphy_exit, + .owner = THIS_MODULE, };static const struct regmap_config sun6i_dphy_regmap_config = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
PATCH 2/10 phy: cadence: cdns-dphy-rx: Set .owner = THIS_MODULE
In reply to Ian Rogersphy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.
Set .owner = THIS_MODULE in cdns_dphy_rx_ops, found with Clang's require_explicit_initialization attribute.
--- drivers/phy/cadence/cdns-dphy-rx.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/cadence/cdns-dphy-rx.c +1 -0
@@ -232,6 +232,7 @@ static const struct phy_ops cdns_dphy_rx_ops = { .power_off = cdns_dphy_rx_power_off, .configure = cdns_dphy_rx_configure, .validate = cdns_dphy_rx_validate, + .owner = THIS_MODULE, };static int cdns_dphy_rx_probe (struct platform_device *pdev)
Signature · 1 line
2.56.1.839.g22a8290db9-goog
PATCH 3/10 phy: cadence: cdns-dphy: Set .owner = THIS_MODULE
In reply to Ian Rogersphy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.
Set .owner = THIS_MODULE in cdns_dphy_ops, found with Clang's require_explicit_initialization attribute.
--- drivers/phy/cadence/cdns-dphy.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/cadence/cdns-dphy.c +1 -0
@@ -463,6 +463,7 @@ static const struct phy_ops cdns_dphy_ops = { .validate = cdns_dphy_validate, .power_on = cdns_dphy_power_on, .power_off = cdns_dphy_power_off, + .owner = THIS_MODULE, };static int cdns_dphy_probe (struct platform_device *pdev)
Signature · 1 line
2.56.1.839.g22a8290db9-goog
PATCH 4/10 phy: eyeq5-eth: Set .owner = THIS_MODULE
In reply to Ian Rogersphy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.
Set .owner = THIS_MODULE in eq5_phy_ops, found with Clang's require_explicit_initialization attribute.
--- drivers/phy/phy-eyeq5-eth.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/phy-eyeq5-eth.c +1 -0
@@ -182,6 +182,7 @@ static const struct phy_ops eq5_phy_ops = { .power_off = eq5_phy_power_off, .set_mode = eq5_phy_set_mode, .validate = eq5_phy_validate, + .owner = THIS_MODULE, }; static struct phy *eq5_phy_xlate(struct device *dev,
Signature · 1 line
2.56.1.839.g22a8290db9-goog
PATCH 5/10 phy: google: usb: Set .owner = THIS_MODULE
In reply to Ian Rogersphy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.
Set .owner = THIS_MODULE in google_usb2_phy_ops and google_usb3_phy_ops, found with Clang's require_explicit_initialization attribute.
--- drivers/phy/phy-google-usb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/phy-google-usb.c +2 -0
@@ -348,6 +348,7 @@ static int google_usb2_phy_exit(struct phy *_phy)static const struct phy_ops google_usb2_phy_ops = { .init = google_usb2_phy_init, .exit = google_usb2_phy_exit, + .owner =THIS_MODULE , };static int google_usb3_phy_init (struct phy *_phy)
@@ -470,6 +471,7 @@ static const struct phy_ops google_usb3_phy_ops = { .init = google_usb3_phy_init, .exit = google_usb3_phy_exit, .power_on = google_usb3_phy_power_on, + .owner = THIS_MODULE, }; static struct phy *google_usb_phy_xlate(struct device *dev,
Signature · 1 line
2.56.1.839.g22a8290db9-goog
PATCH 6/10 phy: qcom: ipq4019-usb: Set .owner = THIS_MODULE
In reply to Ian Rogersphy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.
Set .owner = THIS_MODULE in ipq4019_usb_ss_phy_ops and ipq4019_usb_hs_phy_ops, found with Clang's require_explicit_initialization attribute.
--- drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c +2 -0
@@ -50,6 +50,7 @@ static int ipq4019_ss_phy_power_on(struct phy *_phy)static const struct phy_ops ipq4019_usb_ss_phy_ops = { .power_on = ipq4019_ss_phy_power_on, .power_off = ipq4019_ss_phy_power_off, + .owner =THIS_MODULE , };static int ipq4019_hs_phy_power_off (struct phy *_phy)
@@ -82,6 +83,7 @@ static int ipq4019_hs_phy_power_on(struct phy *_phy)static const struct phy_ops ipq4019_usb_hs_phy_ops = { .power_on = ipq4019_hs_phy_power_on, .power_off = ipq4019_hs_phy_power_off, + .owner =THIS_MODULE , };static const struct of_device_id ipq4019_usb_phy_of_match[] = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
PATCH 7/10 phy: renesas: r8a779f0-ether-serdes: Set .owner = THIS_MODULE
In reply to Ian Rogersphy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.
Set .owner = THIS_MODULE in r8a779f0_eth_serdes_ops, found with Clang's require_explicit_initialization attribute.
--- drivers/phy/renesas/r8a779f0-ether-serdes.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/renesas/r8a779f0-ether-serdes.c +1 -0
@@ -404,6 +404,7 @@ static const struct phy_ops r8a779f0_eth_serdes_ops = { .power_on = r8a779f0_eth_serdes_power_on, .set_mode = r8a779f0_eth_serdes_set_mode, .set_speed = r8a779f0_eth_serdes_set_speed, + .owner = THIS_MODULE, }; static struct phy *r8a779f0_eth_serdes_xlate(struct device *dev,
Signature · 1 line
2.56.1.839.g22a8290db9-goog
PATCH 8/10 phy: starfive: jh7110-dphy-rx: Set .owner = THIS_MODULE
In reply to Ian Rogersphy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.
Set .owner = THIS_MODULE in stf_dphy_ops, found with Clang's require_explicit_initialization attribute.
--- drivers/phy/starfive/phy-jh7110-dphy-rx.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/starfive/phy-jh7110-dphy-rx.c +1 -0
@@ -144,6 +144,7 @@ static const struct phy_ops stf_dphy_ops = { .configure = stf_dphy_configure, .power_on = stf_dphy_power_on, .power_off = stf_dphy_power_off, + .owner = THIS_MODULE, };static int stf_dphy_probe (struct platform_device *pdev)
Signature · 1 line
2.56.1.839.g22a8290db9-goog
PATCH 9/10 phy: sunplus: usb2: Set .owner = THIS_MODULE
In reply to Ian Rogersphy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.
Set .owner = THIS_MODULE in sp_uphy_ops, found with Clang's require_explicit_initialization attribute.
--- drivers/phy/sunplus/phy-sunplus-usb2.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/sunplus/phy-sunplus-usb2.c +1 -0
@@ -227,6 +227,7 @@ static const struct phy_ops sp_uphy_ops = { .power_on = sp_uphy_power_on, .power_off = sp_uphy_power_off, .exit = sp_uphy_exit, + .owner = THIS_MODULE, };static const struct of_device_id sp_uphy_dt_ids[] = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
PATCH 10/10 phy: tegra: mphy: Set .owner = THIS_MODULE
In reply to Ian Rogersphy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.
Set .owner = THIS_MODULE in tegra_mphy_rx_ops and tegra_mphy_tx_ops, found with Clang's require_explicit_initialization attribute.
--- drivers/phy/tegra/phy-tegra-mphy.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/tegra/phy-tegra-mphy.c +2 -0
@@ -276,6 +276,7 @@ static const struct phy_ops tegra_mphy_rx_ops = { .power_off = tegra_mphy_rx_power_off, .configure = tegra_mphy_rx_configure, .calibrate = tegra_mphy_rx_calibrate, + .owner = THIS_MODULE, };static int tegra_mphy_tx_configure (struct phy *phy,union phy_configure_opts *opts)
@@ -339,6 +340,7 @@ static int tegra_mphy_tx_calibrate(struct phy *phy)static const struct phy_ops tegra_mphy_tx_ops = { .configure = tegra_mphy_tx_configure, .calibrate = tegra_mphy_tx_calibrate, + .owner =THIS_MODULE , };static struct phy *tegra_mphy_xlate (struct device *dev,const struct of_phandle_args *args)
Signature · 1 line
2.56.1.839.g22a8290db9-goog
回复: [PATCH 08/10] phy: starfive: jh7110-dphy-rx: Set .owner = THIS_MODULE
In reply to Ian RogersHi, lan
Thanks for the patch.
Quoted 7 lines
phy_get()andof_phy_get()calltry_module_get(phy->ops->owner)to pin the PHY provider module while the PHY is in use, andof_phy_put()callsmodule_put(phy->ops->owner). Becausephy->opsis const structphy_ops*,phy_create()cannot populateops->ownerat runtime, andtry_module_get(NULL)returns true without incrementing the module reference count.
Quoted 5 lines
Set .owner =
THIS_MODULEinstf_dphy_ops, found with Clang'srequire_explicit_initializationattribute.Fixes f8aa660841bc ("phy: starfive: Add mipi dphy rx support")Signed-off-by Ian Rogers <[email protected]>
Best Regards,
Changhuang