From patchwork Thu Jan 3 01:10:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6A8D17D2 for ; Thu, 3 Jan 2019 01:12:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6D6D28409 for ; Thu, 3 Jan 2019 01:12:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB68928417; Thu, 3 Jan 2019 01:12:50 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham 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 3A8F128409 for ; Thu, 3 Jan 2019 01:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726887AbfACBMq (ORCPT ); Wed, 2 Jan 2019 20:12:46 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:35632 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728284AbfACBLO (ORCPT ); Wed, 2 Jan 2019 20:11:14 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVH42TXyz1qvfq; Thu, 3 Jan 2019 02:11:12 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVH42JBbz1qvWk; Thu, 3 Jan 2019 02:11:12 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id dvhZEDhsh1J3; Thu, 3 Jan 2019 02:11:11 +0100 (CET) X-Auth-Info: IN0sRuEtFWqBIEfifouF+OhRotNpA7/myU38xEa4RL4= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 3 Jan 2019 02:11:11 +0100 (CET) From: Marek Vasut To: netdev@vger.kernel.org Cc: Marek Vasut , "David S . Miller" , Nisar Sayed , Woojung Huh , Andrew Lunn , Florian Fainelli , linux-usb@vger.kernel.org Subject: [PATCH 07/19] usbnet: smsc95xx: Split the reset function Date: Thu, 3 Jan 2019 02:10:28 +0100 Message-Id: <20190103011040.25974-8-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190103011040.25974-1-marex@denx.de> References: <20190103011040.25974-1-marex@denx.de> MIME-Version: 1.0 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 The smsc95xx_reset() is called either during bind or later during the driver operation. However, the MII structure can be populated only once, when the smsc95xx_reset() is called from the drivers bind function. Split the reset function to allow filling the MII structure only once. This is done in preparation of phydev conversion, where the code will connect to PHY between those two halves of the reset function. Signed-off-by: Marek Vasut Cc: David S. Miller Cc: Nisar Sayed Cc: Woojung Huh Cc: Andrew Lunn Cc: Florian Fainelli Cc: linux-usb@vger.kernel.org To: netdev@vger.kernel.org --- drivers/net/usb/smsc95xx.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 551d05eb258e..e40cde490a42 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -944,14 +944,6 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) { int bmcr, ret, timeout = 0; - /* Initialize MII structure */ - dev->mii.dev = dev->net; - dev->mii.mdio_read = smsc95xx_mdio_read; - dev->mii.mdio_write = smsc95xx_mdio_write; - dev->mii.phy_id_mask = 0x1f; - dev->mii.reg_num_mask = 0x1f; - dev->mii.phy_id = SMSC95XX_INTERNAL_PHY_ID; - /* reset phy and wait for reset to complete */ smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); @@ -985,7 +977,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) return 0; } -static int smsc95xx_reset(struct usbnet *dev) +static int smsc95xx_reset_pre(struct usbnet *dev) { struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); u32 read_buf, write_buf, burst_cap; @@ -1165,6 +1157,13 @@ static int smsc95xx_reset(struct usbnet *dev) } smsc95xx_set_multicast(dev->net); + return 0; +} + +static int smsc95xx_reset_post(struct usbnet *dev) +{ + u32 read_buf; + int ret; ret = smsc95xx_phy_initialize(dev); if (ret < 0) { @@ -1199,6 +1198,25 @@ static int smsc95xx_reset(struct usbnet *dev) return 0; } +static int smsc95xx_reset(struct usbnet *dev) +{ + int ret; + + ret = smsc95xx_reset_pre(dev); + if (ret) + return ret; + + /* Initialize MII structure */ + dev->mii.dev = dev->net; + dev->mii.mdio_read = smsc95xx_mdio_read; + dev->mii.mdio_write = smsc95xx_mdio_write; + dev->mii.phy_id_mask = 0x1f; + dev->mii.reg_num_mask = 0x1f; + dev->mii.phy_id = SMSC95XX_INTERNAL_PHY_ID; + + return smsc95xx_reset_post(dev); +} + static const struct net_device_ops smsc95xx_netdev_ops = { .ndo_open = usbnet_open, .ndo_stop = usbnet_stop,