Re: [PATCH] net: phy: adin1100: Fix nullptr exception for phy interrupts

From: Andre Werner
Date: Thu Jan 18 2024 - 22:06:03 EST


On Thu, 18 Jan 2024, Russell King (Oracle) wrote:

In addition to Andrew's comments:

On Thu, Jan 18, 2024 at 11:43:41AM +0100, Andre Werner wrote:
+static int adin_config_intr(struct phy_device *phydev)
+{
+ int ret, regval;
+
+ ret = adin_phy_ack_intr(phydev);
+
+ if (ret)
+ return ret;
+
+ regval = phy_read_mmd(phydev, MDIO_MMD_VEND2, ADIN_PHY_SUBSYS_IRQ_MASK);
+ if (regval < 0)
+ return regval;
+
+ if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
+ regval |= ADIN_LINK_STAT_CHNG_IRQ_EN;
+ else
+ regval &= ~ADIN_LINK_STAT_CHNG_IRQ_EN;
+
+ ret = phy_write_mmd(phydev, MDIO_MMD_VEND2,
+ ADIN_PHY_SUBSYS_IRQ_MASK,
+ regval);
+ return ret;

u16 irq_mask;

if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
irq_mask = ADIN_LINK_STAT_CHNG_IRQ_EN;
else
irq_mask = 0;

Unfortunately, I can not do this, because that phy ask for read-modify-write access to
registers and some bits in this register are already set after reset and
should not being modified.


return phy_modify_mmd(phydev, MDIO_MMD_VEND2,
ADIN_PHY_SUBSYS_IRQ_MASK,
ADIN_LINK_STAT_CHNG_IRQ_EN, irq_mask);

+}
+
+static irqreturn_t adin_phy_handle_interrupt(struct phy_device *phydev)
+{
+ int irq_status;
+
+ irq_status = phy_read_mmd(phydev, MDIO_MMD_VEND2, ADIN_PHY_SUBSYS_IRQ_STATUS);

Probably want to wrap this - if you're going to bother wrapping your
phy_write_mmd() above because it overflows 80 columns, then please do
so consistently.

Done.


Thanks.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!