lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1768acfc-ed20-68d3-12a0-1e5bfb7b31a3@gmail.com>
Date:   Tue, 28 May 2019 20:29:11 +0200
From:   Heiner Kallweit <hkallweit1@...il.com>
To:     Marek Vasut <marex@...x.de>, netdev@...r.kernel.org
Cc:     Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        Guenter Roeck <linux@...ck-us.net>,
        Jean Delvare <jdelvare@...e.com>, linux-hwmon@...r.kernel.org
Subject: Re: [PATCH] net: phy: tja11xx: Add IRQ support to the driver

On 28.05.2019 20:16, Marek Vasut wrote:
> Add support for handling the TJA11xx PHY IRQ signal.
> 
> Signed-off-by: Marek Vasut <marex@...x.de>
> Cc: Andrew Lunn <andrew@...n.ch>
> Cc: Florian Fainelli <f.fainelli@...il.com>
> Cc: Guenter Roeck <linux@...ck-us.net>
> Cc: Heiner Kallweit <hkallweit1@...il.com>
> Cc: Jean Delvare <jdelvare@...e.com>
> Cc: linux-hwmon@...r.kernel.org
> ---
>  drivers/net/phy/nxp-tja11xx.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c
> index b705d0bd798b..0be9fe9a9604 100644
> --- a/drivers/net/phy/nxp-tja11xx.c
> +++ b/drivers/net/phy/nxp-tja11xx.c
> @@ -40,6 +40,8 @@
>  #define MII_INTSRC_TEMP_ERR		BIT(1)
>  #define MII_INTSRC_UV_ERR		BIT(3)
>  
> +#define MII_INTEN			22
> +
>  #define MII_COMMSTAT			23
>  #define MII_COMMSTAT_LINK_UP		BIT(15)
>  
> @@ -239,6 +241,30 @@ static int tja11xx_read_status(struct phy_device *phydev)
>  	return 0;
>  }
>  
> +static int tja11xx_config_intr(struct phy_device *phydev)
> +{
> +	int ret;
> +
> +	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
> +		ret = phy_write(phydev, MII_INTEN, 0xcfef);

As Florian commented already, such magic numbers are not nice.
Better add a constant for each bit representing an interrupt
source. Please note that phylib is interested in the link
change event only. Therefore typically only one bit is set.

> +	else
> +		ret = phy_write(phydev, MII_INTEN, 0);
> +
> +	if (ret < 0)
> +		return ret;
> +
> +	ret = phy_read(phydev, MII_INTSRC);
> +

This IRQ ACK can be removed. It's done by phylib, see
phy_enable_interrupts().

> +	return ret < 0 ? ret : 0;
> +}
> +
> +static int tja11xx_ack_interrupt(struct phy_device *phydev)
> +{
> +	int ret = phy_read(phydev, MII_INTSRC);
> +
> +	return ret < 0 ? ret : 0;
> +}
> +
>  static int tja11xx_get_sset_count(struct phy_device *phydev)
>  {
>  	return ARRAY_SIZE(tja11xx_hw_stats);
> @@ -366,6 +392,9 @@ static struct phy_driver tja11xx_driver[] = {
>  		.suspend	= genphy_suspend,
>  		.resume		= genphy_resume,
>  		.set_loopback   = genphy_loopback,
> +		/* IRQ related */
> +		.config_intr	= tja11xx_config_intr,
> +		.ack_interrupt	= tja11xx_ack_interrupt,
>  		/* Statistics */
>  		.get_sset_count = tja11xx_get_sset_count,
>  		.get_strings	= tja11xx_get_strings,
> @@ -381,6 +410,9 @@ static struct phy_driver tja11xx_driver[] = {
>  		.suspend	= genphy_suspend,
>  		.resume		= genphy_resume,
>  		.set_loopback   = genphy_loopback,
> +		/* IRQ related */
> +		.config_intr	= tja11xx_config_intr,
> +		.ack_interrupt	= tja11xx_ack_interrupt,
>  		/* Statistics */
>  		.get_sset_count = tja11xx_get_sset_count,
>  		.get_strings	= tja11xx_get_strings,
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ