diff mbox

phy/at8031: enable at8031 to work on interrupt mode

Message ID 1395901116-16034-1-git-send-email-B45475@freescale.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Zhao Qiang March 27, 2014, 6:18 a.m. UTC
The at8031 can work on polling mode and interrupt mode.
Add ack_interrupt and config intr funcs to enable
interrupt mode for it.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
---
 drivers/net/phy/at803x.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

Comments

Sergei Shtylyov March 27, 2014, 11:52 a.m. UTC | #1
Hello.

On 27-03-2014 10:18, Zhao Qiang wrote:

> The at8031 can work on polling mode and interrupt mode.
> Add ack_interrupt and config intr funcs to enable
> interrupt mode for it.

> Signed-off-by: Zhao Qiang <B45475@freescale.com>
> ---
>   drivers/net/phy/at803x.c | 30 ++++++++++++++++++++++++++++++
>   1 file changed, 30 insertions(+)

> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index bc71947..d034ef5 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
[...]
> @@ -191,6 +194,31 @@ static int at803x_config_init(struct phy_device *phydev)
>   	return 0;
>   }
>
> +static int at803x_ack_interrupt(struct phy_device *phydev)
> +{
> +	int err;
> +
> +	err = phy_read(phydev, AT803X_INSR);

    Could make this an initializer...

> +
> +	return (err < 0) ? err : 0;
> +}
> +
> +static int at803x_config_intr(struct phy_device *phydev)
> +{
> +	int err;
> +	int value;
> +
> +	value = phy_read(phydev, AT803X_INER);
> +
> +	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
> +		err = phy_write(phydev, AT803X_INER,
> +				(value | AT803X_INER_INIT));

    Inner parens not needed.

> +	else
> +		err = phy_write(phydev, AT803X_INER, value);

    Why are you not clearing the bits here? Why write back what has been read 
at all?

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhao Qiang March 28, 2014, 7:36 a.m. UTC | #2
On Thursday, March 27, 2014 7:53 PM, Sergei Shtylyov wrote:
> -----Original Message-----
> From: Sergei Shtylyov [mailto:sergei.shtylyov@cogentembedded.com]
> Sent: Thursday, March 27, 2014 7:53 PM
> To: Zhao Qiang-B45475; linuxppc-dev@lists.ozlabs.org;
> netdev@vger.kernel.org; Wood Scott-B07421
> Cc: linux-kernel@vger.kernel.org; davem@davemloft.net;
> mugunthanvnm@ti.com; zonque@gmail.com; helmut.schaa@googlemail.com; Xie
> Xiaobo-R63061
> Subject: Re: [PATCH] phy/at8031: enable at8031 to work on interrupt mode
> 
> Hello.
> 
> On 27-03-2014 10:18, Zhao Qiang wrote:
> 
> > The at8031 can work on polling mode and interrupt mode.
> > Add ack_interrupt and config intr funcs to enable interrupt mode for
> > it.
> 
> > Signed-off-by: Zhao Qiang <B45475@freescale.com>
> > ---
> >   drivers/net/phy/at803x.c | 30 ++++++++++++++++++++++++++++++
> >   1 file changed, 30 insertions(+)
> 
> > diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index
> > bc71947..d034ef5 100644
> > --- a/drivers/net/phy/at803x.c
> > +++ b/drivers/net/phy/at803x.c
> [...]
> > @@ -191,6 +194,31 @@ static int at803x_config_init(struct phy_device
> *phydev)
> >   	return 0;
> >   }
> >
> > +static int at803x_ack_interrupt(struct phy_device *phydev) {
> > +	int err;
> > +
> > +	err = phy_read(phydev, AT803X_INSR);
> 
>     Could make this an initializer...

Thank you very much. However I have no idea about "make this an initializer".

> 
> > +
> > +	return (err < 0) ? err : 0;
> > +}
> > +
> > +static int at803x_config_intr(struct phy_device *phydev) {
> > +	int err;
> > +	int value;
> > +
> > +	value = phy_read(phydev, AT803X_INER);
> > +
> > +	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
> > +		err = phy_write(phydev, AT803X_INER,
> > +				(value | AT803X_INER_INIT));
> 
>     Inner parens not needed.
> 
> > +	else
> > +		err = phy_write(phydev, AT803X_INER, value);
> 
>     Why are you not clearing the bits here? Why write back what has been
> read at all?
> 
> WBR, Sergei
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sergei Shtylyov March 28, 2014, 6:09 p.m. UTC | #3
Hello.

On 03/28/2014 10:36 AM, qiang.zhao@freescale.com wrote:

>>> The at8031 can work on polling mode and interrupt mode.
>>> Add ack_interrupt and config intr funcs to enable interrupt mode for
>>> it.

>>> Signed-off-by: Zhao Qiang <B45475@freescale.com>
>>> ---
>>>    drivers/net/phy/at803x.c | 30 ++++++++++++++++++++++++++++++
>>>    1 file changed, 30 insertions(+)

>>> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index
>>> bc71947..d034ef5 100644
>>> --- a/drivers/net/phy/at803x.c
>>> +++ b/drivers/net/phy/at803x.c
>> [...]
>>> @@ -191,6 +194,31 @@ static int at803x_config_init(struct phy_device
>> *phydev)
>>>    	return 0;
>>>    }
>>>
>>> +static int at803x_ack_interrupt(struct phy_device *phydev) {
>>> +	int err;
>>> +
>>> +	err = phy_read(phydev, AT803X_INSR);

>>      Could make this an initializer...

> Thank you very much. However I have no idea about "make this an initializer".

	int err = phy_read(phydev, AT803X_INSR);

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index bc71947..d034ef5 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -27,6 +27,9 @@ 
 #define AT803X_MMD_ACCESS_CONTROL		0x0D
 #define AT803X_MMD_ACCESS_CONTROL_DATA		0x0E
 #define AT803X_FUNC_DATA			0x4003
+#define AT803X_INER				0x0012
+#define AT803X_INER_INIT			0xec00
+#define AT803X_INSR				0x0013
 #define AT803X_DEBUG_ADDR			0x1D
 #define AT803X_DEBUG_DATA			0x1E
 #define AT803X_DEBUG_SYSTEM_MODE_CTRL		0x05
@@ -191,6 +194,31 @@  static int at803x_config_init(struct phy_device *phydev)
 	return 0;
 }
 
+static int at803x_ack_interrupt(struct phy_device *phydev)
+{
+	int err;
+
+	err = phy_read(phydev, AT803X_INSR);
+
+	return (err < 0) ? err : 0;
+}
+
+static int at803x_config_intr(struct phy_device *phydev)
+{
+	int err;
+	int value;
+
+	value = phy_read(phydev, AT803X_INER);
+
+	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
+		err = phy_write(phydev, AT803X_INER,
+				(value | AT803X_INER_INIT));
+	else
+		err = phy_write(phydev, AT803X_INER, value);
+
+	return err;
+}
+
 static struct phy_driver at803x_driver[] = {
 {
 	/* ATHEROS 8035 */
@@ -240,6 +268,8 @@  static struct phy_driver at803x_driver[] = {
 	.flags		= PHY_HAS_INTERRUPT,
 	.config_aneg	= genphy_config_aneg,
 	.read_status	= genphy_read_status,
+	.ack_interrupt  = &at803x_ack_interrupt,
+	.config_intr    = &at803x_config_intr,
 	.driver		= {
 		.owner = THIS_MODULE,
 	},