diff mbox series

[RESEND,net-next,17/18] net: phy: adin: implement generic .handle_interrupt() callback

Message ID 20201113165226.561153-18-ciorneiioana@gmail.com (mailing list archive)
State Accepted
Commit 66d7439e83607ff8e13a2a6d3337ba26b4fa2b08
Delegated to: Netdev Maintainers
Headers show
Series net: phy: add support for shared interrupts (part 2) | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count fail Series longer than 15 patches
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 38 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Ioana Ciornei Nov. 13, 2020, 4:52 p.m. UTC
From: Ioana Ciornei <ioana.ciornei@nxp.com>

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: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/phy/adin.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Alexandru Ardelean Nov. 14, 2020, 6:38 a.m. UTC | #1
> -----Original Message-----
> From: Ioana Ciornei <ciorneiioana@gmail.com>
> Sent: Friday, November 13, 2020 6:52 PM
> To: Andrew Lunn <andrew@lunn.ch>; Heiner Kallweit <hkallweit1@gmail.com>;
> Russell King <linux@armlinux.org.uk>; Florian Fainelli <f.fainelli@gmail.com>;
> Jakub Kicinski <kuba@kernel.org>; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Cc: Ioana Ciornei <ioana.ciornei@nxp.com>; Ardelean, Alexandru
> <alexandru.Ardelean@analog.com>
> Subject: [PATCH RESEND net-next 17/18] net: phy: adin: implement generic
> .handle_interrupt() callback
> 
> [External]
> 
> From: Ioana Ciornei <ioana.ciornei@nxp.com>
> 
> 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.
> 

Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

> Cc: Alexandru Ardelean <alexandru.ardelean@analog.com>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
>  drivers/net/phy/adin.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c index
> 3727b38addf7..ba24434b867d 100644
> --- a/drivers/net/phy/adin.c
> +++ b/drivers/net/phy/adin.c
> @@ -479,6 +479,24 @@ static int adin_phy_config_intr(struct phy_device
> *phydev)
>  			      ADIN1300_INT_MASK_EN);
>  }
> 
> +static irqreturn_t adin_phy_handle_interrupt(struct phy_device *phydev)
> +{
> +	int irq_status;
> +
> +	irq_status = phy_read(phydev, ADIN1300_INT_STATUS_REG);
> +	if (irq_status < 0) {
> +		phy_error(phydev);
> +		return IRQ_NONE;
> +	}
> +
> +	if (!(irq_status & ADIN1300_INT_LINK_STAT_CHNG_EN))
> +		return IRQ_NONE;
> +
> +	phy_trigger_machine(phydev);
> +
> +	return IRQ_HANDLED;
> +}
> +
>  static int adin_cl45_to_adin_reg(struct phy_device *phydev, int devad,
>  				 u16 cl45_regnum)
>  {
> @@ -879,6 +897,7 @@ static struct phy_driver adin_driver[] = {
>  		.set_tunable	= adin_set_tunable,
>  		.ack_interrupt	= adin_phy_ack_intr,
>  		.config_intr	= adin_phy_config_intr,
> +		.handle_interrupt = adin_phy_handle_interrupt,
>  		.get_sset_count	= adin_get_sset_count,
>  		.get_strings	= adin_get_strings,
>  		.get_stats	= adin_get_stats,
> @@ -902,6 +921,7 @@ static struct phy_driver adin_driver[] = {
>  		.set_tunable	= adin_set_tunable,
>  		.ack_interrupt	= adin_phy_ack_intr,
>  		.config_intr	= adin_phy_config_intr,
> +		.handle_interrupt = adin_phy_handle_interrupt,
>  		.get_sset_count	= adin_get_sset_count,
>  		.get_strings	= adin_get_strings,
>  		.get_stats	= adin_get_stats,
> --
> 2.28.0
diff mbox series

Patch

diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c
index 3727b38addf7..ba24434b867d 100644
--- a/drivers/net/phy/adin.c
+++ b/drivers/net/phy/adin.c
@@ -479,6 +479,24 @@  static int adin_phy_config_intr(struct phy_device *phydev)
 			      ADIN1300_INT_MASK_EN);
 }
 
+static irqreturn_t adin_phy_handle_interrupt(struct phy_device *phydev)
+{
+	int irq_status;
+
+	irq_status = phy_read(phydev, ADIN1300_INT_STATUS_REG);
+	if (irq_status < 0) {
+		phy_error(phydev);
+		return IRQ_NONE;
+	}
+
+	if (!(irq_status & ADIN1300_INT_LINK_STAT_CHNG_EN))
+		return IRQ_NONE;
+
+	phy_trigger_machine(phydev);
+
+	return IRQ_HANDLED;
+}
+
 static int adin_cl45_to_adin_reg(struct phy_device *phydev, int devad,
 				 u16 cl45_regnum)
 {
@@ -879,6 +897,7 @@  static struct phy_driver adin_driver[] = {
 		.set_tunable	= adin_set_tunable,
 		.ack_interrupt	= adin_phy_ack_intr,
 		.config_intr	= adin_phy_config_intr,
+		.handle_interrupt = adin_phy_handle_interrupt,
 		.get_sset_count	= adin_get_sset_count,
 		.get_strings	= adin_get_strings,
 		.get_stats	= adin_get_stats,
@@ -902,6 +921,7 @@  static struct phy_driver adin_driver[] = {
 		.set_tunable	= adin_set_tunable,
 		.ack_interrupt	= adin_phy_ack_intr,
 		.config_intr	= adin_phy_config_intr,
+		.handle_interrupt = adin_phy_handle_interrupt,
 		.get_sset_count	= adin_get_sset_count,
 		.get_strings	= adin_get_strings,
 		.get_stats	= adin_get_stats,