From patchwork Fri May 24 16:20:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 165129 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp3806573ili; Fri, 24 May 2019 09:20:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4TsZx5EXBC4hmQlM8HJHCwF9JqkTCVyPcUBZaA5sYVxrxNV7Qa+1UV+ymnIC+ZOgwaDro X-Received: by 2002:a63:6e86:: with SMTP id j128mr3496033pgc.161.1558714847246; Fri, 24 May 2019 09:20:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558714847; cv=none; d=google.com; s=arc-20160816; b=PSc2VSi7ZLjqQk/qVppBW5l/Mwa57gRIR2YvHTEd8zeDWLCl3rFr9gka+uYtYbir8h IAM8q37WE282GIrXtjikhO1Tgd0/AoR8cFP3SdJ4ovsyq/9AJuFY+SbvIYrlniM9szYh DUXlRJ115PzyDM11GE5B/iLt0IpCXPOeYrkMOul6hU/qVRQ+Bqzhe+qBuLB33PoxcEyJ F+wnPAQpAmw++DH8Ob8/Z3ANLzOikJYpb5QP3UWvtSZ/F+o0TnY6MAz48b0ft9ykBPKv I6JnsILL6L+M6XsLL0UMxm/xBCFGrHf8suoUtmFFOk6rre9TvF5RuWWqFM7fKFY4Xdix vJ3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+YTaRWfG9Yuoc1VN58/KFdiQHjekpSnoND3oo5X7AWA=; b=dQ2VnF9Xi+2lOTOR951kqvmUlpX8PApw2tGx/lyBbvDT5ZUO4hs4Acx+ktREw1xzOs +GXKqoAoedrO6jBUrbJL8esNamUPGSPmAvaHCdHx+pfAdWKOHPz+n4xTFiy614V4MY2c TOWFv7XwRtP7ODmGOv+gMLft0GIzUKprkdyUQEUUCmR0JC2IIE2le/YdB1STYVkcoepq yAc2NTpk+o9/kLZyk0x2xycuO5V8SJmN89Dxyk3EmZz5gcs6W0g48I5vrb50Xkp26V1i yIlZTrjJHDYsytzhYtwCXLVSIrOuOBTfy+ExSuQWdqA5mhSMCRuT6Z2MgqvA3IqSSHfe 2vcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NjZRAoLx; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m14si5204608pgj.377.2019.05.24.09.20.46; Fri, 24 May 2019 09:20:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NjZRAoLx; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390874AbfEXQUp (ORCPT + 9 others); Fri, 24 May 2019 12:20:45 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:37598 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390662AbfEXQUp (ORCPT ); Fri, 24 May 2019 12:20:45 -0400 Received: by mail-lf1-f67.google.com with SMTP id m15so6970605lfh.4 for ; Fri, 24 May 2019 09:20:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+YTaRWfG9Yuoc1VN58/KFdiQHjekpSnoND3oo5X7AWA=; b=NjZRAoLxo+Ip5dEbPdESYrjYCfaLVSmU05FgO/wDT0mwXn769CYCivZYZEUqwqYZ0r ud5tTPimwETjf05D9g8zyAXhWvzxQXH26CjXkKw22blyRIS1PMn2ZjWgJDn/Ga3a2xBf CC6Vo68JmkGQCDekb3KZvNQQ4cgW7C8bqJJevS/WoUM8wYlMg/hn2Arc78ny0rLmUduN PY4lV8VQNpXtPA+NZDtxNPsP/L61POrZ1OUmQs083KUiiYaKcxgumRVcHwMJ3raAhZ9O 6hji68iQWJeQNo/bD22kEw29OP2Bnh+OSlstU/mA/uPt+u+dRNkdHZb9JEch7wEZ7/4K r2rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+YTaRWfG9Yuoc1VN58/KFdiQHjekpSnoND3oo5X7AWA=; b=l/ZHUnoAc9fY1yjY7SZrFLSkmmkC1krbzuL1ZaUWHD56aSPqvvkm8HjdqfWlae3JtB YnLBN3Z60K7iCRtohGpDxVu5Icx5oEB+U5NTSYuo/QQ4Lxs0mgGUWtdWKLn8LlxvaBek MjL/ZZQsv2KJ1DnXJr/Yb4mwHyBp/QsTxQYmc9LjHwTCehNI7cfEpJHoapOZfnFaSe2T pis0/mMPiOSEEKXXLPntPJBIlLUuD1OlCCQVs1IiivoQ1pSZlwaxale8F/O6h4t1sypS 1iyQY1RQyeTQJ+B30LykOGa6tOfYOVnYixB1BQMZ4pZ7DM2fDFe01CEjCLjkjgW3gHYN 7jUg== X-Gm-Message-State: APjAAAXk0zhdD++PERqoKoGCWnvXGtCyjdt2KzrFYoFMKrgrvefWjvNm Yb+L3IWuzms6P8wYxosyavLIEGqD+HE= X-Received: by 2002:ac2:528f:: with SMTP id q15mr33624519lfm.37.1558714842202; Fri, 24 May 2019 09:20:42 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-d2cd225c.014-348-6c756e10.bbcust.telenor.se. [92.34.205.210]) by smtp.gmail.com with ESMTPSA id y4sm618075lje.24.2019.05.24.09.20.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 May 2019 09:20:41 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Krzysztof Halasa , Linus Walleij Subject: [PATCH 2/8] net: ethernet: ixp4xx: Use distinct local variable Date: Fri, 24 May 2019 18:20:17 +0200 Message-Id: <20190524162023.9115-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190524162023.9115-1-linus.walleij@linaro.org> References: <20190524162023.9115-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use "ndev" for the struct net_device and "dev" for the struct device in probe() and remove(). Add the local "dev" pointer for later use in refactoring. Take this opportunity to fix inverse christmas tree coding style. Signed-off-by: Linus Walleij --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 51 +++++++++++++----------- 1 file changed, 27 insertions(+), 24 deletions(-) -- 2.20.1 diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index ae69836d0080..a0c02458f456 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1369,20 +1369,23 @@ static const struct net_device_ops ixp4xx_netdev_ops = { static int ixp4xx_eth_probe(struct platform_device *pdev) { - struct port *port; - struct net_device *dev; - struct eth_plat_info *plat = dev_get_platdata(&pdev->dev); + char phy_id[MII_BUS_ID_SIZE + 3]; struct phy_device *phydev = NULL; + struct device *dev = &pdev->dev; + struct eth_plat_info *plat; + struct net_device *ndev; + struct port *port; u32 regs_phys; - char phy_id[MII_BUS_ID_SIZE + 3]; int err; - if (!(dev = alloc_etherdev(sizeof(struct port)))) + plat = dev_get_platdata(dev); + + if (!(ndev = alloc_etherdev(sizeof(struct port)))) return -ENOMEM; - SET_NETDEV_DEV(dev, &pdev->dev); - port = netdev_priv(dev); - port->netdev = dev; + SET_NETDEV_DEV(ndev, dev); + port = netdev_priv(ndev); + port->netdev = ndev; port->id = pdev->id; switch (port->id) { @@ -1435,18 +1438,18 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) goto err_free; } - dev->netdev_ops = &ixp4xx_netdev_ops; - dev->ethtool_ops = &ixp4xx_ethtool_ops; - dev->tx_queue_len = 100; + ndev->netdev_ops = &ixp4xx_netdev_ops; + ndev->ethtool_ops = &ixp4xx_ethtool_ops; + ndev->tx_queue_len = 100; - netif_napi_add(dev, &port->napi, eth_poll, NAPI_WEIGHT); + netif_napi_add(ndev, &port->napi, eth_poll, NAPI_WEIGHT); if (!(port->npe = npe_request(NPE_ID(port->id)))) { err = -EIO; goto err_free; } - port->mem_res = request_mem_region(regs_phys, REGS_SIZE, dev->name); + port->mem_res = request_mem_region(regs_phys, REGS_SIZE, ndev->name); if (!port->mem_res) { err = -EBUSY; goto err_npe_rel; @@ -1454,9 +1457,9 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) port->plat = plat; npe_port_tab[NPE_ID(port->id)] = port; - memcpy(dev->dev_addr, plat->hwaddr, ETH_ALEN); + memcpy(ndev->dev_addr, plat->hwaddr, ETH_ALEN); - platform_set_drvdata(pdev, dev); + platform_set_drvdata(pdev, ndev); __raw_writel(DEFAULT_CORE_CNTRL | CORE_RESET, &port->regs->core_control); @@ -1466,7 +1469,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, mdio_bus->id, plat->phy); - phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link, + phydev = phy_connect(ndev, phy_id, &ixp4xx_adjust_link, PHY_INTERFACE_MODE_MII); if (IS_ERR(phydev)) { err = PTR_ERR(phydev); @@ -1475,10 +1478,10 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) phydev->irq = PHY_POLL; - if ((err = register_netdev(dev))) + if ((err = register_netdev(ndev))) goto err_phy_dis; - printk(KERN_INFO "%s: MII PHY %i on %s\n", dev->name, plat->phy, + printk(KERN_INFO "%s: MII PHY %i on %s\n", ndev->name, plat->phy, npe_name(port->npe)); return 0; @@ -1491,23 +1494,23 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) err_npe_rel: npe_release(port->npe); err_free: - free_netdev(dev); + free_netdev(ndev); return err; } static int ixp4xx_eth_remove(struct platform_device *pdev) { - struct net_device *dev = platform_get_drvdata(pdev); - struct phy_device *phydev = dev->phydev; - struct port *port = netdev_priv(dev); + struct net_device *ndev = platform_get_drvdata(pdev); + struct phy_device *phydev = ndev->phydev; + struct port *port = netdev_priv(ndev); - unregister_netdev(dev); + unregister_netdev(ndev); phy_disconnect(phydev); ixp4xx_mdio_remove(); npe_port_tab[NPE_ID(port->id)] = NULL; npe_release(port->npe); release_resource(port->mem_res); - free_netdev(dev); + free_netdev(ndev); return 0; }