Commit f2ef6f75 authored by Fabio Estevam's avatar Fabio Estevam Committed by Jakub Kicinski

net: phy: micrel: Allow probing without .driver_data

Currently, if the .probe element is present in the phy_driver structure
and the .driver_data is not, a NULL pointer dereference happens.

Allow passing .probe without .driver_data by inserting NULL checks
for priv->type.
Signed-off-by: default avatarFabio Estevam <festevam@denx.de>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20220513114613.762810-1-festevam@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d887ae32
...@@ -520,7 +520,7 @@ static int kszphy_config_reset(struct phy_device *phydev) ...@@ -520,7 +520,7 @@ static int kszphy_config_reset(struct phy_device *phydev)
} }
} }
if (priv->led_mode >= 0) if (priv->type && priv->led_mode >= 0)
kszphy_setup_led(phydev, priv->type->led_mode_reg, priv->led_mode); kszphy_setup_led(phydev, priv->type->led_mode_reg, priv->led_mode);
return 0; return 0;
...@@ -536,10 +536,10 @@ static int kszphy_config_init(struct phy_device *phydev) ...@@ -536,10 +536,10 @@ static int kszphy_config_init(struct phy_device *phydev)
type = priv->type; type = priv->type;
if (type->has_broadcast_disable) if (type && type->has_broadcast_disable)
kszphy_broadcast_disable(phydev); kszphy_broadcast_disable(phydev);
if (type->has_nand_tree_disable) if (type && type->has_nand_tree_disable)
kszphy_nand_tree_disable(phydev); kszphy_nand_tree_disable(phydev);
return kszphy_config_reset(phydev); return kszphy_config_reset(phydev);
...@@ -1730,7 +1730,7 @@ static int kszphy_probe(struct phy_device *phydev) ...@@ -1730,7 +1730,7 @@ static int kszphy_probe(struct phy_device *phydev)
priv->type = type; priv->type = type;
if (type->led_mode_reg) { if (type && type->led_mode_reg) {
ret = of_property_read_u32(np, "micrel,led-mode", ret = of_property_read_u32(np, "micrel,led-mode",
&priv->led_mode); &priv->led_mode);
if (ret) if (ret)
...@@ -1751,6 +1751,7 @@ static int kszphy_probe(struct phy_device *phydev) ...@@ -1751,6 +1751,7 @@ static int kszphy_probe(struct phy_device *phydev)
unsigned long rate = clk_get_rate(clk); unsigned long rate = clk_get_rate(clk);
bool rmii_ref_clk_sel_25_mhz; bool rmii_ref_clk_sel_25_mhz;
if (type)
priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel; priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel;
rmii_ref_clk_sel_25_mhz = of_property_read_bool(np, rmii_ref_clk_sel_25_mhz = of_property_read_bool(np,
"micrel,rmii-reference-clock-select-25-mhz"); "micrel,rmii-reference-clock-select-25-mhz");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment