Return-Path: Received: from mail-co1nam03on0118.outbound.protection.outlook.com ([104.47.40.118]:6048 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032136AbeCAP3C (ORCPT ); Thu, 1 Mar 2018 10:29:02 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: hayeswang , "David S . Miller" , Sasha Levin Subject: [added to the 4.1 stable tree] r8152: use test_and_clear_bit Date: Thu, 1 Mar 2018 15:23:58 +0000 Message-ID: <20180301152116.1486-144-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: hayeswang This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 216a8349d3a0dd1bc2afbcc821e374c8f929bd62 ] Replace test_bit() followed by clear_bit() with test_and_clear_bit(). Signed-off-by: Hayes Wang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/r8152.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index c0fb8a051768..55b0129acff7 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -1929,7 +1929,6 @@ static void _rtl8152_set_rx_mode(struct net_device *n= etdev) __le32 tmp[2]; u32 ocp_data; =20 - clear_bit(RTL8152_SET_RX_MODE, &tp->flags); netif_stop_queue(netdev); ocp_data =3D ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); ocp_data &=3D ~RCR_ACPT_ALL; @@ -2364,8 +2363,6 @@ static void rtl_phy_reset(struct r8152 *tp) u16 data; int i; =20 - clear_bit(PHY_RESET, &tp->flags); - data =3D r8152_mdio_read(tp, MII_BMCR); =20 /* don't reset again before the previous one complete */ @@ -2860,10 +2857,9 @@ static int rtl8152_set_speed(struct r8152 *tp, u8 au= toneg, u16 speed, u8 duplex) r8152_mdio_write(tp, MII_ADVERTISE, anar); r8152_mdio_write(tp, MII_BMCR, bmcr); =20 - if (test_bit(PHY_RESET, &tp->flags)) { + if (test_and_clear_bit(PHY_RESET, &tp->flags)) { int i; =20 - clear_bit(PHY_RESET, &tp->flags); for (i =3D 0; i < 50; i++) { msleep(20); if ((r8152_mdio_read(tp, MII_BMCR) & BMCR_RESET) =3D=3D 0) @@ -2872,7 +2868,6 @@ static int rtl8152_set_speed(struct r8152 *tp, u8 aut= oneg, u16 speed, u8 duplex) } =20 out: - return ret; } =20 @@ -2928,7 +2923,6 @@ static void set_carrier(struct r8152 *tp) struct net_device *netdev =3D tp->netdev; u8 speed; =20 - clear_bit(RTL8152_LINK_CHG, &tp->flags); speed =3D rtl8152_get_speed(tp); =20 if (speed & LINK_STATUS) { @@ -2969,20 +2963,18 @@ static void rtl_work_func_t(struct work_struct *wor= k) goto out1; } =20 - if (test_bit(RTL8152_LINK_CHG, &tp->flags)) + if (test_and_clear_bit(RTL8152_LINK_CHG, &tp->flags)) set_carrier(tp); =20 - if (test_bit(RTL8152_SET_RX_MODE, &tp->flags)) + if (test_and_clear_bit(RTL8152_SET_RX_MODE, &tp->flags)) _rtl8152_set_rx_mode(tp->netdev); =20 /* don't schedule napi before linking */ - if (test_bit(SCHEDULE_NAPI, &tp->flags) && - netif_carrier_ok(tp->netdev)) { - clear_bit(SCHEDULE_NAPI, &tp->flags); + if (test_and_clear_bit(SCHEDULE_NAPI, &tp->flags) && + netif_carrier_ok(tp->netdev)) napi_schedule(&tp->napi); - } =20 - if (test_bit(PHY_RESET, &tp->flags)) + if (test_and_clear_bit(PHY_RESET, &tp->flags)) rtl_phy_reset(tp); =20 mutex_unlock(&tp->control); --=20 2.14.1