Skip to content

Commit

Permalink
net: ethernet: lpc_eth: add device and device node local variables
Browse files Browse the repository at this point in the history
Trivial non-functional change added to simplify getting multiple
references to device pointer in lpc_eth_drv_probe().

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vladimir Zapolskiy authored and David S. Miller committed Oct 20, 2018
1 parent 081a1b1 commit b5b4185
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions drivers/net/ethernet/nxp/lpc_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1241,17 +1241,19 @@ static const struct net_device_ops lpc_netdev_ops = {

static int lpc_eth_drv_probe(struct platform_device *pdev)
{
struct resource *res;
struct net_device *ndev;
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
struct netdata_local *pldat;
struct net_device *ndev;
dma_addr_t dma_handle;
struct resource *res;
int irq, ret;
u32 tmp;

/* Setup network interface for RMII or MII mode */
tmp = __raw_readl(LPC32XX_CLKPWR_MACCLK_CTRL);
tmp &= ~LPC32XX_CLKPWR_MACCTRL_PINS_MSK;
if (lpc_phy_interface_mode(&pdev->dev) == PHY_INTERFACE_MODE_MII)
if (lpc_phy_interface_mode(dev) == PHY_INTERFACE_MODE_MII)
tmp |= LPC32XX_CLKPWR_MACCTRL_USE_MII_PINS;
else
tmp |= LPC32XX_CLKPWR_MACCTRL_USE_RMII_PINS;
Expand All @@ -1261,20 +1263,20 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_irq(pdev, 0);
if (!res || irq < 0) {
dev_err(&pdev->dev, "error getting resources.\n");
dev_err(dev, "error getting resources.\n");
ret = -ENXIO;
goto err_exit;
}

/* Allocate net driver data structure */
ndev = alloc_etherdev(sizeof(struct netdata_local));
if (!ndev) {
dev_err(&pdev->dev, "could not allocate device.\n");
dev_err(dev, "could not allocate device.\n");
ret = -ENOMEM;
goto err_exit;
}

SET_NETDEV_DEV(ndev, &pdev->dev);
SET_NETDEV_DEV(ndev, dev);

pldat = netdev_priv(ndev);
pldat->pdev = pdev;
Expand All @@ -1286,9 +1288,9 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
ndev->irq = irq;

/* Get clock for the device */
pldat->clk = clk_get(&pdev->dev, NULL);
pldat->clk = clk_get(dev, NULL);
if (IS_ERR(pldat->clk)) {
dev_err(&pdev->dev, "error getting clock.\n");
dev_err(dev, "error getting clock.\n");
ret = PTR_ERR(pldat->clk);
goto err_out_free_dev;
}
Expand All @@ -1301,14 +1303,14 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
/* Map IO space */
pldat->net_base = ioremap(res->start, resource_size(res));
if (!pldat->net_base) {
dev_err(&pdev->dev, "failed to map registers\n");
dev_err(dev, "failed to map registers\n");
ret = -ENOMEM;
goto err_out_disable_clocks;
}
ret = request_irq(ndev->irq, __lpc_eth_interrupt, 0,
ndev->name, ndev);
if (ret) {
dev_err(&pdev->dev, "error requesting interrupt.\n");
dev_err(dev, "error requesting interrupt.\n");
goto err_out_iounmap;
}

Expand All @@ -1322,7 +1324,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
sizeof(struct txrx_desc_t) + sizeof(struct rx_status_t));
pldat->dma_buff_base_v = 0;

if (use_iram_for_net(&pldat->pdev->dev)) {
if (use_iram_for_net(dev)) {
dma_handle = LPC32XX_IRAM_BASE;
if (pldat->dma_buff_size <= lpc32xx_return_iram_size())
pldat->dma_buff_base_v =
Expand All @@ -1333,7 +1335,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
}

if (pldat->dma_buff_base_v == 0) {
ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
if (ret)
goto err_out_free_irq;

Expand All @@ -1342,7 +1344,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
/* Allocate a chunk of memory for the DMA ethernet buffers
and descriptors */
pldat->dma_buff_base_v =
dma_alloc_coherent(&pldat->pdev->dev,
dma_alloc_coherent(dev,
pldat->dma_buff_size, &dma_handle,
GFP_KERNEL);
if (pldat->dma_buff_base_v == NULL) {
Expand All @@ -1367,7 +1369,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
__lpc_get_mac(pldat, ndev->dev_addr);

if (!is_valid_ether_addr(ndev->dev_addr)) {
const char *macaddr = of_get_mac_address(pdev->dev.of_node);
const char *macaddr = of_get_mac_address(np);
if (macaddr)
memcpy(ndev->dev_addr, macaddr, ETH_ALEN);
}
Expand Down Expand Up @@ -1397,7 +1399,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)

ret = register_netdev(ndev);
if (ret) {
dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
dev_err(dev, "Cannot register net device, aborting.\n");
goto err_out_dma_unmap;
}
platform_set_drvdata(pdev, ndev);
Expand All @@ -1409,17 +1411,17 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
netdev_info(ndev, "LPC mac at 0x%08x irq %d\n",
res->start, ndev->irq);

device_init_wakeup(&pdev->dev, 1);
device_set_wakeup_enable(&pdev->dev, 0);
device_init_wakeup(dev, 1);
device_set_wakeup_enable(dev, 0);

return 0;

err_out_unregister_netdev:
unregister_netdev(ndev);
err_out_dma_unmap:
if (!use_iram_for_net(&pldat->pdev->dev) ||
if (!use_iram_for_net(dev) ||
pldat->dma_buff_size > lpc32xx_return_iram_size())
dma_free_coherent(&pldat->pdev->dev, pldat->dma_buff_size,
dma_free_coherent(dev, pldat->dma_buff_size,
pldat->dma_buff_base_v,
pldat->dma_buff_base_p);
err_out_free_irq:
Expand Down

0 comments on commit b5b4185

Please sign in to comment.