From patchwork Tue Aug 9 23:22:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 9272337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3F4CB60CDC for ; Tue, 9 Aug 2016 23:24:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B3F128375 for ; Tue, 9 Aug 2016 23:24:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 100232835B; Tue, 9 Aug 2016 23:24:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 442BE27E71 for ; Tue, 9 Aug 2016 23:24:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932841AbcHIXXq (ORCPT ); Tue, 9 Aug 2016 19:23:46 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:35623 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932790AbcHIXXh (ORCPT ); Tue, 9 Aug 2016 19:23:37 -0400 Received: by mail-wm0-f42.google.com with SMTP id f65so59314727wmi.0 for ; Tue, 09 Aug 2016 16:23:36 -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; bh=m18X1019UezicAACz4wsQ/Lq1YFnRTJDotqJAzkNRhY=; b=QN8ltO9BZ42U0VtNx9Aym+9JDbHB/n6AXLE6iWfKuFuM1nyer01rWes2o8543RS/wu MSZEHBgg8M+mrGpL0Wa4nhqTwQRxzHk8gYT7kPA1P8aNnLQCFztrEcI2tsedvBWth0xs 6CtHBLa+J0k8HqPaCaLlbVsLW87TYvPksHCUk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=m18X1019UezicAACz4wsQ/Lq1YFnRTJDotqJAzkNRhY=; b=fb4NjAPvmzkBLabGXhaw5UpU+Gq0bNZJrBeVx8K082lx8hSbPLjs3+SooJjyOLymwZ pZpfUsRNlhCJi4PIsiURxHFu/4FT8bfen/Ks9xVU5zPwGdaQo8GUmUtNbaF8kXU85JfJ /TD5jPMvSCNQsDMFvmeDcLPRMDodWrtHgKuz99IAL5QmTi8rkknZn4sQFiXIoL8mYHjN zEobcvZXMhREd6ZBRjSkE/6uSHh5Ulzk+B9N+Gq3UJo1eUOwvU0Dhb4QncxH/gCWRcuO iedVWzc8L2zLY8gyYMnWkqc0qmF1jbHyWzO42JQqGa/IPOJK9htNdXfNTtDqwYutbS96 ZJKg== X-Gm-Message-State: AEkoouvu0q1OpMWWp8J7FfWL4cREabQQzilWiu7WmxOffrqoXwSMgOL+vlRQRl26ddSzN1J9 X-Received: by 10.25.88.145 with SMTP id m139mr121990lfb.19.1470785010992; Tue, 09 Aug 2016 16:23:30 -0700 (PDT) Received: from localhost.localdomain (88-203-94-178.pool.ukrtel.net. [178.94.203.88]) by smtp.gmail.com with ESMTPSA id s2sm904627lja.35.2016.08.09.16.23.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Aug 2016 16:23:30 -0700 (PDT) From: Ivan Khoronzhuk To: netdev@vger.kernel.org, mugunthanvnm@ti.com, grygorii.strashko@ti.com Cc: linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, dlide@ti.com, Ivan Khoronzhuk Subject: [PATCH v3 07/13] net: ethernet: ti: cpsw: replace pdev on dev Date: Wed, 10 Aug 2016 02:22:38 +0300 Message-Id: <1470784964-26440-8-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470784964-26440-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1470784964-26440-1-git-send-email-ivan.khoronzhuk@linaro.org> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP No need to hold pdev link when only dev is needed. This allows to simplify a bunch of cpsw->pdev->dev now and farther. Signed-off-by: Ivan Khoronzhuk Reviewed-by: Mugunthan V N --- drivers/net/ethernet/ti/cpsw.c | 65 ++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 3ccf577..c21cc38 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -364,7 +364,7 @@ static inline void slave_write(struct cpsw_slave *slave, u32 val, u32 offset) } struct cpsw_common { - struct platform_device *pdev; + struct device *dev; }; struct cpsw_priv { @@ -1155,7 +1155,7 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) phy_start(slave->phy); /* Configure GMII_SEL register */ - cpsw_phy_sel(&cpsw->pdev->dev, slave->phy->interface, slave->slave_num); + cpsw_phy_sel(cpsw->dev, slave->phy->interface, slave->slave_num); } static inline void cpsw_add_default_vlan(struct cpsw_priv *priv) @@ -1241,9 +1241,9 @@ static int cpsw_ndo_open(struct net_device *ndev) int i, ret; u32 reg; - ret = pm_runtime_get_sync(&cpsw->pdev->dev); + ret = pm_runtime_get_sync(cpsw->dev); if (ret < 0) { - pm_runtime_put_noidle(&cpsw->pdev->dev); + pm_runtime_put_noidle(cpsw->dev); return ret; } @@ -1320,7 +1320,7 @@ static int cpsw_ndo_open(struct net_device *ndev) */ cpsw_info(priv, ifup, "submitted %d rx descriptors\n", i); - if (cpts_register(&cpsw->pdev->dev, priv->cpts, + if (cpts_register(cpsw->dev, priv->cpts, priv->data.cpts_clock_mult, priv->data.cpts_clock_shift)) dev_err(priv->dev, "error registering cpts device\n"); @@ -1345,7 +1345,7 @@ static int cpsw_ndo_open(struct net_device *ndev) err_cleanup: cpdma_ctlr_stop(priv->dma); for_each_slave(priv, cpsw_slave_stop, priv); - pm_runtime_put_sync(&cpsw->pdev->dev); + pm_runtime_put_sync(cpsw->dev); netif_carrier_off(priv->ndev); return ret; } @@ -1370,7 +1370,7 @@ static int cpsw_ndo_stop(struct net_device *ndev) cpsw_ale_stop(priv->ale); } for_each_slave(priv, cpsw_slave_stop, priv); - pm_runtime_put_sync(&cpsw->pdev->dev); + pm_runtime_put_sync(cpsw->dev); if (priv->data.dual_emac) priv->slaves[priv->emac_port].open_stat = false; return 0; @@ -1610,9 +1610,9 @@ static int cpsw_ndo_set_mac_address(struct net_device *ndev, void *p) if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; - ret = pm_runtime_get_sync(&cpsw->pdev->dev); + ret = pm_runtime_get_sync(cpsw->dev); if (ret < 0) { - pm_runtime_put_noidle(&cpsw->pdev->dev); + pm_runtime_put_noidle(cpsw->dev); return ret; } @@ -1630,7 +1630,7 @@ static int cpsw_ndo_set_mac_address(struct net_device *ndev, void *p) memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN); for_each_slave(priv, cpsw_set_slave_mac, priv); - pm_runtime_put(&cpsw->pdev->dev); + pm_runtime_put(cpsw->dev); return 0; } @@ -1702,9 +1702,9 @@ static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev, if (vid == priv->data.default_vlan) return 0; - ret = pm_runtime_get_sync(&cpsw->pdev->dev); + ret = pm_runtime_get_sync(cpsw->dev); if (ret < 0) { - pm_runtime_put_noidle(&cpsw->pdev->dev); + pm_runtime_put_noidle(cpsw->dev); return ret; } @@ -1724,7 +1724,7 @@ static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev, dev_info(priv->dev, "Adding vlanid %d to vlan filter\n", vid); ret = cpsw_add_vlan_ale_entry(priv, vid); - pm_runtime_put(&cpsw->pdev->dev); + pm_runtime_put(cpsw->dev); return ret; } @@ -1738,9 +1738,9 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev, if (vid == priv->data.default_vlan) return 0; - ret = pm_runtime_get_sync(&cpsw->pdev->dev); + ret = pm_runtime_get_sync(cpsw->dev); if (ret < 0) { - pm_runtime_put_noidle(&cpsw->pdev->dev); + pm_runtime_put_noidle(cpsw->dev); return ret; } @@ -1765,7 +1765,7 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev, ret = cpsw_ale_del_mcast(priv->ale, priv->ndev->broadcast, 0, ALE_VLAN, vid); - pm_runtime_put(&cpsw->pdev->dev); + pm_runtime_put(cpsw->dev); return ret; } @@ -1809,10 +1809,11 @@ static void cpsw_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *info) { struct cpsw_common *cpsw = ndev_to_cpsw(ndev); + struct platform_device *pdev = to_platform_device(cpsw->dev); strlcpy(info->driver, "cpsw", sizeof(info->driver)); strlcpy(info->version, "1.0", sizeof(info->version)); - strlcpy(info->bus_info, cpsw->pdev->name, sizeof(info->bus_info)); + strlcpy(info->bus_info, pdev->name, sizeof(info->bus_info)); } static u32 cpsw_get_msglevel(struct net_device *ndev) @@ -1934,10 +1935,10 @@ static int cpsw_ethtool_op_begin(struct net_device *ndev) struct cpsw_common *cpsw = priv->cpsw; int ret; - ret = pm_runtime_get_sync(&cpsw->pdev->dev); + ret = pm_runtime_get_sync(cpsw->dev); if (ret < 0) { cpsw_err(priv, drv, "ethtool begin failed %d\n", ret); - pm_runtime_put_noidle(&cpsw->pdev->dev); + pm_runtime_put_noidle(cpsw->dev); } return ret; @@ -1948,7 +1949,7 @@ static void cpsw_ethtool_op_complete(struct net_device *ndev) struct cpsw_priv *priv = netdev_priv(ndev); int ret; - ret = pm_runtime_put(&priv->cpsw->pdev->dev); + ret = pm_runtime_put(priv->cpsw->dev); if (ret < 0) cpsw_err(priv, drv, "ethtool complete failed %d\n", ret); } @@ -2152,17 +2153,17 @@ no_phy_slave: return 0; } -static int cpsw_probe_dual_emac(struct platform_device *pdev, - struct cpsw_priv *priv) +static int cpsw_probe_dual_emac(struct cpsw_priv *priv) { struct cpsw_platform_data *data = &priv->data; struct net_device *ndev; struct cpsw_priv *priv_sl2; int ret = 0, i; + struct cpsw_common *cpsw = priv->cpsw; ndev = alloc_etherdev(sizeof(struct cpsw_priv)); if (!ndev) { - dev_err(&pdev->dev, "cpsw: error allocating net_device\n"); + dev_err(cpsw->dev, "cpsw: error allocating net_device\n"); return -ENOMEM; } @@ -2177,10 +2178,12 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev, if (is_valid_ether_addr(data->slave_data[1].mac_addr)) { memcpy(priv_sl2->mac_addr, data->slave_data[1].mac_addr, ETH_ALEN); - dev_info(&pdev->dev, "cpsw: Detected MACID = %pM\n", priv_sl2->mac_addr); + dev_info(cpsw->dev, "cpsw: Detected MACID = %pM\n", + priv_sl2->mac_addr); } else { random_ether_addr(priv_sl2->mac_addr); - dev_info(&pdev->dev, "cpsw: Random MACID = %pM\n", priv_sl2->mac_addr); + dev_info(cpsw->dev, "cpsw: Random MACID = %pM\n", + priv_sl2->mac_addr); } memcpy(ndev->dev_addr, priv_sl2->mac_addr, ETH_ALEN); @@ -2211,10 +2214,10 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev, ndev->ethtool_ops = &cpsw_ethtool_ops; /* register the network device */ - SET_NETDEV_DEV(ndev, &pdev->dev); + SET_NETDEV_DEV(ndev, cpsw->dev); ret = register_netdev(ndev); if (ret) { - dev_err(&pdev->dev, "cpsw: error registering net device\n"); + dev_err(cpsw->dev, "cpsw: error registering net device\n"); free_netdev(ndev); ret = -ENODEV; } @@ -2278,7 +2281,7 @@ static int cpsw_probe(struct platform_device *pdev) int irq; cpsw = devm_kzalloc(&pdev->dev, sizeof(struct cpsw_common), GFP_KERNEL); - cpsw->pdev = pdev; + cpsw->dev = &pdev->dev; ndev = alloc_etherdev(sizeof(struct cpsw_priv)); if (!ndev) { @@ -2541,7 +2544,7 @@ static int cpsw_probe(struct platform_device *pdev) &ss_res->start, ndev->irq); if (priv->data.dual_emac) { - ret = cpsw_probe_dual_emac(pdev, priv); + ret = cpsw_probe_dual_emac(priv); if (ret) { cpsw_err(priv, probe, "error probe slave 2 emac interface\n"); goto clean_ale_ret; @@ -2608,7 +2611,7 @@ static int cpsw_suspend(struct device *dev) } /* Select sleep pin state */ - pinctrl_pm_select_sleep_state(&pdev->dev); + pinctrl_pm_select_sleep_state(dev); return 0; } @@ -2620,7 +2623,7 @@ static int cpsw_resume(struct device *dev) struct cpsw_priv *priv = netdev_priv(ndev); /* Select default pin state */ - pinctrl_pm_select_default_state(&pdev->dev); + pinctrl_pm_select_default_state(dev); if (priv->data.dual_emac) { int i;