ethernet: ti: eliminate a bit of duplicate code in gbe_probe()
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 12 lines
Quoted 12 lines
Review static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, · line 3657
Quoted 8 lines
(quoted diff) +0
-4@@ -3651,22 +3651,18 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, if (ret) return ret; - interfaces = of_get_child_by_name(node, "interfaces"); - if (!interfaces) - dev_err(dev, "could not find interfaces\n"); -How do you think about to skip a bit of statements as a reaction for such a null pointer?
https://elixir.bootlin.com/linux/v5.1-rc4/source/drivers/net/ethernet/ti/netcp_ethss.c#L3562
…
Quoted 2 lines
Maybe you need to look at the implementation of
for_each_child_of_node()andof_node_put(). NULL check before those functions is not needed.
This information is reasonable in principle.
Was the reference counter incremented even if a null pointer was returned by such a function call?
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
ret = netcp_txpipe_init(&gbe_dev->tx_pipe, netcp_device, gbe_dev->dma_chan_name, gbe_dev->tx_queue_id);(quoted diff) +1
-3- if (ret) { - of_node_put(interfaces); + if (ret) return ret; - }
Quoted 6 lines
Quoted 6 lines
Review
Quoted 6 lines
ret = netcp_txpipe_open(&gbe_dev->tx_pipe);(quoted diff) +1
-3- if (ret) { - of_node_put(interfaces); + if (ret) return ret; - }
Does the preparation of the NetCP pipe still matter in this special use case?
Quoted 15 lines
Quoted 15 lines
Review
Quoted 7 lines
(quoted diff) +4
-0+ + interfaces = of_get_child_by_name(node, "interfaces"); + if (!interfaces) + dev_err(dev, "could not find interfaces\n"); /* Create network interfaces */ INIT_LIST_HEAD(&gbe_dev->gbe_intf_head);Can code like the following trigger corresponding software development concerns?
for_each_child_of_node(interfaces, interface){
…
}of_node_put(interfaces);
…
Quoted 2 lines
Quoted 2 lines
if (!gbe_dev->num_slaves)
dev_warn(dev, "No network interface configured\n");
Is this message really required as another response then?
Regards,
Markus