From: Heiner Kallweit <hkallweit1@gmail.com>
To: Russell King - ARM Linux <linux@armlinux.org.uk>,
Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
David Miller <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: [PATCH net-next 2/3] net: phy: add callback for custom interrupt handler to struct phy_driver
Date: Mon, 27 May 2019 20:28:48 +0200 [thread overview]
Message-ID: <9929ba89-5ca0-97bf-7547-72c193866051@gmail.com> (raw)
In-Reply-To: <e3ce708d-d841-bd7e-30bb-bff37f3b89ac@gmail.com>
The phylib interrupt handler handles link change events only currently.
However PHY drivers may want to use other interrupt sources too,
e.g. to report temperature monitoring events. Therefore add a callback
to struct phy_driver allowing PHY drivers to implement a custom
interrupt handler.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Suggested-by: Russell King - ARM Linux admin <linux@armlinux.org.uk>
---
drivers/net/phy/phy.c | 9 +++++++--
include/linux/phy.h | 3 +++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 20955836c..8030d0a97 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -774,8 +774,13 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
if (phydev->drv->did_interrupt && !phydev->drv->did_interrupt(phydev))
return IRQ_NONE;
- /* reschedule state queue work to run as soon as possible */
- phy_trigger_machine(phydev);
+ if (phydev->drv->handle_interrupt) {
+ if (phydev->drv->handle_interrupt(phydev))
+ goto phy_err;
+ } else {
+ /* reschedule state queue work to run as soon as possible */
+ phy_trigger_machine(phydev);
+ }
if (phy_clear_interrupt(phydev))
goto phy_err;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index b133d59f3..f90158c67 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -536,6 +536,9 @@ struct phy_driver {
*/
int (*did_interrupt)(struct phy_device *phydev);
+ /* Override default interrupt handling */
+ int (*handle_interrupt)(struct phy_device *phydev);
+
/* Clears up any memory if needed */
void (*remove)(struct phy_device *phydev);
--
2.21.0
next prev parent reply other threads:[~2019-05-27 18:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-27 18:26 [PATCH net-next 0/3] net: phy: improve handling of more complex C45 PHY's Heiner Kallweit
2019-05-27 18:28 ` [PATCH net-next 1/3] net: phy: export phy_queue_state_machine Heiner Kallweit
2019-05-27 19:19 ` Florian Fainelli
2019-05-28 13:10 ` Russell King - ARM Linux admin
2019-05-27 18:28 ` Heiner Kallweit [this message]
2019-05-27 19:25 ` [PATCH net-next 2/3] net: phy: add callback for custom interrupt handler to struct phy_driver Florian Fainelli
2019-05-27 19:36 ` Heiner Kallweit
2019-05-28 19:37 ` Florian Fainelli
2019-05-28 20:08 ` Heiner Kallweit
2019-05-28 13:12 ` Russell King - ARM Linux admin
2019-05-27 18:29 ` [PATCH net-next 3/3] net: phy: move handling latched link-down to phylib state machine Heiner Kallweit
2019-05-28 13:15 ` Russell King - ARM Linux admin
2019-05-28 18:22 ` Heiner Kallweit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9929ba89-5ca0-97bf-7547-72c193866051@gmail.com \
--to=hkallweit1@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).