lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdMdefZpRh5hE0pWTAYoA-VJepTCrCHD-MYZa9P_aqk6w@mail.gmail.com>
Date:   Wed, 1 Jul 2020 13:37:58 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Calvin Johnson <calvin.johnson@....nxp.com>
Cc:     Jeremy Linton <jeremy.linton@....com>,
        Russell King - ARM Linux admin <linux@...linux.org.uk>,
        Jon <jon@...id-run.com>,
        Cristi Sovaiala <cristian.sovaiala@....com>,
        Ioana Ciornei <ioana.ciornei@....com>,
        Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        Madalin Bucur <madalin.bucur@....nxp.com>,
        netdev <netdev@...r.kernel.org>,
        ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
        linux.cj@...il.com, "David S. Miller" <davem@...emloft.net>,
        Ioana Radulescu <ruxandra.radulescu@....com>,
        Jakub Kicinski <kuba@...nel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [net-next PATCH v2 3/3] net: dpaa2-mac: Add ACPI support for
 DPAA2 MAC driver

On Wed, Jul 1, 2020 at 9:13 AM Calvin Johnson
<calvin.johnson@....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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ