]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: phy: microchip: implement generic .handle_interrupt() callback
authorIoana Ciornei <ioana.ciornei@nxp.com>
Sat, 6 Sep 2025 13:12:34 +0000 (09:12 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Sep 2025 16:45:24 +0000 (18:45 +0200)
[ Upstream commit e01a3feb8f69ab620b0016498603cad364f65224 ]

In an attempt to actually support shared IRQs in phylib, we now move the
responsibility of triggering the phylib state machine or just returning
IRQ_NONE, based on the IRQ status register, to the PHY driver. Having
3 different IRQ handling callbacks (.handle_interrupt(),
.did_interrupt() and .ack_interrupt() ) is confusing so let the PHY
driver implement directly an IRQ handler like any other device driver.
Make this driver follow the new convention.

Cc: Nisar Sayed <Nisar.Sayed@microchip.com>
Cc: Yuiko Oshino <yuiko.oshino@microchip.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 30a41ed32d30 ("net: phy: microchip: force IRQ polling mode for lan88xx")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/phy/microchip.c
drivers/net/phy/microchip_t1.c

index e6ad7d29a05595e0b8da18bb3e3f0cd4be694bd7..b8a1cbd180cdf83c108d69866c7bff3f7978e486 100644 (file)
@@ -56,6 +56,24 @@ static int lan88xx_phy_ack_interrupt(struct phy_device *phydev)
        return rc < 0 ? rc : 0;
 }
 
+static irqreturn_t lan88xx_handle_interrupt(struct phy_device *phydev)
+{
+       int irq_status;
+
+       irq_status = phy_read(phydev, LAN88XX_INT_STS);
+       if (irq_status < 0) {
+               phy_error(phydev);
+               return IRQ_NONE;
+       }
+
+       if (!(irq_status & LAN88XX_INT_STS_LINK_CHANGE_))
+               return IRQ_NONE;
+
+       phy_trigger_machine(phydev);
+
+       return IRQ_HANDLED;
+}
+
 static int lan88xx_suspend(struct phy_device *phydev)
 {
        struct lan88xx_priv *priv = phydev->priv;
@@ -374,6 +392,7 @@ static struct phy_driver microchip_phy_driver[] = {
 
        .ack_interrupt  = lan88xx_phy_ack_interrupt,
        .config_intr    = lan88xx_phy_config_intr,
+       .handle_interrupt = lan88xx_handle_interrupt,
 
        .suspend        = lan88xx_suspend,
        .resume         = genphy_resume,
index fed3e395f18e1c42bd81a5ef6537c18d8782f2ca..553b391d1747a53221b8f9604dade799060a68eb 100644 (file)
@@ -203,6 +203,24 @@ static int lan87xx_phy_ack_interrupt(struct phy_device *phydev)
        return rc < 0 ? rc : 0;
 }
 
+static irqreturn_t lan87xx_handle_interrupt(struct phy_device *phydev)
+{
+       int irq_status;
+
+       irq_status = phy_read(phydev, LAN87XX_INTERRUPT_SOURCE);
+       if (irq_status < 0) {
+               phy_error(phydev);
+               return IRQ_NONE;
+       }
+
+       if (irq_status == 0)
+               return IRQ_NONE;
+
+       phy_trigger_machine(phydev);
+
+       return IRQ_HANDLED;
+}
+
 static int lan87xx_config_init(struct phy_device *phydev)
 {
        int rc = lan87xx_phy_init(phydev);
@@ -223,6 +241,7 @@ static struct phy_driver microchip_t1_phy_driver[] = {
 
                .ack_interrupt  = lan87xx_phy_ack_interrupt,
                .config_intr    = lan87xx_phy_config_intr,
+               .handle_interrupt = lan87xx_handle_interrupt,
 
                .suspend        = genphy_suspend,
                .resume         = genphy_resume,