All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
Cc: "claudiu.manoil@nxp.com" <claudiu.manoil@nxp.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"f.fainelli@gmail.com" <f.fainelli@gmail.com>
Subject: Re: [PATCHv2] gianfar: Add gfar_change_carrier() for Fixed PHYs
Date: Wed, 12 Dec 2018 15:51:54 +0100	[thread overview]
Message-ID: <20181212145154.GC1549@lunn.ch> (raw)
In-Reply-To: <c33b02dab32b4294759bb1bc27b6e797315fc34f.camel@infinera.com>

> fast check, would you be happy with this in fixed PHY:
> --- a/drivers/net/phy/fixed_phy.c
> +++ b/drivers/net/phy/fixed_phy.c
> @@ -25,6 +25,7 @@
>  #include <linux/gpio.h>
>  #include <linux/seqlock.h>
>  #include <linux/idr.h>
> +#include <linux/netdevice.h>
>  
>  #include "swphy.h"
>  
> @@ -38,6 +39,7 @@ struct fixed_phy {
>         struct phy_device *phydev;
>         seqcount_t seqcount;
>         struct fixed_phy_status status;
> +       bool no_carrier;
>         int (*link_update)(struct net_device *, struct fixed_phy_status *);
>         struct list_head node;
>         int link_gpio;
> @@ -48,6 +50,24 @@ static struct fixed_mdio_bus platform_fmb = {
>         .phys = LIST_HEAD_INIT(platform_fmb.phys),
>  };
>  
> +int
> +fixed_phy_change_carrier(struct net_device *dev, bool new_carrier)
> +{
> +       struct fixed_mdio_bus *fmb = &platform_fmb;
> +       struct phy_device *phydev = dev->phydev;
> +       struct fixed_phy *fp;
> +
> +       if (!phydev || !phydev->mdio.bus)
> +               return -EINVAL;
> +
> +       list_for_each_entry(fp, &fmb->phys, node) {
> +               if (fp->addr == phydev->mdio.addr) {
> +                       fp->no_carrier = !new_carrier;

Why is no_carrier needed? You can directly change fp->status.link, so
long as you take care of locking.

> +                       return 0;
> +               }
> +       }
> +       return -EINVAL;
> +}

You need to export the function.

    Andrew

  reply	other threads:[~2018-12-12 14:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-12 12:33 [PATCHv2] gianfar: Add gfar_change_carrier() for Fixed PHYs Joakim Tjernlund
2018-12-12 12:42 ` Andrew Lunn
2018-12-12 13:10   ` Claudiu Manoil
2018-12-12 13:30     ` Joakim Tjernlund
2018-12-12 14:25     ` Joakim Tjernlund
2018-12-12 14:51       ` Andrew Lunn [this message]
2018-12-12 17:25         ` Joakim Tjernlund
2018-12-12 18:34 ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181212145154.GC1549@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=Joakim.Tjernlund@infinera.com \
    --cc=claudiu.manoil@nxp.com \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.