diff mbox series

[net-next,5/5] net: phy: marvell10g: Utilize gen10g_soft_reset()

Message ID 20180228193612.29409-6-f.fainelli@gmail.com
State Superseded, archived
Delegated to: David Miller
Headers show
Series net: phy: Reduce duplication | expand

Commit Message

Florian Fainelli Feb. 28, 2018, 7:36 p.m. UTC
We do the same thing as the generic function: nothing, so utilize it.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/marvell10g.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Russell King Feb. 28, 2018, 7:44 p.m. UTC | #1
On Wed, Feb 28, 2018 at 11:36:12AM -0800, Florian Fainelli wrote:
> We do the same thing as the generic function: nothing, so utilize it.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  drivers/net/phy/marvell10g.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
> index 8a0bd98fdec7..da014eae1476 100644
> --- a/drivers/net/phy/marvell10g.c
> +++ b/drivers/net/phy/marvell10g.c
> @@ -75,11 +75,6 @@ static int mv3310_probe(struct phy_device *phydev)
>   * Resetting the MV88X3310 causes it to become non-responsive.  Avoid
>   * setting the reset bit(s).
>   */
> -static int mv3310_soft_reset(struct phy_device *phydev)
> -{
> -	return 0;
> -}
> -

You do realise that getting rid of that function makes a nonsense of the
comment above it - and removing the comment along with the function gets
rid of the very important reason _why_ we have en empty reset method?

>  static int mv3310_config_init(struct phy_device *phydev)
>  {
>  	__ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, };
> @@ -377,7 +372,7 @@ static struct phy_driver mv3310_drivers[] = {
>  				  SUPPORTED_10000baseT_Full |
>  				  SUPPORTED_Backplane,
>  		.probe		= mv3310_probe,
> -		.soft_reset	= mv3310_soft_reset,
> +		.soft_reset	= gen10g_soft_reset,
>  		.config_init	= mv3310_config_init,
>  		.config_aneg	= mv3310_config_aneg,
>  		.aneg_done	= mv3310_aneg_done,
> -- 
> 2.14.1
>
Moritz Fischer Feb. 28, 2018, 7:49 p.m. UTC | #2
Florian,

On Wed, Feb 28, 2018 at 11:44 AM, Russell King <rmk@armlinux.org.uk> wrote:
> On Wed, Feb 28, 2018 at 11:36:12AM -0800, Florian Fainelli wrote:
>> We do the same thing as the generic function: nothing, so utilize it.
>>
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>> ---
>>  drivers/net/phy/marvell10g.c | 7 +------
>>  1 file changed, 1 insertion(+), 6 deletions(-)
>>
>> diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
>> index 8a0bd98fdec7..da014eae1476 100644
>> --- a/drivers/net/phy/marvell10g.c
>> +++ b/drivers/net/phy/marvell10g.c
>> @@ -75,11 +75,6 @@ static int mv3310_probe(struct phy_device *phydev)
>>   * Resetting the MV88X3310 causes it to become non-responsive.  Avoid
>>   * setting the reset bit(s).
>>   */
>> -static int mv3310_soft_reset(struct phy_device *phydev)
>> -{
>> -     return 0;
>> -}
>> -
>
> You do realise that getting rid of that function makes a nonsense of the
> comment above it - and removing the comment along with the function gets
> rid of the very important reason _why_ we have en empty reset method?
>
>>  static int mv3310_config_init(struct phy_device *phydev)
>>  {
>>       __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, };
>> @@ -377,7 +372,7 @@ static struct phy_driver mv3310_drivers[] = {
>>                                 SUPPORTED_10000baseT_Full |
>>                                 SUPPORTED_Backplane,
>>               .probe          = mv3310_probe,
>> -             .soft_reset     = mv3310_soft_reset,
>> +             .soft_reset     = gen10g_soft_reset,
>>               .config_init    = mv3310_config_init,
>>               .config_aneg    = mv3310_config_aneg,
>>               .aneg_done      = mv3310_aneg_done,
>> --
>> 2.14.1
>>
>
> --
> Russell King
> ARM architecture Linux Kernel maintainer

FWIW I have a local patch that goes something like that, which I meant to send
at one point and forgot

Something like that:

 static int gen10g_soft_reset(struct phy_device *phydev)
 {
+       int val;
+
+       val = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1);
+       if (val < 0)
+               return val;
+
+       val |= MDIO_CTRL1_RESET;
+       phy_write_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1, val);
+
 -       /* Do nothing for now */
        return 0;
 }

If that looks reasonable I can properly submit a patch,

Moritz
Florian Fainelli Feb. 28, 2018, 10:07 p.m. UTC | #3
On 02/28/2018 11:49 AM, Moritz Fischer wrote:
> Florian,
> 
> On Wed, Feb 28, 2018 at 11:44 AM, Russell King <rmk@armlinux.org.uk> wrote:
>> On Wed, Feb 28, 2018 at 11:36:12AM -0800, Florian Fainelli wrote:
>>> We do the same thing as the generic function: nothing, so utilize it.
>>>
>>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>>> ---
>>>  drivers/net/phy/marvell10g.c | 7 +------
>>>  1 file changed, 1 insertion(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
>>> index 8a0bd98fdec7..da014eae1476 100644
>>> --- a/drivers/net/phy/marvell10g.c
>>> +++ b/drivers/net/phy/marvell10g.c
>>> @@ -75,11 +75,6 @@ static int mv3310_probe(struct phy_device *phydev)
>>>   * Resetting the MV88X3310 causes it to become non-responsive.  Avoid
>>>   * setting the reset bit(s).
>>>   */
>>> -static int mv3310_soft_reset(struct phy_device *phydev)
>>> -{
>>> -     return 0;
>>> -}
>>> -
>>
>> You do realise that getting rid of that function makes a nonsense of the
>> comment above it - and removing the comment along with the function gets
>> rid of the very important reason _why_ we have en empty reset method?
>>
>>>  static int mv3310_config_init(struct phy_device *phydev)
>>>  {
>>>       __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, };
>>> @@ -377,7 +372,7 @@ static struct phy_driver mv3310_drivers[] = {
>>>                                 SUPPORTED_10000baseT_Full |
>>>                                 SUPPORTED_Backplane,
>>>               .probe          = mv3310_probe,
>>> -             .soft_reset     = mv3310_soft_reset,
>>> +             .soft_reset     = gen10g_soft_reset,
>>>               .config_init    = mv3310_config_init,
>>>               .config_aneg    = mv3310_config_aneg,
>>>               .aneg_done      = mv3310_aneg_done,
>>> --
>>> 2.14.1
>>>
>>
>> --
>> Russell King
>> ARM architecture Linux Kernel maintainer
> 
> FWIW I have a local patch that goes something like that, which I meant to send
> at one point and forgot
> 
> Something like that:
> 
>  static int gen10g_soft_reset(struct phy_device *phydev)
>  {
> +       int val;
> +
> +       val = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1);
> +       if (val < 0)
> +               return val;
> +
> +       val |= MDIO_CTRL1_RESET;
> +       phy_write_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1, val);
> +
>  -       /* Do nothing for now */
>         return 0;
>  }
> 
> If that looks reasonable I can properly submit a patch,

Sure, I would have to check the specification document to make sure
whether this does not need to be coded similarly to what
genphy_soft_reset() does, which is polling for the reset bit to clear
itself.

v2 also renamed the current gen10g_soft_reset() into
gen10g_no_soft_reset() so your implementation makes even more sense now.
diff mbox series

Patch

diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
index 8a0bd98fdec7..da014eae1476 100644
--- a/drivers/net/phy/marvell10g.c
+++ b/drivers/net/phy/marvell10g.c
@@ -75,11 +75,6 @@  static int mv3310_probe(struct phy_device *phydev)
  * Resetting the MV88X3310 causes it to become non-responsive.  Avoid
  * setting the reset bit(s).
  */
-static int mv3310_soft_reset(struct phy_device *phydev)
-{
-	return 0;
-}
-
 static int mv3310_config_init(struct phy_device *phydev)
 {
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, };
@@ -377,7 +372,7 @@  static struct phy_driver mv3310_drivers[] = {
 				  SUPPORTED_10000baseT_Full |
 				  SUPPORTED_Backplane,
 		.probe		= mv3310_probe,
-		.soft_reset	= mv3310_soft_reset,
+		.soft_reset	= gen10g_soft_reset,
 		.config_init	= mv3310_config_init,
 		.config_aneg	= mv3310_config_aneg,
 		.aneg_done	= mv3310_aneg_done,