From patchwork Thu Jan 3 01:10:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746855 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 9B90C17D2 for ; Thu, 3 Jan 2019 01:12:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C6B828409 for ; Thu, 3 Jan 2019 01:12:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 807FF28417; Thu, 3 Jan 2019 01:12:39 +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 268FC28409 for ; Thu, 3 Jan 2019 01:12:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729902AbfACBMb (ORCPT ); Wed, 2 Jan 2019 20:12:31 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:33732 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728606AbfACBLW (ORCPT ); Wed, 2 Jan 2019 20:11:22 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVHB6HV8z1qvSr; Thu, 3 Jan 2019 02:11:18 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVHB65QNz1qvWk; Thu, 3 Jan 2019 02:11:18 +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 kitwpgUlTPVX; Thu, 3 Jan 2019 02:11:17 +0100 (CET) X-Auth-Info: 5umOaokP7BzKvsKTPYrhS7I9sKWbCeIHe5O5Gm73ojw= 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:17 +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 12/19] usbnet: smsc95xx: Replace ad-hoc PHY functions with generic ones Date: Thu, 3 Jan 2019 02:10:33 +0100 Message-Id: <20190103011040.25974-13-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 Replace the ad-hoc reimplementation of genphy_soft_reset() and genphy_config_aneg() with the generic functions. 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 | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index c1e59813c1fc..fa33eda61275 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -970,25 +970,16 @@ static void smsc95xx_adjust_link(struct net_device *netdev) static int smsc95xx_phy_initialize(struct usbnet *dev) { struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); - int bmcr, ret, timeout = 0; + int ret; /* reset phy and wait for reset to complete */ - phy_write(pdata->phydev, MII_BMCR, BMCR_RESET); - - do { - msleep(10); - bmcr = phy_read(pdata->phydev, MII_BMCR); - timeout++; - } while ((bmcr & BMCR_RESET) && (timeout < 100)); - - if (timeout >= 100) { - netdev_warn(dev->net, "timeout on PHY Reset"); - return -EIO; - } + ret = genphy_soft_reset(pdata->phydev); + if (ret) + return ret; - phy_write(pdata->phydev, MII_ADVERTISE, - ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP | - ADVERTISE_PAUSE_ASYM); + ret = genphy_config_aneg(pdata->phydev); + if (ret) + return ret; /* read to clear */ ret = phy_read(pdata->phydev, PHY_INT_SRC);