From patchwork Thu Jan 3 01:10:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746875 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 ADF8617D2 for ; Thu, 3 Jan 2019 01:13:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EF1828409 for ; Thu, 3 Jan 2019 01:13:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9187328417; Thu, 3 Jan 2019 01:13:02 +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 2F27228409 for ; Thu, 3 Jan 2019 01:13:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbfACBLI (ORCPT ); Wed, 2 Jan 2019 20:11:08 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:47448 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726376AbfACBLH (ORCPT ); Wed, 2 Jan 2019 20:11:07 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVGw3tybz1qvTW; Thu, 3 Jan 2019 02:11:04 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVGw3Jdnz1qvWb; Thu, 3 Jan 2019 02:11:04 +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 5r0M4OV4RJk0; Thu, 3 Jan 2019 02:11:03 +0100 (CET) X-Auth-Info: 2UZhZVkU+evCQU3zQpqZV+k6AnUycMyzx+8Ml3U0c/c= 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:03 +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 01/19] usbnet: smsc95xx: Fix memory leak in smsc95xx_bind Date: Thu, 3 Jan 2019 02:10:22 +0100 Message-Id: <20190103011040.25974-2-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 In case reading of PHY register fails in smsc95xx_bind(), the private data allocated earlier are not free()d. Free them before bailing out. 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index e3d08626828e..772429c17ae1 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -1303,7 +1303,7 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) /* detect device revision as different features may be available */ ret = smsc95xx_read_reg(dev, ID_REV, &val); if (ret < 0) - return ret; + goto err_read_reg; val >>= 16; pdata->chip_id = val; pdata->mdix_ctrl = get_mdix_status(dev->net); @@ -1329,6 +1329,9 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) schedule_delayed_work(&pdata->carrier_check, CARRIER_CHECK_DELAY); return 0; +err_read_reg: + kfree(pdata); + return ret; } static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) From patchwork Thu Jan 3 01:10:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746809 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 AE0CE1399 for ; Thu, 3 Jan 2019 01:11:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BEBD28409 for ; Thu, 3 Jan 2019 01:11:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C89A28417; Thu, 3 Jan 2019 01:11:17 +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 1958328409 for ; Thu, 3 Jan 2019 01:11:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728164AbfACBLM (ORCPT ); Wed, 2 Jan 2019 20:11:12 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:43928 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726071AbfACBLL (ORCPT ); Wed, 2 Jan 2019 20:11:11 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVGy0mNdz1qvSr; Thu, 3 Jan 2019 02:11:06 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVGy0b6Fz1qvWb; Thu, 3 Jan 2019 02:11:06 +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 LERbfVc-Hb88; Thu, 3 Jan 2019 02:11:04 +0100 (CET) X-Auth-Info: DyF7z22xaKQQMnvmb+KADW11d2YbpetDMcj+FtLhy+I= 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:04 +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 02/19] usbnet: smsc95xx: Stop propagation of in_pm Date: Thu, 3 Jan 2019 02:10:23 +0100 Message-Id: <20190103011040.25974-3-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 information whether the SMSC95xx is in_pm or not can be derived from the usbdev->suspend_count. First thing called in smsc95xx_suspend() is usbnet_suspend(), which increments the usbdev->suspend_count and since then the driver only calls _nopm() functions and functions with in_pm set to 1. The smsc95xx_resume() does the inverse, it calls functions with _nopm() suffix and with in_pm set to 1 until usbnet_resume(), which sets the usbdev->suspend_count to 0. Thus, this patch replaces all the in_pm variables used throughout the driver with simple call to smsc95xx_in_pm(), which checks whether the usbdev->suspend_count is zero or not. 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 | 63 ++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 772429c17ae1..c74183b51d5b 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -82,8 +82,13 @@ static bool turbo_mode = true; module_param(turbo_mode, bool, 0644); MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction"); +static int smsc95xx_in_pm(struct usbnet *dev) +{ + return dev->suspend_count != 0; +} + static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index, - u32 *data, int in_pm) + u32 *data) { u32 buf; int ret; @@ -91,7 +96,7 @@ static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index, BUG_ON(!dev); - if (!in_pm) + if (!smsc95xx_in_pm(dev)) fn = usbnet_read_cmd; else fn = usbnet_read_cmd_nopm; @@ -112,7 +117,7 @@ static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index, } static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index, - u32 data, int in_pm) + u32 data) { u32 buf; int ret; @@ -120,7 +125,7 @@ static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index, BUG_ON(!dev); - if (!in_pm) + if (!smsc95xx_in_pm(dev)) fn = usbnet_write_cmd; else fn = usbnet_write_cmd_nopm; @@ -141,38 +146,37 @@ static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index, static int __must_check smsc95xx_read_reg_nopm(struct usbnet *dev, u32 index, u32 *data) { - return __smsc95xx_read_reg(dev, index, data, 1); + return __smsc95xx_read_reg(dev, index, data); } static int __must_check smsc95xx_write_reg_nopm(struct usbnet *dev, u32 index, u32 data) { - return __smsc95xx_write_reg(dev, index, data, 1); + return __smsc95xx_write_reg(dev, index, data); } static int __must_check smsc95xx_read_reg(struct usbnet *dev, u32 index, u32 *data) { - return __smsc95xx_read_reg(dev, index, data, 0); + return __smsc95xx_read_reg(dev, index, data); } static int __must_check smsc95xx_write_reg(struct usbnet *dev, u32 index, u32 data) { - return __smsc95xx_write_reg(dev, index, data, 0); + return __smsc95xx_write_reg(dev, index, data); } /* Loop until the read is completed with timeout * called with phy_mutex held */ -static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev, - int in_pm) +static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev) { unsigned long start_time = jiffies; u32 val; int ret; do { - ret = __smsc95xx_read_reg(dev, MII_ADDR, &val, in_pm); + ret = __smsc95xx_read_reg(dev, MII_ADDR, &val); if (ret < 0) { netdev_warn(dev->net, "Error reading MII_ACCESS\n"); return ret; @@ -185,8 +189,7 @@ static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev, return -EIO; } -static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx, - int in_pm) +static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) { struct usbnet *dev = netdev_priv(netdev); u32 val, addr; @@ -195,7 +198,7 @@ static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx, mutex_lock(&dev->phy_mutex); /* confirm MII not busy */ - ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); + ret = __smsc95xx_phy_wait_not_busy(dev); if (ret < 0) { netdev_warn(dev->net, "MII is busy in smsc95xx_mdio_read\n"); goto done; @@ -205,19 +208,19 @@ static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx, phy_id &= dev->mii.phy_id_mask; idx &= dev->mii.reg_num_mask; addr = (phy_id << 11) | (idx << 6) | MII_READ_ | MII_BUSY_; - ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm); + ret = __smsc95xx_write_reg(dev, MII_ADDR, addr); if (ret < 0) { netdev_warn(dev->net, "Error writing MII_ADDR\n"); goto done; } - ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); + ret = __smsc95xx_phy_wait_not_busy(dev); if (ret < 0) { netdev_warn(dev->net, "Timed out reading MII reg %02X\n", idx); goto done; } - ret = __smsc95xx_read_reg(dev, MII_DATA, &val, in_pm); + ret = __smsc95xx_read_reg(dev, MII_DATA, &val); if (ret < 0) { netdev_warn(dev->net, "Error reading MII_DATA\n"); goto done; @@ -231,7 +234,7 @@ static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx, } static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id, - int idx, int regval, int in_pm) + int idx, int regval) { struct usbnet *dev = netdev_priv(netdev); u32 val, addr; @@ -240,14 +243,14 @@ static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id, mutex_lock(&dev->phy_mutex); /* confirm MII not busy */ - ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); + ret = __smsc95xx_phy_wait_not_busy(dev); if (ret < 0) { netdev_warn(dev->net, "MII is busy in smsc95xx_mdio_write\n"); goto done; } val = regval; - ret = __smsc95xx_write_reg(dev, MII_DATA, val, in_pm); + ret = __smsc95xx_write_reg(dev, MII_DATA, val); if (ret < 0) { netdev_warn(dev->net, "Error writing MII_DATA\n"); goto done; @@ -257,13 +260,13 @@ static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id, phy_id &= dev->mii.phy_id_mask; idx &= dev->mii.reg_num_mask; addr = (phy_id << 11) | (idx << 6) | MII_WRITE_ | MII_BUSY_; - ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm); + ret = __smsc95xx_write_reg(dev, MII_ADDR, addr); if (ret < 0) { netdev_warn(dev->net, "Error writing MII_ADDR\n"); goto done; } - ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); + ret = __smsc95xx_phy_wait_not_busy(dev); if (ret < 0) { netdev_warn(dev->net, "Timed out writing MII reg %02X\n", idx); goto done; @@ -276,24 +279,24 @@ static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id, static int smsc95xx_mdio_read_nopm(struct net_device *netdev, int phy_id, int idx) { - return __smsc95xx_mdio_read(netdev, phy_id, idx, 1); + return __smsc95xx_mdio_read(netdev, phy_id, idx); } static void smsc95xx_mdio_write_nopm(struct net_device *netdev, int phy_id, int idx, int regval) { - __smsc95xx_mdio_write(netdev, phy_id, idx, regval, 1); + __smsc95xx_mdio_write(netdev, phy_id, idx, regval); } static int smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) { - return __smsc95xx_mdio_read(netdev, phy_id, idx, 0); + return __smsc95xx_mdio_read(netdev, phy_id, idx); } static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, int idx, int regval) { - __smsc95xx_mdio_write(netdev, phy_id, idx, regval, 0); + __smsc95xx_mdio_write(netdev, phy_id, idx, regval); } static int __must_check smsc95xx_wait_eeprom(struct usbnet *dev) @@ -972,7 +975,7 @@ static int smsc95xx_start_tx_path(struct usbnet *dev) } /* Starts the Receive path */ -static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm) +static int smsc95xx_start_rx_path(struct usbnet *dev) { struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); unsigned long flags; @@ -981,7 +984,7 @@ static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm) pdata->mac_cr |= MAC_CR_RXEN_; spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); - return __smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr, in_pm); + return __smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); } static int smsc95xx_phy_initialize(struct usbnet *dev) @@ -1233,7 +1236,7 @@ static int smsc95xx_reset(struct usbnet *dev) return ret; } - ret = smsc95xx_start_rx_path(dev, 0); + ret = smsc95xx_start_rx_path(dev); if (ret < 0) { netdev_warn(dev->net, "Failed to start RX path\n"); return ret; @@ -1833,7 +1836,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) goto done; /* enable receiver to enable frame reception */ - smsc95xx_start_rx_path(dev, 1); + smsc95xx_start_rx_path(dev); /* some wol options are enabled, so enter SUSPEND0 */ netdev_info(dev->net, "entering SUSPEND0 mode\n"); From patchwork Thu Jan 3 01:10:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746867 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 A60B51399 for ; Thu, 3 Jan 2019 01:12:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95ED528415 for ; Thu, 3 Jan 2019 01:12:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89CC22841E; Thu, 3 Jan 2019 01:12:52 +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 D14442841D for ; Thu, 3 Jan 2019 01:12:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728424AbfACBLN (ORCPT ); Wed, 2 Jan 2019 20:11:13 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:47701 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728015AbfACBLL (ORCPT ); Wed, 2 Jan 2019 20:11:11 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVGz6dpPz1qvTn; Thu, 3 Jan 2019 02:11:07 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVGz3L4Cz1qvWh; Thu, 3 Jan 2019 02:11:07 +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 r4NnoiZxE5sH; Thu, 3 Jan 2019 02:11:06 +0100 (CET) X-Auth-Info: Yq6qbDL+omLikLAMg5nzzv4YFvv/IJQfOmxz9RJ58rE= 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:06 +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 03/19] usbnet: smsc95xx: Remove smsc95xx_{read,write}_reg_nopm() Date: Thu, 3 Jan 2019 02:10:24 +0100 Message-Id: <20190103011040.25974-4-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 These functions are now equal to smsc95xx_{read,write}_reg(), deduplicate them. 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 | 78 ++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 45 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index c74183b51d5b..7200f40511b6 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -143,18 +143,6 @@ static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index, return ret; } -static int __must_check smsc95xx_read_reg_nopm(struct usbnet *dev, u32 index, - u32 *data) -{ - return __smsc95xx_read_reg(dev, index, data); -} - -static int __must_check smsc95xx_write_reg_nopm(struct usbnet *dev, u32 index, - u32 data) -{ - return __smsc95xx_write_reg(dev, index, data); -} - static int __must_check smsc95xx_read_reg(struct usbnet *dev, u32 index, u32 *data) { @@ -1403,14 +1391,14 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev) u32 val; int ret; - ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); + ret = smsc95xx_read_reg(dev, PM_CTRL, &val); if (ret < 0) return ret; val &= (~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_)); val |= PM_CTL_SUS_MODE_0; - ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); + ret = smsc95xx_write_reg(dev, PM_CTRL, val); if (ret < 0) return ret; @@ -1422,12 +1410,12 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev) if (pdata->wolopts & WAKE_PHY) val |= PM_CTL_WUPS_ED_; - ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); + ret = smsc95xx_write_reg(dev, PM_CTRL, val); if (ret < 0) return ret; /* read back PM_CTRL */ - ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); + ret = smsc95xx_read_reg(dev, PM_CTRL, &val); if (ret < 0) return ret; @@ -1460,14 +1448,14 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_MODE_CTRL_STS, ret); /* enter SUSPEND1 mode */ - ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); + ret = smsc95xx_read_reg(dev, PM_CTRL, &val); if (ret < 0) return ret; val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_); val |= PM_CTL_SUS_MODE_1; - ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); + ret = smsc95xx_write_reg(dev, PM_CTRL, val); if (ret < 0) return ret; @@ -1475,7 +1463,7 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) val &= ~PM_CTL_WUPS_; val |= (PM_CTL_WUPS_ED_ | PM_CTL_ED_EN_); - ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); + ret = smsc95xx_write_reg(dev, PM_CTRL, val); if (ret < 0) return ret; @@ -1490,14 +1478,14 @@ static int smsc95xx_enter_suspend2(struct usbnet *dev) u32 val; int ret; - ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); + ret = smsc95xx_read_reg(dev, PM_CTRL, &val); if (ret < 0) return ret; val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_); val |= PM_CTL_SUS_MODE_2; - ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); + ret = smsc95xx_write_reg(dev, PM_CTRL, val); if (ret < 0) return ret; @@ -1512,7 +1500,7 @@ static int smsc95xx_enter_suspend3(struct usbnet *dev) u32 val; int ret; - ret = smsc95xx_read_reg_nopm(dev, RX_FIFO_INF, &val); + ret = smsc95xx_read_reg(dev, RX_FIFO_INF, &val); if (ret < 0) return ret; @@ -1521,14 +1509,14 @@ static int smsc95xx_enter_suspend3(struct usbnet *dev) return -EBUSY; } - ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); + ret = smsc95xx_read_reg(dev, PM_CTRL, &val); if (ret < 0) return ret; val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_); val |= PM_CTL_SUS_MODE_3 | PM_CTL_RES_CLR_WKP_STS; - ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); + ret = smsc95xx_write_reg(dev, PM_CTRL, val); if (ret < 0) return ret; @@ -1536,7 +1524,7 @@ static int smsc95xx_enter_suspend3(struct usbnet *dev) val &= ~PM_CTL_WUPS_; val |= PM_CTL_WUPS_WOL_; - ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); + ret = smsc95xx_write_reg(dev, PM_CTRL, val); if (ret < 0) return ret; @@ -1630,23 +1618,23 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) netdev_info(dev->net, "entering SUSPEND2 mode\n"); /* disable energy detect (link up) & wake up events */ - ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); + ret = smsc95xx_read_reg(dev, WUCSR, &val); if (ret < 0) goto done; val &= ~(WUCSR_MPEN_ | WUCSR_WAKE_EN_); - ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); + ret = smsc95xx_write_reg(dev, WUCSR, val); if (ret < 0) goto done; - ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); + ret = smsc95xx_read_reg(dev, PM_CTRL, &val); if (ret < 0) goto done; val &= ~(PM_CTL_ED_EN_ | PM_CTL_WOL_EN_); - ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); + ret = smsc95xx_write_reg(dev, PM_CTRL, val); if (ret < 0) goto done; @@ -1744,7 +1732,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) } for (i = 0; i < (wuff_filter_count * 4); i++) { - ret = smsc95xx_write_reg_nopm(dev, WUFF, filter_mask[i]); + ret = smsc95xx_write_reg(dev, WUFF, filter_mask[i]); if (ret < 0) { kfree(filter_mask); goto done; @@ -1753,50 +1741,50 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) kfree(filter_mask); for (i = 0; i < (wuff_filter_count / 4); i++) { - ret = smsc95xx_write_reg_nopm(dev, WUFF, command[i]); + ret = smsc95xx_write_reg(dev, WUFF, command[i]); if (ret < 0) goto done; } for (i = 0; i < (wuff_filter_count / 4); i++) { - ret = smsc95xx_write_reg_nopm(dev, WUFF, offset[i]); + ret = smsc95xx_write_reg(dev, WUFF, offset[i]); if (ret < 0) goto done; } for (i = 0; i < (wuff_filter_count / 2); i++) { - ret = smsc95xx_write_reg_nopm(dev, WUFF, crc[i]); + ret = smsc95xx_write_reg(dev, WUFF, crc[i]); if (ret < 0) goto done; } /* clear any pending pattern match packet status */ - ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); + ret = smsc95xx_read_reg(dev, WUCSR, &val); if (ret < 0) goto done; val |= WUCSR_WUFR_; - ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); + ret = smsc95xx_write_reg(dev, WUCSR, val); if (ret < 0) goto done; } if (pdata->wolopts & WAKE_MAGIC) { /* clear any pending magic packet status */ - ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); + ret = smsc95xx_read_reg(dev, WUCSR, &val); if (ret < 0) goto done; val |= WUCSR_MPR_; - ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); + ret = smsc95xx_write_reg(dev, WUCSR, val); if (ret < 0) goto done; } /* enable/disable wakeup sources */ - ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); + ret = smsc95xx_read_reg(dev, WUCSR, &val); if (ret < 0) goto done; @@ -1816,12 +1804,12 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) val &= ~WUCSR_MPEN_; } - ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); + ret = smsc95xx_write_reg(dev, WUCSR, val); if (ret < 0) goto done; /* enable wol wakeup source */ - ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); + ret = smsc95xx_read_reg(dev, PM_CTRL, &val); if (ret < 0) goto done; @@ -1831,7 +1819,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) if (pdata->wolopts & WAKE_PHY) val |= PM_CTL_ED_EN_; - ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); + ret = smsc95xx_write_reg(dev, PM_CTRL, val); if (ret < 0) goto done; @@ -1877,25 +1865,25 @@ static int smsc95xx_resume(struct usb_interface *intf) if (suspend_flags & SUSPEND_ALLMODES) { /* clear wake-up sources */ - ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); + ret = smsc95xx_read_reg(dev, WUCSR, &val); if (ret < 0) return ret; val &= ~(WUCSR_WAKE_EN_ | WUCSR_MPEN_); - ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); + ret = smsc95xx_write_reg(dev, WUCSR, val); if (ret < 0) return ret; /* clear wake-up status */ - ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); + ret = smsc95xx_read_reg(dev, PM_CTRL, &val); if (ret < 0) return ret; val &= ~PM_CTL_WOL_EN_; val |= PM_CTL_WUPS_; - ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); + ret = smsc95xx_write_reg(dev, PM_CTRL, val); if (ret < 0) return ret; } From patchwork Thu Jan 3 01:10:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746869 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 9C70217D2 for ; Thu, 3 Jan 2019 01:12:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C2A928409 for ; Thu, 3 Jan 2019 01:12:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 804D228417; Thu, 3 Jan 2019 01:12:53 +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 0880528409 for ; Thu, 3 Jan 2019 01:12:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728605AbfACBLN (ORCPT ); Wed, 2 Jan 2019 20:11:13 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:45203 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726337AbfACBLM (ORCPT ); Wed, 2 Jan 2019 20:11:12 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVH05Wfbz1qvTP; Thu, 3 Jan 2019 02:11:08 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVH05L3wz1qvWb; Thu, 3 Jan 2019 02:11:08 +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 K2vANrW6oYr8; Thu, 3 Jan 2019 02:11:07 +0100 (CET) X-Auth-Info: BwJ4C2Tv+LxrvbyYfVMeQJoSk8cuDF5E49CIeyB/9lk= 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:07 +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 04/19] usbnet: smsc95xx: Remove __smsc95xx_{read,write}_reg() Date: Thu, 3 Jan 2019 02:10:25 +0100 Message-Id: <20190103011040.25974-5-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 Inline those functions into smsc95xx_{read,write}_reg() to get rid of the wrapper. 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 | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 7200f40511b6..6c48fec2e5b5 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -87,8 +87,8 @@ static int smsc95xx_in_pm(struct usbnet *dev) return dev->suspend_count != 0; } -static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index, - u32 *data) +static int __must_check smsc95xx_read_reg(struct usbnet *dev, u32 index, + u32 *data) { u32 buf; int ret; @@ -116,8 +116,8 @@ static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index, return ret; } -static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index, - u32 data) +static int __must_check smsc95xx_write_reg(struct usbnet *dev, u32 index, + u32 data) { u32 buf; int ret; @@ -143,18 +143,6 @@ static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index, return ret; } -static int __must_check smsc95xx_read_reg(struct usbnet *dev, u32 index, - u32 *data) -{ - return __smsc95xx_read_reg(dev, index, data); -} - -static int __must_check smsc95xx_write_reg(struct usbnet *dev, u32 index, - u32 data) -{ - return __smsc95xx_write_reg(dev, index, data); -} - /* Loop until the read is completed with timeout * called with phy_mutex held */ static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev) @@ -164,7 +152,7 @@ static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev) int ret; do { - ret = __smsc95xx_read_reg(dev, MII_ADDR, &val); + ret = smsc95xx_read_reg(dev, MII_ADDR, &val); if (ret < 0) { netdev_warn(dev->net, "Error reading MII_ACCESS\n"); return ret; @@ -196,7 +184,7 @@ static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) phy_id &= dev->mii.phy_id_mask; idx &= dev->mii.reg_num_mask; addr = (phy_id << 11) | (idx << 6) | MII_READ_ | MII_BUSY_; - ret = __smsc95xx_write_reg(dev, MII_ADDR, addr); + ret = smsc95xx_write_reg(dev, MII_ADDR, addr); if (ret < 0) { netdev_warn(dev->net, "Error writing MII_ADDR\n"); goto done; @@ -208,7 +196,7 @@ static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) goto done; } - ret = __smsc95xx_read_reg(dev, MII_DATA, &val); + ret = smsc95xx_read_reg(dev, MII_DATA, &val); if (ret < 0) { netdev_warn(dev->net, "Error reading MII_DATA\n"); goto done; @@ -238,7 +226,7 @@ static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id, } val = regval; - ret = __smsc95xx_write_reg(dev, MII_DATA, val); + ret = smsc95xx_write_reg(dev, MII_DATA, val); if (ret < 0) { netdev_warn(dev->net, "Error writing MII_DATA\n"); goto done; @@ -248,7 +236,7 @@ static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id, phy_id &= dev->mii.phy_id_mask; idx &= dev->mii.reg_num_mask; addr = (phy_id << 11) | (idx << 6) | MII_WRITE_ | MII_BUSY_; - ret = __smsc95xx_write_reg(dev, MII_ADDR, addr); + ret = smsc95xx_write_reg(dev, MII_ADDR, addr); if (ret < 0) { netdev_warn(dev->net, "Error writing MII_ADDR\n"); goto done; @@ -972,7 +960,7 @@ static int smsc95xx_start_rx_path(struct usbnet *dev) pdata->mac_cr |= MAC_CR_RXEN_; spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); - return __smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); + return smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); } static int smsc95xx_phy_initialize(struct usbnet *dev) From patchwork Thu Jan 3 01:10:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746873 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 013B81399 for ; Thu, 3 Jan 2019 01:13:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E588128409 for ; Thu, 3 Jan 2019 01:12:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA0CA28417; Thu, 3 Jan 2019 01:12:59 +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 6EFB028409 for ; Thu, 3 Jan 2019 01:12:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727284AbfACBM5 (ORCPT ); Wed, 2 Jan 2019 20:12:57 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:43928 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726376AbfACBLM (ORCPT ); Wed, 2 Jan 2019 20:11:12 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVH203YCz1qvTW; Thu, 3 Jan 2019 02:11:10 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVH16zs5z1qvWh; Thu, 3 Jan 2019 02:11:09 +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 XwTOkQKQfftW; Thu, 3 Jan 2019 02:11:08 +0100 (CET) X-Auth-Info: bMxLHe63APZwpnzE5s74dXIa44PZ/WN1O+mnBZhxcb4= 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:08 +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 05/19] usbnet: smsc95xx: Remove smsc95xx_{read,write}_nopm() Date: Thu, 3 Jan 2019 02:10:26 +0100 Message-Id: <20190103011040.25974-6-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 These functions are now equal to smsc95xx_mdio_{read,write}(), deduplicate them. 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 | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 6c48fec2e5b5..1ab7e6fa6d7a 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -252,18 +252,6 @@ static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id, mutex_unlock(&dev->phy_mutex); } -static int smsc95xx_mdio_read_nopm(struct net_device *netdev, int phy_id, - int idx) -{ - return __smsc95xx_mdio_read(netdev, phy_id, idx); -} - -static void smsc95xx_mdio_write_nopm(struct net_device *netdev, int phy_id, - int idx, int regval) -{ - __smsc95xx_mdio_write(netdev, phy_id, idx, regval); -} - static int smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) { return __smsc95xx_mdio_read(netdev, phy_id, idx); @@ -1340,18 +1328,18 @@ static int smsc95xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask) netdev_dbg(dev->net, "enabling PHY wakeup interrupts\n"); /* read to clear */ - ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_SRC); + ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC); if (ret < 0) return ret; /* enable interrupt source */ - ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_MASK); + ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_INT_MASK); if (ret < 0) return ret; ret |= mask; - smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_INT_MASK, ret); + smsc95xx_mdio_write(dev->net, mii->phy_id, PHY_INT_MASK, ret); return 0; } @@ -1362,11 +1350,11 @@ static int smsc95xx_link_ok_nopm(struct usbnet *dev) int ret; /* first, a dummy read, needed to latch some MII phys */ - ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); + ret = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_BMSR); if (ret < 0) return ret; - ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); + ret = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_BMSR); if (ret < 0) return ret; @@ -1423,17 +1411,17 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) * compatibility with non-standard link partners */ if (pdata->features & FEATURE_PHY_NLP_CROSSOVER) - smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_EDPD_CONFIG, - PHY_EDPD_CONFIG_DEFAULT); + smsc95xx_mdio_write(dev->net, mii->phy_id, PHY_EDPD_CONFIG, + PHY_EDPD_CONFIG_DEFAULT); /* enable energy detect power-down mode */ - ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_MODE_CTRL_STS); + ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_MODE_CTRL_STS); if (ret < 0) return ret; ret |= MODE_CTRL_STS_EDPWRDOWN_; - smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_MODE_CTRL_STS, ret); + smsc95xx_mdio_write(dev->net, mii->phy_id, PHY_MODE_CTRL_STS, ret); /* enter SUSPEND1 mode */ ret = smsc95xx_read_reg(dev, PM_CTRL, &val); From patchwork Thu Jan 3 01:10:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746871 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 7FB6217D2 for ; Thu, 3 Jan 2019 01:12:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7093328409 for ; Thu, 3 Jan 2019 01:12:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64D3428417; Thu, 3 Jan 2019 01:12:54 +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 0B92928409 for ; Thu, 3 Jan 2019 01:12:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727627AbfACBMw (ORCPT ); Wed, 2 Jan 2019 20:12:52 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:32769 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726462AbfACBLN (ORCPT ); Wed, 2 Jan 2019 20:11:13 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVH30tXPz1qvTy; Thu, 3 Jan 2019 02:11:11 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVH30kL0z1qvWb; Thu, 3 Jan 2019 02:11:11 +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 Q5aJaN2CiIc2; Thu, 3 Jan 2019 02:11:10 +0100 (CET) X-Auth-Info: jKXGlkueqqDRyaYnguTTB78G1kJpbVYkFiDqL81UmoI= 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:10 +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 06/19] usbnet: smsc95xx: Remove __smsc95xx_mdio_{read,write}() Date: Thu, 3 Jan 2019 02:10:27 +0100 Message-Id: <20190103011040.25974-7-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 Inline those functions into smsc95xx_mdio_{read,write}() to get rid of the wrapper. 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 | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 1ab7e6fa6d7a..551d05eb258e 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -165,7 +165,7 @@ static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev) return -EIO; } -static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) +static int smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) { struct usbnet *dev = netdev_priv(netdev); u32 val, addr; @@ -209,8 +209,8 @@ static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) return ret; } -static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id, - int idx, int regval) +static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, + int idx, int regval) { struct usbnet *dev = netdev_priv(netdev); u32 val, addr; @@ -252,17 +252,6 @@ static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id, mutex_unlock(&dev->phy_mutex); } -static int smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) -{ - return __smsc95xx_mdio_read(netdev, phy_id, idx); -} - -static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, int idx, - int regval) -{ - __smsc95xx_mdio_write(netdev, phy_id, idx, regval); -} - static int __must_check smsc95xx_wait_eeprom(struct usbnet *dev) { unsigned long start_time = jiffies; 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, From patchwork Thu Jan 3 01:10:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746811 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 E7ADA1399 for ; Thu, 3 Jan 2019 01:11:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D889D28409 for ; Thu, 3 Jan 2019 01:11:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCF6628417; Thu, 3 Jan 2019 01:11:21 +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 44C0A28409 for ; Thu, 3 Jan 2019 01:11:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728779AbfACBLR (ORCPT ); Wed, 2 Jan 2019 20:11:17 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:37442 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728606AbfACBLQ (ORCPT ); Wed, 2 Jan 2019 20:11:16 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVH55Y8jz1qvgR; Thu, 3 Jan 2019 02:11:13 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVH55Md7z1qvWh; Thu, 3 Jan 2019 02:11:13 +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 awC6qBpRPofm; Thu, 3 Jan 2019 02:11:12 +0100 (CET) X-Auth-Info: 9poh50Js/YuAxS250X/ZfayBOeVSrpDxfZOnkQrAeOc= 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:12 +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 08/19] usbnet: smsc95xx: Register MII bus Date: Thu, 3 Jan 2019 02:10:29 +0100 Message-Id: <20190103011040.25974-9-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 Register MII bus so that a phydev can attach to it. This works in parallel with the existing MII bus accessors within the driver, however the existing accessors will be removed in subsequent patch. 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 | 77 ++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 12 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index e40cde490a42..2cd5e1d34559 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "smsc95xx.h" #define SMSC_CHIPNAME "smsc95xx" @@ -76,6 +77,7 @@ struct smsc95xx_priv { bool link_ok; struct delayed_work carrier_check; struct usbnet *dev; + struct mii_bus *mii_bus; }; static bool turbo_mode = true; @@ -209,6 +211,14 @@ static int smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) return ret; } +static int smsc95xx_mii_read(struct mii_bus *bus, int phy_id, int reg) +{ + struct usbnet *dev = bus->priv; + struct net_device *netdev = dev->net; + + return smsc95xx_mdio_read(netdev, phy_id, reg); +} + static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, int idx, int regval) { @@ -252,6 +262,16 @@ static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, mutex_unlock(&dev->phy_mutex); } +static int smsc95xx_mii_write(struct mii_bus *bus, int phy_id, int reg, u16 val) +{ + struct usbnet *dev = bus->priv; + struct net_device *netdev = dev->net; + + smsc95xx_mdio_write(netdev, phy_id, reg, val); + + return 0; +} + static int __must_check smsc95xx_wait_eeprom(struct usbnet *dev) { unsigned long start_time = jiffies; @@ -1206,14 +1226,6 @@ static int smsc95xx_reset(struct usbnet *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); } @@ -1234,6 +1246,7 @@ static const struct net_device_ops smsc95xx_netdev_ops = { static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) { struct smsc95xx_priv *pdata = NULL; + struct mii_bus *bus; u32 val; int ret; @@ -1252,6 +1265,25 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) if (!pdata) return -ENOMEM; + pdata->dev = dev; + + bus = mdiobus_alloc(); + if (!bus) { + ret = -ENOMEM; + goto err_mdiobus_alloc; + } + + bus->priv = dev; + bus->name = "smsc95xx_mii_bus"; + bus->read = smsc95xx_mii_read; + bus->write = smsc95xx_mii_write; + bus->parent = dev->net->dev.parent; + bus->phy_mask = BIT(0); + snprintf(bus->id, MII_BUS_ID_SIZE, "usb-%03d:%03d", + dev->udev->bus->busnum, dev->udev->devnum); + + pdata->mii_bus = bus; + spin_lock_init(&pdata->mac_cr_lock); /* LAN95xx devices do not alter the computed checksum of 0 to 0xffff. @@ -1272,12 +1304,30 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) smsc95xx_init_mac_address(dev); /* Init all registers */ - ret = smsc95xx_reset(dev); + ret = smsc95xx_reset_pre(dev); + if (ret) + goto err_mdiobus_alloc; + + /* 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; + + ret = mdiobus_register(bus); + if (ret) + goto err_mdiobus_register; + + ret = smsc95xx_reset_post(dev); + if (ret) + goto err_mdiobus_register; /* detect device revision as different features may be available */ ret = smsc95xx_read_reg(dev, ID_REV, &val); if (ret < 0) - goto err_read_reg; + goto err_mdiobus_register; val >>= 16; pdata->chip_id = val; pdata->mdix_ctrl = get_mdix_status(dev->net); @@ -1298,12 +1348,13 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) dev->net->max_mtu = ETH_DATA_LEN; dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; - pdata->dev = dev; INIT_DELAYED_WORK(&pdata->carrier_check, check_carrier); schedule_delayed_work(&pdata->carrier_check, CARRIER_CHECK_DELAY); return 0; -err_read_reg: +err_mdiobus_register: + mdiobus_free(bus); +err_mdiobus_alloc: kfree(pdata); return ret; } @@ -1315,6 +1366,8 @@ static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) if (pdata) { cancel_delayed_work(&pdata->carrier_check); netif_dbg(dev, ifdown, dev->net, "free pdata\n"); + mdiobus_unregister(pdata->mii_bus); + mdiobus_free(pdata->mii_bus); kfree(pdata); pdata = NULL; dev->data[0] = 0; From patchwork Thu Jan 3 01:10:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746857 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 03A4817D2 for ; Thu, 3 Jan 2019 01:12:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8E8E28409 for ; Thu, 3 Jan 2019 01:12:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCD4F28417; Thu, 3 Jan 2019 01:12:44 +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 7925C28409 for ; Thu, 3 Jan 2019 01:12:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726776AbfACBMl (ORCPT ); Wed, 2 Jan 2019 20:12:41 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:51436 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726553AbfACBLR (ORCPT ); Wed, 2 Jan 2019 20:11:17 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVH70DV3z1qvSr; Thu, 3 Jan 2019 02:11:15 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVH7035Lz1qvWh; Thu, 3 Jan 2019 02:11:15 +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 XjxeMPklKouF; Thu, 3 Jan 2019 02:11:13 +0100 (CET) X-Auth-Info: MrZqCBrsz0xCs9v1uGwwyVhWdR2olXbtXFNoljhD/Vo= 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:13 +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 09/19] usbnet: smsc95xx: Connect to phydev Date: Thu, 3 Jan 2019 02:10:30 +0100 Message-Id: <20190103011040.25974-10-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 Add code to detect and connect to PHY. The internal PHY of the SMSC95xx is a regular SMSC LAN8700 and the driver only supports the internal PHY, so just use the SMSC PHY driver to configure the PHY. Note that the driver does a lot of extra configuration of the PHY, which is left in to avoid breakage. Some of the extra configuration is sorted out by later patches in this series. 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 | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 2cd5e1d34559..ce61be8ee32b 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -78,6 +78,7 @@ struct smsc95xx_priv { struct delayed_work carrier_check; struct usbnet *dev; struct mii_bus *mii_bus; + struct phy_device *phydev; }; static bool turbo_mode = true; @@ -960,6 +961,11 @@ static int smsc95xx_start_rx_path(struct usbnet *dev) return smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); } + +static void smsc95xx_adjust_link(struct net_device *netdev) +{ +} + static int smsc95xx_phy_initialize(struct usbnet *dev) { int bmcr, ret, timeout = 0; @@ -1308,6 +1314,10 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) if (ret) goto err_mdiobus_alloc; + ret = mdiobus_register(bus); + if (ret) + goto err_mdiobus_register; + /* Initialize MII structure */ dev->mii.dev = dev->net; dev->mii.mdio_read = smsc95xx_mdio_read; @@ -1316,9 +1326,24 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) dev->mii.reg_num_mask = 0x1f; dev->mii.phy_id = SMSC95XX_INTERNAL_PHY_ID; - ret = mdiobus_register(bus); - if (ret) + /* Connect to PHY */ + pdata->phydev = phy_find_first(pdata->mii_bus); + if (!pdata->phydev) { + netdev_err(dev->net, "no PHY found\n"); + ret = -EIO; goto err_mdiobus_register; + } + + ret = phy_connect_direct(dev->net, pdata->phydev, + &smsc95xx_adjust_link, + PHY_INTERFACE_MODE_MII); + if (ret) { + netdev_err(dev->net, "Could not connect to PHY device\n"); + goto err_mdiobus_register; + } + + genphy_resume(pdata->phydev); + phy_start(pdata->phydev); ret = smsc95xx_reset_post(dev); if (ret) From patchwork Thu Jan 3 01:10:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746849 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 A06AB17D2 for ; Thu, 3 Jan 2019 01:12:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9112E28409 for ; Thu, 3 Jan 2019 01:12:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8568428417; Thu, 3 Jan 2019 01:12:31 +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 E474928409 for ; Thu, 3 Jan 2019 01:12:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729055AbfACBLX (ORCPT ); Wed, 2 Jan 2019 20:11:23 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:58505 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728645AbfACBLT (ORCPT ); Wed, 2 Jan 2019 20:11:19 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVH82z0cz1qvTP; Thu, 3 Jan 2019 02:11:16 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVH82ljcz1qvWb; Thu, 3 Jan 2019 02:11:16 +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 LKn__eggzj3b; Thu, 3 Jan 2019 02:11:15 +0100 (CET) X-Auth-Info: DSAtS+3kR2dx+DhBXT4aPBbT9IVRohjfTYYW7Rjbpy0= 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:15 +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 10/19] usbnet: smsc95xx: Replace smsc95xx_mdio_read() with phy_read() Date: Thu, 3 Jan 2019 02:10:31 +0100 Message-Id: <20190103011040.25974-11-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 Just replace smsc95xx_mdio_read() with generic phy_read() to reduce usage of the ad-hoc accessors. 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 | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index ce61be8ee32b..53f817e699df 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -547,7 +547,7 @@ static int smsc95xx_link_reset(struct usbnet *dev) int ret; /* clear interrupt status */ - ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC); + ret = phy_read(pdata->phydev, PHY_INT_SRC); if (ret < 0) return ret; @@ -557,8 +557,8 @@ static int smsc95xx_link_reset(struct usbnet *dev) mii_check_media(mii, 1, 1); mii_ethtool_gset(&dev->mii, &ecmd); - lcladv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE); - rmtadv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_LPA); + lcladv = phy_read(pdata->phydev, MII_ADVERTISE); + rmtadv = phy_read(pdata->phydev, MII_LPA); netif_dbg(dev, link, dev->net, "speed: %u duplex: %d lcladv: %04x rmtadv: %04x\n", @@ -630,7 +630,7 @@ static void check_carrier(struct work_struct *work) if (pdata->suspend_flags != 0) return; - ret = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMSR); + ret = phy_read(pdata->phydev, MII_BMSR); if (ret < 0) { netdev_warn(dev->net, "Failed to read MII_BMSR\n"); return; @@ -764,10 +764,11 @@ static int smsc95xx_ethtool_set_wol(struct net_device *net, static int get_mdix_status(struct net_device *net) { struct usbnet *dev = netdev_priv(net); + struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); u32 val; int buf; - buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, SPECIAL_CTRL_STS); + buf = phy_read(pdata->phydev, SPECIAL_CTRL_STS); if (buf & SPECIAL_CTRL_STS_OVRRD_AMDIX_) { if (buf & SPECIAL_CTRL_STS_AMDIX_ENABLE_) return ETH_TP_MDI_AUTO; @@ -793,7 +794,7 @@ static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl) (pdata->chip_id == ID_REV_CHIP_ID_89530_) || (pdata->chip_id == ID_REV_CHIP_ID_9730_)) { /* Extend Manual AutoMDIX timer for 9500A/9500Ai */ - buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, + buf = phy_read(pdata->phydev, PHY_EDPD_CONFIG); buf |= PHY_EDPD_CONFIG_EXT_CROSSOVER_; smsc95xx_mdio_write(dev->net, dev->mii.phy_id, @@ -801,7 +802,7 @@ static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl) } if (mdix_ctrl == ETH_TP_MDI) { - buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, + buf = phy_read(pdata->phydev, SPECIAL_CTRL_STS); buf |= SPECIAL_CTRL_STS_OVRRD_AMDIX_; buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | @@ -809,7 +810,7 @@ static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl) smsc95xx_mdio_write(dev->net, dev->mii.phy_id, SPECIAL_CTRL_STS, buf); } else if (mdix_ctrl == ETH_TP_MDI_X) { - buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, + buf = phy_read(pdata->phydev, SPECIAL_CTRL_STS); buf |= SPECIAL_CTRL_STS_OVRRD_AMDIX_; buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | @@ -818,7 +819,7 @@ static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl) smsc95xx_mdio_write(dev->net, dev->mii.phy_id, SPECIAL_CTRL_STS, buf); } else if (mdix_ctrl == ETH_TP_MDI_AUTO) { - buf = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, + buf = phy_read(pdata->phydev, SPECIAL_CTRL_STS); buf &= ~SPECIAL_CTRL_STS_OVRRD_AMDIX_; buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | @@ -968,6 +969,7 @@ 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; /* reset phy and wait for reset to complete */ @@ -975,7 +977,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) do { msleep(10); - bmcr = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); + bmcr = phy_read(pdata->phydev, MII_BMCR); timeout++; } while ((bmcr & BMCR_RESET) && (timeout < 100)); @@ -989,7 +991,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) ADVERTISE_PAUSE_ASYM); /* read to clear */ - ret = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC); + ret = phy_read(pdata->phydev, PHY_INT_SRC); if (ret < 0) { netdev_warn(dev->net, "Failed to read PHY_INT_SRC during init\n"); return ret; @@ -1407,18 +1409,19 @@ static u32 smsc_crc(const u8 *buffer, size_t len, int filter) static int smsc95xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask) { + struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); struct mii_if_info *mii = &dev->mii; int ret; netdev_dbg(dev->net, "enabling PHY wakeup interrupts\n"); /* read to clear */ - ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC); + ret = phy_read(pdata->phydev, PHY_INT_SRC); if (ret < 0) return ret; /* enable interrupt source */ - ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_INT_MASK); + ret = phy_read(pdata->phydev, PHY_INT_MASK); if (ret < 0) return ret; @@ -1431,15 +1434,15 @@ static int smsc95xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask) static int smsc95xx_link_ok_nopm(struct usbnet *dev) { - struct mii_if_info *mii = &dev->mii; + struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); int ret; /* first, a dummy read, needed to latch some MII phys */ - ret = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_BMSR); + ret = phy_read(pdata->phydev, MII_BMSR); if (ret < 0) return ret; - ret = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_BMSR); + ret = phy_read(pdata->phydev, MII_BMSR); if (ret < 0) return ret; @@ -1500,7 +1503,7 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) PHY_EDPD_CONFIG_DEFAULT); /* enable energy detect power-down mode */ - ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_MODE_CTRL_STS); + ret = phy_read(pdata->phydev, PHY_MODE_CTRL_STS); if (ret < 0) return ret; From patchwork Thu Jan 3 01:10:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746815 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 01FBA17D2 for ; Thu, 3 Jan 2019 01:11:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E385028415 for ; Thu, 3 Jan 2019 01:11:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5B002841D; Thu, 3 Jan 2019 01:11:27 +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 624A028415 for ; Thu, 3 Jan 2019 01:11:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728645AbfACBLY (ORCPT ); Wed, 2 Jan 2019 20:11:24 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:49061 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728814AbfACBLV (ORCPT ); Wed, 2 Jan 2019 20:11:21 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVH94znFz1qvTW; Thu, 3 Jan 2019 02:11:17 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVH94pMnz1qvWb; Thu, 3 Jan 2019 02:11:17 +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 VnThscKzqTn1; Thu, 3 Jan 2019 02:11:16 +0100 (CET) X-Auth-Info: 76RxfvCbdRGno/Le2KL4I5Jw+z+YZKHtAcp7EdQLkcU= 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:16 +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 11/19] usbnet: smsc95xx: Replace smsc95xx_mdio_write() with phy_write() Date: Thu, 3 Jan 2019 02:10:32 +0100 Message-Id: <20190103011040.25974-12-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 Just replace smsc95xx_mdio_write() with generic phy_write() to reduce usage of the ad-hoc accessors. 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 | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 53f817e699df..c1e59813c1fc 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -797,7 +797,7 @@ static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl) buf = phy_read(pdata->phydev, PHY_EDPD_CONFIG); buf |= PHY_EDPD_CONFIG_EXT_CROSSOVER_; - smsc95xx_mdio_write(dev->net, dev->mii.phy_id, + phy_write(pdata->phydev, PHY_EDPD_CONFIG, buf); } @@ -807,7 +807,7 @@ static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl) buf |= SPECIAL_CTRL_STS_OVRRD_AMDIX_; buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | SPECIAL_CTRL_STS_AMDIX_STATE_); - smsc95xx_mdio_write(dev->net, dev->mii.phy_id, + phy_write(pdata->phydev, SPECIAL_CTRL_STS, buf); } else if (mdix_ctrl == ETH_TP_MDI_X) { buf = phy_read(pdata->phydev, @@ -816,7 +816,7 @@ static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl) buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | SPECIAL_CTRL_STS_AMDIX_STATE_); buf |= SPECIAL_CTRL_STS_AMDIX_STATE_; - smsc95xx_mdio_write(dev->net, dev->mii.phy_id, + phy_write(pdata->phydev, SPECIAL_CTRL_STS, buf); } else if (mdix_ctrl == ETH_TP_MDI_AUTO) { buf = phy_read(pdata->phydev, @@ -825,7 +825,7 @@ static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl) buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | SPECIAL_CTRL_STS_AMDIX_STATE_); buf |= SPECIAL_CTRL_STS_AMDIX_ENABLE_; - smsc95xx_mdio_write(dev->net, dev->mii.phy_id, + phy_write(pdata->phydev, SPECIAL_CTRL_STS, buf); } pdata->mdix_ctrl = mdix_ctrl; @@ -973,7 +973,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) int bmcr, ret, timeout = 0; /* reset phy and wait for reset to complete */ - smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); + phy_write(pdata->phydev, MII_BMCR, BMCR_RESET); do { msleep(10); @@ -986,7 +986,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) return -EIO; } - smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, + phy_write(pdata->phydev, MII_ADVERTISE, ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM); @@ -997,7 +997,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) return ret; } - smsc95xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK, + phy_write(pdata->phydev, PHY_INT_MASK, PHY_INT_MASK_DEFAULT_); mii_nway_restart(&dev->mii); @@ -1410,7 +1410,6 @@ static u32 smsc_crc(const u8 *buffer, size_t len, int filter) static int smsc95xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask) { struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); - struct mii_if_info *mii = &dev->mii; int ret; netdev_dbg(dev->net, "enabling PHY wakeup interrupts\n"); @@ -1427,7 +1426,7 @@ static int smsc95xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask) ret |= mask; - smsc95xx_mdio_write(dev->net, mii->phy_id, PHY_INT_MASK, ret); + phy_write(pdata->phydev, PHY_INT_MASK, ret); return 0; } @@ -1491,7 +1490,6 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev) static int smsc95xx_enter_suspend1(struct usbnet *dev) { struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); - struct mii_if_info *mii = &dev->mii; u32 val; int ret; @@ -1499,7 +1497,7 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) * compatibility with non-standard link partners */ if (pdata->features & FEATURE_PHY_NLP_CROSSOVER) - smsc95xx_mdio_write(dev->net, mii->phy_id, PHY_EDPD_CONFIG, + phy_write(pdata->phydev, PHY_EDPD_CONFIG, PHY_EDPD_CONFIG_DEFAULT); /* enable energy detect power-down mode */ @@ -1509,7 +1507,7 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) ret |= MODE_CTRL_STS_EDPWRDOWN_; - smsc95xx_mdio_write(dev->net, mii->phy_id, PHY_MODE_CTRL_STS, ret); + phy_write(pdata->phydev, PHY_MODE_CTRL_STS, ret); /* enter SUSPEND1 mode */ ret = smsc95xx_read_reg(dev, PM_CTRL, &val); 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); From patchwork Thu Jan 3 01:10:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746813 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 BABC017D2 for ; Thu, 3 Jan 2019 01:11:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB3CB28415 for ; Thu, 3 Jan 2019 01:11:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CBE52841D; Thu, 3 Jan 2019 01:11:26 +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 4746128415 for ; Thu, 3 Jan 2019 01:11:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729142AbfACBLX (ORCPT ); Wed, 2 Jan 2019 20:11:23 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:51655 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728869AbfACBLV (ORCPT ); Wed, 2 Jan 2019 20:11:21 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVHD0P4Hz1qvfq; Thu, 3 Jan 2019 02:11:20 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVHD0BnMz1qvWb; Thu, 3 Jan 2019 02:11:20 +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 fMSJpKEjOISN; Thu, 3 Jan 2019 02:11:18 +0100 (CET) X-Auth-Info: CeTqdvR1K70h5J1GV8hlZpw0jdQTAqOlrfv06Vy6khU= 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:18 +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 13/19] usbnet: smsc95xx: Replace smsc95xx_link_ok_nopm() Date: Thu, 3 Jan 2019 02:10:34 +0100 Message-Id: <20190103011040.25974-14-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 function with genphy_update_link(), since that's really all that it is. 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 | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index fa33eda61275..401662f28f01 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -1427,16 +1427,11 @@ static int smsc95xx_link_ok_nopm(struct usbnet *dev) struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); int ret; - /* first, a dummy read, needed to latch some MII phys */ - ret = phy_read(pdata->phydev, MII_BMSR); - if (ret < 0) - return ret; - - ret = phy_read(pdata->phydev, MII_BMSR); - if (ret < 0) + ret = genphy_update_link(pdata->phydev); + if (ret) return ret; - return !!(ret & BMSR_LSTATUS); + return pdata->phydev->link; } static int smsc95xx_enter_suspend0(struct usbnet *dev) From patchwork Thu Jan 3 01:10:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746853 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 1E3BE1399 for ; Thu, 3 Jan 2019 01:12:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 101F728409 for ; Thu, 3 Jan 2019 01:12:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0408428417; Thu, 3 Jan 2019 01:12:37 +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 A517D28409 for ; Thu, 3 Jan 2019 01:12:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730267AbfACBMb (ORCPT ); Wed, 2 Jan 2019 20:12:31 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:60984 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728902AbfACBLW (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 43VVHF1Wh8z1qvgR; Thu, 3 Jan 2019 02:11:21 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVHF16xjz1qvWh; Thu, 3 Jan 2019 02:11:21 +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 v3UjrHfevI2J; Thu, 3 Jan 2019 02:11:20 +0100 (CET) X-Auth-Info: xoAXUAo4THPgrcoEIvyrDeE0oDrLCatWqQGEKYPl+Og= 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:20 +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 14/19] usbnet: smsc95xx: Replace mii_nway_restart() Date: Thu, 3 Jan 2019 02:10:35 +0100 Message-Id: <20190103011040.25974-15-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 This is in fact genphy_restart_aneg(), just use the generic phydev 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 401662f28f01..87830c67aee1 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -990,7 +990,10 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) phy_write(pdata->phydev, PHY_INT_MASK, PHY_INT_MASK_DEFAULT_); - mii_nway_restart(&dev->mii); + + ret = genphy_restart_aneg(pdata->phydev); + if (ret) + return ret; netif_dbg(dev, ifup, dev->net, "phy initialised successfully\n"); return 0; From patchwork Thu Jan 3 01:10:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746847 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 A9BDB17D2 for ; Thu, 3 Jan 2019 01:12:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A8D028409 for ; Thu, 3 Jan 2019 01:12:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EAC928417; Thu, 3 Jan 2019 01:12:27 +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 32A7928409 for ; Thu, 3 Jan 2019 01:12:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729301AbfACBL1 (ORCPT ); Wed, 2 Jan 2019 20:11:27 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:49061 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728935AbfACBLY (ORCPT ); Wed, 2 Jan 2019 20:11:24 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVHG26p5z1qvTP; Thu, 3 Jan 2019 02:11:22 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVHG1tgbz1qvWb; Thu, 3 Jan 2019 02:11:22 +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 Lxbw7EY84Jmy; Thu, 3 Jan 2019 02:11:21 +0100 (CET) X-Auth-Info: ZOBandG6haY03z+91rjhpGT36pgLxC5VyU4WcDsdy+U= 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:21 +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 15/19] usbnet: smsc95xx: Replace mii_ethtool_gset() Date: Thu, 3 Jan 2019 02:10:36 +0100 Message-Id: <20190103011040.25974-16-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 mii_ethtool_gset() with a phydev compatible function and update the code to match. 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 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 87830c67aee1..b04df07d882e 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -541,7 +541,7 @@ static int smsc95xx_link_reset(struct usbnet *dev) { struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); struct mii_if_info *mii = &dev->mii; - struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; + struct ethtool_link_ksettings ecmd; unsigned long flags; u16 lcladv, rmtadv; int ret; @@ -556,16 +556,16 @@ static int smsc95xx_link_reset(struct usbnet *dev) return ret; mii_check_media(mii, 1, 1); - mii_ethtool_gset(&dev->mii, &ecmd); + phy_ethtool_ksettings_get(pdata->phydev, &ecmd); lcladv = phy_read(pdata->phydev, MII_ADVERTISE); rmtadv = phy_read(pdata->phydev, MII_LPA); netif_dbg(dev, link, dev->net, "speed: %u duplex: %d lcladv: %04x rmtadv: %04x\n", - ethtool_cmd_speed(&ecmd), ecmd.duplex, lcladv, rmtadv); + ecmd.base.speed, ecmd.base.duplex, lcladv, rmtadv); spin_lock_irqsave(&pdata->mac_cr_lock, flags); - if (ecmd.duplex != DUPLEX_FULL) { + if (ecmd.base.duplex != DUPLEX_FULL) { pdata->mac_cr &= ~MAC_CR_FDPX_; pdata->mac_cr |= MAC_CR_RCVOWN_; } else { @@ -578,7 +578,8 @@ static int smsc95xx_link_reset(struct usbnet *dev) if (ret < 0) return ret; - ret = smsc95xx_phy_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv); + ret = smsc95xx_phy_update_flowcontrol(dev, ecmd.base.duplex, + lcladv, rmtadv); if (ret < 0) netdev_warn(dev->net, "Error updating PHY flow control\n"); From patchwork Thu Jan 3 01:10:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746845 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 552141399 for ; Thu, 3 Jan 2019 01:12:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4652528409 for ; Thu, 3 Jan 2019 01:12:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39EDF28417; Thu, 3 Jan 2019 01:12:18 +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 D531A28409 for ; Thu, 3 Jan 2019 01:12:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726828AbfACBMP (ORCPT ); Wed, 2 Jan 2019 20:12:15 -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 S1729257AbfACBLb (ORCPT ); Wed, 2 Jan 2019 20:11:31 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVHH4bZ7z1qvTW; Thu, 3 Jan 2019 02:11:23 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVHH3jJ1z1qvWb; Thu, 3 Jan 2019 02:11:23 +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 x03__dzUdsXy; Thu, 3 Jan 2019 02:11:22 +0100 (CET) X-Auth-Info: yiTdH3H0zy8HnSOsoPc18tUKeRIvXfKDW7U23hQy/qY= 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:22 +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 16/19] usbnet: smsc95xx: Replace mii_check_media() Date: Thu, 3 Jan 2019 02:10:37 +0100 Message-Id: <20190103011040.25974-17-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 mii_check_media() is called to read out the PHY status registers and update the internal status reported by mii_ethtool_gset(), just replace it with phydev compatible phy_read_status(). 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 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index b04df07d882e..14a83358cb35 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -540,7 +540,6 @@ static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex, static int smsc95xx_link_reset(struct usbnet *dev) { struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); - struct mii_if_info *mii = &dev->mii; struct ethtool_link_ksettings ecmd; unsigned long flags; u16 lcladv, rmtadv; @@ -555,7 +554,7 @@ static int smsc95xx_link_reset(struct usbnet *dev) if (ret < 0) return ret; - mii_check_media(mii, 1, 1); + phy_read_status(pdata->phydev); phy_ethtool_ksettings_get(pdata->phydev, &ecmd); lcladv = phy_read(pdata->phydev, MII_ADVERTISE); rmtadv = phy_read(pdata->phydev, MII_LPA); From patchwork Thu Jan 3 01:10:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746827 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 67E2017E6 for ; Thu, 3 Jan 2019 01:11:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59D0A28415 for ; Thu, 3 Jan 2019 01:11:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E4002841D; Thu, 3 Jan 2019 01:11:40 +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 F249628417 for ; Thu, 3 Jan 2019 01:11:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729568AbfACBLh (ORCPT ); Wed, 2 Jan 2019 20:11:37 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:49061 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729271AbfACBLb (ORCPT ); Wed, 2 Jan 2019 20:11:31 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVHJ56SZz1qvnY; Thu, 3 Jan 2019 02:11:24 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVHJ4w2qz1qvWb; Thu, 3 Jan 2019 02:11:24 +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 6FASkhFbXl4E; Thu, 3 Jan 2019 02:11:23 +0100 (CET) X-Auth-Info: ldEufo6RkTD9b99QO10TFhrro/8AuCmlvNIx18hPzqE= 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:23 +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 17/19] usbnet: smsc95xx: Replace generic_mii_ioctl() Date: Thu, 3 Jan 2019 02:10:38 +0100 Message-Id: <20190103011040.25974-18-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 generic_mii_ioctl() with phydev compatible phy_mii_ioctl(). 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 14a83358cb35..ea5b9de10348 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -882,11 +882,12 @@ static const struct ethtool_ops smsc95xx_ethtool_ops = { static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) { struct usbnet *dev = netdev_priv(netdev); + struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); if (!netif_running(netdev)) return -EINVAL; - return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); + return phy_mii_ioctl(pdata->phydev, rq, cmd); } static void smsc95xx_init_mac_address(struct usbnet *dev) From patchwork Thu Jan 3 01:10:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746837 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 48F0E17D2 for ; Thu, 3 Jan 2019 01:12:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A98428409 for ; Thu, 3 Jan 2019 01:12:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F11E28417; Thu, 3 Jan 2019 01:12:14 +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 B4B2928409 for ; Thu, 3 Jan 2019 01:12:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729495AbfACBLg (ORCPT ); Wed, 2 Jan 2019 20:11:36 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:33866 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726529AbfACBLc (ORCPT ); Wed, 2 Jan 2019 20:11:32 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVHK725xz1qvgr; Thu, 3 Jan 2019 02:11:25 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVHK6v9Gz1qvWb; Thu, 3 Jan 2019 02:11:25 +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 KnFFSUlitAmM; Thu, 3 Jan 2019 02:11:24 +0100 (CET) X-Auth-Info: oyxmQ3+oxLvi10hjd0WUvn1QbKgUaNdAlFBh1TOBLbo= 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:24 +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 18/19] usbnet: smsc95xx: Remove all of the carrier checking code Date: Thu, 3 Jan 2019 02:10:39 +0100 Message-Id: <20190103011040.25974-19-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 carrier checking code is completely handled by the internal phydev state machine, remove it. 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 | 53 ++++---------------------------------- 1 file changed, 5 insertions(+), 48 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index ea5b9de10348..c9931955c22a 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -75,7 +75,6 @@ struct smsc95xx_priv { u8 suspend_flags; u8 mdix_ctrl; bool link_ok; - struct delayed_work carrier_check; struct usbnet *dev; struct mii_bus *mii_bus; struct phy_device *phydev; @@ -605,44 +604,6 @@ static void smsc95xx_status(struct usbnet *dev, struct urb *urb) intdata); } -static void set_carrier(struct usbnet *dev, bool link) -{ - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); - - if (pdata->link_ok == link) - return; - - pdata->link_ok = link; - - if (link) - usbnet_link_change(dev, 1, 0); - else - usbnet_link_change(dev, 0, 0); -} - -static void check_carrier(struct work_struct *work) -{ - struct smsc95xx_priv *pdata = container_of(work, struct smsc95xx_priv, - carrier_check.work); - struct usbnet *dev = pdata->dev; - int ret; - - if (pdata->suspend_flags != 0) - return; - - ret = phy_read(pdata->phydev, MII_BMSR); - if (ret < 0) { - netdev_warn(dev->net, "Failed to read MII_BMSR\n"); - return; - } - if (ret & BMSR_LSTATUS) - set_carrier(dev, 1); - else - set_carrier(dev, 0); - - schedule_delayed_work(&pdata->carrier_check, CARRIER_CHECK_DELAY); -} - /* Enable or disable Tx & Rx checksum offload engines */ static int smsc95xx_set_features(struct net_device *netdev, netdev_features_t features) @@ -1370,9 +1331,6 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) dev->net->max_mtu = ETH_DATA_LEN; dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; - INIT_DELAYED_WORK(&pdata->carrier_check, check_carrier); - schedule_delayed_work(&pdata->carrier_check, CARRIER_CHECK_DELAY); - return 0; err_mdiobus_register: mdiobus_free(bus); @@ -1386,7 +1344,6 @@ static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); if (pdata) { - cancel_delayed_work(&pdata->carrier_check); netif_dbg(dev, ifdown, dev->net, "free pdata\n"); mdiobus_unregister(pdata->mii_bus); mdiobus_free(pdata->mii_bus); @@ -1639,14 +1596,14 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) u32 val, link_up; int ret; + phy_stop(pdata->phydev); + ret = usbnet_suspend(intf, message); if (ret < 0) { netdev_warn(dev->net, "usbnet_suspend error\n"); return ret; } - cancel_delayed_work_sync(&pdata->carrier_check); - if (pdata->suspend_flags) { netdev_warn(dev->net, "error during last resume\n"); pdata->suspend_flags = 0; @@ -1891,8 +1848,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) usbnet_resume(intf); if (ret) - schedule_delayed_work(&pdata->carrier_check, - CARRIER_CHECK_DELAY); + phy_start(pdata->phydev); return ret; } @@ -1913,7 +1869,6 @@ static int smsc95xx_resume(struct usb_interface *intf) /* do this first to ensure it's cleared even in error case */ pdata->suspend_flags = 0; - schedule_delayed_work(&pdata->carrier_check, CARRIER_CHECK_DELAY); if (suspend_flags & SUSPEND_ALLMODES) { /* clear wake-up sources */ @@ -1944,6 +1899,8 @@ static int smsc95xx_resume(struct usb_interface *intf) if (ret < 0) netdev_warn(dev->net, "usbnet_resume error\n"); + phy_start(pdata->phydev); + return ret; } From patchwork Thu Jan 3 01:10:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746835 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 53FE317D2 for ; Thu, 3 Jan 2019 01:12:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44E4528409 for ; Thu, 3 Jan 2019 01:12:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 395DE28417; Thu, 3 Jan 2019 01:12:08 +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 BC5FE28409 for ; Thu, 3 Jan 2019 01:12:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729626AbfACBLj (ORCPT ); Wed, 2 Jan 2019 20:11:39 -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 S1726990AbfACBLh (ORCPT ); Wed, 2 Jan 2019 20:11:37 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVHM1fT5z1qvnl; Thu, 3 Jan 2019 02:11:27 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVHM1QzYz1qvWb; Thu, 3 Jan 2019 02:11:27 +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 cfo6aKyrpp03; Thu, 3 Jan 2019 02:11:26 +0100 (CET) X-Auth-Info: 8HK9j28goHyo3LbB09WXILHjkREn7EbpYrbydMaZw58= 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:26 +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 19/19] usbnet: smsc95xx: Use phy bit operations Date: Thu, 3 Jan 2019 02:10:40 +0100 Message-Id: <20190103011040.25974-20-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 Use bit operations provided by bit.h instead of reimplementing them. No functional change. 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 | 67 +++++++++++++------------------------- 1 file changed, 22 insertions(+), 45 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index c9931955c22a..20e41c15ce13 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -748,47 +748,35 @@ static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl) { struct usbnet *dev = netdev_priv(net); struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); - int buf; if ((pdata->chip_id == ID_REV_CHIP_ID_9500A_) || (pdata->chip_id == ID_REV_CHIP_ID_9530_) || (pdata->chip_id == ID_REV_CHIP_ID_89530_) || (pdata->chip_id == ID_REV_CHIP_ID_9730_)) { /* Extend Manual AutoMDIX timer for 9500A/9500Ai */ - buf = phy_read(pdata->phydev, - PHY_EDPD_CONFIG); - buf |= PHY_EDPD_CONFIG_EXT_CROSSOVER_; - phy_write(pdata->phydev, - PHY_EDPD_CONFIG, buf); + phy_set_bits(pdata->phydev, PHY_EDPD_CONFIG, + PHY_EDPD_CONFIG_EXT_CROSSOVER_); } if (mdix_ctrl == ETH_TP_MDI) { - buf = phy_read(pdata->phydev, - SPECIAL_CTRL_STS); - buf |= SPECIAL_CTRL_STS_OVRRD_AMDIX_; - buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | - SPECIAL_CTRL_STS_AMDIX_STATE_); - phy_write(pdata->phydev, - SPECIAL_CTRL_STS, buf); + phy_modify(pdata->phydev, SPECIAL_CTRL_STS, + SPECIAL_CTRL_STS_AMDIX_ENABLE_ | + SPECIAL_CTRL_STS_AMDIX_STATE_, + SPECIAL_CTRL_STS_OVRRD_AMDIX_); } else if (mdix_ctrl == ETH_TP_MDI_X) { - buf = phy_read(pdata->phydev, - SPECIAL_CTRL_STS); - buf |= SPECIAL_CTRL_STS_OVRRD_AMDIX_; - buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | - SPECIAL_CTRL_STS_AMDIX_STATE_); - buf |= SPECIAL_CTRL_STS_AMDIX_STATE_; - phy_write(pdata->phydev, - SPECIAL_CTRL_STS, buf); + phy_modify(pdata->phydev, SPECIAL_CTRL_STS, + SPECIAL_CTRL_STS_AMDIX_ENABLE_ | + SPECIAL_CTRL_STS_AMDIX_STATE_, + SPECIAL_CTRL_STS_OVRRD_AMDIX_ | + SPECIAL_CTRL_STS_AMDIX_STATE_); } else if (mdix_ctrl == ETH_TP_MDI_AUTO) { - buf = phy_read(pdata->phydev, - SPECIAL_CTRL_STS); - buf &= ~SPECIAL_CTRL_STS_OVRRD_AMDIX_; - buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ | - SPECIAL_CTRL_STS_AMDIX_STATE_); - buf |= SPECIAL_CTRL_STS_AMDIX_ENABLE_; - phy_write(pdata->phydev, - SPECIAL_CTRL_STS, buf); + phy_modify(pdata->phydev, SPECIAL_CTRL_STS, + SPECIAL_CTRL_STS_OVRRD_AMDIX_ | + SPECIAL_CTRL_STS_AMDIX_ENABLE_ | + SPECIAL_CTRL_STS_AMDIX_STATE_, + SPECIAL_CTRL_STS_AMDIX_ENABLE_); } + pdata->mdix_ctrl = mdix_ctrl; } @@ -951,7 +939,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) } phy_write(pdata->phydev, PHY_INT_MASK, - PHY_INT_MASK_DEFAULT_); + PHY_INT_MASK_DEFAULT_); ret = genphy_restart_aneg(pdata->phydev); if (ret) @@ -1372,15 +1360,7 @@ static int smsc95xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask) return ret; /* enable interrupt source */ - ret = phy_read(pdata->phydev, PHY_INT_MASK); - if (ret < 0) - return ret; - - ret |= mask; - - phy_write(pdata->phydev, PHY_INT_MASK, ret); - - return 0; + return phy_set_bits(pdata->phydev, PHY_INT_MASK, mask); } static int smsc95xx_link_ok_nopm(struct usbnet *dev) @@ -1445,17 +1425,14 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) */ if (pdata->features & FEATURE_PHY_NLP_CROSSOVER) phy_write(pdata->phydev, PHY_EDPD_CONFIG, - PHY_EDPD_CONFIG_DEFAULT); + PHY_EDPD_CONFIG_DEFAULT); /* enable energy detect power-down mode */ - ret = phy_read(pdata->phydev, PHY_MODE_CTRL_STS); + ret = phy_set_bits(pdata->phydev, PHY_MODE_CTRL_STS, + MODE_CTRL_STS_EDPWRDOWN_); if (ret < 0) return ret; - ret |= MODE_CTRL_STS_EDPWRDOWN_; - - phy_write(pdata->phydev, PHY_MODE_CTRL_STS, ret); - /* enter SUSPEND1 mode */ ret = smsc95xx_read_reg(dev, PM_CTRL, &val); if (ret < 0)