Skip to content

Commit 1566db0

Browse files
IoanaCiorneikuba-moo
authored andcommitted
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 <[email protected]> Cc: Hauke Mehrtens <[email protected]> Signed-off-by: Ioana Ciornei <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 470dfd8 commit 1566db0

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

drivers/net/phy/intel-xway.c

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,6 @@ static int xway_gphy_ack_interrupt(struct phy_device *phydev)
209209
return (reg < 0) ? reg : 0;
210210
}
211211

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-
220212
static int xway_gphy_config_intr(struct phy_device *phydev)
221213
{
222214
u16 mask = 0;
@@ -227,6 +219,24 @@ static int xway_gphy_config_intr(struct phy_device *phydev)
227219
return phy_write(phydev, XWAY_MDIO_IMASK, mask);
228220
}
229221

222+
static irqreturn_t xway_gphy_handle_interrupt(struct phy_device *phydev)
223+
{
224+
int irq_status;
225+
226+
irq_status = phy_read(phydev, XWAY_MDIO_ISTAT);
227+
if (irq_status < 0) {
228+
phy_error(phydev);
229+
return IRQ_NONE;
230+
}
231+
232+
if (!(irq_status & XWAY_MDIO_INIT_MASK))
233+
return IRQ_NONE;
234+
235+
phy_trigger_machine(phydev);
236+
237+
return IRQ_HANDLED;
238+
}
239+
230240
static struct phy_driver xway_gphy[] = {
231241
{
232242
.phy_id = PHY_ID_PHY11G_1_3,
@@ -236,7 +246,7 @@ static struct phy_driver xway_gphy[] = {
236246
.config_init = xway_gphy_config_init,
237247
.config_aneg = xway_gphy14_config_aneg,
238248
.ack_interrupt = xway_gphy_ack_interrupt,
239-
.did_interrupt = xway_gphy_did_interrupt,
249+
.handle_interrupt = xway_gphy_handle_interrupt,
240250
.config_intr = xway_gphy_config_intr,
241251
.suspend = genphy_suspend,
242252
.resume = genphy_resume,
@@ -248,7 +258,7 @@ static struct phy_driver xway_gphy[] = {
248258
.config_init = xway_gphy_config_init,
249259
.config_aneg = xway_gphy14_config_aneg,
250260
.ack_interrupt = xway_gphy_ack_interrupt,
251-
.did_interrupt = xway_gphy_did_interrupt,
261+
.handle_interrupt = xway_gphy_handle_interrupt,
252262
.config_intr = xway_gphy_config_intr,
253263
.suspend = genphy_suspend,
254264
.resume = genphy_resume,
@@ -260,7 +270,7 @@ static struct phy_driver xway_gphy[] = {
260270
.config_init = xway_gphy_config_init,
261271
.config_aneg = xway_gphy14_config_aneg,
262272
.ack_interrupt = xway_gphy_ack_interrupt,
263-
.did_interrupt = xway_gphy_did_interrupt,
273+
.handle_interrupt = xway_gphy_handle_interrupt,
264274
.config_intr = xway_gphy_config_intr,
265275
.suspend = genphy_suspend,
266276
.resume = genphy_resume,
@@ -272,7 +282,7 @@ static struct phy_driver xway_gphy[] = {
272282
.config_init = xway_gphy_config_init,
273283
.config_aneg = xway_gphy14_config_aneg,
274284
.ack_interrupt = xway_gphy_ack_interrupt,
275-
.did_interrupt = xway_gphy_did_interrupt,
285+
.handle_interrupt = xway_gphy_handle_interrupt,
276286
.config_intr = xway_gphy_config_intr,
277287
.suspend = genphy_suspend,
278288
.resume = genphy_resume,
@@ -283,7 +293,7 @@ static struct phy_driver xway_gphy[] = {
283293
/* PHY_GBIT_FEATURES */
284294
.config_init = xway_gphy_config_init,
285295
.ack_interrupt = xway_gphy_ack_interrupt,
286-
.did_interrupt = xway_gphy_did_interrupt,
296+
.handle_interrupt = xway_gphy_handle_interrupt,
287297
.config_intr = xway_gphy_config_intr,
288298
.suspend = genphy_suspend,
289299
.resume = genphy_resume,
@@ -294,7 +304,7 @@ static struct phy_driver xway_gphy[] = {
294304
/* PHY_BASIC_FEATURES */
295305
.config_init = xway_gphy_config_init,
296306
.ack_interrupt = xway_gphy_ack_interrupt,
297-
.did_interrupt = xway_gphy_did_interrupt,
307+
.handle_interrupt = xway_gphy_handle_interrupt,
298308
.config_intr = xway_gphy_config_intr,
299309
.suspend = genphy_suspend,
300310
.resume = genphy_resume,
@@ -305,7 +315,7 @@ static struct phy_driver xway_gphy[] = {
305315
/* PHY_GBIT_FEATURES */
306316
.config_init = xway_gphy_config_init,
307317
.ack_interrupt = xway_gphy_ack_interrupt,
308-
.did_interrupt = xway_gphy_did_interrupt,
318+
.handle_interrupt = xway_gphy_handle_interrupt,
309319
.config_intr = xway_gphy_config_intr,
310320
.suspend = genphy_suspend,
311321
.resume = genphy_resume,
@@ -316,7 +326,7 @@ static struct phy_driver xway_gphy[] = {
316326
/* PHY_BASIC_FEATURES */
317327
.config_init = xway_gphy_config_init,
318328
.ack_interrupt = xway_gphy_ack_interrupt,
319-
.did_interrupt = xway_gphy_did_interrupt,
329+
.handle_interrupt = xway_gphy_handle_interrupt,
320330
.config_intr = xway_gphy_config_intr,
321331
.suspend = genphy_suspend,
322332
.resume = genphy_resume,
@@ -327,7 +337,7 @@ static struct phy_driver xway_gphy[] = {
327337
/* PHY_GBIT_FEATURES */
328338
.config_init = xway_gphy_config_init,
329339
.ack_interrupt = xway_gphy_ack_interrupt,
330-
.did_interrupt = xway_gphy_did_interrupt,
340+
.handle_interrupt = xway_gphy_handle_interrupt,
331341
.config_intr = xway_gphy_config_intr,
332342
.suspend = genphy_suspend,
333343
.resume = genphy_resume,
@@ -338,7 +348,7 @@ static struct phy_driver xway_gphy[] = {
338348
/* PHY_BASIC_FEATURES */
339349
.config_init = xway_gphy_config_init,
340350
.ack_interrupt = xway_gphy_ack_interrupt,
341-
.did_interrupt = xway_gphy_did_interrupt,
351+
.handle_interrupt = xway_gphy_handle_interrupt,
342352
.config_intr = xway_gphy_config_intr,
343353
.suspend = genphy_suspend,
344354
.resume = genphy_resume,

0 commit comments

Comments
 (0)