static int fe_probe(struct platform_device *pdev)
{
- struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
const struct of_device_id *match;
struct fe_soc_data *soc;
struct net_device *netdev;
else
soc->reg_table = fe_reg_table;
- fe_base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(fe_base)) {
- err = -EADDRNOTAVAIL;
- goto err_out;
- }
+ fe_base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(fe_base))
+ return PTR_ERR(fe_base);
- netdev = alloc_etherdev(sizeof(*priv));
+ netdev = devm_alloc_etherdev_mqs(&pdev->dev, sizeof(*priv), 4, 4);
if (!netdev) {
dev_err(&pdev->dev, "alloc_etherdev failed\n");
- err = -ENOMEM;
- goto err_iounmap;
+ return -ENOMEM;
}
SET_NETDEV_DEV(netdev, &pdev->dev);
netdev->irq = platform_get_irq(pdev, 0);
if (netdev->irq < 0) {
dev_err(&pdev->dev, "no IRQ resource found\n");
- err = -ENXIO;
- goto err_free_dev;
+ return -ENXIO;
}
priv = netdev_priv(netdev);
spin_lock_init(&priv->page_lock);
- priv->resets = devm_reset_control_array_get_exclusive(&pdev->dev);
+ priv->resets = devm_reset_control_array_get_optional_exclusive(&pdev->dev);
if (IS_ERR(priv->resets)) {
dev_err(&pdev->dev, "Failed to get resets for FE and ESW cores: %pe\n", priv->resets);
- priv->resets = NULL;
+ return PTR_ERR(priv->resets);
}
if (soc->init_data)
netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
if (fe_reg_table[FE_REG_FE_COUNTER_BASE]) {
- priv->hw_stats = kzalloc(sizeof(*priv->hw_stats), GFP_KERNEL);
- if (!priv->hw_stats) {
- err = -ENOMEM;
- goto err_free_dev;
- }
+ priv->hw_stats = devm_kzalloc(&pdev->dev, sizeof(*priv->hw_stats), GFP_KERNEL);
+ if (!priv->hw_stats)
+ return -ENOMEM;
spin_lock_init(&priv->hw_stats->stats_lock);
u64_stats_init(&priv->hw_stats->syncp);
}
priv->sysclk = clk_get_rate(sysclk);
} else if ((priv->flags & FE_FLAG_CALIBRATE_CLK)) {
dev_err(&pdev->dev, "this soc needs a clk for calibration\n");
- err = -ENXIO;
- goto err_free_dev;
+ return -ENXIO;
}
priv->switch_np = of_parse_phandle(pdev->dev.of_node, "mediatek,switch", 0);
if ((priv->flags & FE_FLAG_HAS_SWITCH) && !priv->switch_np) {
dev_err(&pdev->dev, "failed to read switch phandle\n");
- err = -ENODEV;
- goto err_free_dev;
+ return -ENODEV;
}
priv->netdev = netdev;
netif_napi_add_weight(netdev, &priv->rx_napi, fe_poll, napi_weight);
fe_set_ethtool_ops(netdev);
- err = register_netdev(netdev);
+ err = devm_register_netdev(&pdev->dev, netdev);
if (err) {
dev_err(&pdev->dev, "error bringing up device\n");
- goto err_free_dev;
+ return err;
}
platform_set_drvdata(pdev, netdev);
netdev->base_addr, netdev->irq);
return 0;
-
-err_free_dev:
- free_netdev(netdev);
-err_iounmap:
- devm_iounmap(&pdev->dev, fe_base);
-err_out:
- return err;
}
static int fe_remove(struct platform_device *pdev)
struct fe_priv *priv = netdev_priv(dev);
netif_napi_del(&priv->rx_napi);
- kfree(priv->hw_stats);
cancel_work_sync(&priv->pending_work);
- unregister_netdev(dev);
- free_netdev(dev);
platform_set_drvdata(pdev, NULL);
return 0;