[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1219972777.634130.1740141305362.JavaMail.zimbra@couthit.local>
Date: Fri, 21 Feb 2025 18:05:05 +0530 (IST)
From: Parvathi Pudi <parvathi@...thit.com>
To: Ratheesh Kannoth <rkannoth@...vell.com>
Cc: parvathi <parvathi@...thit.com>, danishanwar <danishanwar@...com>,
rogerq <rogerq@...nel.org>, andrew+netdev <andrew+netdev@...n.ch>,
davem <davem@...emloft.net>, edumazet <edumazet@...gle.com>,
kuba <kuba@...nel.org>, pabeni <pabeni@...hat.com>,
robh <robh@...nel.org>, krzk+dt <krzk+dt@...nel.org>,
conor+dt <conor+dt@...nel.org>, nm <nm@...com>,
ssantosh <ssantosh@...nel.org>,
richardcochran <richardcochran@...il.com>,
basharath <basharath@...thit.com>, schnelle <schnelle@...ux.ibm.com>,
diogo ivo <diogo.ivo@...mens.com>,
m-karicheri2 <m-karicheri2@...com>, horms <horms@...nel.org>,
jacob e keller <jacob.e.keller@...el.com>,
m-malladi <m-malladi@...com>,
javier carrasco cruz <javier.carrasco.cruz@...il.com>,
afd <afd@...com>, s-anna <s-anna@...com>,
linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
netdev <netdev@...r.kernel.org>,
devicetree <devicetree@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
pratheesh <pratheesh@...com>, Prajith Jayarajan <prajith@...com>,
Vignesh Raghavendra <vigneshr@...com>, praneeth <praneeth@...com>,
srk <srk@...com>, rogerq <rogerq@...com>,
krishna <krishna@...thit.com>, pmohan <pmohan@...thit.com>,
mohan <mohan@...thit.com>
Subject: Re: [PATCH net-next v3 02/10] net: ti: prueth: Adds ICSSM Ethernet
driver
Hi,
> On 2025-02-14 at 11:16:54, parvathi (parvathi@...thit.com) wrote:
>> From: Roger Quadros <rogerq@...com>
>>
>> +static int icssm_prueth_probe(struct platform_device *pdev)
>> +{
>> + struct device_node *eth0_node = NULL, *eth1_node = NULL;
>> + struct device_node *eth_node, *eth_ports_node;
>> + enum pruss_pru_id pruss_id0, pruss_id1;
>> + struct device *dev = &pdev->dev;
>> + struct device_node *np;
>> + struct prueth *prueth;
>> + int i, ret;
>> +
>> + np = dev->of_node;
>> + if (!np)
>> + return -ENODEV; /* we don't support non DT */
>> +
>> + prueth = devm_kzalloc(dev, sizeof(*prueth), GFP_KERNEL);
>> + if (!prueth)
>> + return -ENOMEM;
>> +
>> + platform_set_drvdata(pdev, prueth);
>> + prueth->dev = dev;
>> + prueth->fw_data = device_get_match_data(dev);
>> +
>> + eth_ports_node = of_get_child_by_name(np, "ethernet-ports");
>> + if (!eth_ports_node)
>> + return -ENOENT;
>> +
>> + for_each_child_of_node(eth_ports_node, eth_node) {
>> + u32 reg;
>> +
>> + if (strcmp(eth_node->name, "ethernet-port"))
>> + continue;
>> + ret = of_property_read_u32(eth_node, "reg", ®);
>> + if (ret < 0) {
>> + dev_err(dev, "%pOF error reading port_id %d\n",
>> + eth_node, ret);
>> + }
>> +
>> + of_node_get(eth_node);
>> +
>> + if (reg == 0) {
>> + eth0_node = eth_node;
>> + if (!of_device_is_available(eth0_node)) {
>> + of_node_put(eth0_node);
>> + eth0_node = NULL;
>> + }
>> + } else if (reg == 1) {
>> + eth1_node = eth_node;
>> + if (!of_device_is_available(eth1_node)) {
>> + of_node_put(eth1_node);
>> + eth1_node = NULL;
>> + }
> It depends on your DT, but is there any chance that more than once, we reach
> here in else case.
> { if (of_device_is_availabke(...) } ?
>
Yes, we will enter here in case of "EPROBE_DEFER".
>> + } else {
>> + dev_err(dev, "port reg should be 0 or 1\n");
>> + }
>> + }
>> +
>> + of_node_put(eth_ports_node);
>> +
>> + /* At least one node must be present and available else we fail */
>> + if (!eth0_node && !eth1_node) {
>> + dev_err(dev, "neither port0 nor port1 node available\n");
>> + return -ENODEV;
>> + }
>> +
>> + if (eth0_node == eth1_node) {
>> + dev_err(dev, "port0 and port1 can't have same reg\n");
>> + of_node_put(eth0_node);
>> + return -ENODEV;
>> + }
>> +
>> + prueth->eth_node[PRUETH_MAC0] = eth0_node;
>> + prueth->eth_node[PRUETH_MAC1] = eth1_node;
> ...
> +
>> + if (eth0_node) {
>> + prueth->pru0 = pru_rproc_get(np, 0, &pruss_id0);
>> + if (IS_ERR(prueth->pru0)) {
>> + ret = PTR_ERR(prueth->pru0);
>> + if (ret != -EPROBE_DEFER)
>> + dev_err(dev, "unable to get PRU0: %d\n", ret);
>> + goto put_pru;
>> + }
>> + }
>> +
>> + if (eth1_node) {
>> + prueth->pru1 = pru_rproc_get(np, 1, &pruss_id1);
>> + if (IS_ERR(prueth->pru1)) {
>> + ret = PTR_ERR(prueth->pru1);
>> + if (ret != -EPROBE_DEFER)
>> + dev_err(dev, "unable to get PRU1: %d\n", ret);
>> + goto put_pru;
>> + }
>> + }
>> +
>> + /* setup netdev interfaces */
>> + if (eth0_node) {
>> + ret = icssm_prueth_netdev_init(prueth, eth0_node);
>> + if (ret) {
>> + if (ret != -EPROBE_DEFER) {
>> + dev_err(dev, "netdev init %s failed: %d\n",
>> + eth0_node->name, ret);
>> + }
>> + goto put_pru;
>> + }
>> + }
>> +
>> + if (eth1_node) {
>> + ret = icssm_prueth_netdev_init(prueth, eth1_node);
>> + if (ret) {
>> + if (ret != -EPROBE_DEFER) {
>> + dev_err(dev, "netdev init %s failed: %d\n",
>> + eth1_node->name, ret);
>> + }
>> + goto netdev_exit;
>> + }
>> + }
>> +
>> + /* register the network devices */
>> + if (eth0_node) {
>> + ret = register_netdev(prueth->emac[PRUETH_MAC0]->ndev);
>> + if (ret) {
>> + dev_err(dev, "can't register netdev for port MII0");
>> + goto netdev_exit;
>> + }
>> +
>> + prueth->registered_netdevs[PRUETH_MAC0] =
>> + prueth->emac[PRUETH_MAC0]->ndev;
>> + }
>> +
>> + if (eth1_node) {
>> + ret = register_netdev(prueth->emac[PRUETH_MAC1]->ndev);
>> + if (ret) {
>> + dev_err(dev, "can't register netdev for port MII1");
>> + goto netdev_unregister;
>> + }
>> +
>> + prueth->registered_netdevs[PRUETH_MAC1] =
>> + prueth->emac[PRUETH_MAC1]->ndev;
>> + }
>> +
>> + if (eth1_node)
>> + of_node_put(eth1_node);
>> + if (eth0_node)
>> + of_node_put(eth0_node);
> nit: A function would be better than code duplication for eth0_node and
> eth1_node ?
It is due to possibility of using a single node.
Thanks and Regards,
Parvathi.
Powered by blists - more mailing lists