From patchwork Thu Mar 10 11:44:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 12776216 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10964C43217 for ; Thu, 10 Mar 2022 11:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241790AbiCJLpy (ORCPT ); Thu, 10 Mar 2022 06:45:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241764AbiCJLpr (ORCPT ); Thu, 10 Mar 2022 06:45:47 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71257140749 for ; Thu, 10 Mar 2022 03:44:46 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nSHDh-0001NO-34; Thu, 10 Mar 2022 12:44:37 +0100 Received: from ore by dude.hi.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1nSHDf-00EXXl-C5; Thu, 10 Mar 2022 12:44:35 +0100 From: Oleksij Rempel To: "David S. Miller" , Jakub Kicinski , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org, paskripkin@gmail.com Subject: [PATCH net-next v1 1/4] net: usb: asix: unify ax88772_resume code Date: Thu, 10 Mar 2022 12:44:31 +0100 Message-Id: <20220310114434.3465481-1-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-usb@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The only difference is the reset code, so remove not needed duplicates. Signed-off-by: Oleksij Rempel --- drivers/net/usb/asix.h | 1 + drivers/net/usb/asix_devices.c | 32 ++++++++------------------------ 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/drivers/net/usb/asix.h b/drivers/net/usb/asix.h index 4334aafab59a..b5ac693cebf2 100644 --- a/drivers/net/usb/asix.h +++ b/drivers/net/usb/asix.h @@ -177,6 +177,7 @@ struct asix_rx_fixup_info { struct asix_common_private { void (*resume)(struct usbnet *dev); void (*suspend)(struct usbnet *dev); + int (*reset)(struct usbnet *dev, int in_pm); u16 presvd_phy_advertise; u16 presvd_phy_bmcr; struct asix_rx_fixup_info rx_fixup_info; diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c index 6ea44e53713a..bb09181596c5 100644 --- a/drivers/net/usb/asix_devices.c +++ b/drivers/net/usb/asix_devices.c @@ -625,27 +625,13 @@ static void ax88772_resume(struct usbnet *dev) int i; for (i = 0; i < 3; i++) - if (!ax88772_hw_reset(dev, 1)) + if (!priv->reset(dev, 1)) break; if (netif_running(dev->net)) phy_start(priv->phydev); } -static void ax88772a_resume(struct usbnet *dev) -{ - struct asix_common_private *priv = dev->driver_priv; - int i; - - for (i = 0; i < 3; i++) { - if (!ax88772a_hw_reset(dev, 1)) - break; - } - - if (netif_running(dev->net)) - phy_start(priv->phydev); -} - static int asix_resume(struct usb_interface *intf) { struct usbnet *dev = usb_get_intfdata(intf); @@ -763,9 +749,14 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) chipcode &= AX_CHIPCODE_MASK; - ret = (chipcode == AX_AX88772_CHIPCODE) ? ax88772_hw_reset(dev, 0) : - ax88772a_hw_reset(dev, 0); + priv->resume = ax88772_resume; + priv->suspend = ax88772_suspend; + if (chipcode == AX_AX88772_CHIPCODE) + priv->reset = ax88772_hw_reset; + else + priv->reset = ax88772a_hw_reset; + ret = priv->reset(dev, 0); if (ret < 0) { netdev_dbg(dev->net, "Failed to reset AX88772: %d\n", ret); return ret; @@ -780,13 +771,6 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) priv->presvd_phy_bmcr = 0; priv->presvd_phy_advertise = 0; - if (chipcode == AX_AX88772_CHIPCODE) { - priv->resume = ax88772_resume; - priv->suspend = ax88772_suspend; - } else { - priv->resume = ax88772a_resume; - priv->suspend = ax88772_suspend; - } ret = ax88772_init_mdio(dev); if (ret)