From patchwork Tue May 15 21:59:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10402089 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 DA61F601C8 for ; Tue, 15 May 2018 22:00:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C362928662 for ; Tue, 15 May 2018 22:00:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B79282866C; Tue, 15 May 2018 22:00:45 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, 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 2016328662 for ; Tue, 15 May 2018 22:00:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752505AbeEOWA1 (ORCPT ); Tue, 15 May 2018 18:00:27 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:39755 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752176AbeEOV7q (ORCPT ); Tue, 15 May 2018 17:59:46 -0400 Received: by mail-qk0-f195.google.com with SMTP id z75-v6so1520263qkb.6; Tue, 15 May 2018 14:59:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KO6N7SW9tSH1ga4w0+iwGgkUSGntUjI3iOV0pqmC8pw=; b=uBqCR9/YP7emvOdy9ohTXSgAPzdAvTexin7JMPiMtFPm7MoXxVsWdzcgXp778QovoX vbiACxMQnpPokNt6paIsRB1jSJ3mrfxF7hAYWu0sPqgAnjDtyXIGrLFLL3GHH5C0Ojpg KOcN3E+NAX8SIB/WDMdk5Aip6XwiLjzqxYGTQQY/k7bo14Z1wHWLTBQMRVYUmw5Tt8ex CEn+jBe6J7wFrClp2ao1W9tzl1Bzn3ivXv2VRF7Q218oIxaVl6g/yQvJmFRxfmPpgnb9 haIvLnEqsYmY2yXolVjoKCRBDsczm6QBxCykmG6r20Yf+rC4t/WkU3EOkBqTHR6antjV BkIQ== 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; bh=KO6N7SW9tSH1ga4w0+iwGgkUSGntUjI3iOV0pqmC8pw=; b=gDGALAA+rrq9rzopsHDvZqljzC2XKxZBweRJmGN4v9/y5oOofqO/aMPCuVRin8zkzf ylyDBvHUrl54cFBZkZ/JdkiuT1Iz3i41nCxHHJ81XsJzh35YKXOgxFIo7aHfVPiDu44q h8gmkK2VuXqzaOz0ekTKj00AFY9LK32svkln+tnR85w7FTLAYnlrk/VKtfhXv0JJhp/x tS8B0VHvhsM7ncT0xOVrIO0opFQtFW5tfM8wYZF4vqJNYEtBSW7LxU5or+KDnqxLxAmX 29oYevPMWOMNS2nQ/n+YRSzCq94lifipe8fguFePbD35Fbj6ZIXIuP4s38B1/X8AEsSj b2yw== X-Gm-Message-State: ALKqPwfDblxOdbTO61hMSQfkRZ0aMhNiHgo7ZMyhQCAZss7SIXn0aFec xU3MtCKbPS2NQV7/L6O5gJ2juJpe X-Google-Smtp-Source: AB8JxZpGISvmpfkutOjy4sriDqN/sUBOftLrX/3lByvYyPUBBrwJR+KRxukq4y9blBP5OcsUbEUZcA== X-Received: by 2002:a37:6c02:: with SMTP id h2-v6mr13808866qkc.145.1526421584062; Tue, 15 May 2018 14:59:44 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.250]) by smtp.gmail.com with ESMTPSA id g8-v6sm878969qtg.59.2018.05.15.14.59.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 May 2018 14:59:43 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , "David S. Miller" , Nicolas Ferre , Fugang Duan , Sergei Shtylyov , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Grygorii Strashko , Woojung Huh , Microchip Linux Driver Support , Rob Herring , Frank Rowand , Antoine Tenart , Tobias Jordan , Russell King , Geert Uytterhoeven , Thomas Petazzoni , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Simon Horman , Maxim Uvarov , Sekhar Nori , linux-kernel@vger.kernel.org (open list), linux-renesas-soc@vger.kernel.org (open list:RENESAS ETHERNET DRIVERS), linux-omap@vger.kernel.org (open list:TI ETHERNET SWITCH DRIVER (CPSW)), linux-usb@vger.kernel.org (open list:USB NETWORKING DRIVERS), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE) Subject: [PATCH net-next 2/2] drivers: net: Remove device_node checks with of_mdiobus_register() Date: Tue, 15 May 2018 14:59:30 -0700 Message-Id: <20180515215930.12115-3-f.fainelli@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180515215930.12115-1-f.fainelli@gmail.com> References: <20180515215930.12115-1-f.fainelli@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A number of drivers have the following pattern: if (np) of_mdiobus_register() else mdiobus_register() which the implementation of of_mdiobus_register() now takes care of. Remove that pattern in drivers that strictly adhere to it. Signed-off-by: Florian Fainelli --- drivers/net/dsa/bcm_sf2.c | 8 ++------ drivers/net/dsa/mv88e6xxx/chip.c | 5 +---- drivers/net/ethernet/cadence/macb_main.c | 12 +++--------- drivers/net/ethernet/freescale/fec_main.c | 8 ++------ drivers/net/ethernet/marvell/mvmdio.c | 5 +---- drivers/net/ethernet/renesas/sh_eth.c | 11 +++-------- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 5 +---- drivers/net/ethernet/ti/davinci_mdio.c | 6 ++---- drivers/net/phy/mdio-gpio.c | 6 +----- drivers/net/phy/mdio-mscc-miim.c | 6 +----- drivers/net/usb/lan78xx.c | 7 ++----- 11 files changed, 19 insertions(+), 60 deletions(-) diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c index ac621f44237a..02e8982519ce 100644 --- a/drivers/net/dsa/bcm_sf2.c +++ b/drivers/net/dsa/bcm_sf2.c @@ -450,12 +450,8 @@ static int bcm_sf2_mdio_register(struct dsa_switch *ds) priv->slave_mii_bus->parent = ds->dev->parent; priv->slave_mii_bus->phy_mask = ~priv->indir_phy_mask; - if (dn) - err = of_mdiobus_register(priv->slave_mii_bus, dn); - else - err = mdiobus_register(priv->slave_mii_bus); - - if (err) + err = of_mdiobus_register(priv->slave_mii_bus, dn); + if (err && dn) of_node_put(dn); return err; diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index b23c11d9f4b2..2bb3f03ee1cb 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -2454,10 +2454,7 @@ static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip, return err; } - if (np) - err = of_mdiobus_register(bus, np); - else - err = mdiobus_register(bus); + err = of_mdiobus_register(bus, np); if (err) { dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err); mv88e6xxx_g2_irq_mdio_free(chip, bus); diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index b4c9268100bb..3e93df5d4e3b 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -591,16 +591,10 @@ static int macb_mii_init(struct macb *bp) dev_set_drvdata(&bp->dev->dev, bp->mii_bus); np = bp->pdev->dev.of_node; + if (pdata) + bp->mii_bus->phy_mask = pdata->phy_mask; - if (np) { - err = of_mdiobus_register(bp->mii_bus, np); - } else { - if (pdata) - bp->mii_bus->phy_mask = pdata->phy_mask; - - err = mdiobus_register(bp->mii_bus); - } - + err = of_mdiobus_register(bp->mii_bus, np); if (err) goto err_out_free_mdiobus; diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index d4604bc8eb5b..f3e43db0d6cb 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2052,13 +2052,9 @@ static int fec_enet_mii_init(struct platform_device *pdev) fep->mii_bus->parent = &pdev->dev; node = of_get_child_by_name(pdev->dev.of_node, "mdio"); - if (node) { - err = of_mdiobus_register(fep->mii_bus, node); + err = of_mdiobus_register(fep->mii_bus, node); + if (node) of_node_put(node); - } else { - err = mdiobus_register(fep->mii_bus); - } - if (err) goto err_out_free_mdiobus; diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c index 0495487f7b42..c5dac6bd2be4 100644 --- a/drivers/net/ethernet/marvell/mvmdio.c +++ b/drivers/net/ethernet/marvell/mvmdio.c @@ -348,10 +348,7 @@ static int orion_mdio_probe(struct platform_device *pdev) goto out_mdio; } - if (pdev->dev.of_node) - ret = of_mdiobus_register(bus, pdev->dev.of_node); - else - ret = mdiobus_register(bus); + ret = of_mdiobus_register(bus, pdev->dev.of_node); if (ret < 0) { dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret); goto out_mdio; diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 5970d9e5ddf1..8dd41e08a6c6 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -3025,15 +3025,10 @@ static int sh_mdio_init(struct sh_eth_private *mdp, pdev->name, pdev->id); /* register MDIO bus */ - if (dev->of_node) { - ret = of_mdiobus_register(mdp->mii_bus, dev->of_node); - } else { - if (pd->phy_irq > 0) - mdp->mii_bus->irq[pd->phy] = pd->phy_irq; - - ret = mdiobus_register(mdp->mii_bus); - } + if (pd->phy_irq > 0) + mdp->mii_bus->irq[pd->phy] = pd->phy_irq; + ret = of_mdiobus_register(mdp->mii_bus, dev->of_node); if (ret) goto out_free_bus; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index f5f37bfa1d58..5df1a608e566 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -233,10 +233,7 @@ int stmmac_mdio_register(struct net_device *ndev) new_bus->phy_mask = mdio_bus_data->phy_mask; new_bus->parent = priv->device; - if (mdio_node) - err = of_mdiobus_register(new_bus, mdio_node); - else - err = mdiobus_register(new_bus); + err = of_mdiobus_register(new_bus, mdio_node); if (err != 0) { dev_err(dev, "Cannot register the MDIO bus\n"); goto bus_register_fail; diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c index 98a1c97fb95e..e720244e7f71 100644 --- a/drivers/net/ethernet/ti/davinci_mdio.c +++ b/drivers/net/ethernet/ti/davinci_mdio.c @@ -431,10 +431,8 @@ static int davinci_mdio_probe(struct platform_device *pdev) */ if (dev->of_node && of_get_child_count(dev->of_node)) { data->skip_scan = true; - ret = of_mdiobus_register(data->bus, dev->of_node); - } else { - ret = mdiobus_register(data->bus); - } + + ret = of_mdiobus_register(data->bus, dev->of_node); if (ret) goto bail_out; diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index b501221819e1..4e4c8daf44c3 100644 --- a/drivers/net/phy/mdio-gpio.c +++ b/drivers/net/phy/mdio-gpio.c @@ -179,11 +179,7 @@ static int mdio_gpio_probe(struct platform_device *pdev) if (!new_bus) return -ENODEV; - if (pdev->dev.of_node) - ret = of_mdiobus_register(new_bus, pdev->dev.of_node); - else - ret = mdiobus_register(new_bus); - + ret = of_mdiobus_register(new_bus, pdev->dev.of_node); if (ret) mdio_gpio_bus_deinit(&pdev->dev); diff --git a/drivers/net/phy/mdio-mscc-miim.c b/drivers/net/phy/mdio-mscc-miim.c index 8c689ccfdbca..badbc99bedd3 100644 --- a/drivers/net/phy/mdio-mscc-miim.c +++ b/drivers/net/phy/mdio-mscc-miim.c @@ -151,11 +151,7 @@ static int mscc_miim_probe(struct platform_device *pdev) } } - if (pdev->dev.of_node) - ret = of_mdiobus_register(bus, pdev->dev.of_node); - else - ret = mdiobus_register(bus); - + ret = of_mdiobus_register(bus, pdev->dev.of_node); if (ret < 0) { dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret); return ret; diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 91761436709a..8dff87ec6d99 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -1843,12 +1843,9 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev) } node = of_get_child_by_name(dev->udev->dev.of_node, "mdio"); - if (node) { - ret = of_mdiobus_register(dev->mdiobus, node); + ret = of_mdiobus_register(dev->mdiobus, node); + if (node) of_node_put(node); - } else { - ret = mdiobus_register(dev->mdiobus); - } if (ret) { netdev_err(dev->net, "can't register MDIO bus\n"); goto exit1;