.. | .. |
---|
426 | 426 | writel(common->rx_flow_id_base, |
---|
427 | 427 | host_p->port_base + AM65_CPSW_PORT0_REG_FLOW_ID_OFFSET); |
---|
428 | 428 | /* 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); |
---|
432 | 430 | |
---|
433 | 431 | am65_cpsw_nuss_set_p0_ptype(common); |
---|
434 | 432 | |
---|
.. | .. |
---|
1369 | 1367 | stats->tx_dropped = dev->stats.tx_dropped; |
---|
1370 | 1368 | } |
---|
1371 | 1369 | |
---|
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 | | - |
---|
1397 | 1370 | static const struct net_device_ops am65_cpsw_nuss_netdev_ops_2g = { |
---|
1398 | 1371 | .ndo_open = am65_cpsw_nuss_ndo_slave_open, |
---|
1399 | 1372 | .ndo_stop = am65_cpsw_nuss_ndo_slave_stop, |
---|
.. | .. |
---|
1406 | 1379 | .ndo_vlan_rx_add_vid = am65_cpsw_nuss_ndo_slave_add_vid, |
---|
1407 | 1380 | .ndo_vlan_rx_kill_vid = am65_cpsw_nuss_ndo_slave_kill_vid, |
---|
1408 | 1381 | .ndo_do_ioctl = am65_cpsw_nuss_ndo_slave_ioctl, |
---|
1409 | | - .ndo_set_features = am65_cpsw_nuss_ndo_slave_set_features, |
---|
1410 | 1382 | .ndo_setup_tc = am65_cpsw_qos_ndo_setup_tc, |
---|
1411 | 1383 | }; |
---|
1412 | 1384 | |
---|
.. | .. |
---|
1515 | 1487 | tx_chn->tx_chn_name, |
---|
1516 | 1488 | &tx_cfg); |
---|
1517 | 1489 | 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"); |
---|
1521 | 1492 | goto err; |
---|
1522 | 1493 | } |
---|
1523 | 1494 | |
---|
.. | .. |
---|
1525 | 1496 | if (tx_chn->irq <= 0) { |
---|
1526 | 1497 | dev_err(dev, "Failed to get tx dma irq %d\n", |
---|
1527 | 1498 | tx_chn->irq); |
---|
| 1499 | + ret = tx_chn->irq ?: -ENXIO; |
---|
1528 | 1500 | goto err; |
---|
1529 | 1501 | } |
---|
1530 | 1502 | |
---|
.. | .. |
---|
1588 | 1560 | |
---|
1589 | 1561 | rx_chn->rx_chn = k3_udma_glue_request_rx_chn(dev, "rx", &rx_cfg); |
---|
1590 | 1562 | 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"); |
---|
1593 | 1565 | goto err; |
---|
1594 | 1566 | } |
---|
1595 | 1567 | |
---|
.. | .. |
---|
1753 | 1725 | if (ret < 0) { |
---|
1754 | 1726 | dev_err(dev, "%pOF error reading port_id %d\n", |
---|
1755 | 1727 | port_np, ret); |
---|
1756 | | - return ret; |
---|
| 1728 | + goto of_node_put; |
---|
1757 | 1729 | } |
---|
1758 | 1730 | |
---|
1759 | 1731 | if (!port_id || port_id > common->port_num) { |
---|
1760 | 1732 | dev_err(dev, "%pOF has invalid port_id %u %s\n", |
---|
1761 | 1733 | port_np, port_id, port_np->name); |
---|
1762 | | - return -EINVAL; |
---|
| 1734 | + ret = -EINVAL; |
---|
| 1735 | + goto of_node_put; |
---|
1763 | 1736 | } |
---|
1764 | 1737 | |
---|
1765 | 1738 | port = am65_common_get_port(common, port_id); |
---|
.. | .. |
---|
1775 | 1748 | (AM65_CPSW_NU_FRAM_PORT_OFFSET * (port_id - 1)); |
---|
1776 | 1749 | |
---|
1777 | 1750 | 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 | + } |
---|
1780 | 1755 | |
---|
1781 | 1756 | port->disabled = !of_device_is_available(port_np); |
---|
1782 | 1757 | if (port->disabled) |
---|
.. | .. |
---|
1787 | 1762 | ret = PTR_ERR(port->slave.ifphy); |
---|
1788 | 1763 | dev_err(dev, "%pOF error retrieving port phy: %d\n", |
---|
1789 | 1764 | port_np, ret); |
---|
1790 | | - return ret; |
---|
| 1765 | + goto of_node_put; |
---|
1791 | 1766 | } |
---|
1792 | 1767 | |
---|
1793 | 1768 | port->slave.mac_only = |
---|
.. | .. |
---|
1797 | 1772 | if (of_phy_is_fixed_link(port_np)) { |
---|
1798 | 1773 | ret = of_phy_register_fixed_link(port_np); |
---|
1799 | 1774 | 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; |
---|
1804 | 1779 | } |
---|
1805 | 1780 | port->slave.phy_node = of_node_get(port_np); |
---|
1806 | 1781 | } else { |
---|
.. | .. |
---|
1811 | 1786 | if (!port->slave.phy_node) { |
---|
1812 | 1787 | dev_err(dev, |
---|
1813 | 1788 | "slave[%d] no phy found\n", port_id); |
---|
1814 | | - return -ENODEV; |
---|
| 1789 | + ret = -ENODEV; |
---|
| 1790 | + goto of_node_put; |
---|
1815 | 1791 | } |
---|
1816 | 1792 | |
---|
1817 | 1793 | ret = of_get_phy_mode(port_np, &port->slave.phy_if); |
---|
1818 | 1794 | if (ret) { |
---|
1819 | 1795 | dev_err(dev, "%pOF read phy-mode err %d\n", |
---|
1820 | 1796 | port_np, ret); |
---|
1821 | | - return ret; |
---|
| 1797 | + goto of_node_put; |
---|
1822 | 1798 | } |
---|
1823 | 1799 | |
---|
1824 | 1800 | mac_addr = of_get_mac_address(port_np); |
---|
.. | .. |
---|
1835 | 1811 | of_node_put(node); |
---|
1836 | 1812 | |
---|
1837 | 1813 | return 0; |
---|
| 1814 | + |
---|
| 1815 | +of_node_put: |
---|
| 1816 | + of_node_put(port_np); |
---|
| 1817 | + of_node_put(node); |
---|
| 1818 | + return ret; |
---|
1838 | 1819 | } |
---|
1839 | 1820 | |
---|
1840 | 1821 | static void am65_cpsw_pcpu_stats_free(void *data) |
---|
.. | .. |
---|
2090 | 2071 | return -ENOMEM; |
---|
2091 | 2072 | |
---|
2092 | 2073 | 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"); |
---|
2100 | 2076 | common->bus_freq = clk_get_rate(clk); |
---|
2101 | 2077 | |
---|
2102 | 2078 | pm_runtime_enable(dev); |
---|
.. | .. |
---|
2178 | 2154 | return 0; |
---|
2179 | 2155 | |
---|
2180 | 2156 | 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); |
---|
2182 | 2159 | err_pm_clear: |
---|
2183 | 2160 | pm_runtime_put_sync(dev); |
---|
2184 | 2161 | pm_runtime_disable(dev); |
---|
.. | .. |
---|
2204 | 2181 | */ |
---|
2205 | 2182 | am65_cpsw_nuss_cleanup_ndev(common); |
---|
2206 | 2183 | |
---|
2207 | | - of_platform_device_destroy(common->mdio_dev, NULL); |
---|
| 2184 | + if (common->mdio_dev) |
---|
| 2185 | + of_platform_device_destroy(common->mdio_dev, NULL); |
---|
2208 | 2186 | |
---|
2209 | 2187 | pm_runtime_put_sync(&pdev->dev); |
---|
2210 | 2188 | pm_runtime_disable(&pdev->dev); |
---|