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]
Date:   Thu, 1 Oct 2020 18:36:06 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Calvin Johnson <calvin.johnson@....nxp.com>
Cc:     Grant Likely <grant.likely@....com>,
        "Rafael J . Wysocki" <rafael@...nel.org>,
        Jeremy Linton <jeremy.linton@....com>,
        Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        Russell King - ARM Linux admin <linux@...linux.org.uk>,
        Cristi Sovaiala <cristian.sovaiala@....com>,
        Florin Laurentiu Chiculita <florinlaurentiu.chiculita@....com>,
        Ioana Ciornei <ioana.ciornei@....com>,
        Madalin Bucur <madalin.bucur@....nxp.com>,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        "linux.cj" <linux.cj@...il.com>, netdev <netdev@...r.kernel.org>,
        ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
        linux-arm Mailing List <linux-arm-kernel@...ts.infradead.org>,
        Diana Madalina Craciun <diana.craciun@....com>,
        Laurentiu Tudor <laurentiu.tudor@....com>,
        "David S. Miller" <davem@...emloft.net>,
        Ioana Radulescu <ruxandra.radulescu@....com>,
        Jakub Kicinski <kuba@...nel.org>
Subject: Re: [net-next PATCH v1 6/7] net: dpaa2-mac: Add ACPI support for
 DPAA2 MAC driver

On Wed, Sep 30, 2020 at 7:06 PM 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.
>
> Use helper function phylink_fwnode_phy_connect() to find phy_dev and
> connect to mac->phylink.

...

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

> +#include <linux/acpi.h>

Please, put generic headers first.

> +       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
> +       struct fwnode_handle *dpmacs, *dpmac = NULL;
> +       unsigned long long adr;
> +       acpi_status status;
>         int err;
> +       u32 id;
>
> -       dpmacs = of_find_node_by_name(NULL, "dpmacs");
> -       if (!dpmacs)
> -               return NULL;
> +       if (is_of_node(dev->parent->fwnode)) {
> +               dpmacs = device_get_named_child_node(dev->parent, "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(dev->parent->fwnode)) {
> +               device_for_each_child_node(dev->parent, dpmac) {
> +                       status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(dpmac),
> +                                                      "_ADR", NULL, &adr);
> +                       if (ACPI_FAILURE(status)) {
> +                               pr_debug("_ADR returned %d on %s\n",
> +                                        status, (char *)buffer.pointer);
> +                               continue;
> +                       } else {
> +                               id = (u32)adr;
> +                               if (id == dpmac_id)
> +                                       return dpmac;
> +                       }
> +               }

Can you rather implement generic one which will be

int fwnode_get_child_id(struct fwnode_handle *fwnode, u64 *id);

and put the logic of retrieving 'reg' or _ADR? Also, for the latter we
have a special macro
METHOD_NAME__ADR.

See [1] as well. Same idea I have shared already.

[1]: https://lore.kernel.org/linux-iio/20200824054347.3805-1-william.sung@advantech.com.tw/T/#m5f61921fa67a5b40522b7f7b17216e0d204647be

...

> -       of_node_put(dpmac_node);
> +       if (is_of_node(dpmac_node))
> +               of_node_put(to_of_node(dpmac_node));

I'm not sure why you can't use fwnode_handle_put()?

> +       if (is_of_node(dpmac_node))
> +               of_node_put(to_of_node(dpmac_node));

Ditto.

--
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ