hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/net/ethernet/ti/am65-cpsw-nuss.c
....@@ -426,9 +426,7 @@
426426 writel(common->rx_flow_id_base,
427427 host_p->port_base + AM65_CPSW_PORT0_REG_FLOW_ID_OFFSET);
428428 /* en tx crc offload */
429
- if (features & NETIF_F_HW_CSUM)
430
- writel(AM65_CPSW_P0_REG_CTL_RX_CHECKSUM_EN,
431
- host_p->port_base + AM65_CPSW_P0_REG_CTL);
429
+ writel(AM65_CPSW_P0_REG_CTL_RX_CHECKSUM_EN, host_p->port_base + AM65_CPSW_P0_REG_CTL);
432430
433431 am65_cpsw_nuss_set_p0_ptype(common);
434432
....@@ -1369,31 +1367,6 @@
13691367 stats->tx_dropped = dev->stats.tx_dropped;
13701368 }
13711369
1372
-static int am65_cpsw_nuss_ndo_slave_set_features(struct net_device *ndev,
1373
- netdev_features_t features)
1374
-{
1375
- struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
1376
- netdev_features_t changes = features ^ ndev->features;
1377
- struct am65_cpsw_host *host_p;
1378
-
1379
- host_p = am65_common_get_host(common);
1380
-
1381
- if (changes & NETIF_F_HW_CSUM) {
1382
- bool enable = !!(features & NETIF_F_HW_CSUM);
1383
-
1384
- dev_info(common->dev, "Turn %s tx-checksum-ip-generic\n",
1385
- enable ? "ON" : "OFF");
1386
- if (enable)
1387
- writel(AM65_CPSW_P0_REG_CTL_RX_CHECKSUM_EN,
1388
- host_p->port_base + AM65_CPSW_P0_REG_CTL);
1389
- else
1390
- writel(0,
1391
- host_p->port_base + AM65_CPSW_P0_REG_CTL);
1392
- }
1393
-
1394
- return 0;
1395
-}
1396
-
13971370 static const struct net_device_ops am65_cpsw_nuss_netdev_ops_2g = {
13981371 .ndo_open = am65_cpsw_nuss_ndo_slave_open,
13991372 .ndo_stop = am65_cpsw_nuss_ndo_slave_stop,
....@@ -1406,7 +1379,6 @@
14061379 .ndo_vlan_rx_add_vid = am65_cpsw_nuss_ndo_slave_add_vid,
14071380 .ndo_vlan_rx_kill_vid = am65_cpsw_nuss_ndo_slave_kill_vid,
14081381 .ndo_do_ioctl = am65_cpsw_nuss_ndo_slave_ioctl,
1409
- .ndo_set_features = am65_cpsw_nuss_ndo_slave_set_features,
14101382 .ndo_setup_tc = am65_cpsw_qos_ndo_setup_tc,
14111383 };
14121384
....@@ -1515,9 +1487,8 @@
15151487 tx_chn->tx_chn_name,
15161488 &tx_cfg);
15171489 if (IS_ERR(tx_chn->tx_chn)) {
1518
- ret = PTR_ERR(tx_chn->tx_chn);
1519
- dev_err(dev, "Failed to request tx dma channel %d\n",
1520
- ret);
1490
+ ret = dev_err_probe(dev, PTR_ERR(tx_chn->tx_chn),
1491
+ "Failed to request tx dma channel\n");
15211492 goto err;
15221493 }
15231494
....@@ -1525,6 +1496,7 @@
15251496 if (tx_chn->irq <= 0) {
15261497 dev_err(dev, "Failed to get tx dma irq %d\n",
15271498 tx_chn->irq);
1499
+ ret = tx_chn->irq ?: -ENXIO;
15281500 goto err;
15291501 }
15301502
....@@ -1588,8 +1560,8 @@
15881560
15891561 rx_chn->rx_chn = k3_udma_glue_request_rx_chn(dev, "rx", &rx_cfg);
15901562 if (IS_ERR(rx_chn->rx_chn)) {
1591
- ret = PTR_ERR(rx_chn->rx_chn);
1592
- dev_err(dev, "Failed to request rx dma channel %d\n", ret);
1563
+ ret = dev_err_probe(dev, PTR_ERR(rx_chn->rx_chn),
1564
+ "Failed to request rx dma channel\n");
15931565 goto err;
15941566 }
15951567
....@@ -1753,13 +1725,14 @@
17531725 if (ret < 0) {
17541726 dev_err(dev, "%pOF error reading port_id %d\n",
17551727 port_np, ret);
1756
- return ret;
1728
+ goto of_node_put;
17571729 }
17581730
17591731 if (!port_id || port_id > common->port_num) {
17601732 dev_err(dev, "%pOF has invalid port_id %u %s\n",
17611733 port_np, port_id, port_np->name);
1762
- return -EINVAL;
1734
+ ret = -EINVAL;
1735
+ goto of_node_put;
17631736 }
17641737
17651738 port = am65_common_get_port(common, port_id);
....@@ -1775,8 +1748,10 @@
17751748 (AM65_CPSW_NU_FRAM_PORT_OFFSET * (port_id - 1));
17761749
17771750 port->slave.mac_sl = cpsw_sl_get("am65", dev, port->port_base);
1778
- if (IS_ERR(port->slave.mac_sl))
1779
- return PTR_ERR(port->slave.mac_sl);
1751
+ if (IS_ERR(port->slave.mac_sl)) {
1752
+ ret = PTR_ERR(port->slave.mac_sl);
1753
+ goto of_node_put;
1754
+ }
17801755
17811756 port->disabled = !of_device_is_available(port_np);
17821757 if (port->disabled)
....@@ -1787,7 +1762,7 @@
17871762 ret = PTR_ERR(port->slave.ifphy);
17881763 dev_err(dev, "%pOF error retrieving port phy: %d\n",
17891764 port_np, ret);
1790
- return ret;
1765
+ goto of_node_put;
17911766 }
17921767
17931768 port->slave.mac_only =
....@@ -1797,10 +1772,10 @@
17971772 if (of_phy_is_fixed_link(port_np)) {
17981773 ret = of_phy_register_fixed_link(port_np);
17991774 if (ret) {
1800
- if (ret != -EPROBE_DEFER)
1801
- dev_err(dev, "%pOF failed to register fixed-link phy: %d\n",
1802
- port_np, ret);
1803
- return ret;
1775
+ ret = dev_err_probe(dev, ret,
1776
+ "failed to register fixed-link phy %pOF\n",
1777
+ port_np);
1778
+ goto of_node_put;
18041779 }
18051780 port->slave.phy_node = of_node_get(port_np);
18061781 } else {
....@@ -1811,14 +1786,15 @@
18111786 if (!port->slave.phy_node) {
18121787 dev_err(dev,
18131788 "slave[%d] no phy found\n", port_id);
1814
- return -ENODEV;
1789
+ ret = -ENODEV;
1790
+ goto of_node_put;
18151791 }
18161792
18171793 ret = of_get_phy_mode(port_np, &port->slave.phy_if);
18181794 if (ret) {
18191795 dev_err(dev, "%pOF read phy-mode err %d\n",
18201796 port_np, ret);
1821
- return ret;
1797
+ goto of_node_put;
18221798 }
18231799
18241800 mac_addr = of_get_mac_address(port_np);
....@@ -1835,6 +1811,11 @@
18351811 of_node_put(node);
18361812
18371813 return 0;
1814
+
1815
+of_node_put:
1816
+ of_node_put(port_np);
1817
+ of_node_put(node);
1818
+ return ret;
18381819 }
18391820
18401821 static void am65_cpsw_pcpu_stats_free(void *data)
....@@ -2090,13 +2071,8 @@
20902071 return -ENOMEM;
20912072
20922073 clk = devm_clk_get(dev, "fck");
2093
- if (IS_ERR(clk)) {
2094
- ret = PTR_ERR(clk);
2095
-
2096
- if (ret != -EPROBE_DEFER)
2097
- dev_err(dev, "error getting fck clock %d\n", ret);
2098
- return ret;
2099
- }
2074
+ if (IS_ERR(clk))
2075
+ return dev_err_probe(dev, PTR_ERR(clk), "getting fck clock\n");
21002076 common->bus_freq = clk_get_rate(clk);
21012077
21022078 pm_runtime_enable(dev);
....@@ -2178,7 +2154,8 @@
21782154 return 0;
21792155
21802156 err_of_clear:
2181
- of_platform_device_destroy(common->mdio_dev, NULL);
2157
+ if (common->mdio_dev)
2158
+ of_platform_device_destroy(common->mdio_dev, NULL);
21822159 err_pm_clear:
21832160 pm_runtime_put_sync(dev);
21842161 pm_runtime_disable(dev);
....@@ -2204,7 +2181,8 @@
22042181 */
22052182 am65_cpsw_nuss_cleanup_ndev(common);
22062183
2207
- of_platform_device_destroy(common->mdio_dev, NULL);
2184
+ if (common->mdio_dev)
2185
+ of_platform_device_destroy(common->mdio_dev, NULL);
22082186
22092187 pm_runtime_put_sync(&pdev->dev);
22102188 pm_runtime_disable(&pdev->dev);