All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Yisen Zhuang <Yisen.Zhuang@huawei.com>,
	davem@davemloft.net, rjw@rjwysocki.net, lenb@kernel.org
Cc: arnd@arndb.de, andrew@lunn.ch, geliangtang@163.com,
	ivecera@redhat.com, fengguang.wu@intel.com,
	charles.chenxin@huawei.com, haifeng.wei@huawei.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linuxarm@huawei.com
Subject: Re: [patch net-next 05/11] net: hns: add uniform interface for phy connection
Date: Fri, 13 May 2016 16:07:25 +0300	[thread overview]
Message-ID: <1463144845.17131.342.camel@linux.intel.com> (raw)
In-Reply-To: <1463127557-90824-6-git-send-email-Yisen.Zhuang@huawei.com>

On Fri, 2016-05-13 at 16:19 +0800, Yisen Zhuang wrote:
> From: Kejian Yan <yankejian@huawei.com>
> 
> As device_node is only used by OF case, HNS needs to treat the others
> cases including ACPI. It needs to use uniform ways to handle both of
> OF and ACPI. This patch chooses phy_device, and of_phy_connect and
> of_phy_attach are only used by OF case. It needs to add uniform
> interface
> to handle that sequence by both OF and ACPI.

--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> @@ -987,6 +987,41 @@ static void hns_nic_adjust_link(struct net_device
> *ndev)
>  	h->dev->ops->adjust_link(h, ndev->phydev->speed, ndev-
> >phydev->duplex);
>  }
>  
> +static
> +struct phy_device *hns_nic_phy_attach(struct net_device *dev,
> +				      struct phy_device *phy,
> +				      u32 flags,
> +				      phy_interface_t iface)
> +{
> +	int ret;
> +
> +	if (!phy)
> +		return NULL;

No need to use defensive programming here.

> +
> +	ret = phy_attach_direct(dev, phy, flags, iface);
> +
> +	return ret ? NULL : phy;

Shouldn't it return an error?


> +}
> +
> +static
> +struct phy_device *hns_nic_phy_connect(struct net_device *dev,
> +				       struct phy_device *phy,
> +				       void (*hndlr)(struct
> net_device *),
> +				       u32 flags,
> +				       phy_interface_t iface)
> +{
> +	int ret;
> +
> +	if (!phy)
> +		return NULL;
> +
> +	phy->dev_flags = flags;
> +
> +	ret = phy_connect_direct(dev, phy, hndlr, iface);
> +
> +	return ret ? NULL : phy;
> +}
> +

For now looks that above functions are redundant and you may call them
directly in below code.

>  /**
>   *hns_nic_init_phy - init phy
>   *@ndev: net device
> @@ -996,16 +1031,17 @@ static void hns_nic_adjust_link(struct
> net_device *ndev)
>  int hns_nic_init_phy(struct net_device *ndev, struct hnae_handle *h)
>  {
>  	struct hns_nic_priv *priv = netdev_priv(ndev);
> -	struct phy_device *phy_dev = NULL;
> +	struct phy_device *phy_dev = h->phy_dev;
>  
> -	if (!h->phy_node)
> +	if (!h->phy_dev)
>  		return 0;
>  
>  	if (h->phy_if != PHY_INTERFACE_MODE_XGMII)
> -		phy_dev = of_phy_connect(ndev, h->phy_node,
> -					 hns_nic_adjust_link, 0, h-
> >phy_if);
> +		phy_dev = hns_nic_phy_connect(ndev, phy_dev,
> +					      hns_nic_adjust_link,
> +					      0, h->phy_if);
>  	else
> -		phy_dev = of_phy_attach(ndev, h->phy_node, 0, h-
> >phy_if);
> +		phy_dev = hns_nic_phy_attach(ndev, phy_dev, 0, h-
> >phy_if);


-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

  reply	other threads:[~2016-05-13 13:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-13  8:19 [patch net-next 00/11] net: hns: add support of ACPI Yisen Zhuang
2016-05-13  8:19 ` [patch net-next 01/11] net: hisilicon: add support of acpi for hns-mdio Yisen Zhuang
2016-05-13 12:59   ` Andy Shevchenko
2016-05-16  7:10     ` Yankejian (Hackim Yim)
2016-05-13  8:19 ` [patch net-next 02/11] net: hns: use device_* APIs instead of of_* APIs Yisen Zhuang
2016-05-13  8:19 ` [patch net-next 03/11] net: hns: use platform_get_irq instead of irq_of_parse_and_map Yisen Zhuang
2016-05-13  8:19 ` [patch net-next 04/11] net: hns: enet specify a reference to dsaf by fwnode_handle Yisen Zhuang
2016-05-13 13:01   ` Andy Shevchenko
2016-05-13  8:19 ` [patch net-next 05/11] net: hns: add uniform interface for phy connection Yisen Zhuang
2016-05-13 13:07   ` Andy Shevchenko [this message]
2016-05-16  0:40     ` Yankejian (Hackim Yim)
2016-05-13  8:19 ` [patch net-next 06/11] ACPI: bus: move acpi_match_device_ids() to linux/acpi.h Yisen Zhuang
2016-05-13 13:15   ` Andy Shevchenko
2016-05-16  1:57     ` Yankejian (Hackim Yim)
2016-05-13  8:19 ` [patch net-next 07/11] net: hns: dsaf adds support of acpi Yisen Zhuang
2016-05-13 13:12   ` Andy Shevchenko
2016-05-16  2:06     ` Yankejian (Hackim Yim)
2016-05-13  8:19 ` [patch net-next 08/11] net: hns: register phy device in each mac initial sequence Yisen Zhuang
2016-05-13  8:29   ` kbuild test robot
2016-05-13  8:19 ` [patch net-next 09/11] ACPI: bus: add stub acpi_evaluate_dsm() to linux/acpi.h Yisen Zhuang
2016-05-13  8:19 ` [patch net-next 10/11] net: hns: implement the reset sequence by asl Yisen Zhuang
2016-05-13  8:19 ` [patch net-next 11/11] net: hns: enet adds support of acpi Yisen Zhuang

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=1463144845.17131.342.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=Yisen.Zhuang@huawei.com \
    --cc=andrew@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=charles.chenxin@huawei.com \
    --cc=davem@davemloft.net \
    --cc=fengguang.wu@intel.com \
    --cc=geliangtang@163.com \
    --cc=haifeng.wei@huawei.com \
    --cc=ivecera@redhat.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /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.