[net-next PATCH v1 6/7] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver

Andy Shevchenko andy.shevchenko at gmail.com
Thu Oct 1 11:36:06 EDT 2020


On Wed, Sep 30, 2020 at 7:06 PM Calvin Johnson
<calvin.johnson at 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.
>
> 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



More information about the linux-arm-kernel mailing list