* [PATCH net-next 1/2] net: phy: micrel: Allow probing without .driver_data
@ 2022-05-13 11:46 Fabio Estevam
2022-05-13 11:46 ` [PATCH net-next 2/2] net: phy: micrel: Use the kszphy probe/suspend/resume Fabio Estevam
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Fabio Estevam @ 2022-05-13 11:46 UTC (permalink / raw)
To: kuba; +Cc: davem, andrew, netdev, Fabio Estevam
From: Fabio Estevam <festevam@denx.de>
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: Fabio Estevam <festevam@denx.de>
---
drivers/net/phy/micrel.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index c34a93403d1e..5e356e23c1b7 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -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);
return 0;
@@ -536,10 +536,10 @@ static int kszphy_config_init(struct phy_device *phydev)
type = priv->type;
- if (type->has_broadcast_disable)
+ if (type && type->has_broadcast_disable)
kszphy_broadcast_disable(phydev);
- if (type->has_nand_tree_disable)
+ if (type && type->has_nand_tree_disable)
kszphy_nand_tree_disable(phydev);
return kszphy_config_reset(phydev);
@@ -1730,7 +1730,7 @@ static int kszphy_probe(struct phy_device *phydev)
priv->type = type;
- if (type->led_mode_reg) {
+ if (type && type->led_mode_reg) {
ret = of_property_read_u32(np, "micrel,led-mode",
&priv->led_mode);
if (ret)
@@ -1751,7 +1751,8 @@ static int kszphy_probe(struct phy_device *phydev)
unsigned long rate = clk_get_rate(clk);
bool rmii_ref_clk_sel_25_mhz;
- priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel;
+ if (type)
+ priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel;
rmii_ref_clk_sel_25_mhz = of_property_read_bool(np,
"micrel,rmii-reference-clock-select-25-mhz");
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 2/2] net: phy: micrel: Use the kszphy probe/suspend/resume
2022-05-13 11:46 [PATCH net-next 1/2] net: phy: micrel: Allow probing without .driver_data Fabio Estevam
@ 2022-05-13 11:46 ` Fabio Estevam
2022-05-13 19:37 ` Andrew Lunn
2022-05-13 19:36 ` [PATCH net-next 1/2] net: phy: micrel: Allow probing without .driver_data Andrew Lunn
2022-05-16 20:10 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Fabio Estevam @ 2022-05-13 11:46 UTC (permalink / raw)
To: kuba; +Cc: davem, andrew, netdev, Fabio Estevam
From: Fabio Estevam <festevam@denx.de>
Now that it is possible to use .probe without having .driver_data, let
KSZ8061 use the kszphy specific hooks for probe,suspend and resume,
which is preferred.
Switch to using the dedicated kszphy probe/suspend/resume functions.
Signed-off-by: Fabio Estevam <festevam@denx.de>
---
drivers/net/phy/micrel.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 5e356e23c1b7..22139901f01c 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -3019,11 +3019,12 @@ static struct phy_driver ksphy_driver[] = {
.name = "Micrel KSZ8061",
.phy_id_mask = MICREL_PHY_ID_MASK,
/* PHY_BASIC_FEATURES */
+ .probe = kszphy_probe,
.config_init = ksz8061_config_init,
.config_intr = kszphy_config_intr,
.handle_interrupt = kszphy_handle_interrupt,
- .suspend = genphy_suspend,
- .resume = genphy_resume,
+ .suspend = kszphy_suspend,
+ .resume = kszphy_resume,
}, {
.phy_id = PHY_ID_KSZ9021,
.phy_id_mask = 0x000ffffe,
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 1/2] net: phy: micrel: Allow probing without .driver_data
2022-05-13 11:46 [PATCH net-next 1/2] net: phy: micrel: Allow probing without .driver_data Fabio Estevam
2022-05-13 11:46 ` [PATCH net-next 2/2] net: phy: micrel: Use the kszphy probe/suspend/resume Fabio Estevam
@ 2022-05-13 19:36 ` Andrew Lunn
2022-05-16 20:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2022-05-13 19:36 UTC (permalink / raw)
To: Fabio Estevam; +Cc: kuba, davem, netdev, Fabio Estevam
On Fri, May 13, 2022 at 08:46:12AM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <festevam@denx.de>
>
> 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: Fabio Estevam <festevam@denx.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 2/2] net: phy: micrel: Use the kszphy probe/suspend/resume
2022-05-13 11:46 ` [PATCH net-next 2/2] net: phy: micrel: Use the kszphy probe/suspend/resume Fabio Estevam
@ 2022-05-13 19:37 ` Andrew Lunn
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2022-05-13 19:37 UTC (permalink / raw)
To: Fabio Estevam; +Cc: kuba, davem, netdev, Fabio Estevam
On Fri, May 13, 2022 at 08:46:13AM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <festevam@denx.de>
>
> Now that it is possible to use .probe without having .driver_data, let
> KSZ8061 use the kszphy specific hooks for probe,suspend and resume,
> which is preferred.
>
> Switch to using the dedicated kszphy probe/suspend/resume functions.
>
> Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 1/2] net: phy: micrel: Allow probing without .driver_data
2022-05-13 11:46 [PATCH net-next 1/2] net: phy: micrel: Allow probing without .driver_data Fabio Estevam
2022-05-13 11:46 ` [PATCH net-next 2/2] net: phy: micrel: Use the kszphy probe/suspend/resume Fabio Estevam
2022-05-13 19:36 ` [PATCH net-next 1/2] net: phy: micrel: Allow probing without .driver_data Andrew Lunn
@ 2022-05-16 20:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-16 20:10 UTC (permalink / raw)
To: Fabio Estevam; +Cc: kuba, davem, andrew, netdev, festevam
Hello:
This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 13 May 2022 08:46:12 -0300 you wrote:
> From: Fabio Estevam <festevam@denx.de>
>
> 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.
>
> [...]
Here is the summary with links:
- [net-next,1/2] net: phy: micrel: Allow probing without .driver_data
https://git.kernel.org/netdev/net-next/c/f2ef6f7539c6
- [net-next,2/2] net: phy: micrel: Use the kszphy probe/suspend/resume
https://git.kernel.org/netdev/net-next/c/8e6004dfecb7
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-05-16 20:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13 11:46 [PATCH net-next 1/2] net: phy: micrel: Allow probing without .driver_data Fabio Estevam
2022-05-13 11:46 ` [PATCH net-next 2/2] net: phy: micrel: Use the kszphy probe/suspend/resume Fabio Estevam
2022-05-13 19:37 ` Andrew Lunn
2022-05-13 19:36 ` [PATCH net-next 1/2] net: phy: micrel: Allow probing without .driver_data Andrew Lunn
2022-05-16 20:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).