提交 b5b4185c 编写于 作者: V Vladimir Zapolskiy 提交者: David S. Miller

net: ethernet: lpc_eth: add device and device node local variables

Trivial non-functional change added to simplify getting multiple
references to device pointer in lpc_eth_drv_probe().
Signed-off-by: NVladimir Zapolskiy <vz@mleia.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 081a1b12
...@@ -1241,17 +1241,19 @@ static const struct net_device_ops lpc_netdev_ops = { ...@@ -1241,17 +1241,19 @@ static const struct net_device_ops lpc_netdev_ops = {
static int lpc_eth_drv_probe(struct platform_device *pdev) static int lpc_eth_drv_probe(struct platform_device *pdev)
{ {
struct resource *res; struct device *dev = &pdev->dev;
struct net_device *ndev; struct device_node *np = dev->of_node;
struct netdata_local *pldat; struct netdata_local *pldat;
struct net_device *ndev;
dma_addr_t dma_handle; dma_addr_t dma_handle;
struct resource *res;
int irq, ret; int irq, ret;
u32 tmp; u32 tmp;
/* Setup network interface for RMII or MII mode */ /* Setup network interface for RMII or MII mode */
tmp = __raw_readl(LPC32XX_CLKPWR_MACCLK_CTRL); tmp = __raw_readl(LPC32XX_CLKPWR_MACCLK_CTRL);
tmp &= ~LPC32XX_CLKPWR_MACCTRL_PINS_MSK; 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; tmp |= LPC32XX_CLKPWR_MACCTRL_USE_MII_PINS;
else else
tmp |= LPC32XX_CLKPWR_MACCTRL_USE_RMII_PINS; tmp |= LPC32XX_CLKPWR_MACCTRL_USE_RMII_PINS;
...@@ -1261,7 +1263,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev) ...@@ -1261,7 +1263,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (!res || irq < 0) { if (!res || irq < 0) {
dev_err(&pdev->dev, "error getting resources.\n"); dev_err(dev, "error getting resources.\n");
ret = -ENXIO; ret = -ENXIO;
goto err_exit; goto err_exit;
} }
...@@ -1269,12 +1271,12 @@ static int lpc_eth_drv_probe(struct platform_device *pdev) ...@@ -1269,12 +1271,12 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
/* Allocate net driver data structure */ /* Allocate net driver data structure */
ndev = alloc_etherdev(sizeof(struct netdata_local)); ndev = alloc_etherdev(sizeof(struct netdata_local));
if (!ndev) { if (!ndev) {
dev_err(&pdev->dev, "could not allocate device.\n"); dev_err(dev, "could not allocate device.\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err_exit; goto err_exit;
} }
SET_NETDEV_DEV(ndev, &pdev->dev); SET_NETDEV_DEV(ndev, dev);
pldat = netdev_priv(ndev); pldat = netdev_priv(ndev);
pldat->pdev = pdev; pldat->pdev = pdev;
...@@ -1286,9 +1288,9 @@ static int lpc_eth_drv_probe(struct platform_device *pdev) ...@@ -1286,9 +1288,9 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
ndev->irq = irq; ndev->irq = irq;
/* Get clock for the device */ /* Get clock for the device */
pldat->clk = clk_get(&pdev->dev, NULL); pldat->clk = clk_get(dev, NULL);
if (IS_ERR(pldat->clk)) { 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); ret = PTR_ERR(pldat->clk);
goto err_out_free_dev; goto err_out_free_dev;
} }
...@@ -1301,14 +1303,14 @@ static int lpc_eth_drv_probe(struct platform_device *pdev) ...@@ -1301,14 +1303,14 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
/* Map IO space */ /* Map IO space */
pldat->net_base = ioremap(res->start, resource_size(res)); pldat->net_base = ioremap(res->start, resource_size(res));
if (!pldat->net_base) { if (!pldat->net_base) {
dev_err(&pdev->dev, "failed to map registers\n"); dev_err(dev, "failed to map registers\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err_out_disable_clocks; goto err_out_disable_clocks;
} }
ret = request_irq(ndev->irq, __lpc_eth_interrupt, 0, ret = request_irq(ndev->irq, __lpc_eth_interrupt, 0,
ndev->name, ndev); ndev->name, ndev);
if (ret) { if (ret) {
dev_err(&pdev->dev, "error requesting interrupt.\n"); dev_err(dev, "error requesting interrupt.\n");
goto err_out_iounmap; goto err_out_iounmap;
} }
...@@ -1322,7 +1324,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev) ...@@ -1322,7 +1324,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
sizeof(struct txrx_desc_t) + sizeof(struct rx_status_t)); sizeof(struct txrx_desc_t) + sizeof(struct rx_status_t));
pldat->dma_buff_base_v = 0; 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; dma_handle = LPC32XX_IRAM_BASE;
if (pldat->dma_buff_size <= lpc32xx_return_iram_size()) if (pldat->dma_buff_size <= lpc32xx_return_iram_size())
pldat->dma_buff_base_v = pldat->dma_buff_base_v =
...@@ -1333,7 +1335,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev) ...@@ -1333,7 +1335,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
} }
if (pldat->dma_buff_base_v == 0) { 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) if (ret)
goto err_out_free_irq; goto err_out_free_irq;
...@@ -1342,7 +1344,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev) ...@@ -1342,7 +1344,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
/* Allocate a chunk of memory for the DMA ethernet buffers /* Allocate a chunk of memory for the DMA ethernet buffers
and descriptors */ and descriptors */
pldat->dma_buff_base_v = pldat->dma_buff_base_v =
dma_alloc_coherent(&pldat->pdev->dev, dma_alloc_coherent(dev,
pldat->dma_buff_size, &dma_handle, pldat->dma_buff_size, &dma_handle,
GFP_KERNEL); GFP_KERNEL);
if (pldat->dma_buff_base_v == NULL) { if (pldat->dma_buff_base_v == NULL) {
...@@ -1367,7 +1369,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev) ...@@ -1367,7 +1369,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
__lpc_get_mac(pldat, ndev->dev_addr); __lpc_get_mac(pldat, ndev->dev_addr);
if (!is_valid_ether_addr(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) if (macaddr)
memcpy(ndev->dev_addr, macaddr, ETH_ALEN); memcpy(ndev->dev_addr, macaddr, ETH_ALEN);
} }
...@@ -1397,7 +1399,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev) ...@@ -1397,7 +1399,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
ret = register_netdev(ndev); ret = register_netdev(ndev);
if (ret) { 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; goto err_out_dma_unmap;
} }
platform_set_drvdata(pdev, ndev); platform_set_drvdata(pdev, ndev);
...@@ -1409,17 +1411,17 @@ static int lpc_eth_drv_probe(struct platform_device *pdev) ...@@ -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", netdev_info(ndev, "LPC mac at 0x%08x irq %d\n",
res->start, ndev->irq); res->start, ndev->irq);
device_init_wakeup(&pdev->dev, 1); device_init_wakeup(dev, 1);
device_set_wakeup_enable(&pdev->dev, 0); device_set_wakeup_enable(dev, 0);
return 0; return 0;
err_out_unregister_netdev: err_out_unregister_netdev:
unregister_netdev(ndev); unregister_netdev(ndev);
err_out_dma_unmap: 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()) 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_v,
pldat->dma_buff_base_p); pldat->dma_buff_base_p);
err_out_free_irq: err_out_free_irq:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册