From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam01on0127.outbound.protection.outlook.com ([104.47.32.127]:39117 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932553AbeDIAkT (ORCPT ); Sun, 8 Apr 2018 20:40:19 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: hayeswang , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 3.18 035/101] r8152: add byte_enable for ocp_read_word function Date: Mon, 9 Apr 2018 00:35:43 +0000 Message-ID: <20180409003505.164715-35-alexander.levin@microsoft.com> References: <20180409003505.164715-1-alexander.levin@microsoft.com> In-Reply-To: <20180409003505.164715-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 [ Upstream commit d8fbd27469fc02049c674de296a3263bef089131 ] Add byte_enable for ocp_read_word() to replace reading 4 bytes data with reading the desired 2 bytes data. This is used to avoid the issue which is described in commit b4d99def0938 ("r8152: remove sram_read"). The original method always reads 4 bytes data, and it may have problem when reading the PHY registers. The new method is supported since RTL8153B, but it doesn't influence the previous chips. The bits of the byte_enable for the previous chips are the reserved bits, and the hw would ignore them. Signed-off-by: Hayes Wang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/r8152.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 31cb1cda7166..c0b6b8875eac 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -804,11 +804,13 @@ static u16 ocp_read_word(struct r8152 *tp, u16 type, = u16 index) { u32 data; __le32 tmp; + u16 byen =3D BYTE_EN_WORD; u8 shift =3D index & 2; =20 index &=3D ~3; + byen <<=3D shift; =20 - generic_ocp_read(tp, index, sizeof(tmp), &tmp, type); + generic_ocp_read(tp, index, sizeof(tmp), &tmp, type | byen); =20 data =3D __le32_to_cpu(tmp); data >>=3D (shift * 8); --=20 2.15.1