* [net-next PATCH v1 0/2] Introduce new APIs to support phylink and phy layers @ 2020-04-24 3:16 Calvin Johnson 2020-04-24 3:16 ` [net-next PATCH v1 1/2] device property: Introduce fwnode_phy_find_device() Calvin Johnson 2020-04-24 3:16 ` [net-next PATCH v1 2/2] phylink: introduce phylink_fwnode_phy_connect() Calvin Johnson 0 siblings, 2 replies; 10+ messages in thread From: Calvin Johnson @ 2020-04-24 3:16 UTC (permalink / raw) To: linux.cj, Jeremy Linton, Andrew Lunn, Andy Shevchenko, Florian Fainelli, Russell King - ARM Linux admin, Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur Cc: Laurentiu Tudor, linux-acpi, Diana Madalina Craciun, linux-arm-kernel, Pankaj Bansal, linux-kernel, netdev, Varun Sethi, Marcin Wojtas, Makarand Pawagi, Rajesh V . Bikkina, Calvin Johnson, Andy Shevchenko, David S. Miller, Dmitry Torokhov, Greg Kroah-Hartman, Heikki Krogerus, Heiner Kallweit, Rafael J. Wysocki, Sakari Ailus, Thomas Gleixner Following functions are defined: phylink_fwnode_phy_connect() phylink_device_phy_connect() fwnode_phy_find_device() device_phy_find_device() First two help in connecting phy to phylink instance. Remaining two help to find a phy on a mdiobus. Calvin Johnson (2): device property: Introduce fwnode_phy_find_device() phylink: introduce phylink_fwnode_phy_connect() drivers/base/property.c | 41 ++++++++++++++++++ drivers/net/phy/phylink.c | 90 +++++++++++++++++++++++++++++++++++++++ include/linux/phylink.h | 6 +++ include/linux/property.h | 5 +++ 4 files changed, 142 insertions(+) -- 2.17.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [net-next PATCH v1 1/2] device property: Introduce fwnode_phy_find_device() 2020-04-24 3:16 [net-next PATCH v1 0/2] Introduce new APIs to support phylink and phy layers Calvin Johnson @ 2020-04-24 3:16 ` Calvin Johnson 2020-04-24 3:45 ` Florian Fainelli 2020-04-24 10:04 ` Heikki Krogerus 2020-04-24 3:16 ` [net-next PATCH v1 2/2] phylink: introduce phylink_fwnode_phy_connect() Calvin Johnson 1 sibling, 2 replies; 10+ messages in thread From: Calvin Johnson @ 2020-04-24 3:16 UTC (permalink / raw) To: linux.cj, Jeremy Linton, Andrew Lunn, Andy Shevchenko, Florian Fainelli, Russell King - ARM Linux admin, Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur Cc: Laurentiu Tudor, linux-acpi, Diana Madalina Craciun, linux-arm-kernel, Pankaj Bansal, linux-kernel, netdev, Varun Sethi, Marcin Wojtas, Makarand Pawagi, Rajesh V . Bikkina, Calvin Johnson, Andy Shevchenko, Dmitry Torokhov, Greg Kroah-Hartman, Heikki Krogerus, Rafael J. Wysocki, Sakari Ailus, Thomas Gleixner Define fwnode_phy_find_device() to iterate an mdiobus and find the phy device of the provided phy fwnode. Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com> --- drivers/base/property.c | 41 ++++++++++++++++++++++++++++++++++++++++ include/linux/property.h | 5 +++++ 2 files changed, 46 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 5f35c0ccf5e0..7c0c14c800b7 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -870,6 +870,47 @@ int device_get_phy_mode(struct device *dev) } EXPORT_SYMBOL_GPL(device_get_phy_mode); +/** + * fwnode_phy_find_device - Give a phy fwnode to find the corresponding + * phy_device on the mdiobus. + * @phy_fwnode: Pointer to the phy's fwnode. + * + * If successful, returns a pointer to the phy_device with the embedded + * struct device refcount incremented by one, or NULL on failure. + */ +struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode) +{ + struct device *d; + struct mdio_device *mdiodev; + + if (!phy_fwnode) + return NULL; + + d = bus_find_device_by_fwnode(&mdio_bus_type, phy_fwnode); + if (d) { + mdiodev = to_mdio_device(d); + if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) + return to_phy_device(d); + put_device(d); + } + + return NULL; +} +EXPORT_SYMBOL(fwnode_phy_find_device); + +/** + * device_phy_find_device - For the given device, get the phy_device + * @dev: Pointer to the given device + * + * If successful, returns a pointer to the phy_device with the embedded + * struct device refcount incremented by one, or NULL on failure. + */ +struct phy_device *device_phy_find_device(struct device *dev) +{ + return fwnode_phy_find_device(dev_fwnode(dev)); +} +EXPORT_SYMBOL_GPL(device_phy_find_device); + static void *fwnode_get_mac_addr(struct fwnode_handle *fwnode, const char *name, char *addr, int alen) diff --git a/include/linux/property.h b/include/linux/property.h index d86de017c689..236d656a2981 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -370,9 +370,14 @@ const void *device_get_match_data(struct device *dev); int device_get_phy_mode(struct device *dev); +struct phy_device *device_phy_find_device(struct device *dev); + void *device_get_mac_address(struct device *dev, char *addr, int alen); int fwnode_get_phy_mode(struct fwnode_handle *fwnode); + +struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode); + void *fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr, int alen); struct fwnode_handle *fwnode_graph_get_next_endpoint( -- 2.17.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [net-next PATCH v1 1/2] device property: Introduce fwnode_phy_find_device() 2020-04-24 3:16 ` [net-next PATCH v1 1/2] device property: Introduce fwnode_phy_find_device() Calvin Johnson @ 2020-04-24 3:45 ` Florian Fainelli 2020-04-24 9:26 ` Calvin Johnson 2020-04-24 10:04 ` Heikki Krogerus 1 sibling, 1 reply; 10+ messages in thread From: Florian Fainelli @ 2020-04-24 3:45 UTC (permalink / raw) To: Calvin Johnson, linux.cj, Jeremy Linton, Andrew Lunn, Andy Shevchenko, Russell King - ARM Linux admin, Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur Cc: Laurentiu Tudor, linux-acpi, Diana Madalina Craciun, linux-arm-kernel, Pankaj Bansal, linux-kernel, netdev, Varun Sethi, Marcin Wojtas, Makarand Pawagi, Rajesh V . Bikkina, Andy Shevchenko, Dmitry Torokhov, Greg Kroah-Hartman, Heikki Krogerus, Rafael J. Wysocki, Sakari Ailus, Thomas Gleixner On 4/23/2020 8:16 PM, Calvin Johnson wrote: > Define fwnode_phy_find_device() to iterate an mdiobus and find the > phy device of the provided phy fwnode. > > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com> If you forget to update the MAINTAINERS file, or do not place this code under drivers/net/phy/* or drivers/of/of_mdio.c then this is going to completely escape the sight of the PHYLIB/PHYLINK maintainers... -- Florian ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [net-next PATCH v1 1/2] device property: Introduce fwnode_phy_find_device() 2020-04-24 3:45 ` Florian Fainelli @ 2020-04-24 9:26 ` Calvin Johnson 2020-04-24 9:34 ` Greg Kroah-Hartman 2020-04-24 9:54 ` Andy Shevchenko 0 siblings, 2 replies; 10+ messages in thread From: Calvin Johnson @ 2020-04-24 9:26 UTC (permalink / raw) To: Florian Fainelli Cc: linux.cj, Jeremy Linton, Andrew Lunn, Andy Shevchenko, Russell King - ARM Linux admin, Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur, Laurentiu Tudor, linux-acpi, Diana Madalina Craciun, linux-arm-kernel, Pankaj Bansal, linux-kernel, netdev, Varun Sethi, Marcin Wojtas, Makarand Pawagi, Rajesh V . Bikkina, Andy Shevchenko, Dmitry Torokhov, Greg Kroah-Hartman, Heikki Krogerus, Rafael J. Wysocki, Sakari Ailus, Thomas Gleixner On Thu, Apr 23, 2020 at 08:45:03PM -0700, Florian Fainelli wrote: > > > On 4/23/2020 8:16 PM, Calvin Johnson wrote: > > Define fwnode_phy_find_device() to iterate an mdiobus and find the > > phy device of the provided phy fwnode. > > > > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com> > > If you forget to update the MAINTAINERS file, or do not place this code > under drivers/net/phy/* or drivers/of/of_mdio.c then this is going to > completely escape the sight of the PHYLIB/PHYLINK maintainers... Did you mean the following change? --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6354,6 +6354,7 @@ F: Documentation/devicetree/bindings/net/ethernet-phy.yaml F: Documentation/devicetree/bindings/net/mdio* F: Documentation/devicetree/bindings/net/qca,ar803x.yaml F: Documentation/networking/phy.rst +F: drivers/base/property.c F: drivers/net/phy/ F: drivers/of/of_mdio.c Do I need to send v2 with this? On checking CC and MAINTAINERS, I see only hkallweit1@gmail.com was missed. Please let me know. Regards Calvin ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [net-next PATCH v1 1/2] device property: Introduce fwnode_phy_find_device() 2020-04-24 9:26 ` Calvin Johnson @ 2020-04-24 9:34 ` Greg Kroah-Hartman 2020-04-24 9:54 ` Andy Shevchenko 1 sibling, 0 replies; 10+ messages in thread From: Greg Kroah-Hartman @ 2020-04-24 9:34 UTC (permalink / raw) To: Calvin Johnson Cc: Florian Fainelli, linux.cj, Jeremy Linton, Andrew Lunn, Andy Shevchenko, Russell King - ARM Linux admin, Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur, Laurentiu Tudor, linux-acpi, Diana Madalina Craciun, linux-arm-kernel, Pankaj Bansal, linux-kernel, netdev, Varun Sethi, Marcin Wojtas, Makarand Pawagi, Rajesh V . Bikkina, Andy Shevchenko, Dmitry Torokhov, Heikki Krogerus, Rafael J. Wysocki, Sakari Ailus, Thomas Gleixner On Fri, Apr 24, 2020 at 02:56:51PM +0530, Calvin Johnson wrote: > On Thu, Apr 23, 2020 at 08:45:03PM -0700, Florian Fainelli wrote: > > > > > > On 4/23/2020 8:16 PM, Calvin Johnson wrote: > > > Define fwnode_phy_find_device() to iterate an mdiobus and find the > > > phy device of the provided phy fwnode. > > > > > > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com> > > > > If you forget to update the MAINTAINERS file, or do not place this code > > under drivers/net/phy/* or drivers/of/of_mdio.c then this is going to > > completely escape the sight of the PHYLIB/PHYLINK maintainers... > > Did you mean the following change? > > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -6354,6 +6354,7 @@ F: > Documentation/devicetree/bindings/net/ethernet-phy.yaml > F: Documentation/devicetree/bindings/net/mdio* > F: Documentation/devicetree/bindings/net/qca,ar803x.yaml > F: Documentation/networking/phy.rst > +F: drivers/base/property.c > F: drivers/net/phy/ > F: drivers/of/of_mdio.c I really doubt the phy maintainers want to maintain all of property.c, right? Please be kinder... greg k-h ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [net-next PATCH v1 1/2] device property: Introduce fwnode_phy_find_device() 2020-04-24 9:26 ` Calvin Johnson 2020-04-24 9:34 ` Greg Kroah-Hartman @ 2020-04-24 9:54 ` Andy Shevchenko 2020-04-24 13:41 ` Calvin Johnson 1 sibling, 1 reply; 10+ messages in thread From: Andy Shevchenko @ 2020-04-24 9:54 UTC (permalink / raw) To: Calvin Johnson Cc: Florian Fainelli, linux.cj, Jeremy Linton, Andrew Lunn, Russell King - ARM Linux admin, Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur, Laurentiu Tudor, ACPI Devel Maling List, Diana Madalina Craciun, linux-arm Mailing List, Pankaj Bansal, Linux Kernel Mailing List, netdev, Varun Sethi, Marcin Wojtas, Makarand Pawagi, Rajesh V . Bikkina, Andy Shevchenko, Dmitry Torokhov, Greg Kroah-Hartman, Heikki Krogerus, Rafael J. Wysocki, Sakari Ailus, Thomas Gleixner On Fri, Apr 24, 2020 at 12:27 PM Calvin Johnson <calvin.johnson@oss.nxp.com> wrote: > On Thu, Apr 23, 2020 at 08:45:03PM -0700, Florian Fainelli wrote: > > On 4/23/2020 8:16 PM, Calvin Johnson wrote: > > If you forget to update the MAINTAINERS file, or do not place this code > > under drivers/net/phy/* or drivers/of/of_mdio.c then this is going to > > completely escape the sight of the PHYLIB/PHYLINK maintainers... > > Did you mean the following change? I don't think this is an appreciated option. Second one was to locate this code under drivers/net, which may be better. And perhaps other not basic (to the properties) stuff should be also moved to respective subsystems. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [net-next PATCH v1 1/2] device property: Introduce fwnode_phy_find_device() 2020-04-24 9:54 ` Andy Shevchenko @ 2020-04-24 13:41 ` Calvin Johnson 0 siblings, 0 replies; 10+ messages in thread From: Calvin Johnson @ 2020-04-24 13:41 UTC (permalink / raw) To: Andy Shevchenko Cc: Florian Fainelli, linux.cj, Jeremy Linton, Andrew Lunn, Russell King - ARM Linux admin, Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur, Laurentiu Tudor, ACPI Devel Maling List, Diana Madalina Craciun, linux-arm Mailing List, Pankaj Bansal, Linux Kernel Mailing List, netdev, Varun Sethi, Marcin Wojtas, Makarand Pawagi, Rajesh V . Bikkina, Andy Shevchenko, Dmitry Torokhov, Greg Kroah-Hartman, Heikki Krogerus, Rafael J. Wysocki, Sakari Ailus, Thomas Gleixner On Fri, Apr 24, 2020 at 12:54:26PM +0300, Andy Shevchenko wrote: > On Fri, Apr 24, 2020 at 12:27 PM Calvin Johnson > <calvin.johnson@oss.nxp.com> wrote: > > On Thu, Apr 23, 2020 at 08:45:03PM -0700, Florian Fainelli wrote: > > > On 4/23/2020 8:16 PM, Calvin Johnson wrote: > > > > If you forget to update the MAINTAINERS file, or do not place this code > > > under drivers/net/phy/* or drivers/of/of_mdio.c then this is going to > > > completely escape the sight of the PHYLIB/PHYLINK maintainers... > > > > Did you mean the following change? > > I don't think this is an appreciated option. > Second one was to locate this code under drivers/net, which may be > better. And perhaps other not basic (to the properties) stuff should > be also moved to respective subsystems. How about placing it in drivers/net/phy/phy_device.c? If it is ok, I can do it in v2. Thanks Calvin ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [net-next PATCH v1 1/2] device property: Introduce fwnode_phy_find_device() 2020-04-24 3:16 ` [net-next PATCH v1 1/2] device property: Introduce fwnode_phy_find_device() Calvin Johnson 2020-04-24 3:45 ` Florian Fainelli @ 2020-04-24 10:04 ` Heikki Krogerus 1 sibling, 0 replies; 10+ messages in thread From: Heikki Krogerus @ 2020-04-24 10:04 UTC (permalink / raw) To: Calvin Johnson Cc: linux.cj, Jeremy Linton, Andrew Lunn, Andy Shevchenko, Florian Fainelli, Russell King - ARM Linux admin, Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur, Laurentiu Tudor, linux-acpi, Diana Madalina Craciun, linux-arm-kernel, Pankaj Bansal, linux-kernel, netdev, Varun Sethi, Marcin Wojtas, Makarand Pawagi, Rajesh V . Bikkina, Andy Shevchenko, Dmitry Torokhov, Greg Kroah-Hartman, Rafael J. Wysocki, Sakari Ailus, Thomas Gleixner On Fri, Apr 24, 2020 at 08:46:16AM +0530, Calvin Johnson wrote: > Define fwnode_phy_find_device() to iterate an mdiobus and find the > phy device of the provided phy fwnode. > > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com> > --- > > drivers/base/property.c | 41 ++++++++++++++++++++++++++++++++++++++++ > include/linux/property.h | 5 +++++ > 2 files changed, 46 insertions(+) > > diff --git a/drivers/base/property.c b/drivers/base/property.c > index 5f35c0ccf5e0..7c0c14c800b7 100644 > --- a/drivers/base/property.c > +++ b/drivers/base/property.c > @@ -870,6 +870,47 @@ int device_get_phy_mode(struct device *dev) > } > EXPORT_SYMBOL_GPL(device_get_phy_mode); > > +/** > + * fwnode_phy_find_device - Give a phy fwnode to find the corresponding > + * phy_device on the mdiobus. > + * @phy_fwnode: Pointer to the phy's fwnode. > + * > + * If successful, returns a pointer to the phy_device with the embedded > + * struct device refcount incremented by one, or NULL on failure. > + */ > +struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode) > +{ > + struct device *d; > + struct mdio_device *mdiodev; > + > + if (!phy_fwnode) > + return NULL; > + > + d = bus_find_device_by_fwnode(&mdio_bus_type, phy_fwnode); > + if (d) { > + mdiodev = to_mdio_device(d); > + if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) > + return to_phy_device(d); > + put_device(d); > + } > + > + return NULL; > +} > +EXPORT_SYMBOL(fwnode_phy_find_device); > + > +/** > + * device_phy_find_device - For the given device, get the phy_device > + * @dev: Pointer to the given device > + * > + * If successful, returns a pointer to the phy_device with the embedded > + * struct device refcount incremented by one, or NULL on failure. > + */ > +struct phy_device *device_phy_find_device(struct device *dev) > +{ > + return fwnode_phy_find_device(dev_fwnode(dev)); > +} > +EXPORT_SYMBOL_GPL(device_phy_find_device); Let's not put any more subsystem specific functions into property.c. thanks, -- heikki ^ permalink raw reply [flat|nested] 10+ messages in thread
* [net-next PATCH v1 2/2] phylink: introduce phylink_fwnode_phy_connect() 2020-04-24 3:16 [net-next PATCH v1 0/2] Introduce new APIs to support phylink and phy layers Calvin Johnson 2020-04-24 3:16 ` [net-next PATCH v1 1/2] device property: Introduce fwnode_phy_find_device() Calvin Johnson @ 2020-04-24 3:16 ` Calvin Johnson 2020-04-24 9:56 ` Andy Shevchenko 1 sibling, 1 reply; 10+ messages in thread From: Calvin Johnson @ 2020-04-24 3:16 UTC (permalink / raw) To: linux.cj, Jeremy Linton, Andrew Lunn, Andy Shevchenko, Florian Fainelli, Russell King - ARM Linux admin, Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur Cc: Laurentiu Tudor, linux-acpi, Diana Madalina Craciun, linux-arm-kernel, Pankaj Bansal, linux-kernel, netdev, Varun Sethi, Marcin Wojtas, Makarand Pawagi, Rajesh V . Bikkina, Calvin Johnson, David S. Miller, Heiner Kallweit Define phylink_fwnode_phy_connect() to connect phy specified by a fwnode to a phylink instance. This function will handle both DT and ACPI nodes. Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com> --- drivers/net/phy/phylink.c | 90 +++++++++++++++++++++++++++++++++++++++ include/linux/phylink.h | 6 +++ 2 files changed, 96 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 34ca12aec61b..4f6552389ffb 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -18,6 +18,7 @@ #include <linux/spinlock.h> #include <linux/timer.h> #include <linux/workqueue.h> +#include <linux/acpi.h> #include "sfp.h" #include "swphy.h" @@ -961,6 +962,95 @@ int phylink_connect_phy(struct phylink *pl, struct phy_device *phy) } EXPORT_SYMBOL_GPL(phylink_connect_phy); +/** + * phylink_fwnode_phy_connect() - connect the PHY specified in the fwnode. + * @pl: a pointer to a &struct phylink returned from phylink_create() + * @fwnode: a pointer to a &struct fwnode_handle. + * @flags: PHY-specific flags to communicate to the PHY device driver + * + * Connect the phy specified @fwnode to the phylink instance specified + * by @pl. Actions specified in phylink_connect_phy() will be + * performed. + * + * Returns 0 on success or a negative errno. + */ +int phylink_fwnode_phy_connect(struct phylink *pl, + struct fwnode_handle *fwnode, + u32 flags) +{ + struct device_node *dn = to_of_node(fwnode); + struct fwnode_reference_args args; + struct device_node *phy_node; + struct phy_device *phy_dev; + acpi_status status; + int ret; + + /* Fixed links and 802.3z are handled without needing a PHY */ + if (pl->cfg_link_an_mode == MLO_AN_FIXED || + (pl->cfg_link_an_mode == MLO_AN_INBAND && + phy_interface_mode_is_8023z(pl->link_interface))) + return 0; + + if (is_of_node(fwnode)) { + phy_node = of_parse_phandle(dn, "phy-handle", 0); + if (!phy_node) + phy_node = of_parse_phandle(dn, "phy", 0); + if (!phy_node) + phy_node = of_parse_phandle(dn, "phy-device", 0); + + if (!phy_node) { + if (pl->cfg_link_an_mode == MLO_AN_PHY) + return -ENODEV; + return 0; + } + + phy_dev = of_phy_find_device(phy_node); + /* We're done with the phy_node handle */ + of_node_put(phy_node); + } else if (is_acpi_node(fwnode)) { + status = acpi_node_get_property_reference(fwnode, + "phy-handle", + 0, &args); + if (ACPI_FAILURE(status)) + return -ENODEV; + phy_dev = fwnode_phy_find_device(args.fwnode); + } + if (!phy_dev) + return -ENODEV; + + ret = phy_attach_direct(pl->netdev, phy_dev, flags, + pl->link_interface); + if (ret) + return ret; + + ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface); + if (ret) + phy_detach(phy_dev); + + return ret; +} +EXPORT_SYMBOL_GPL(phylink_fwnode_phy_connect); + +/** + * phylink_fwnode_phy_connect() - connect the PHY specified in the fwnode. + * @pl: a pointer to a &struct phylink returned from phylink_create() + * @dev: a pointer to a &struct device. + * @flags: PHY-specific flags to communicate to the PHY device driver + * + * Connect the phy specified @fwnode to the phylink instance specified + * by @pl. Actions specified in phylink_connect_phy() will be + * performed. + * + * Returns 0 on success or a negative errno. + */ +int phylink_device_phy_connect(struct phylink *pl, + struct device *dev, + u32 flags) +{ + return phylink_fwnode_phy_connect(pl, dev_fwnode(dev), flags); +} +EXPORT_SYMBOL_GPL(phylink_device_phy_connect); + /** * phylink_of_phy_connect() - connect the PHY specified in the DT mode. * @pl: a pointer to a &struct phylink returned from phylink_create() diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 3f8d37ec5503..c2966a067792 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -364,6 +364,12 @@ void phylink_add_pcs(struct phylink *, const struct phylink_pcs_ops *ops); void phylink_destroy(struct phylink *); int phylink_connect_phy(struct phylink *, struct phy_device *); +int phylink_fwnode_phy_connect(struct phylink *pl, + struct fwnode_handle *fwnode, + u32 flags); +int phylink_device_phy_connect(struct phylink *pl, + struct device *dev, + u32 flags); int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags); void phylink_disconnect_phy(struct phylink *); int phylink_fixed_state_cb(struct phylink *, -- 2.17.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [net-next PATCH v1 2/2] phylink: introduce phylink_fwnode_phy_connect() 2020-04-24 3:16 ` [net-next PATCH v1 2/2] phylink: introduce phylink_fwnode_phy_connect() Calvin Johnson @ 2020-04-24 9:56 ` Andy Shevchenko 0 siblings, 0 replies; 10+ messages in thread From: Andy Shevchenko @ 2020-04-24 9:56 UTC (permalink / raw) To: Calvin Johnson Cc: linux.cj, Jeremy Linton, Andrew Lunn, Florian Fainelli, Russell King - ARM Linux admin, Cristi Sovaiala, Florin Laurentiu Chiculita, Ioana Ciornei, Madalin Bucur, Laurentiu Tudor, ACPI Devel Maling List, Diana Madalina Craciun, linux-arm Mailing List, Pankaj Bansal, Linux Kernel Mailing List, netdev, Varun Sethi, Marcin Wojtas, Makarand Pawagi, Rajesh V . Bikkina, David S. Miller, Heiner Kallweit On Fri, Apr 24, 2020 at 6:17 AM Calvin Johnson <calvin.johnson@oss.nxp.com> wrote: > > Define phylink_fwnode_phy_connect() to connect phy specified by > a fwnode to a phylink instance. This function will handle both > DT and ACPI nodes. > #include <linux/spinlock.h> > #include <linux/timer.h> > #include <linux/workqueue.h> > +#include <linux/acpi.h> Looks like broken order. > + if (is_of_node(fwnode)) { > + } else if (is_acpi_node(fwnode)) { > + } I'm wondering if there is an API that allows you to drop all this stuff. In property provider agnostic code we really don't want to see this. > + if (!phy_dev) > + return -ENODEV; -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-04-24 13:41 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-04-24 3:16 [net-next PATCH v1 0/2] Introduce new APIs to support phylink and phy layers Calvin Johnson 2020-04-24 3:16 ` [net-next PATCH v1 1/2] device property: Introduce fwnode_phy_find_device() Calvin Johnson 2020-04-24 3:45 ` Florian Fainelli 2020-04-24 9:26 ` Calvin Johnson 2020-04-24 9:34 ` Greg Kroah-Hartman 2020-04-24 9:54 ` Andy Shevchenko 2020-04-24 13:41 ` Calvin Johnson 2020-04-24 10:04 ` Heikki Krogerus 2020-04-24 3:16 ` [net-next PATCH v1 2/2] phylink: introduce phylink_fwnode_phy_connect() Calvin Johnson 2020-04-24 9:56 ` Andy Shevchenko
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).