Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755322AbaJIKBO (ORCPT ); Thu, 9 Oct 2014 06:01:14 -0400 Received: from rtits2.realtek.com ([60.250.210.242]:47395 "EHLO rtits2.realtek.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754903AbaJIKAp (ORCPT ); Thu, 9 Oct 2014 06:00:45 -0400 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.49 with qID s99A0fTI028738, This message is accepted by code: ctloc85258 From: Hayes Wang To: CC: , , , Hayes Wang Subject: [PATCH net-next v2 2/3] r8152: adjust usb_autopm_xxx Date: Thu, 9 Oct 2014 18:00:25 +0800 Message-ID: <1394712342-15778-62-Taiwan-albertk@realtek.com> X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <1394712342-15778-60-Taiwan-albertk@realtek.com> References: <1394712342-15778-58-Taiwan-albertk@realtek.com> <1394712342-15778-60-Taiwan-albertk@realtek.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.21.71.44] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add usb_autopm_xxx for rtl8152_get_settings() ,and remove usb_autopm_xxx from read_mii_word() and write_mii_word(). Signed-off-by: Hayes Wang --- drivers/net/usb/r8152.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index c5afe8c..1d2fc8e 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -942,15 +942,8 @@ static int read_mii_word(struct net_device *netdev, int phy_id, int reg) if (phy_id != R8152_PHY_ID) return -EINVAL; - ret = usb_autopm_get_interface(tp->intf); - if (ret < 0) - goto out; - ret = r8152_mdio_read(tp, reg); - usb_autopm_put_interface(tp->intf); - -out: return ret; } @@ -965,12 +958,7 @@ void write_mii_word(struct net_device *netdev, int phy_id, int reg, int val) if (phy_id != R8152_PHY_ID) return; - if (usb_autopm_get_interface(tp->intf) < 0) - return; - r8152_mdio_write(tp, reg, val); - - usb_autopm_put_interface(tp->intf); } static int @@ -3290,11 +3278,21 @@ static int rtl8152_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd) { struct r8152 *tp = netdev_priv(netdev); + int ret; if (!tp->mii.mdio_read) return -EOPNOTSUPP; - return mii_ethtool_gset(&tp->mii, cmd); + ret = usb_autopm_get_interface(tp->intf); + if (ret < 0) + goto out; + + ret = mii_ethtool_gset(&tp->mii, cmd); + + usb_autopm_put_interface(tp->intf); + +out: + return ret; } static int rtl8152_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/