[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231124161145.q4zww6m5hi3ccqzk@skbuf>
Date: Fri, 24 Nov 2023 18:11:45 +0200
From: Vladimir Oltean <olteanv@...il.com>
To: Ante Knezic <ante.knezic@...mholz.de>
Cc: netdev@...r.kernel.org, woojung.huh@...rochip.com, andrew@...n.ch,
f.fainelli@...il.com, davem@...emloft.net, edumazet@...gle.com,
kuba@...nel.org, pabeni@...hat.com, robh+dt@...nel.org,
krzysztof.kozlowski+dt@...aro.org, conor+dt@...nel.org,
marex@...x.de, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v5 2/2] net: dsa: microchip: add property to
select internal RMII reference clock
On Fri, Nov 24, 2023 at 05:01:48PM +0100, Ante Knezic wrote:
> +static int ksz88x3_config_rmii_clk(struct ksz_device *dev, int cpu_port)
> +{
> + struct device_node *ports, *port, *cpu_node;
> + bool rmii_clk_internal;
> +
> + if (!ksz_is_ksz88x3(dev))
> + return 0;
> +
> + cpu_node = NULL;
> +
> + ports = of_get_child_by_name(dev->dev->of_node, "ports");
> + if (!ports)
> + ports = of_get_child_by_name(dev->dev->of_node,
> + "ethernet-ports");
> + if (!ports)
> + return -ENODEV;
> +
> + for_each_available_child_of_node(ports, port) {
> + u32 index;
> +
> + if (of_property_read_u32(port, "reg", &index) < 0)
> + return -ENODEV;
> +
> + if (index == cpu_port) {
> + cpu_node = port;
> + break;
> + }
> + }
> +
> + if (!cpu_node)
> + return -ENODEV;
Too much code. Assuming you have struct dsa_port *cpu_dp, you can access
cpu_dp->dn instead of re-parsing the device tree.
> +
> + rmii_clk_internal = of_property_read_bool(cpu_node,
> + "microchip,rmii-clk-internal");
> +
> + ksz_cfg(dev, KSZ88X3_REG_FVID_AND_HOST_MODE,
> + KSZ88X3_PORT3_RMII_CLK_INTERNAL, rmii_clk_internal);
> +
> + return 0;
> +}
Please wait for 24 hours before reposting, maybe you get more feedback.
Powered by blists - more mailing lists