* [PATCH v2] net: phy: smsc: move smsc_phy_config_init reset part in a soft_reset function
@ 2014-08-15 13:00 Gwenhael Goavec-Merou
  2014-08-15 15:02 ` Florian Fainelli
  2014-08-17  3:16 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Gwenhael Goavec-Merou @ 2014-08-15 13:00 UTC (permalink / raw)
  To: linux-kernel; +Cc: Florian Fainelli, netdev, Gwenhael Goavec-Merou
On the one hand, phy_device.c provides a generic reset function if the phy
driver does not provide a soft_reset pointer. This generic reset does not take
into account the state of the phy, with a potential failure if the phy is in
powerdown mode. On the other hand, smsc driver provides a function with both
correct reset behaviour and configuration.
This patch moves the reset part into a new smsc_phy_reset function and provides
the soft_reset pointer to have a correct reset behaviour by default.
Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@armadeus.com>
---
Changes since v1 (as advised by Sergei Shtylyov): 
 * fix '=' alignment
 drivers/net/phy/smsc.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index 180c494..a4b0819 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -43,6 +43,22 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)
 
 static int smsc_phy_config_init(struct phy_device *phydev)
 {
+	int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
+
+	if (rc < 0)
+		return rc;
+
+	/* Enable energy detect mode for this SMSC Transceivers */
+	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
+		       rc | MII_LAN83C185_EDPWRDOWN);
+	if (rc < 0)
+		return rc;
+
+	return smsc_phy_ack_interrupt(phydev);
+}
+
+static int smsc_phy_reset(struct phy_device *phydev)
+{
 	int rc = phy_read(phydev, MII_LAN83C185_SPECIAL_MODES);
 	if (rc < 0)
 		return rc;
@@ -66,18 +82,7 @@ static int smsc_phy_config_init(struct phy_device *phydev)
 			rc = phy_read(phydev, MII_BMCR);
 		} while (rc & BMCR_RESET);
 	}
-
-	rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
-	if (rc < 0)
-		return rc;
-
-	/* Enable energy detect mode for this SMSC Transceivers */
-	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
-		       rc | MII_LAN83C185_EDPWRDOWN);
-	if (rc < 0)
-		return rc;
-
-	return smsc_phy_ack_interrupt (phydev);
+	return 0;
 }
 
 static int lan911x_config_init(struct phy_device *phydev)
@@ -142,6 +147,7 @@ static struct phy_driver smsc_phy_driver[] = {
 	.config_aneg	= genphy_config_aneg,
 	.read_status	= genphy_read_status,
 	.config_init	= smsc_phy_config_init,
+	.soft_reset	= smsc_phy_reset,
 
 	/* IRQ related */
 	.ack_interrupt	= smsc_phy_ack_interrupt,
@@ -164,6 +170,7 @@ static struct phy_driver smsc_phy_driver[] = {
 	.config_aneg	= genphy_config_aneg,
 	.read_status	= genphy_read_status,
 	.config_init	= smsc_phy_config_init,
+	.soft_reset	= smsc_phy_reset,
 
 	/* IRQ related */
 	.ack_interrupt	= smsc_phy_ack_interrupt,
@@ -186,6 +193,7 @@ static struct phy_driver smsc_phy_driver[] = {
 	.config_aneg	= genphy_config_aneg,
 	.read_status	= genphy_read_status,
 	.config_init	= smsc_phy_config_init,
+	.soft_reset	= smsc_phy_reset,
 
 	/* IRQ related */
 	.ack_interrupt	= smsc_phy_ack_interrupt,
@@ -230,6 +238,7 @@ static struct phy_driver smsc_phy_driver[] = {
 	.config_aneg	= genphy_config_aneg,
 	.read_status	= lan87xx_read_status,
 	.config_init	= smsc_phy_config_init,
+	.soft_reset	= smsc_phy_reset,
 
 	/* IRQ related */
 	.ack_interrupt	= smsc_phy_ack_interrupt,
-- 
1.8.5.5
^ permalink raw reply related	[flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: phy: smsc: move smsc_phy_config_init reset part in a soft_reset function
  2014-08-15 13:00 [PATCH v2] net: phy: smsc: move smsc_phy_config_init reset part in a soft_reset function Gwenhael Goavec-Merou
@ 2014-08-15 15:02 ` Florian Fainelli
  2014-08-17  3:16 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2014-08-15 15:02 UTC (permalink / raw)
  To: Gwenhael Goavec-Merou; +Cc: linux-kernel@vger.kernel.org, netdev
2014-08-15 6:00 GMT-07:00 Gwenhael Goavec-Merou
<gwenhael.goavec-merou@armadeus.com>:
> On the one hand, phy_device.c provides a generic reset function if the phy
> driver does not provide a soft_reset pointer. This generic reset does not take
> into account the state of the phy, with a potential failure if the phy is in
> powerdown mode. On the other hand, smsc driver provides a function with both
> correct reset behaviour and configuration.
>
> This patch moves the reset part into a new smsc_phy_reset function and provides
> the soft_reset pointer to have a correct reset behaviour by default.
>
> Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@armadeus.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> Changes since v1 (as advised by Sergei Shtylyov):
>  * fix '=' alignment
>
>  drivers/net/phy/smsc.c | 33 +++++++++++++++++++++------------
>  1 file changed, 21 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
> index 180c494..a4b0819 100644
> --- a/drivers/net/phy/smsc.c
> +++ b/drivers/net/phy/smsc.c
> @@ -43,6 +43,22 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)
>
>  static int smsc_phy_config_init(struct phy_device *phydev)
>  {
> +       int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
> +
> +       if (rc < 0)
> +               return rc;
> +
> +       /* Enable energy detect mode for this SMSC Transceivers */
> +       rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
> +                      rc | MII_LAN83C185_EDPWRDOWN);
> +       if (rc < 0)
> +               return rc;
> +
> +       return smsc_phy_ack_interrupt(phydev);
> +}
> +
> +static int smsc_phy_reset(struct phy_device *phydev)
> +{
>         int rc = phy_read(phydev, MII_LAN83C185_SPECIAL_MODES);
>         if (rc < 0)
>                 return rc;
> @@ -66,18 +82,7 @@ static int smsc_phy_config_init(struct phy_device *phydev)
>                         rc = phy_read(phydev, MII_BMCR);
>                 } while (rc & BMCR_RESET);
>         }
> -
> -       rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
> -       if (rc < 0)
> -               return rc;
> -
> -       /* Enable energy detect mode for this SMSC Transceivers */
> -       rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
> -                      rc | MII_LAN83C185_EDPWRDOWN);
> -       if (rc < 0)
> -               return rc;
> -
> -       return smsc_phy_ack_interrupt (phydev);
> +       return 0;
>  }
>
>  static int lan911x_config_init(struct phy_device *phydev)
> @@ -142,6 +147,7 @@ static struct phy_driver smsc_phy_driver[] = {
>         .config_aneg    = genphy_config_aneg,
>         .read_status    = genphy_read_status,
>         .config_init    = smsc_phy_config_init,
> +       .soft_reset     = smsc_phy_reset,
>
>         /* IRQ related */
>         .ack_interrupt  = smsc_phy_ack_interrupt,
> @@ -164,6 +170,7 @@ static struct phy_driver smsc_phy_driver[] = {
>         .config_aneg    = genphy_config_aneg,
>         .read_status    = genphy_read_status,
>         .config_init    = smsc_phy_config_init,
> +       .soft_reset     = smsc_phy_reset,
>
>         /* IRQ related */
>         .ack_interrupt  = smsc_phy_ack_interrupt,
> @@ -186,6 +193,7 @@ static struct phy_driver smsc_phy_driver[] = {
>         .config_aneg    = genphy_config_aneg,
>         .read_status    = genphy_read_status,
>         .config_init    = smsc_phy_config_init,
> +       .soft_reset     = smsc_phy_reset,
>
>         /* IRQ related */
>         .ack_interrupt  = smsc_phy_ack_interrupt,
> @@ -230,6 +238,7 @@ static struct phy_driver smsc_phy_driver[] = {
>         .config_aneg    = genphy_config_aneg,
>         .read_status    = lan87xx_read_status,
>         .config_init    = smsc_phy_config_init,
> +       .soft_reset     = smsc_phy_reset,
>
>         /* IRQ related */
>         .ack_interrupt  = smsc_phy_ack_interrupt,
> --
> 1.8.5.5
>
-- 
Florian
^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: phy: smsc: move smsc_phy_config_init reset part in a soft_reset function
  2014-08-15 13:00 [PATCH v2] net: phy: smsc: move smsc_phy_config_init reset part in a soft_reset function Gwenhael Goavec-Merou
  2014-08-15 15:02 ` Florian Fainelli
@ 2014-08-17  3:16 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-08-17  3:16 UTC (permalink / raw)
  To: gwenhael.goavec-merou; +Cc: linux-kernel, f.fainelli, netdev
From: Gwenhael Goavec-Merou <gwenhael.goavec-merou@armadeus.com>
Date: Fri, 15 Aug 2014 15:00:38 +0200
> On the one hand, phy_device.c provides a generic reset function if the phy
> driver does not provide a soft_reset pointer. This generic reset does not take
> into account the state of the phy, with a potential failure if the phy is in
> powerdown mode. On the other hand, smsc driver provides a function with both
> correct reset behaviour and configuration.
> 
> This patch moves the reset part into a new smsc_phy_reset function and provides
> the soft_reset pointer to have a correct reset behaviour by default.
> 
> Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@armadeus.com>
Applied, thanks.
^ permalink raw reply	[flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-08-17  3:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-15 13:00 [PATCH v2] net: phy: smsc: move smsc_phy_config_init reset part in a soft_reset function Gwenhael Goavec-Merou
2014-08-15 15:02 ` Florian Fainelli
2014-08-17  3:16 ` David Miller
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).