From nobody Sat Nov 23 07:37:16 2024 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FFBE192B9A; Fri, 15 Nov 2024 09:55:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.75.126.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731664515; cv=none; b=sQzl7jjNDN7i0q0qNBQmawqRRZw83n4vmTRKhSb7uxovG96HRAh/oiGLpT2qkmUOttZE9vDV9Te+m4KjVFkZCZla1OwHS1h7kw3Swl53Y9S4MBHnfHl2epdY7na6hzx3ahAQ9AHWO9cKwKPXWiuu5mCXf/Lp3KSuyHmjRwi3yOw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731664515; c=relaxed/simple; bh=QfVWlreJZg/l0pgy+fenk87ylKvpPC5vFMVGj7hj1Pk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W80dSNBKzFxHVznfryf4YMQh4KyusNZg6PGvyW12OkJ9moJugRY982tCt/Zg/fpyubFY4FzsYY1PP0/kRkuHxS77z3bBnEuZbOkLok9YNP1fjike4RO6YEnFsDvrjVUoZvMdLInpoMnZJ93heE1DhDN/LEtzW5KyYf3McXEXE3c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realtek.com; spf=pass smtp.mailfrom=realtek.com; dkim=temperror (0-bit key) header.d=realtek.com header.i=@realtek.com header.b=NRkbd/zB; arc=none smtp.client-ip=211.75.126.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realtek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realtek.com Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=realtek.com header.i=@realtek.com header.b="NRkbd/zB" X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 4AF9srBZ3284339, This message is accepted by code: ctloc85258 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=realtek.com; s=dkim; t=1731664493; bh=QfVWlreJZg/l0pgy+fenk87ylKvpPC5vFMVGj7hj1Pk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type; b=NRkbd/zBiFbpAVh4qtmXTAU8qEP7Mjqs13+bmkM+q43bjq9NUBciknOlhr0zMZYBT 0uccR59bha0qIy+qZmxArnDxLNp1MM6T+CB86kED0TYj9KiZOh9cZVsivJfPJPBR8i cj2EbkX5qDnn8+VGPL4JQcPiPxHrNWL63oX5Rg9ke1VXcUoipvrY6r799fGcSpg7z3 NsxZiwZmh6p3fZj3tw9NpixS1tRo0nvX8sZHQtrYrhBAGWfy37AGQ0VjxbQLl4SBwm gCM3eN/KmB3ehMgAtBz8GYEYvm63ewjPJEtGtQy7yDreUizqEuyN5lQWi1TQAEYL+b znCZqLvUaSVsg== Received: from mail.realtek.com (rtexh36505.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/3.06/5.92) with ESMTPS id 4AF9srBZ3284339 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2024 17:54:53 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36505.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 15 Nov 2024 17:54:54 +0800 Received: from RTDOMAIN (172.21.210.74) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 15 Nov 2024 17:54:53 +0800 From: Justin Lai To: CC: , , , , , , , , , Justin Lai Subject: [PATCH net v2 1/5] rtase: Refactor the rtase_check_mac_version_valid() function Date: Fri, 15 Nov 2024 17:54:25 +0800 Message-ID: <20241115095429.399029-2-justinlai0215@realtek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115095429.399029-1-justinlai0215@realtek.com> References: <20241115095429.399029-1-justinlai0215@realtek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: RTEXH36505.realtek.com.tw (172.21.6.25) To RTEXMBS04.realtek.com.tw (172.21.6.97) Content-Type: text/plain; charset="utf-8" 1. Sets tp->hw_ver. 2. Changes the return type from bool to int. 3. Modify the error message for an invalid hardware version id. Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this module") Signed-off-by: Justin Lai --- drivers/net/ethernet/realtek/rtase/rtase.h | 2 ++ .../net/ethernet/realtek/rtase/rtase_main.c | 22 +++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/realtek/rtase/rtase.h b/drivers/net/ether= net/realtek/rtase/rtase.h index 583c33930f88..547c71937b01 100644 --- a/drivers/net/ethernet/realtek/rtase/rtase.h +++ b/drivers/net/ethernet/realtek/rtase/rtase.h @@ -327,6 +327,8 @@ struct rtase_private { u16 int_nums; u16 tx_int_mit; u16 rx_int_mit; + + u32 hw_ver; }; =20 #define RTASE_LSO_64K 64000 diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/= ethernet/realtek/rtase/rtase_main.c index f8777b7663d3..0c19c5645d53 100644 --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c @@ -1972,20 +1972,21 @@ static void rtase_init_software_variable(struct pci= _dev *pdev, tp->dev->max_mtu =3D RTASE_MAX_JUMBO_SIZE; } =20 -static bool rtase_check_mac_version_valid(struct rtase_private *tp) +static int rtase_check_mac_version_valid(struct rtase_private *tp) { - u32 hw_ver =3D rtase_r32(tp, RTASE_TX_CONFIG_0) & RTASE_HW_VER_MASK; - bool known_ver =3D false; + int ret =3D -ENODEV; =20 - switch (hw_ver) { + tp->hw_ver =3D rtase_r32(tp, RTASE_TX_CONFIG_0) & RTASE_HW_VER_MASK; + + switch (tp->hw_ver) { case 0x00800000: case 0x04000000: case 0x04800000: - known_ver =3D true; + ret =3D 0; break; } =20 - return known_ver; + return ret; } =20 static int rtase_init_board(struct pci_dev *pdev, struct net_device **dev_= out, @@ -2105,9 +2106,12 @@ static int rtase_init_one(struct pci_dev *pdev, tp->pdev =3D pdev; =20 /* identify chip attached to board */ - if (!rtase_check_mac_version_valid(tp)) - return dev_err_probe(&pdev->dev, -ENODEV, - "unknown chip version, contact rtase maintainers (see MAINTAINERS= file)\n"); + ret =3D rtase_check_mac_version_valid(tp); + if (ret !=3D 0) { + dev_err(&pdev->dev, + "unknown chip version: 0x%08x, contact rtase maintainers (see MAINTAINE= RS file)\n", + tp->hw_ver); + } =20 rtase_init_software_variable(pdev, tp); rtase_init_hardware(tp); --=20 2.34.1