net: phy: qsemi: remove the use of .ack_interrupt()
authorIoana Ciornei <ioana.ciornei@nxp.com>
Mon, 23 Nov 2020 15:38:16 +0000 (17:38 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 25 Nov 2020 19:18:38 +0000 (11:18 -0800)
In preparation of removing the .ack_interrupt() callback, we must replace
its occurrences (aka phy_clear_interrupt), from the 2 places where it is
called from (phy_enable_interrupts and phy_disable_interrupts), with
equivalent functionality.

This means that clearing interrupts now becomes something that the PHY
driver is responsible of doing, before enabling interrupts and after
clearing them. Make this driver follow the new contract.

Also, add a comment describing the multiple step interrupt
acknoledgement process.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/qsemi.c

index 97f29ed2f0cadd684d16b32e85f62995ac7e6e3d..d5c1aaa8236a96f176b7be58369edbde59cd081e 100644 (file)
@@ -75,6 +75,10 @@ static int qs6612_ack_interrupt(struct phy_device *phydev)
 {
        int err;
 
+       /* The Interrupt Source register is not self-clearing, bits 4 and 5 are
+        * cleared when MII_BMSR is read and bits 1 and 3 are cleared when
+        * MII_EXPANSION is read
+        */
        err = phy_read(phydev, MII_QS6612_ISR);
 
        if (err < 0)
@@ -96,11 +100,22 @@ static int qs6612_ack_interrupt(struct phy_device *phydev)
 static int qs6612_config_intr(struct phy_device *phydev)
 {
        int err;
-       if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
+       if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
+               /* clear any interrupts before enabling them */
+               err = qs6612_ack_interrupt(phydev);
+               if (err)
+                       return err;
+
                err = phy_write(phydev, MII_QS6612_IMR,
                                MII_QS6612_IMR_INIT);
-       else
+       } else {
                err = phy_write(phydev, MII_QS6612_IMR, 0);
+               if (err)
+                       return err;
+
+               /* clear any leftover interrupts */
+               err = qs6612_ack_interrupt(phydev);
+       }
 
        return err;
 
@@ -133,7 +148,6 @@ static struct phy_driver qs6612_driver[] = { {
        .phy_id_mask    = 0xfffffff0,
        /* PHY_BASIC_FEATURES */
        .config_init    = qs6612_config_init,
-       .ack_interrupt  = qs6612_ack_interrupt,
        .config_intr    = qs6612_config_intr,
        .handle_interrupt = qs6612_handle_interrupt,
 } };