From nobody Mon Feb 9 13:01:20 2026 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 2506F1EBFF7 for ; Sat, 31 Jan 2026 02:19:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769825960; cv=none; b=dID7kA4em8PWR7MgVPz9XGE791BAsogZTe3uL5qyCTfDIjTU/kJe1v9GBVepA9GsiQh2dVBTHo9qvwFO++TRGjwXlwPuUcQRG90mi2kYxZV/wo6JTej8YJ02AWQWKCfjuePO4+evb3yoJCMNAsNAwVkGPuj+AvbDTnDoLMJcHjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769825960; c=relaxed/simple; bh=DfgWrEGffh9/+P3GtbIsWglSO7Wu0dHRozZJpQB4z7A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mZwsvMrIeaGUKt8ypeYK8qaIGoQ2nNUOm3LE/+CdpQeTa6Noh283fsPLhn+YwP0KCj/6IV2aAZ1YxG/pO7cpGEqIUfaU7oyMJBbvaJKuUEEmJTL4tHF6xp9N7KKFwuWWeyf2XwYfTfKSodmQCGEBBgM0A4uYbJ/dxBSX1Bdb7kw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GaZlFqll; arc=none smtp.client-ip=209.85.215.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GaZlFqll" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-c635559e1c3so1127657a12.0 for ; Fri, 30 Jan 2026 18:19:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769825958; x=1770430758; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+/I+oT8E/nunUvWBaGvhrVbfUpyTt006WYcjriTKPhY=; b=GaZlFqllJoTTlgmMhdPLg7G/3OIMq/tuR++QDZ9wZ0rq165Ti5/cp6FvfS5BJH33d5 Ya+B+zQRjz1UKF3HS3koMfQh8oV9MAuLswB/6rxC8CdAXFdkQZN2l8vcisBVZSmmSPIF Zpbz+qO4gMiJjMfauixObjogBIgSlxe9r3DOpXdhaHzkWMN5TPIyCDGHtuY+uA12uxTD k84QApkw9L/uWiLzhpR1nIJepbFpUOTrrk1iQTuoGOpmO0d6K6t5iD1aLE0DlKKN8/UA Gh0k1En0ohbxBgP7FLGhQnxhgDQXikrp49EKLecsyCYxBJc5BGNnwl22T96wFDLEcql0 aOCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769825958; x=1770430758; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+/I+oT8E/nunUvWBaGvhrVbfUpyTt006WYcjriTKPhY=; b=fdzhwb2mygHOlVzGMHZUqjab8SPiHQvjvLJOh+60Q22+GwnKAm+aimhqwP10/HGwGH hf2sz58JPQ2PyeonzQu+y5MAJJ5rxAz3AR7dl2eZgpHwq8thQ/6twkTn335ws2+51i+a wtTh3ll1ze7Mv4EO4RxjJEYHyLSsTAHzcX/0dOuvOlpgatgmaVC6ZDQXLT7CGvBA302/ ye3NnGsQDm1wHgSzzYAOGXRLFiPH5qW82sx8Vl4iMZqtWKjUoBxLu2IrUyKHwZpKL+Hk S0ueZ5MKNdFoSQvZecFQHZlP3d2eMfLmHt8VFBSNu94/48bWi4V62Gc3ltnhQqZv2JMX zLuw== X-Forwarded-Encrypted: i=1; AJvYcCWMlphVNbj6ID4HnkcpSSqx0guRYHCcdzl8Ix/ZQohUWS40nBYFYR20rfuuPIlqKRwp6SRtkAtjfkL4rgo=@vger.kernel.org X-Gm-Message-State: AOJu0Yyc63GhjBIGyyg+FZHYwaN0zdbMDUOwvPX4NVAk+QfEO4Se5Hd6 oMJ/KKxpN6XTLnn5msg0skFfhnoalSMxYrx3nvr6uSbcoIqXKwteIUj6 X-Gm-Gg: AZuq6aJM6yhi+Ss6z4WvJppNQee6pUi0DVuVUMyAx3Ntax+aS2e1vfxkx/j80WJ1M6N tL6QoWJbiAzqHZfz15YzP9ZaqUZZZpO//Apto8LD18eemkTJOaa41kbl99ph8fkb4ueSke+6Ivu nE8pyNx+DyG8jUZkvzb3AsxPtXaSyh1ATJZ05eAmJD/BsSt+/H94xin2y50LwNJIF5EjtHT3xWe ypgWrxe/NHdr2ZeGJbp/aI9x+ARV5AOgaPSuUqQPiJPEQLk9G7DOTiaH6JFn62Mhs0nss8cVAAt KvdjyTM4DJgh4ngtUZm0AZ/rSCpZg+duTbjbzcNsmRAOqCIMbUPmyUSxAUkY0HanWyXUKdAwdSz aNBRCHzIe+aXiUlgmCRtYI0e7HPD0qu2kfjwCvdeOg9O2rL7iI72lNr4uwKXS3oyj0UHaJKsbJ/ EAXscE3cGKUGXBUu6QU5Y7y4CyEsl07+/nw9k= X-Received: by 2002:a17:903:198e:b0:2a0:d0ae:454d with SMTP id d9443c01a7336-2a8bd4f11a7mr78003725ad.22.1769825958448; Fri, 30 Jan 2026 18:19:18 -0800 (PST) Received: from d.home.mmyangfl.tk ([2a09:bac1:7680:d30::4:384]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a88b3eeebcsm83427365ad.10.2026.01.30.18.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jan 2026 18:19:18 -0800 (PST) From: David Yang To: netdev@vger.kernel.org Cc: David Yang , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v6 3/5] net: dsa: yt921x: Refactor VLAN awareness setting Date: Sat, 31 Jan 2026 10:18:49 +0800 Message-ID: <20260131021854.3405036-4-mmyangfl@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260131021854.3405036-1-mmyangfl@gmail.com> References: <20260131021854.3405036-1-mmyangfl@gmail.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 Content-Type: text/plain; charset="utf-8" Create a helper function to centralize the logic for enabling and disabling VLAN awareness on a port. Signed-off-by: David Yang --- drivers/net/dsa/yt921x.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/net/dsa/yt921x.c b/drivers/net/dsa/yt921x.c index d82608154c4f..c2998b6ae535 100644 --- a/drivers/net/dsa/yt921x.c +++ b/drivers/net/dsa/yt921x.c @@ -1769,6 +1769,18 @@ yt921x_dsa_port_mdb_add(struct dsa_switch *ds, int p= ort, return res; } =20 +static int +yt921x_vlan_aware_set(struct yt921x_priv *priv, int port, bool vlan_aware) +{ + u32 ctrl; + + if (!vlan_aware) + ctrl =3D 0; + else + ctrl =3D YT921X_PORT_IGR_TPIDn_CTAG(0); + return yt921x_reg_write(priv, YT921X_PORTn_IGR_TPID(port), ctrl); +} + static int yt921x_port_set_pvid(struct yt921x_priv *priv, int port, u16 vid) { @@ -1818,14 +1830,7 @@ yt921x_vlan_filtering(struct yt921x_priv *priv, int = port, bool vlan_filtering) if (res) return res; =20 - /* Turn on / off VLAN awareness */ - mask =3D YT921X_PORT_IGR_TPIDn_CTAG_M; - if (!vlan_filtering) - ctrl =3D 0; - else - ctrl =3D YT921X_PORT_IGR_TPIDn_CTAG(0); - res =3D yt921x_reg_update_bits(priv, YT921X_PORTn_IGR_TPID(port), - mask, ctrl); + res =3D yt921x_vlan_aware_set(priv, port, vlan_filtering); if (res) return res; =20 @@ -2022,8 +2027,7 @@ static int yt921x_userport_standalone(struct yt921x_p= riv *priv, int port) return res; =20 /* Turn off VLAN awareness */ - mask =3D YT921X_PORT_IGR_TPIDn_CTAG_M; - res =3D yt921x_reg_clear_bits(priv, YT921X_PORTn_IGR_TPID(port), mask); + res =3D yt921x_vlan_aware_set(priv, port, false); if (res) return res; =20 --=20 2.51.0