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

net: phy: ti: remove the use of .ack_interrupt()

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.

Cc: Dan Murphy <dmurphy@ti.com>
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
aa2d603a 1d1ae3c6

+56 -31
+9 -2
drivers/net/phy/dp83640.c
··· 1159 1159 int err; 1160 1160 1161 1161 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { 1162 + err = dp83640_ack_interrupt(phydev); 1163 + if (err) 1164 + return err; 1165 + 1162 1166 misr = phy_read(phydev, MII_DP83640_MISR); 1163 1167 if (misr < 0) 1164 1168 return misr; ··· 1201 1197 MII_DP83640_MISR_DUP_INT_EN | 1202 1198 MII_DP83640_MISR_SPD_INT_EN | 1203 1199 MII_DP83640_MISR_LINK_INT_EN); 1204 - return phy_write(phydev, MII_DP83640_MISR, misr); 1200 + err = phy_write(phydev, MII_DP83640_MISR, misr); 1201 + if (err) 1202 + return err; 1203 + 1204 + return dp83640_ack_interrupt(phydev); 1205 1205 } 1206 1206 } 1207 1207 ··· 1549 1541 .remove = dp83640_remove, 1550 1542 .soft_reset = dp83640_soft_reset, 1551 1543 .config_init = dp83640_config_init, 1552 - .ack_interrupt = dp83640_ack_interrupt, 1553 1544 .config_intr = dp83640_config_intr, 1554 1545 .handle_interrupt = dp83640_handle_interrupt, 1555 1546 };
-17
drivers/net/phy/dp83822.c
··· 119 119 u16 fx_sd_enable; 120 120 }; 121 121 122 - static int dp83822_ack_interrupt(struct phy_device *phydev) 123 - { 124 - int err; 125 - 126 - err = phy_read(phydev, MII_DP83822_MISR1); 127 - if (err < 0) 128 - return err; 129 - 130 - err = phy_read(phydev, MII_DP83822_MISR2); 131 - if (err < 0) 132 - return err; 133 - 134 - return 0; 135 - } 136 - 137 122 static int dp83822_set_wol(struct phy_device *phydev, 138 123 struct ethtool_wolinfo *wol) 139 124 { ··· 594 609 .read_status = dp83822_read_status, \ 595 610 .get_wol = dp83822_get_wol, \ 596 611 .set_wol = dp83822_set_wol, \ 597 - .ack_interrupt = dp83822_ack_interrupt, \ 598 612 .config_intr = dp83822_config_intr, \ 599 613 .handle_interrupt = dp83822_handle_interrupt, \ 600 614 .suspend = dp83822_suspend, \ ··· 609 625 .config_init = dp8382x_config_init, \ 610 626 .get_wol = dp83822_get_wol, \ 611 627 .set_wol = dp83822_set_wol, \ 612 - .ack_interrupt = dp83822_ack_interrupt, \ 613 628 .config_intr = dp83822_config_intr, \ 614 629 .handle_interrupt = dp83822_handle_interrupt, \ 615 630 .suspend = dp83822_suspend, \
+12 -2
drivers/net/phy/dp83848.c
··· 67 67 return control; 68 68 69 69 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { 70 + ret = dp83848_ack_interrupt(phydev); 71 + if (ret) 72 + return ret; 73 + 70 74 control |= DP83848_MICR_INT_OE; 71 75 control |= DP83848_MICR_INTEN; 72 76 73 77 ret = phy_write(phydev, DP83848_MISR, DP83848_INT_EN_MASK); 74 78 if (ret < 0) 75 79 return ret; 80 + 81 + ret = phy_write(phydev, DP83848_MICR, control); 76 82 } else { 77 83 control &= ~DP83848_MICR_INTEN; 84 + ret = phy_write(phydev, DP83848_MICR, control); 85 + if (ret) 86 + return ret; 87 + 88 + ret = dp83848_ack_interrupt(phydev); 78 89 } 79 90 80 - return phy_write(phydev, DP83848_MICR, control); 91 + return ret; 81 92 } 82 93 83 94 static irqreturn_t dp83848_handle_interrupt(struct phy_device *phydev) ··· 145 134 .resume = genphy_resume, \ 146 135 \ 147 136 /* IRQ related */ \ 148 - .ack_interrupt = dp83848_ack_interrupt, \ 149 137 .config_intr = dp83848_config_intr, \ 150 138 .handle_interrupt = dp83848_handle_interrupt, \ 151 139 }
+14 -5
drivers/net/phy/dp83867.c
··· 288 288 289 289 static int dp83867_config_intr(struct phy_device *phydev) 290 290 { 291 - int micr_status; 291 + int micr_status, err; 292 292 293 293 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { 294 + err = dp83867_ack_interrupt(phydev); 295 + if (err) 296 + return err; 297 + 294 298 micr_status = phy_read(phydev, MII_DP83867_MICR); 295 299 if (micr_status < 0) 296 300 return micr_status; ··· 307 303 MII_DP83867_MICR_DUP_MODE_CHNG_INT_EN | 308 304 MII_DP83867_MICR_SLEEP_MODE_CHNG_INT_EN); 309 305 310 - return phy_write(phydev, MII_DP83867_MICR, micr_status); 306 + err = phy_write(phydev, MII_DP83867_MICR, micr_status); 307 + } else { 308 + micr_status = 0x0; 309 + err = phy_write(phydev, MII_DP83867_MICR, micr_status); 310 + if (err) 311 + return err; 312 + 313 + err = dp83867_ack_interrupt(phydev); 311 314 } 312 315 313 - micr_status = 0x0; 314 - return phy_write(phydev, MII_DP83867_MICR, micr_status); 316 + return err; 315 317 } 316 318 317 319 static irqreturn_t dp83867_handle_interrupt(struct phy_device *phydev) ··· 859 849 .set_wol = dp83867_set_wol, 860 850 861 851 /* IRQ related */ 862 - .ack_interrupt = dp83867_ack_interrupt, 863 852 .config_intr = dp83867_config_intr, 864 853 .handle_interrupt = dp83867_handle_interrupt, 865 854
+13 -4
drivers/net/phy/dp83869.c
··· 186 186 187 187 static int dp83869_config_intr(struct phy_device *phydev) 188 188 { 189 - int micr_status = 0; 189 + int micr_status = 0, err; 190 190 191 191 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { 192 + err = dp83869_ack_interrupt(phydev); 193 + if (err) 194 + return err; 195 + 192 196 micr_status = phy_read(phydev, MII_DP83869_MICR); 193 197 if (micr_status < 0) 194 198 return micr_status; ··· 205 201 MII_DP83869_MICR_DUP_MODE_CHNG_INT_EN | 206 202 MII_DP83869_MICR_SLEEP_MODE_CHNG_INT_EN); 207 203 208 - return phy_write(phydev, MII_DP83869_MICR, micr_status); 204 + err = phy_write(phydev, MII_DP83869_MICR, micr_status); 205 + } else { 206 + err = phy_write(phydev, MII_DP83869_MICR, micr_status); 207 + if (err) 208 + return err; 209 + 210 + err = dp83869_ack_interrupt(phydev); 209 211 } 210 212 211 - return phy_write(phydev, MII_DP83869_MICR, micr_status); 213 + return err; 212 214 } 213 215 214 216 static irqreturn_t dp83869_handle_interrupt(struct phy_device *phydev) ··· 884 874 .soft_reset = dp83869_phy_reset, 885 875 886 876 /* IRQ related */ 887 - .ack_interrupt = dp83869_ack_interrupt, 888 877 .config_intr = dp83869_config_intr, 889 878 .handle_interrupt = dp83869_handle_interrupt, 890 879 .read_status = dp83869_read_status,
+8 -1
drivers/net/phy/dp83tc811.c
··· 197 197 int misr_status, err; 198 198 199 199 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { 200 + err = dp83811_ack_interrupt(phydev); 201 + if (err) 202 + return err; 203 + 200 204 misr_status = phy_read(phydev, MII_DP83811_INT_STAT1); 201 205 if (misr_status < 0) 202 206 return misr_status; ··· 253 249 return err; 254 250 255 251 err = phy_write(phydev, MII_DP83811_INT_STAT3, 0); 252 + if (err < 0) 253 + return err; 254 + 255 + err = dp83811_ack_interrupt(phydev); 256 256 } 257 257 258 258 return err; ··· 394 386 .soft_reset = dp83811_phy_reset, 395 387 .get_wol = dp83811_get_wol, 396 388 .set_wol = dp83811_set_wol, 397 - .ack_interrupt = dp83811_ack_interrupt, 398 389 .config_intr = dp83811_config_intr, 399 390 .handle_interrupt = dp83811_handle_interrupt, 400 391 .suspend = dp83811_suspend,