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

net: phy: intel-xway: implement generic .handle_interrupt() callback

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: Mathias Kresin <dev@kresin.me>
Cc: Hauke Mehrtens <hauke@hauke-m.de>
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
1566db04 470dfd80

+28 -18
+28 -18
drivers/net/phy/intel-xway.c
··· 209 209 return (reg < 0) ? reg : 0; 210 210 } 211 211 212 - static int xway_gphy_did_interrupt(struct phy_device *phydev) 213 - { 214 - int reg; 215 - 216 - reg = phy_read(phydev, XWAY_MDIO_ISTAT); 217 - return reg & XWAY_MDIO_INIT_MASK; 218 - } 219 - 220 212 static int xway_gphy_config_intr(struct phy_device *phydev) 221 213 { 222 214 u16 mask = 0; ··· 217 225 mask = XWAY_MDIO_INIT_MASK; 218 226 219 227 return phy_write(phydev, XWAY_MDIO_IMASK, mask); 228 + } 229 + 230 + static irqreturn_t xway_gphy_handle_interrupt(struct phy_device *phydev) 231 + { 232 + int irq_status; 233 + 234 + irq_status = phy_read(phydev, XWAY_MDIO_ISTAT); 235 + if (irq_status < 0) { 236 + phy_error(phydev); 237 + return IRQ_NONE; 238 + } 239 + 240 + if (!(irq_status & XWAY_MDIO_INIT_MASK)) 241 + return IRQ_NONE; 242 + 243 + phy_trigger_machine(phydev); 244 + 245 + return IRQ_HANDLED; 220 246 } 221 247 222 248 static struct phy_driver xway_gphy[] = { ··· 246 236 .config_init = xway_gphy_config_init, 247 237 .config_aneg = xway_gphy14_config_aneg, 248 238 .ack_interrupt = xway_gphy_ack_interrupt, 249 - .did_interrupt = xway_gphy_did_interrupt, 239 + .handle_interrupt = xway_gphy_handle_interrupt, 250 240 .config_intr = xway_gphy_config_intr, 251 241 .suspend = genphy_suspend, 252 242 .resume = genphy_resume, ··· 258 248 .config_init = xway_gphy_config_init, 259 249 .config_aneg = xway_gphy14_config_aneg, 260 250 .ack_interrupt = xway_gphy_ack_interrupt, 261 - .did_interrupt = xway_gphy_did_interrupt, 251 + .handle_interrupt = xway_gphy_handle_interrupt, 262 252 .config_intr = xway_gphy_config_intr, 263 253 .suspend = genphy_suspend, 264 254 .resume = genphy_resume, ··· 270 260 .config_init = xway_gphy_config_init, 271 261 .config_aneg = xway_gphy14_config_aneg, 272 262 .ack_interrupt = xway_gphy_ack_interrupt, 273 - .did_interrupt = xway_gphy_did_interrupt, 263 + .handle_interrupt = xway_gphy_handle_interrupt, 274 264 .config_intr = xway_gphy_config_intr, 275 265 .suspend = genphy_suspend, 276 266 .resume = genphy_resume, ··· 282 272 .config_init = xway_gphy_config_init, 283 273 .config_aneg = xway_gphy14_config_aneg, 284 274 .ack_interrupt = xway_gphy_ack_interrupt, 285 - .did_interrupt = xway_gphy_did_interrupt, 275 + .handle_interrupt = xway_gphy_handle_interrupt, 286 276 .config_intr = xway_gphy_config_intr, 287 277 .suspend = genphy_suspend, 288 278 .resume = genphy_resume, ··· 293 283 /* PHY_GBIT_FEATURES */ 294 284 .config_init = xway_gphy_config_init, 295 285 .ack_interrupt = xway_gphy_ack_interrupt, 296 - .did_interrupt = xway_gphy_did_interrupt, 286 + .handle_interrupt = xway_gphy_handle_interrupt, 297 287 .config_intr = xway_gphy_config_intr, 298 288 .suspend = genphy_suspend, 299 289 .resume = genphy_resume, ··· 304 294 /* PHY_BASIC_FEATURES */ 305 295 .config_init = xway_gphy_config_init, 306 296 .ack_interrupt = xway_gphy_ack_interrupt, 307 - .did_interrupt = xway_gphy_did_interrupt, 297 + .handle_interrupt = xway_gphy_handle_interrupt, 308 298 .config_intr = xway_gphy_config_intr, 309 299 .suspend = genphy_suspend, 310 300 .resume = genphy_resume, ··· 315 305 /* PHY_GBIT_FEATURES */ 316 306 .config_init = xway_gphy_config_init, 317 307 .ack_interrupt = xway_gphy_ack_interrupt, 318 - .did_interrupt = xway_gphy_did_interrupt, 308 + .handle_interrupt = xway_gphy_handle_interrupt, 319 309 .config_intr = xway_gphy_config_intr, 320 310 .suspend = genphy_suspend, 321 311 .resume = genphy_resume, ··· 326 316 /* PHY_BASIC_FEATURES */ 327 317 .config_init = xway_gphy_config_init, 328 318 .ack_interrupt = xway_gphy_ack_interrupt, 329 - .did_interrupt = xway_gphy_did_interrupt, 319 + .handle_interrupt = xway_gphy_handle_interrupt, 330 320 .config_intr = xway_gphy_config_intr, 331 321 .suspend = genphy_suspend, 332 322 .resume = genphy_resume, ··· 337 327 /* PHY_GBIT_FEATURES */ 338 328 .config_init = xway_gphy_config_init, 339 329 .ack_interrupt = xway_gphy_ack_interrupt, 340 - .did_interrupt = xway_gphy_did_interrupt, 330 + .handle_interrupt = xway_gphy_handle_interrupt, 341 331 .config_intr = xway_gphy_config_intr, 342 332 .suspend = genphy_suspend, 343 333 .resume = genphy_resume, ··· 348 338 /* PHY_BASIC_FEATURES */ 349 339 .config_init = xway_gphy_config_init, 350 340 .ack_interrupt = xway_gphy_ack_interrupt, 351 - .did_interrupt = xway_gphy_did_interrupt, 341 + .handle_interrupt = xway_gphy_handle_interrupt, 352 342 .config_intr = xway_gphy_config_intr, 353 343 .suspend = genphy_suspend, 354 344 .resume = genphy_resume,