From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAE40C433DB for ; Thu, 11 Mar 2021 12:10:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A495764FD9 for ; Thu, 11 Mar 2021 12:10:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232690AbhCKMKQ (ORCPT ); Thu, 11 Mar 2021 07:10:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232919AbhCKMJz (ORCPT ); Thu, 11 Mar 2021 07:09:55 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E366C061574; Thu, 11 Mar 2021 04:09:55 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id mz6-20020a17090b3786b02900c16cb41d63so9258823pjb.2; Thu, 11 Mar 2021 04:09:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Fgejs9NwV9XHSr5esguFyo9ZNJH3pXg6b5W2nj6hE9Y=; b=inU5Zx8EGGSu9ee0nwxvKjp/gAnj96crRgmjon+zOWjAbvJB7CIm3DlXUzlRygC/Py x17TbBsF4biwzm1xgY5XIRUAB9PMMg7p7SHc+J2teqQ1fotk809vKUZjQxkg8iVzGB6x DY8Js1w8UPPl/ENngUg1oNtfRIs24G/i64UZl+7HRNiVvMBb/bXO6xoTIw4qHd0ev+Qf IFq2Ovcc3rG3qOh5DeD7px0UynbpOlpQuQ4Cwyzf8g57+Wh1otNdVLzt4/yZ+QsvcVSV 77p2IYAPDN2gsyKB4Ca9J1rOutvrW0R1gDN6b6je+Xw+xoZ2SMFlbBcowlEF1e6FKZjH uQpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Fgejs9NwV9XHSr5esguFyo9ZNJH3pXg6b5W2nj6hE9Y=; b=MtYOFd95zIy18FUJTD3DViPlkClkwIuDSS/oJV1suP1WORi7nqw3JBcvyVt2NcB7mM AXfP5/kDj7t1j2RdoTiD1BCniYJwbqODrYeYPWFm81NwcCZSmvFp6cO5KFNwD3c1fJXi wxE3Hd9RXYDpUlfKReZ98vRVpH5E+nBkqck5BpK1GZQrrFDY5sW2+qwdC2mfImgz73Fq TgK+HVTkQnXjHDq+bU1prXhAnVQOXRmaIfTwF0N1atNtprvC4byoCWNpx7cETI1et/5r to3Fu5bffAMtfOft2LvQDB3XC8/LqnAGiQbyLjPyzFh9g8+zlXdT+KAC3FPpZ6dReaeo mNmw== X-Gm-Message-State: AOAM5337CSoXx50xNJuaBY7Kqw2mo7CegBhwBsf0UjzKSFkbdTpPUUTt Lf8doW4W8cjquBaCyNa3py1MPQqRZJTflJu++vc= X-Google-Smtp-Source: ABdhPJwpHihmwOjDMAypNOI8HBpk366v1P70tH9iUFlgBuBvxBR5OS42lhnweZRQdWNdWm0tILL6xA21z+6UYXLUudM= X-Received: by 2002:a17:902:c808:b029:e6:4204:f62f with SMTP id u8-20020a170902c808b02900e64204f62fmr7943918plx.0.1615464594250; Thu, 11 Mar 2021 04:09:54 -0800 (PST) MIME-Version: 1.0 References: <20210311062011.8054-1-calvin.johnson@oss.nxp.com> <20210311062011.8054-9-calvin.johnson@oss.nxp.com> In-Reply-To: <20210311062011.8054-9-calvin.johnson@oss.nxp.com> From: Andy Shevchenko Date: Thu, 11 Mar 2021 14:09:37 +0200 Message-ID: Subject: Re: [net-next PATCH v7 08/16] net: mdiobus: Introduce fwnode_mdiobus_register_phy() To: Calvin Johnson Cc: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap , linux-arm Mailing List , Diana Madalina Craciun , ACPI Devel Maling List , Linux Kernel Mailing List , "linux.cj" , netdev , Laurentiu Tudor , "David S. Miller" , Frank Rowand , Heiner Kallweit , Jakub Kicinski , Rob Herring , devicetree Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Thu, Mar 11, 2021 at 8:21 AM Calvin Johnson wrote: > > Introduce fwnode_mdiobus_register_phy() to register PHYs on the > mdiobus. From the compatible string, identify whether the PHY is > c45 and based on this create a PHY device instance which is > registered on the mdiobus. > uninitialized symbol 'mii_ts' > Reported-by: kernel test robot > Reported-by: Dan Carpenter I don't think it's important to have it in a history of Git. I would move this after the cutter '---' line below. > Signed-off-by: Calvin Johnson > --- > > Changes in v7: > - Call unregister_mii_timestamper() without NULL check > - Create fwnode_mdio.c and move fwnode_mdiobus_register_phy() > > Changes in v6: > - Initialize mii_ts to NULL > > Changes in v5: None > Changes in v4: None > Changes in v3: None > Changes in v2: None > > MAINTAINERS | 1 + > drivers/net/mdio/Kconfig | 9 ++++ > drivers/net/mdio/Makefile | 3 +- > drivers/net/mdio/fwnode_mdio.c | 77 ++++++++++++++++++++++++++++++++++ > drivers/net/mdio/of_mdio.c | 3 +- > include/linux/fwnode_mdio.h | 24 +++++++++++ > include/linux/of_mdio.h | 6 ++- > 7 files changed, 120 insertions(+), 3 deletions(-) > create mode 100644 drivers/net/mdio/fwnode_mdio.c > create mode 100644 include/linux/fwnode_mdio.h > > diff --git a/MAINTAINERS b/MAINTAINERS > index e1fa5ad9bb30..146de41d2656 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -6680,6 +6680,7 @@ F: Documentation/devicetree/bindings/net/mdio* > F: Documentation/devicetree/bindings/net/qca,ar803x.yaml > F: Documentation/networking/phy.rst > F: drivers/net/mdio/ > +F: drivers/net/mdio/fwnode_mdio.c > F: drivers/net/mdio/of_mdio.c > F: drivers/net/pcs/ > F: drivers/net/phy/ > diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig > index a10cc460d7cf..2d5bf5ccffb5 100644 > --- a/drivers/net/mdio/Kconfig > +++ b/drivers/net/mdio/Kconfig > @@ -19,6 +19,15 @@ config MDIO_BUS > reflects whether the mdio_bus/mdio_device code is built as a > loadable module or built-in. > > +config FWNODE_MDIO > + def_tristate PHYLIB (Seems "selectable only" item) > + depends on ACPI > + depends on OF Wouldn't be better to have depends on (ACPI || OF) || COMPILE_TEST And honestly I don't understand it in either (AND or OR) variant. Why do you need a dependency like this for fwnode API? Moreover dependencies don't work for "selectable only" items. > + depends on PHYLIB > + select FIXED_PHY > + help > + FWNODE MDIO bus (Ethernet PHY) accessors > + > config OF_MDIO > def_tristate PHYLIB > depends on OF > diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile > index 5c498dde463f..ea5390e2ef84 100644 > --- a/drivers/net/mdio/Makefile > +++ b/drivers/net/mdio/Makefile > @@ -1,7 +1,8 @@ > # SPDX-License-Identifier: GPL-2.0 > # Makefile for Linux MDIO bus drivers > > -obj-$(CONFIG_OF_MDIO) += of_mdio.o > +obj-$(CONFIG_FWNODE_MDIO) += fwnode_mdio.o > +obj-$(CONFIG_OF_MDIO) += of_mdio.o > > obj-$(CONFIG_MDIO_ASPEED) += mdio-aspeed.o > obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o > diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c > new file mode 100644 > index 000000000000..0982e816a6fb > --- /dev/null > +++ b/drivers/net/mdio/fwnode_mdio.c > @@ -0,0 +1,77 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * fwnode helpers for the MDIO (Ethernet PHY) API > + * > + * This file provides helper functions for extracting PHY device information > + * out of the fwnode and using it to populate an mii_bus. > + */ > + > +#include > +#include > +#include > +#include > + > +MODULE_AUTHOR("Calvin Johnson "); > +MODULE_LICENSE("GPL"); > + > +int fwnode_mdiobus_register_phy(struct mii_bus *bus, > + struct fwnode_handle *child, u32 addr) > +{ > + struct mii_timestamper *mii_ts = NULL; > + struct phy_device *phy; > + bool is_c45 = false; > + u32 phy_id; > + int rc; > + > + if (is_of_node(child)) { > + mii_ts = of_find_mii_timestamper(to_of_node(child)); > + if (IS_ERR(mii_ts)) > + return PTR_ERR(mii_ts); > + } > + > + rc = fwnode_property_match_string(child, "compatible", "ethernet-phy-ieee802.3-c45"); > + if (rc >= 0) > + is_c45 = true; > + > + if (is_c45 || fwnode_get_phy_id(child, &phy_id)) > + phy = get_phy_device(bus, addr, is_c45); > + else > + phy = phy_device_create(bus, addr, phy_id, 0, NULL); > + if (IS_ERR(phy)) { > + unregister_mii_timestamper(mii_ts); > + return PTR_ERR(phy); > + } > + > + if (is_acpi_node(child)) { > + phy->irq = bus->irq[addr]; > + > + /* Associate the fwnode with the device structure so it > + * can be looked up later. > + */ > + phy->mdio.dev.fwnode = child; > + > + /* All data is now stored in the phy struct, so register it */ > + rc = phy_device_register(phy); > + if (rc) { > + phy_device_free(phy); > + fwnode_handle_put(phy->mdio.dev.fwnode); > + return rc; > + } > + } else if (is_of_node(child)) { > + rc = of_mdiobus_phy_device_register(bus, phy, to_of_node(child), addr); > + if (rc) { > + unregister_mii_timestamper(mii_ts); > + phy_device_free(phy); > + return rc; > + } > + } > + > + /* phy->mii_ts may already be defined by the PHY driver. A > + * mii_timestamper probed via the device tree will still have > + * precedence. > + */ > + if (mii_ts) > + phy->mii_ts = mii_ts; > + return 0; > +} > +EXPORT_SYMBOL(fwnode_mdiobus_register_phy); > diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c > index 48b6b8458c17..db293e0b8249 100644 > --- a/drivers/net/mdio/of_mdio.c > +++ b/drivers/net/mdio/of_mdio.c > @@ -32,7 +32,7 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id) > return fwnode_get_phy_id(of_fwnode_handle(device), phy_id); > } > > -static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node) > +struct mii_timestamper *of_find_mii_timestamper(struct device_node *node) > { > struct of_phandle_args arg; > int err; > @@ -49,6 +49,7 @@ static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node) > > return register_mii_timestamper(arg.np, arg.args[0]); > } > +EXPORT_SYMBOL(of_find_mii_timestamper); > > int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy, > struct device_node *child, u32 addr) > diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h > new file mode 100644 > index 000000000000..8c0392845916 > --- /dev/null > +++ b/include/linux/fwnode_mdio.h > @@ -0,0 +1,24 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * FWNODE helper for the MDIO (Ethernet PHY) API > + */ > + > +#ifndef __LINUX_FWNODE_MDIO_H > +#define __LINUX_FWNODE_MDIO_H > + > +#include > + > +#if IS_ENABLED(CONFIG_FWNODE_MDIO) > +int fwnode_mdiobus_register_phy(struct mii_bus *bus, > + struct fwnode_handle *child, u32 addr); > + > +#else /* CONFIG_FWNODE_MDIO */ > +static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus, > + struct fwnode_handle *child, > + u32 addr) > +{ > + return -EINVAL; > +} > +#endif > + > +#endif /* __LINUX_FWNODE_MDIO_H */ > diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h > index 2b05e7f7c238..e4ee6c4d9431 100644 > --- a/include/linux/of_mdio.h > +++ b/include/linux/of_mdio.h > @@ -31,6 +31,7 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np); > int of_phy_register_fixed_link(struct device_node *np); > void of_phy_deregister_fixed_link(struct device_node *np); > bool of_phy_is_fixed_link(struct device_node *np); > +struct mii_timestamper *of_find_mii_timestamper(struct device_node *np); > int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy, > struct device_node *child, u32 addr); > > @@ -118,7 +119,10 @@ static inline bool of_phy_is_fixed_link(struct device_node *np) > { > return false; > } > - > +static inline struct mii_timestamper *of_find_mii_timestamper(struct device_node *np) > +{ > + return NULL; > +} > static inline int of_mdiobus_phy_device_register(struct mii_bus *mdio, > struct phy_device *phy, > struct device_node *child, u32 addr) > -- > 2.17.1 > -- With Best Regards, Andy Shevchenko From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81D78C433DB for ; Thu, 11 Mar 2021 12:11:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F72B64EFD for ; Thu, 11 Mar 2021 12:11:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F72B64EFD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DJq/+JNvskQVaQAlS0UN4HZhnhgxrHJddpoyAYIcIhg=; b=ZY3TZf4E/EZ/OwSuyh+Uqj1KN AjOUzzRv6Dw0DF3oXSSvB8/b/Eb6qQk/iA/2Hn/t79k84NB7dZq6syqUrlKbyGDQj/ZJ24gESNR5M BMvNJKMlRJO8gSZ2R/jdht7y4v3S18S3X9NRnkoFK8VxIKV0BSVvihBdA4vm1djFNiCmMfLX4V6w+ L7AR+Xk05ftowcG+nCkw6aYZJ+llFUYtjd0LbnK1MIgWVAiig1c1Tp400xZWAheVO1CgMDLF5Gl+i bfeZGgZA2h7pnuqWoEhANihGRYoAX1aE1XI/w0PF2aFORlGidM+b/Ho0C90MjBvYKhX1tGgTSwVpD eEURF5qGg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKK8g-0092WV-LV; Thu, 11 Mar 2021 12:10:02 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKK8Z-0092V7-SZ for linux-arm-kernel@lists.infradead.org; Thu, 11 Mar 2021 12:09:58 +0000 Received: by mail-pj1-x1030.google.com with SMTP id kk2-20020a17090b4a02b02900c777aa746fso9250978pjb.3 for ; Thu, 11 Mar 2021 04:09:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Fgejs9NwV9XHSr5esguFyo9ZNJH3pXg6b5W2nj6hE9Y=; b=inU5Zx8EGGSu9ee0nwxvKjp/gAnj96crRgmjon+zOWjAbvJB7CIm3DlXUzlRygC/Py x17TbBsF4biwzm1xgY5XIRUAB9PMMg7p7SHc+J2teqQ1fotk809vKUZjQxkg8iVzGB6x DY8Js1w8UPPl/ENngUg1oNtfRIs24G/i64UZl+7HRNiVvMBb/bXO6xoTIw4qHd0ev+Qf IFq2Ovcc3rG3qOh5DeD7px0UynbpOlpQuQ4Cwyzf8g57+Wh1otNdVLzt4/yZ+QsvcVSV 77p2IYAPDN2gsyKB4Ca9J1rOutvrW0R1gDN6b6je+Xw+xoZ2SMFlbBcowlEF1e6FKZjH uQpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Fgejs9NwV9XHSr5esguFyo9ZNJH3pXg6b5W2nj6hE9Y=; b=fcqvC0NZvy05IABwXAU3GvivVXGbNNDrBy7+nSVLuF4uzPH7ZvrD+QFYxFq2rCfLZJ bKC0meXUA6+IyvI9OJAa4RC1LiuL3KEirda3+A2q7/Ao8entvKRr7wqVDIs4ciqnQXZ+ B8tcIMRyQmAeRk+dWRSL1dqsLGEGAyLkCH/P0Iege7TceYwPqGfaSgKU80XHfuYpMZC6 eeHzTTKnGPozv6WcbjeCU41JcqZ5zDvhocxKGFsmqXOtni/0ZR8KkG5b35fR4rG8BVL1 prcaM5l9M8cwB7k42oG4DZD2cX5BDZdl0MQ+LaY2D6gF303GpF894chYSTyhfCiOahw4 av2w== X-Gm-Message-State: AOAM532gLjIKdSZ4YvvW9v7ntQH8zqCBygKfs7QN0V06cye/sG3dgV8e vC1pxGNm1rTclmWDpDz5oaFlv6wGO4FF+FuAC+U= X-Google-Smtp-Source: ABdhPJwpHihmwOjDMAypNOI8HBpk366v1P70tH9iUFlgBuBvxBR5OS42lhnweZRQdWNdWm0tILL6xA21z+6UYXLUudM= X-Received: by 2002:a17:902:c808:b029:e6:4204:f62f with SMTP id u8-20020a170902c808b02900e64204f62fmr7943918plx.0.1615464594250; Thu, 11 Mar 2021 04:09:54 -0800 (PST) MIME-Version: 1.0 References: <20210311062011.8054-1-calvin.johnson@oss.nxp.com> <20210311062011.8054-9-calvin.johnson@oss.nxp.com> In-Reply-To: <20210311062011.8054-9-calvin.johnson@oss.nxp.com> From: Andy Shevchenko Date: Thu, 11 Mar 2021 14:09:37 +0200 Message-ID: Subject: Re: [net-next PATCH v7 08/16] net: mdiobus: Introduce fwnode_mdiobus_register_phy() To: Calvin Johnson Cc: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap , linux-arm Mailing List , Diana Madalina Craciun , ACPI Devel Maling List , Linux Kernel Mailing List , "linux.cj" , netdev , Laurentiu Tudor , "David S. Miller" , Frank Rowand , Heiner Kallweit , Jakub Kicinski , Rob Herring , devicetree X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210311_120956_125050_11A32AC5 X-CRM114-Status: GOOD ( 39.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Mar 11, 2021 at 8:21 AM Calvin Johnson wrote: > > Introduce fwnode_mdiobus_register_phy() to register PHYs on the > mdiobus. From the compatible string, identify whether the PHY is > c45 and based on this create a PHY device instance which is > registered on the mdiobus. > uninitialized symbol 'mii_ts' > Reported-by: kernel test robot > Reported-by: Dan Carpenter I don't think it's important to have it in a history of Git. I would move this after the cutter '---' line below. > Signed-off-by: Calvin Johnson > --- > > Changes in v7: > - Call unregister_mii_timestamper() without NULL check > - Create fwnode_mdio.c and move fwnode_mdiobus_register_phy() > > Changes in v6: > - Initialize mii_ts to NULL > > Changes in v5: None > Changes in v4: None > Changes in v3: None > Changes in v2: None > > MAINTAINERS | 1 + > drivers/net/mdio/Kconfig | 9 ++++ > drivers/net/mdio/Makefile | 3 +- > drivers/net/mdio/fwnode_mdio.c | 77 ++++++++++++++++++++++++++++++++++ > drivers/net/mdio/of_mdio.c | 3 +- > include/linux/fwnode_mdio.h | 24 +++++++++++ > include/linux/of_mdio.h | 6 ++- > 7 files changed, 120 insertions(+), 3 deletions(-) > create mode 100644 drivers/net/mdio/fwnode_mdio.c > create mode 100644 include/linux/fwnode_mdio.h > > diff --git a/MAINTAINERS b/MAINTAINERS > index e1fa5ad9bb30..146de41d2656 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -6680,6 +6680,7 @@ F: Documentation/devicetree/bindings/net/mdio* > F: Documentation/devicetree/bindings/net/qca,ar803x.yaml > F: Documentation/networking/phy.rst > F: drivers/net/mdio/ > +F: drivers/net/mdio/fwnode_mdio.c > F: drivers/net/mdio/of_mdio.c > F: drivers/net/pcs/ > F: drivers/net/phy/ > diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig > index a10cc460d7cf..2d5bf5ccffb5 100644 > --- a/drivers/net/mdio/Kconfig > +++ b/drivers/net/mdio/Kconfig > @@ -19,6 +19,15 @@ config MDIO_BUS > reflects whether the mdio_bus/mdio_device code is built as a > loadable module or built-in. > > +config FWNODE_MDIO > + def_tristate PHYLIB (Seems "selectable only" item) > + depends on ACPI > + depends on OF Wouldn't be better to have depends on (ACPI || OF) || COMPILE_TEST And honestly I don't understand it in either (AND or OR) variant. Why do you need a dependency like this for fwnode API? Moreover dependencies don't work for "selectable only" items. > + depends on PHYLIB > + select FIXED_PHY > + help > + FWNODE MDIO bus (Ethernet PHY) accessors > + > config OF_MDIO > def_tristate PHYLIB > depends on OF > diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile > index 5c498dde463f..ea5390e2ef84 100644 > --- a/drivers/net/mdio/Makefile > +++ b/drivers/net/mdio/Makefile > @@ -1,7 +1,8 @@ > # SPDX-License-Identifier: GPL-2.0 > # Makefile for Linux MDIO bus drivers > > -obj-$(CONFIG_OF_MDIO) += of_mdio.o > +obj-$(CONFIG_FWNODE_MDIO) += fwnode_mdio.o > +obj-$(CONFIG_OF_MDIO) += of_mdio.o > > obj-$(CONFIG_MDIO_ASPEED) += mdio-aspeed.o > obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o > diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c > new file mode 100644 > index 000000000000..0982e816a6fb > --- /dev/null > +++ b/drivers/net/mdio/fwnode_mdio.c > @@ -0,0 +1,77 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * fwnode helpers for the MDIO (Ethernet PHY) API > + * > + * This file provides helper functions for extracting PHY device information > + * out of the fwnode and using it to populate an mii_bus. > + */ > + > +#include > +#include > +#include > +#include > + > +MODULE_AUTHOR("Calvin Johnson "); > +MODULE_LICENSE("GPL"); > + > +int fwnode_mdiobus_register_phy(struct mii_bus *bus, > + struct fwnode_handle *child, u32 addr) > +{ > + struct mii_timestamper *mii_ts = NULL; > + struct phy_device *phy; > + bool is_c45 = false; > + u32 phy_id; > + int rc; > + > + if (is_of_node(child)) { > + mii_ts = of_find_mii_timestamper(to_of_node(child)); > + if (IS_ERR(mii_ts)) > + return PTR_ERR(mii_ts); > + } > + > + rc = fwnode_property_match_string(child, "compatible", "ethernet-phy-ieee802.3-c45"); > + if (rc >= 0) > + is_c45 = true; > + > + if (is_c45 || fwnode_get_phy_id(child, &phy_id)) > + phy = get_phy_device(bus, addr, is_c45); > + else > + phy = phy_device_create(bus, addr, phy_id, 0, NULL); > + if (IS_ERR(phy)) { > + unregister_mii_timestamper(mii_ts); > + return PTR_ERR(phy); > + } > + > + if (is_acpi_node(child)) { > + phy->irq = bus->irq[addr]; > + > + /* Associate the fwnode with the device structure so it > + * can be looked up later. > + */ > + phy->mdio.dev.fwnode = child; > + > + /* All data is now stored in the phy struct, so register it */ > + rc = phy_device_register(phy); > + if (rc) { > + phy_device_free(phy); > + fwnode_handle_put(phy->mdio.dev.fwnode); > + return rc; > + } > + } else if (is_of_node(child)) { > + rc = of_mdiobus_phy_device_register(bus, phy, to_of_node(child), addr); > + if (rc) { > + unregister_mii_timestamper(mii_ts); > + phy_device_free(phy); > + return rc; > + } > + } > + > + /* phy->mii_ts may already be defined by the PHY driver. A > + * mii_timestamper probed via the device tree will still have > + * precedence. > + */ > + if (mii_ts) > + phy->mii_ts = mii_ts; > + return 0; > +} > +EXPORT_SYMBOL(fwnode_mdiobus_register_phy); > diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c > index 48b6b8458c17..db293e0b8249 100644 > --- a/drivers/net/mdio/of_mdio.c > +++ b/drivers/net/mdio/of_mdio.c > @@ -32,7 +32,7 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id) > return fwnode_get_phy_id(of_fwnode_handle(device), phy_id); > } > > -static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node) > +struct mii_timestamper *of_find_mii_timestamper(struct device_node *node) > { > struct of_phandle_args arg; > int err; > @@ -49,6 +49,7 @@ static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node) > > return register_mii_timestamper(arg.np, arg.args[0]); > } > +EXPORT_SYMBOL(of_find_mii_timestamper); > > int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy, > struct device_node *child, u32 addr) > diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h > new file mode 100644 > index 000000000000..8c0392845916 > --- /dev/null > +++ b/include/linux/fwnode_mdio.h > @@ -0,0 +1,24 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * FWNODE helper for the MDIO (Ethernet PHY) API > + */ > + > +#ifndef __LINUX_FWNODE_MDIO_H > +#define __LINUX_FWNODE_MDIO_H > + > +#include > + > +#if IS_ENABLED(CONFIG_FWNODE_MDIO) > +int fwnode_mdiobus_register_phy(struct mii_bus *bus, > + struct fwnode_handle *child, u32 addr); > + > +#else /* CONFIG_FWNODE_MDIO */ > +static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus, > + struct fwnode_handle *child, > + u32 addr) > +{ > + return -EINVAL; > +} > +#endif > + > +#endif /* __LINUX_FWNODE_MDIO_H */ > diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h > index 2b05e7f7c238..e4ee6c4d9431 100644 > --- a/include/linux/of_mdio.h > +++ b/include/linux/of_mdio.h > @@ -31,6 +31,7 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np); > int of_phy_register_fixed_link(struct device_node *np); > void of_phy_deregister_fixed_link(struct device_node *np); > bool of_phy_is_fixed_link(struct device_node *np); > +struct mii_timestamper *of_find_mii_timestamper(struct device_node *np); > int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy, > struct device_node *child, u32 addr); > > @@ -118,7 +119,10 @@ static inline bool of_phy_is_fixed_link(struct device_node *np) > { > return false; > } > - > +static inline struct mii_timestamper *of_find_mii_timestamper(struct device_node *np) > +{ > + return NULL; > +} > static inline int of_mdiobus_phy_device_register(struct mii_bus *mdio, > struct phy_device *phy, > struct device_node *child, u32 addr) > -- > 2.17.1 > -- With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel