Re: [net-next PATCH v1 6/7] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
From: Calvin Johnson <hidden>
Date: 2020-10-03 16:31:33
Also in:
linux-acpi, linux-arm-kernel, lkml
Hi Andy, On Thu, Oct 01, 2020 at 06:36:06PM +0300, Andy Shevchenko wrote:
On Wed, Sep 30, 2020 at 7:06 PM Calvin Johnson [off-list ref] wrote:quoted
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....quoted
#include "dpaa2-eth.h" #include "dpaa2-mac.h"quoted
+#include <linux/acpi.h>Please, put generic headers first.quoted
+ 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 (local) ...quoted
- 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()?quoted
+ if (is_of_node(dpmac_node)) + of_node_put(to_of_node(dpmac_node));Ditto.
Sure. I'll take care of these comments. Thanks Calvin