On 23.02.2019 03:36, Linus Walleij wrote:
> This fixes a regression introduced by
> commit 0d2e778e38e0ddffab4bb2b0e9ed2ad5165c4bf7
> "net: phy: replace PHY_HAS_INTERRUPT with a check for
> config_intr and ack_interrupt".
>
> This assumes that a PHY cannot trigger interrupt unless
> it has .config_intr() or .ack_interrupt() implemented.
> A later patch makes the code assume both need to be
> implemented for interrupts to be present.
>
> But this PHY (which is inside a DSA) will happily
> fire interrupts without either callback.
>
> Implement a dummy callback for .config_intr() and
> .ack_interrupt() as a workaround.
>
> Tested on the RTL8366RB on D-Link DIR-685.
>
> Fixes: 0d2e778e38e0 ("net: phy: replace PHY_HAS_INTERRUPT with a check for
> config_intr and ack_interrupt")
> Cc: Heiner Kallweit <[email protected]>
> Signed-off-by: Linus Walleij <[email protected]>
> ---
> drivers/net/phy/realtek.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> index c6010fb1aa0f..31372be44570 100644
> --- a/drivers/net/phy/realtek.c
> +++ b/drivers/net/phy/realtek.c
> @@ -211,6 +211,17 @@ static int rtl8366rb_config_init(struct phy_device
> *phydev)
> return ret;
> }
>
> +static int rtl8366rb_ack_interrupt(struct phy_device *phydev)
> +{
> + return 0;
> +}
> +
> +static int rtl8366rb_config_intr(struct phy_device *phydev)
> +{
> + /* Dummy function to make sure we get interrupts */
> + return 0;
> +}
> +
Maybe we should place these dummy calls in the core. We have this for
other cases already, see e.g. genphy_no_soft_reset. Then these dummies
can be re-used by other drivers that may have the need to do so.
Names could be:
genphy_no_ack_interrupt
genphy_no_config_intr
> static struct phy_driver realtek_drvs[] = {
> {
> PHY_ID_MATCH_EXACT(0x00008201),
> @@ -282,6 +293,8 @@ static struct phy_driver realtek_drvs[] = {
> .name = "RTL8366RB Gigabit Ethernet",
> .features = PHY_GBIT_FEATURES,
> .config_init = &rtl8366rb_config_init,
> + .ack_interrupt = &rtl8366rb_ack_interrupt,
> + .config_intr = &rtl8366rb_config_intr,
> .suspend = genphy_suspend,
> .resume = genphy_resume,
> },
>