Linux-ACPI Archive on lore.kernel.org
 help / color / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Calvin Johnson <calvin.johnson@oss.nxp.com>
Cc: Jeremy Linton <jeremy.linton@arm.com>,
	Russell King - ARM Linux admin <linux@armlinux.org.uk>,
	Jon <jon@solid-run.com>,
	Cristi Sovaiala <cristian.sovaiala@nxp.com>,
	Ioana Ciornei <ioana.ciornei@nxp.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Madalin Bucur <madalin.bucur@oss.nxp.com>,
	netdev <netdev@vger.kernel.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	linux.cj@gmail.com, "David S. Miller" <davem@davemloft.net>,
	Ioana Radulescu <ruxandra.radulescu@nxp.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [net-next PATCH v2 3/3] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
Date: Wed, 1 Jul 2020 13:37:58 +0300
Message-ID: <CAHp75VdMdefZpRh5hE0pWTAYoA-VJepTCrCHD-MYZa9P_aqk6w@mail.gmail.com> (raw)
In-Reply-To: <20200701061233.31120-4-calvin.johnson@oss.nxp.com>

On Wed, Jul 1, 2020 at 9:13 AM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> Modify dpaa2_mac_connect() to support ACPI along with DT.
> Modify dpaa2_mac_get_node() to get the dpmac fwnode from either
> DT or ACPI.
> Replace of_get_phy_mode with fwnode_get_phy_mode to get
> phy-mode for a dpmac_node.
> Define and use helper function find_phy_device() to find phy_dev
> that is later connected to mac->phylink.

...

>  #include "dpaa2-eth.h"
>  #include "dpaa2-mac.h"

> +#include <linux/acpi.h>
> +#include <linux/platform_device.h>

Can we put (more) generic headers atop of (more) private ones?

...

> +       struct fwnode_handle *fsl_mc_fwnode = dev->parent->parent->fwnode;

dev_fwnode() please.

> +       struct fwnode_handle *dpmacs, *dpmac = NULL;
> +       struct device *fsl_mc = dev->parent->parent;

So. something like
       struct device *fsl_mc = dev->parent->parent;
       struct fwnode_handle *fsl_mc_fwnode = dev_fwnode(fsl_mc);

...

> +               dpmacs = device_get_named_child_node(fsl_mc, "dpmacs");

If you have fwnode, why to use device_* API?
               dpmacs = fwnode_get_named_child_node(fsl_mc_fwnode, "dpmacs");

> +               if (!dpmacs)
> +                       return NULL;
> +
> +               while ((dpmac = fwnode_get_next_child_node(dpmacs, dpmac))) {
> +                       err = fwnode_property_read_u32(dpmac, "reg", &id);
> +                       if (err)
> +                               continue;
> +                       if (id == dpmac_id)
> +                               return dpmac;
> +               }

...

> +       } else if (is_acpi_node(fsl_mc_fwnode)) {

is_acpi_device_node() ?

> +               adev = acpi_find_child_device(ACPI_COMPANION(dev->parent),
> +                                             dpmac_id, false);
> +               if (adev)

> +                       return (&adev->fwnode);

No need to have parentheses. Don't we have some special macro to get
fwnode out of ACPI device?

...

> +       err = fwnode_get_phy_mode(dpmac_node);
> +       if (err > 0)
> +               return err;

Positive?! Why? What's going on here?

...

> +       if (is_of_node(dpmac_node))
> +               err = phylink_of_phy_connect(mac->phylink,
> +                                            to_of_node(dpmac_node), 0);
> +       else if (is_acpi_node(dpmac_node)) {
> +               phy_dev = find_phy_device(dpmac_node);
> +               if (IS_ERR(phy_dev))
> +                       goto err_phylink_destroy;
> +               err = phylink_connect_phy(mac->phylink, phy_dev);

Can't you rather provide phylink_fwnode_connect_phy API and drop this
conditional tree entirely?

...

> +       if (is_of_node(dpmac_node))

Redundant.

> +               of_node_put(to_of_node(dpmac_node));

Honestly, looking at this code, I think one needs a bit more time to
get into fwnode paradigm and APIs.

...

> +       if (is_of_node(dpmac_node))

Ditto.

> +               of_node_put(to_of_node(dpmac_node));

-- 
With Best Regards,
Andy Shevchenko

  reply index

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-01  6:12 [net-next PATCH v2 0/3] ACPI support for dpaa2 " Calvin Johnson
2020-07-01  6:12 ` [net-next PATCH v2 1/3] net: phy: introduce find_phy_device() Calvin Johnson
2020-07-01 10:23   ` Andy Shevchenko
2020-07-01 13:24   ` Andrew Lunn
2020-07-01  6:12 ` [net-next PATCH v2 2/3] Documentation: ACPI: DSD: Document MDIO PHY Calvin Johnson
2020-07-01 10:27   ` Andy Shevchenko
2020-07-03 11:35     ` Calvin Johnson
2020-07-04 11:40       ` Andy Shevchenko
2020-07-01 13:16   ` Randy Dunlap
2020-07-01 13:30   ` Andrew Lunn
2020-07-01  6:12 ` [net-next PATCH v2 3/3] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Calvin Johnson
2020-07-01 10:37   ` Andy Shevchenko [this message]
2020-07-02  8:48   ` Ioana Ciornei
2020-07-02  9:34     ` Andy Shevchenko

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=CAHp75VdMdefZpRh5hE0pWTAYoA-VJepTCrCHD-MYZa9P_aqk6w@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=calvin.johnson@oss.nxp.com \
    --cc=cristian.sovaiala@nxp.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=jeremy.linton@arm.com \
    --cc=jon@solid-run.com \
    --cc=kuba@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux.cj@gmail.com \
    --cc=linux@armlinux.org.uk \
    --cc=madalin.bucur@oss.nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=ruxandra.radulescu@nxp.com \
    /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

Linux-ACPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \
		linux-acpi@vger.kernel.org
	public-inbox-index linux-acpi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git