Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: phy: davicom: implement generic .handle_interrupt() calback

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.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Ioana Ciornei and committed by
Jakub Kicinski
e954631c a758087f

+26
+26
drivers/net/phy/davicom.c
··· 47 47 #define MII_DM9161_INTR_STOP \ 48 48 (MII_DM9161_INTR_DPLX_MASK | MII_DM9161_INTR_SPD_MASK \ 49 49 | MII_DM9161_INTR_LINK_MASK | MII_DM9161_INTR_MASK) 50 + #define MII_DM9161_INTR_CHANGE \ 51 + (MII_DM9161_INTR_DPLX_CHANGE | \ 52 + MII_DM9161_INTR_SPD_CHANGE | \ 53 + MII_DM9161_INTR_LINK_CHANGE) 50 54 51 55 /* DM9161 10BT Configuration/Status */ 52 56 #define MII_DM9161_10BTCSR 0x12 ··· 79 75 temp = phy_write(phydev, MII_DM9161_INTR, temp); 80 76 81 77 return temp; 78 + } 79 + 80 + static irqreturn_t dm9161_handle_interrupt(struct phy_device *phydev) 81 + { 82 + int irq_status; 83 + 84 + irq_status = phy_read(phydev, MII_DM9161_INTR); 85 + if (irq_status < 0) { 86 + phy_error(phydev); 87 + return IRQ_NONE; 88 + } 89 + 90 + if (!(irq_status & MII_DM9161_INTR_CHANGE)) 91 + return IRQ_NONE; 92 + 93 + phy_trigger_machine(phydev); 94 + 95 + return IRQ_HANDLED; 82 96 } 83 97 84 98 static int dm9161_config_aneg(struct phy_device *phydev) ··· 171 149 .config_aneg = dm9161_config_aneg, 172 150 .ack_interrupt = dm9161_ack_interrupt, 173 151 .config_intr = dm9161_config_intr, 152 + .handle_interrupt = dm9161_handle_interrupt, 174 153 }, { 175 154 .phy_id = 0x0181b8b0, 176 155 .name = "Davicom DM9161B/C", ··· 181 158 .config_aneg = dm9161_config_aneg, 182 159 .ack_interrupt = dm9161_ack_interrupt, 183 160 .config_intr = dm9161_config_intr, 161 + .handle_interrupt = dm9161_handle_interrupt, 184 162 }, { 185 163 .phy_id = 0x0181b8a0, 186 164 .name = "Davicom DM9161A", ··· 191 167 .config_aneg = dm9161_config_aneg, 192 168 .ack_interrupt = dm9161_ack_interrupt, 193 169 .config_intr = dm9161_config_intr, 170 + .handle_interrupt = dm9161_handle_interrupt, 194 171 }, { 195 172 .phy_id = 0x00181b80, 196 173 .name = "Davicom DM9131", ··· 199 174 /* PHY_BASIC_FEATURES */ 200 175 .ack_interrupt = dm9161_ack_interrupt, 201 176 .config_intr = dm9161_config_intr, 177 + .handle_interrupt = dm9161_handle_interrupt, 202 178 } }; 203 179 204 180 module_phy_driver(dm91xx_driver);