From patchwork Tue Jan 23 21:44:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 13528167 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 D8C753A8EE for ; Tue, 23 Jan 2024 21:44:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046275; cv=none; b=vCR/EvqQLKeCrS7a3VmXAP3xl3Ws/QXamxlgKXuHLF1NfOPeHVeTP8w7RdolTTqkf26g1Ah31O8r+l2yFtsDuO/J7cFxEzMmTSci2QVqnLQyHTfm2RGcc5aPrJNAR7U4Dpt0XJSEjvyBIwTt0OUFgKtIdYdPy7suWIoSXmf3aiU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046275; c=relaxed/simple; bh=dQad2+Z/Xb/mU7me8aRLowsUyHw4NHkMWxImuVtMQuQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=INcHFNVf/QSr3eNO4Ft6KBXHRBb4dD7Z4E0v4geD96dQtnhZeO/k4u3hGRhi4S4K7nc9gWri6S7BE8nKMqBYt2sg8Yg7+UZQ4UgS92HhRHTXDrpSWta6RdiSJJ01citZIqU6snd7YA0xKgbzNJGwSHK5JhkaR+xZEs6FrywpbZ0= 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=Ym9Nmxr/; arc=none smtp.client-ip=209.85.214.169 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="Ym9Nmxr/" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1d711d7a940so41843415ad.1 for ; Tue, 23 Jan 2024 13:44:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706046272; x=1706651072; 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=uhR6ETdnDbAnJOABgKbs6pb2nligN/fWqMlDmzJKoA0=; b=Ym9Nmxr/c/yn9y134If2wHxp2oGmXbk6bh9M8vinxkHxhHPDQIcKQVWzzI+8MRdo92 4306pUzH4nlae7Pq7Wv/DvgHisS9buwSJeFgQV9S+Hk10PgTE9P1d5kHrnDidvLE5/BD rHZH/7mGqIWxZX17s8hT2igq0/68wR5agpcbMHV/FUyAzpVLa442U1kTYyYD3ZsFWNpX rZxd1KkRDG/YnMGZPi084p1SfWIs5lQVreOPz+Q7zl/+D8ChGKJQuCLMNpIZ8N5GcyLp ddyGZU3Ep2RRYdf3woazOZ62DiLkqruu9ti5zE3FY0g9MOQuDEDiEamp5bprDrXsAAcX UoOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706046272; x=1706651072; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uhR6ETdnDbAnJOABgKbs6pb2nligN/fWqMlDmzJKoA0=; b=V7VAKJ6Ld8+NrXDbOP95VA46g3VuNbKk3SapZo27VmzVRZpHOLS71jjUCwUTCAn/em QtD2u75/U1N0vKDYEP8Qn8aqpuAvr1umatCOWmNCEmZdivhgcX62d6as7E1VpZpr+2uN crKhSLbKzJ7z0gIxE4gQtzKzURW9kMaUIzlJwGZ5iqyER3F3lw1OIrqhb+FFM+Z53QQi Xe8BEA6LrWIqPJbH2csu9Nwguihx0VUxmBk/abdb0POHUkKFjNDpaZ2WEFpcdZUsme1R BlrDvaeoFFh4F4RDbKB4L2KwR0eDVwEMev+SEI1SLiDpdZBLvHL6kmK1YZuPUfwCpf90 qotA== X-Gm-Message-State: AOJu0YypMAjoeBD6q4ucQFmH85noSLsrx19EUiGjJA00VUCgaxH6W3iD 2pN4EK+HBbx8I+ljFglWVjfc0Ob7esFlHJlDuVAaEDdXlsTEG+N/luyy60HDt9g= X-Google-Smtp-Source: AGHT+IG+lm6wBs6IpeSOgrJA+2myvCAPTCHva9NAotIG0A4kRwo9Dl+Ys3VxUxmqMA0AamunkU5S1A== X-Received: by 2002:a17:903:1107:b0:1d3:f1ca:6a13 with SMTP id n7-20020a170903110700b001d3f1ca6a13mr7164686plh.109.1706046272199; Tue, 23 Jan 2024 13:44:32 -0800 (PST) Received: from tresc054937.tre-sc.gov.br ([187.94.103.218]) by smtp.gmail.com with ESMTPSA id t10-20020a170902bc4a00b001d714a1530bsm8108858plz.176.2024.01.23.13.44.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:44:31 -0800 (PST) From: Luiz Angelo Daros de Luca To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, arinc.unal@arinc9.com, ansuelsmth@gmail.com, Luiz Angelo Daros de Luca , Florian Fainelli Subject: [PATCH 01/11] net: dsa: realtek: drop cleanup from realtek_ops Date: Tue, 23 Jan 2024 18:44:09 -0300 Message-ID: <20240123214420.25716-2-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123214420.25716-1-luizluca@gmail.com> References: <20240123214420.25716-1-luizluca@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org It was never used and never referenced. Signed-off-by: Luiz Angelo Daros de Luca Reviewed-by: Alvin Šipraga Reviewed-by: Florian Fainelli Reviewed-by: Linus Walleij --- drivers/net/dsa/realtek/realtek.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h index 790488e9c667..e9ee778665b2 100644 --- a/drivers/net/dsa/realtek/realtek.h +++ b/drivers/net/dsa/realtek/realtek.h @@ -91,7 +91,6 @@ struct realtek_ops { int (*detect)(struct realtek_priv *priv); int (*reset_chip)(struct realtek_priv *priv); int (*setup)(struct realtek_priv *priv); - void (*cleanup)(struct realtek_priv *priv); int (*get_mib_counter)(struct realtek_priv *priv, int port, struct rtl8366_mib_counter *mib, From patchwork Tue Jan 23 21:44:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 13528168 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 E2BC739AE5 for ; Tue, 23 Jan 2024 21:44:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046279; cv=none; b=kZTH77qzfvuQkgC86X9TGiMCZ/B0FshIiebyXErLMFDvBZYu+VRBQr+R8nGy6MSBOEI3zJnK/LOgc/yl2gbYiyQ/9QNuNEeOq+wIsKPK9D/Zh0hJOiwShz5ST66RQp66lg0QeOiiYezwT+33UHRRVucFd7j0iMLmQ82OFYJ9HQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046279; c=relaxed/simple; bh=JxlhgfKDAH9pG+T7CbuWIczAu124O8TR8etJzIuzVIc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cuqiZtynVmOU8vqVQAyO1o3n5FEKkPhYKLIq50mU3OmXzMKYUw4xxZ5PAp+oRKruqB6wuZVu5Ll29oublVgsaxxyF5DrMe+6owLCe8lmxbIQ9R3PwA287CLapJZ1IXMSbqW3BRELhSg0SkCFP6A+Hco/nD7Dl3aKpd8RiL8OmGs= 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=jHQ42DCm; arc=none smtp.client-ip=209.85.214.180 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="jHQ42DCm" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1d73066880eso27679605ad.3 for ; Tue, 23 Jan 2024 13:44:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706046276; x=1706651076; 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=dOT+C6LeaBh5H7EKXV1iub7JX9Ztsgpq6Az56Cc9H5k=; b=jHQ42DCmTRKSS6t0VFmU1AJc+gINM6dG5z679GLvDKJpnclnkpaqcR7L/C16JXwhEm 8jfDR8UeGaiwZItVxgB7JNS8wRcuOUFJQ6HwlT27nlh9vMziNtt30tgB8EaEvrI7zXeL +FHeg/GF6v4bgJNnoKbxasfA8ErHdboNU+V5ietnWPDUa+JtDinM0xcDfUzxmWE8QAOr 0wbg2eD+OcejZC1LMeibJ4UPGPsP9QJEHi6xy1A/HmFiC6bWBSFM14tcyjWkA2CVFG83 AcndsxO6DcOB72WNe5KKvOoePerFu2py4/o/lwNbI0xrcCAJiALZvbUlmQXNZcLxjlRO vNug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706046276; x=1706651076; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dOT+C6LeaBh5H7EKXV1iub7JX9Ztsgpq6Az56Cc9H5k=; b=Ob7hanEvvODCzNOWl7tegZNbr41ezO4XtYnPhhWOs/bHXby+6ene5zuKJbb7kDSkGD mtLw+FZXvmg93aXEkJxB3DPI4u2+zXgllFQFFS2vp1qSr+JVdW9Qou1kVy5Sj1Q4qJUt T6rCxDMJW6PgAxJ6b/0f1oKIeCCT3+2lU0KLdfxHOH/MztUSiEbWx5bKSQxiW/m5XdQD QNplCMtqaq/J/Du/bv76O+toxPn8M//4OZDlsAo7zYnI+kjBvtfWNO2v/0w8dPMuyk/C P6Pi8yOkywH4VP7cHlQYghoE6FfHoY4kErWKyQerAPLyCqrDtB/i6l7zOYGUGBmE8Q5v S0Rg== X-Gm-Message-State: AOJu0YzN4yA96R7oTeyvBRglxWGrBegFEY10tmj7kbi7i/3ZUXUhM/hh SVPPw6dc1z3M6//6f72pegdEqh8ZsdpdUeK4hKB28USm0pSi65LCHwzbng+FyRY= X-Google-Smtp-Source: AGHT+IGoaBmsXUcbwSEbesKEcFiz6JliQ+rvBy+4K91T34yX35Dw4Ay9YdpEX//b1wWpgRrXutcxpA== X-Received: by 2002:a17:902:d489:b0:1d7:752f:1e23 with SMTP id c9-20020a170902d48900b001d7752f1e23mr1145162plg.76.1706046276320; Tue, 23 Jan 2024 13:44:36 -0800 (PST) Received: from tresc054937.tre-sc.gov.br ([187.94.103.218]) by smtp.gmail.com with ESMTPSA id t10-20020a170902bc4a00b001d714a1530bsm8108858plz.176.2024.01.23.13.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:44:35 -0800 (PST) From: Luiz Angelo Daros de Luca To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, arinc.unal@arinc9.com, ansuelsmth@gmail.com, Luiz Angelo Daros de Luca Subject: [PATCH 02/11] net: dsa: realtek: introduce REALTEK_DSA namespace Date: Tue, 23 Jan 2024 18:44:10 -0300 Message-ID: <20240123214420.25716-3-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123214420.25716-1-luizluca@gmail.com> References: <20240123214420.25716-1-luizluca@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Create a namespace to group the exported symbols. Signed-off-by: Luiz Angelo Daros de Luca --- drivers/net/dsa/realtek/realtek-mdio.c | 2 ++ drivers/net/dsa/realtek/realtek-smi.c | 2 ++ drivers/net/dsa/realtek/rtl8365mb.c | 2 ++ drivers/net/dsa/realtek/rtl8366-core.c | 22 +++++++++++----------- drivers/net/dsa/realtek/rtl8366rb.c | 2 ++ 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c index 292e6d087e8b..df214b2f60d1 100644 --- a/drivers/net/dsa/realtek/realtek-mdio.c +++ b/drivers/net/dsa/realtek/realtek-mdio.c @@ -288,3 +288,5 @@ mdio_module_driver(realtek_mdio_driver); MODULE_AUTHOR("Luiz Angelo Daros de Luca "); MODULE_DESCRIPTION("Driver for Realtek ethernet switch connected via MDIO interface"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(REALTEK_DSA); + diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c index 755546ed8db6..f628b54de538 100644 --- a/drivers/net/dsa/realtek/realtek-smi.c +++ b/drivers/net/dsa/realtek/realtek-smi.c @@ -565,3 +565,5 @@ module_platform_driver(realtek_smi_driver); MODULE_AUTHOR("Linus Walleij "); MODULE_DESCRIPTION("Driver for Realtek ethernet switch connected via SMI interface"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(REALTEK_DSA); + diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c index b072045eb154..462d5a9a280e 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -2177,3 +2177,5 @@ EXPORT_SYMBOL_GPL(rtl8365mb_variant); MODULE_AUTHOR("Alvin Šipraga "); MODULE_DESCRIPTION("Driver for RTL8365MB-VC ethernet switch"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(REALTEK_DSA); + diff --git a/drivers/net/dsa/realtek/rtl8366-core.c b/drivers/net/dsa/realtek/rtl8366-core.c index 59f98d2c8769..7c6520ba3a26 100644 --- a/drivers/net/dsa/realtek/rtl8366-core.c +++ b/drivers/net/dsa/realtek/rtl8366-core.c @@ -34,7 +34,7 @@ int rtl8366_mc_is_used(struct realtek_priv *priv, int mc_index, int *used) return 0; } -EXPORT_SYMBOL_GPL(rtl8366_mc_is_used); +EXPORT_SYMBOL_NS_GPL(rtl8366_mc_is_used, REALTEK_DSA); /** * rtl8366_obtain_mc() - retrieve or allocate a VLAN member configuration @@ -187,7 +187,7 @@ int rtl8366_set_vlan(struct realtek_priv *priv, int vid, u32 member, return ret; } -EXPORT_SYMBOL_GPL(rtl8366_set_vlan); +EXPORT_SYMBOL_NS_GPL(rtl8366_set_vlan, REALTEK_DSA); int rtl8366_set_pvid(struct realtek_priv *priv, unsigned int port, unsigned int vid) @@ -217,7 +217,7 @@ int rtl8366_set_pvid(struct realtek_priv *priv, unsigned int port, return 0; } -EXPORT_SYMBOL_GPL(rtl8366_set_pvid); +EXPORT_SYMBOL_NS_GPL(rtl8366_set_pvid, REALTEK_DSA); int rtl8366_enable_vlan4k(struct realtek_priv *priv, bool enable) { @@ -243,7 +243,7 @@ int rtl8366_enable_vlan4k(struct realtek_priv *priv, bool enable) priv->vlan4k_enabled = enable; return 0; } -EXPORT_SYMBOL_GPL(rtl8366_enable_vlan4k); +EXPORT_SYMBOL_NS_GPL(rtl8366_enable_vlan4k, REALTEK_DSA); int rtl8366_enable_vlan(struct realtek_priv *priv, bool enable) { @@ -265,7 +265,7 @@ int rtl8366_enable_vlan(struct realtek_priv *priv, bool enable) return ret; } -EXPORT_SYMBOL_GPL(rtl8366_enable_vlan); +EXPORT_SYMBOL_NS_GPL(rtl8366_enable_vlan, REALTEK_DSA); int rtl8366_reset_vlan(struct realtek_priv *priv) { @@ -290,7 +290,7 @@ int rtl8366_reset_vlan(struct realtek_priv *priv) return 0; } -EXPORT_SYMBOL_GPL(rtl8366_reset_vlan); +EXPORT_SYMBOL_NS_GPL(rtl8366_reset_vlan, REALTEK_DSA); int rtl8366_vlan_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan, @@ -345,7 +345,7 @@ int rtl8366_vlan_add(struct dsa_switch *ds, int port, return 0; } -EXPORT_SYMBOL_GPL(rtl8366_vlan_add); +EXPORT_SYMBOL_NS_GPL(rtl8366_vlan_add, REALTEK_DSA); int rtl8366_vlan_del(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan) @@ -389,7 +389,7 @@ int rtl8366_vlan_del(struct dsa_switch *ds, int port, return 0; } -EXPORT_SYMBOL_GPL(rtl8366_vlan_del); +EXPORT_SYMBOL_NS_GPL(rtl8366_vlan_del, REALTEK_DSA); void rtl8366_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *data) @@ -403,7 +403,7 @@ void rtl8366_get_strings(struct dsa_switch *ds, int port, u32 stringset, for (i = 0; i < priv->num_mib_counters; i++) ethtool_puts(&data, priv->mib_counters[i].name); } -EXPORT_SYMBOL_GPL(rtl8366_get_strings); +EXPORT_SYMBOL_NS_GPL(rtl8366_get_strings, REALTEK_DSA); int rtl8366_get_sset_count(struct dsa_switch *ds, int port, int sset) { @@ -417,7 +417,7 @@ int rtl8366_get_sset_count(struct dsa_switch *ds, int port, int sset) return priv->num_mib_counters; } -EXPORT_SYMBOL_GPL(rtl8366_get_sset_count); +EXPORT_SYMBOL_NS_GPL(rtl8366_get_sset_count, REALTEK_DSA); void rtl8366_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data) { @@ -441,4 +441,4 @@ void rtl8366_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data) data[i] = mibvalue; } } -EXPORT_SYMBOL_GPL(rtl8366_get_ethtool_stats); +EXPORT_SYMBOL_NS_GPL(rtl8366_get_ethtool_stats, REALTEK_DSA); diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c index e3b6a470ca67..baeab5445d99 100644 --- a/drivers/net/dsa/realtek/rtl8366rb.c +++ b/drivers/net/dsa/realtek/rtl8366rb.c @@ -1938,3 +1938,5 @@ EXPORT_SYMBOL_GPL(rtl8366rb_variant); MODULE_AUTHOR("Linus Walleij "); MODULE_DESCRIPTION("Driver for RTL8366RB ethernet switch"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(REALTEK_DSA); + From patchwork Tue Jan 23 21:44:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 13528169 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 700F63D566 for ; Tue, 23 Jan 2024 21:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046284; cv=none; b=Sdazm7Cq9WKQvAd3Odt88W5cikFoevNB9uABQHJRQpCfYYFVoCsUqYPsYxExX5pM0kzpusLK2OBitzdSafACndLNeWWP/W0Fs8py3F8LZi4pz2bGSH4aqVCPuGz998XUakG392SfAwzYFB2JVrVGKLyIqx+t81HoS4Ry4BUcdyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046284; c=relaxed/simple; bh=5aALzbuhfhobesH+1J/zCqBKWfr8+X/99JULSE4qCD0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q8GxoqiSCwfhneIJJL4MFvWMiACS7OQX3kf3kAkoeRw/0f3/mq1W/8/Li39LkQW0kQ6IfuudphMihFY1w46xJIIIMupug0xSKUS7lQEhez+qf/qwJJlQPQiJCvPvLYp6JDvwaAGgScrzxLislmwWQVsYEfpqPCJ7oR/YVUJIAyE= 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=c4ZyHfwA; arc=none smtp.client-ip=209.85.214.173 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="c4ZyHfwA" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d731314e67so14621435ad.1 for ; Tue, 23 Jan 2024 13:44:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706046281; x=1706651081; 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=X8l162FyL7BsSvEnm9+5KTuz+1GnUBpR9xqcqVw78Y8=; b=c4ZyHfwA29T1i9J+JMwcd/VmUmrmVPjZYFscVsazpzgPlHHg0AVDEnF2DTmtk8oyHg sIjfNRuFPAw5DkXLPlisRTADIsccpPA1c4hNR8LTb6ba7H3SFTqB2FKfShJTennuke76 lTKUjfmM67K6j4W7lstluj8FuYnMe6bgYJ1cdxO2S0BoeGcVlsyM7DOrfRjPfzbjgGyK Ef2SzE1GJ3hodNVwLSk/2UxbMha9CZWbasncEH3fp8wu4M773lwaCMCmz7en23LO4Wxj nx/5/21tBb7mocihRYxs/Mqanrw1c46Q2LsVSNoisxs4LleIvWge53Qa/HylghiVYfh5 7sWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706046281; x=1706651081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X8l162FyL7BsSvEnm9+5KTuz+1GnUBpR9xqcqVw78Y8=; b=A/jnfTsnaSWUQpu/gNLtxiuWxYcYiET4+oTsRHcqHZOYoL1j7x6ALxjAFD8JGB0WCy 0+9VPR2VzuSpSgoo1dl3EGlslHEs2+ZKLcMmn4JIjghl3lV2gVBinOBTobEegJ/a+X8j bqKYfBp9AIXh8W94wSwEetFjbDAbVUCU4fzCbjh7UzvnnlRgiXa/LCdMw1ptVCSJwRjh y6qkP9n/1PIrVl4ocnc8isfFgMpJVFfeFtryOE1vIPLvyuP2dL9c/zRShjcG++RxQcM4 8uQCDcsg68nvH2HUtfgRvQnvbRw5Z9VehFAR8jxk5fViJgjDWE2ChL2jOMFPqOBpAlqB B4iw== X-Gm-Message-State: AOJu0Yxc7AMahheNs4nGSu/LtgMretC2BBCxwX00COWQITVU/Jm1Yqm4 Qk0FVH7oFNB8h7NdfqCLoMS7/m8bVWjf4UEkgnEIUcT5MdNxZua2unJmu+5JD3s= X-Google-Smtp-Source: AGHT+IHIcorwJ3QO0GQe3dFO8/ZwyKlp4iF/JQOjHttRNWzdviCibMnTz1u3fXq7yJSMLZu9zY3+YA== X-Received: by 2002:a17:902:9344:b0:1d4:98fd:376d with SMTP id g4-20020a170902934400b001d498fd376dmr3120813plp.139.1706046280742; Tue, 23 Jan 2024 13:44:40 -0800 (PST) Received: from tresc054937.tre-sc.gov.br ([187.94.103.218]) by smtp.gmail.com with ESMTPSA id t10-20020a170902bc4a00b001d714a1530bsm8108858plz.176.2024.01.23.13.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:44:40 -0800 (PST) From: Luiz Angelo Daros de Luca To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, arinc.unal@arinc9.com, ansuelsmth@gmail.com, Luiz Angelo Daros de Luca Subject: [PATCH 03/11] net: dsa: realtek: convert variants into real drivers Date: Tue, 23 Jan 2024 18:44:11 -0300 Message-ID: <20240123214420.25716-4-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123214420.25716-1-luizluca@gmail.com> References: <20240123214420.25716-1-luizluca@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Previously, the interface modules realtek-smi and realtek-mdio served as a platform and an MDIO driver, respectively. Each interface module redundantly specified the same compatible strings for both variants and referenced symbols from the variants. Now, each variant module has been transformed into a unified driver serving both as a platform and an MDIO driver. This modification reverses the relationship between the interface and variant modules, with the variant module now utilizing symbols from the interface modules. Signed-off-by: Luiz Angelo Daros de Luca --- drivers/net/dsa/realtek/Kconfig | 20 ++----- drivers/net/dsa/realtek/realtek-mdio.c | 71 ++++++++++++++---------- drivers/net/dsa/realtek/realtek-mdio.h | 48 ++++++++++++++++ drivers/net/dsa/realtek/realtek-smi.c | 76 +++++++++++++++----------- drivers/net/dsa/realtek/realtek-smi.h | 48 ++++++++++++++++ drivers/net/dsa/realtek/rtl8365mb.c | 54 +++++++++++++++++- drivers/net/dsa/realtek/rtl8366rb.c | 54 +++++++++++++++++- 7 files changed, 294 insertions(+), 77 deletions(-) create mode 100644 drivers/net/dsa/realtek/realtek-mdio.h create mode 100644 drivers/net/dsa/realtek/realtek-smi.h diff --git a/drivers/net/dsa/realtek/Kconfig b/drivers/net/dsa/realtek/Kconfig index 060165a85fb7..9d182fde11b4 100644 --- a/drivers/net/dsa/realtek/Kconfig +++ b/drivers/net/dsa/realtek/Kconfig @@ -16,37 +16,29 @@ menuconfig NET_DSA_REALTEK if NET_DSA_REALTEK config NET_DSA_REALTEK_MDIO - tristate "Realtek MDIO interface driver" + tristate "Realtek MDIO interface support" depends on OF - depends on NET_DSA_REALTEK_RTL8365MB || NET_DSA_REALTEK_RTL8366RB - depends on NET_DSA_REALTEK_RTL8365MB || !NET_DSA_REALTEK_RTL8365MB - depends on NET_DSA_REALTEK_RTL8366RB || !NET_DSA_REALTEK_RTL8366RB help Select to enable support for registering switches configured through MDIO. config NET_DSA_REALTEK_SMI - tristate "Realtek SMI interface driver" + tristate "Realtek SMI interface support" depends on OF - depends on NET_DSA_REALTEK_RTL8365MB || NET_DSA_REALTEK_RTL8366RB - depends on NET_DSA_REALTEK_RTL8365MB || !NET_DSA_REALTEK_RTL8365MB - depends on NET_DSA_REALTEK_RTL8366RB || !NET_DSA_REALTEK_RTL8366RB help Select to enable support for registering switches connected through SMI. config NET_DSA_REALTEK_RTL8365MB - tristate "Realtek RTL8365MB switch subdriver" - imply NET_DSA_REALTEK_SMI - imply NET_DSA_REALTEK_MDIO + tristate "Realtek RTL8365MB switch driver" + depends on NET_DSA_REALTEK_SMI || NET_DSA_REALTEK_MDIO select NET_DSA_TAG_RTL8_4 help Select to enable support for Realtek RTL8365MB-VC and RTL8367S. config NET_DSA_REALTEK_RTL8366RB - tristate "Realtek RTL8366RB switch subdriver" - imply NET_DSA_REALTEK_SMI - imply NET_DSA_REALTEK_MDIO + tristate "Realtek RTL8366RB switch driver" + depends on NET_DSA_REALTEK_SMI || NET_DSA_REALTEK_MDIO select NET_DSA_TAG_RTL4_A help Select to enable support for Realtek RTL8366RB. diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c index df214b2f60d1..22a63f41e3f2 100644 --- a/drivers/net/dsa/realtek/realtek-mdio.c +++ b/drivers/net/dsa/realtek/realtek-mdio.c @@ -25,6 +25,7 @@ #include #include "realtek.h" +#include "realtek-mdio.h" /* Read/write via mdiobus */ #define REALTEK_MDIO_CTRL0_REG 31 @@ -140,7 +141,20 @@ static const struct regmap_config realtek_mdio_nolock_regmap_config = { .disable_locking = true, }; -static int realtek_mdio_probe(struct mdio_device *mdiodev) +/** + * realtek_mdio_probe() - Probe a platform device for an MDIO-connected switch + * @pdev: platform_device to probe on. + * + * This function should be used as the .probe in an mdio_driver. It + * initializes realtek_priv and read data from the device-tree node. The switch + * is hard resetted if a method is provided. It checks the switch chip ID and, + * finally, a DSA switch is registered. + * + * Context: Any context. Takes and releases priv->map_lock. + * Return: Returns 0 on success, a negative error on failure. + * + */ +int realtek_mdio_probe(struct mdio_device *mdiodev) { struct realtek_priv *priv; struct device *dev = &mdiodev->dev; @@ -235,8 +249,21 @@ static int realtek_mdio_probe(struct mdio_device *mdiodev) return 0; } +EXPORT_SYMBOL_NS_GPL(realtek_mdio_probe, REALTEK_DSA); -static void realtek_mdio_remove(struct mdio_device *mdiodev) +/** + * realtek_mdio_remove() - Remove the driver of an MDIO-connected switch + * @pdev: platform_device to probe on. + * + * This function should be used as the .remove_new in an mdio_driver. First + * it unregisters the DSA switch and cleans internal data. If a method is + * provided, the hard reset is asserted to avoid traffic leakage. + * + * Context: Any context. + * Return: Nothing. + * + */ +void realtek_mdio_remove(struct mdio_device *mdiodev) { struct realtek_priv *priv = dev_get_drvdata(&mdiodev->dev); @@ -249,8 +276,20 @@ static void realtek_mdio_remove(struct mdio_device *mdiodev) if (priv->reset) gpiod_set_value(priv->reset, 1); } +EXPORT_SYMBOL_NS_GPL(realtek_mdio_remove, REALTEK_DSA); -static void realtek_mdio_shutdown(struct mdio_device *mdiodev) +/** + * realtek_mdio_shutdown() - Shutdown the driver of a MDIO-connected switch + * @pdev: platform_device to probe on. + * + * This function should be used as the .shutdown in an mdio_driver. It shuts + * down the DSA switch and cleans the platform driver data. + * + * Context: Any context. + * Return: Nothing. + * + */ +void realtek_mdio_shutdown(struct mdio_device *mdiodev) { struct realtek_priv *priv = dev_get_drvdata(&mdiodev->dev); @@ -261,32 +300,8 @@ static void realtek_mdio_shutdown(struct mdio_device *mdiodev) dev_set_drvdata(&mdiodev->dev, NULL); } - -static const struct of_device_id realtek_mdio_of_match[] = { -#if IS_ENABLED(CONFIG_NET_DSA_REALTEK_RTL8366RB) - { .compatible = "realtek,rtl8366rb", .data = &rtl8366rb_variant, }, -#endif -#if IS_ENABLED(CONFIG_NET_DSA_REALTEK_RTL8365MB) - { .compatible = "realtek,rtl8365mb", .data = &rtl8365mb_variant, }, -#endif - { /* sentinel */ }, -}; -MODULE_DEVICE_TABLE(of, realtek_mdio_of_match); - -static struct mdio_driver realtek_mdio_driver = { - .mdiodrv.driver = { - .name = "realtek-mdio", - .of_match_table = realtek_mdio_of_match, - }, - .probe = realtek_mdio_probe, - .remove = realtek_mdio_remove, - .shutdown = realtek_mdio_shutdown, -}; - -mdio_module_driver(realtek_mdio_driver); +EXPORT_SYMBOL_NS_GPL(realtek_mdio_shutdown, REALTEK_DSA); MODULE_AUTHOR("Luiz Angelo Daros de Luca "); MODULE_DESCRIPTION("Driver for Realtek ethernet switch connected via MDIO interface"); MODULE_LICENSE("GPL"); -MODULE_IMPORT_NS(REALTEK_DSA); - diff --git a/drivers/net/dsa/realtek/realtek-mdio.h b/drivers/net/dsa/realtek/realtek-mdio.h new file mode 100644 index 000000000000..ee70f6a5b8ff --- /dev/null +++ b/drivers/net/dsa/realtek/realtek-mdio.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _REALTEK_MDIO_H +#define _REALTEK_MDIO_H + +#if IS_ENABLED(CONFIG_NET_DSA_REALTEK_MDIO) + +static inline int realtek_mdio_driver_register(struct mdio_driver *drv) +{ + return mdio_driver_register(drv); +} + +static inline void realtek_mdio_driver_unregister(struct mdio_driver *drv) +{ + mdio_driver_unregister(drv); +} + +int realtek_mdio_probe(struct mdio_device *mdiodev); +void realtek_mdio_remove(struct mdio_device *mdiodev); +void realtek_mdio_shutdown(struct mdio_device *mdiodev); + +#else /* IS_ENABLED(CONFIG_NET_DSA_REALTEK_MDIO) */ + +static inline int realtek_mdio_driver_register(struct mdio_driver *drv) +{ + return 0; +} + +static inline void realtek_mdio_driver_unregister(struct mdio_driver *drv) +{ +} + +static inline int realtek_mdio_probe(struct mdio_device *mdiodev) +{ + return -ENOENT; +} + +static inline void realtek_mdio_remove(struct mdio_device *mdiodev) +{ +} + +static inline void realtek_mdio_shutdown(struct mdio_device *mdiodev) +{ +} + +#endif /* IS_ENABLED(CONFIG_NET_DSA_REALTEK_MDIO) */ + +#endif /* _REALTEK_MDIO_H */ diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c index f628b54de538..618547befa13 100644 --- a/drivers/net/dsa/realtek/realtek-smi.c +++ b/drivers/net/dsa/realtek/realtek-smi.c @@ -40,6 +40,7 @@ #include #include "realtek.h" +#include "realtek-smi.h" #define REALTEK_SMI_ACK_RETRY_COUNT 5 @@ -408,7 +409,20 @@ static int realtek_smi_setup_mdio(struct dsa_switch *ds) return ret; } -static int realtek_smi_probe(struct platform_device *pdev) +/** + * realtek_smi_probe() - Probe a platform device for an SMI-connected switch + * @pdev: platform_device to probe on. + * + * This function should be used as the .probe in a platform_driver. It + * initializes realtek_priv and read data from the device-tree node. The switch + * is hard resetted if a method is provided. It checks the switch chip ID and, + * finally, a DSA switch is registered. + * + * Context: Any context. Takes and releases priv->map_lock. + * Return: Returns 0 on success, a negative error on failure. + * + */ +int realtek_smi_probe(struct platform_device *pdev) { const struct realtek_variant *var; struct device *dev = &pdev->dev; @@ -505,8 +519,21 @@ static int realtek_smi_probe(struct platform_device *pdev) } return 0; } +EXPORT_SYMBOL_NS_GPL(realtek_smi_probe, REALTEK_DSA); -static void realtek_smi_remove(struct platform_device *pdev) +/** + * realtek_smi_remove() - Remove the driver of a SMI-connected switch + * @pdev: platform_device to probe on. + * + * This function should be used as the .remove_new in a platform_driver. First + * it unregisters the DSA switch and cleans internal data. If a method is + * provided, the hard reset is asserted to avoid traffic leakage. + * + * Context: Any context. + * Return: Nothing. + * + */ +void realtek_smi_remove(struct platform_device *pdev) { struct realtek_priv *priv = platform_get_drvdata(pdev); @@ -521,8 +548,20 @@ static void realtek_smi_remove(struct platform_device *pdev) if (priv->reset) gpiod_set_value(priv->reset, 1); } +EXPORT_SYMBOL_NS_GPL(realtek_smi_remove, REALTEK_DSA); -static void realtek_smi_shutdown(struct platform_device *pdev) +/** + * realtek_smi_shutdown() - Shutdown the driver of a SMI-connected switch + * @pdev: platform_device to probe on. + * + * This function should be used as the .shutdown in a platform_driver. It shuts + * down the DSA switch and cleans the platform driver data. + * + * Context: Any context. + * Return: Nothing. + * + */ +void realtek_smi_shutdown(struct platform_device *pdev) { struct realtek_priv *priv = platform_get_drvdata(pdev); @@ -533,37 +572,8 @@ static void realtek_smi_shutdown(struct platform_device *pdev) platform_set_drvdata(pdev, NULL); } - -static const struct of_device_id realtek_smi_of_match[] = { -#if IS_ENABLED(CONFIG_NET_DSA_REALTEK_RTL8366RB) - { - .compatible = "realtek,rtl8366rb", - .data = &rtl8366rb_variant, - }, -#endif -#if IS_ENABLED(CONFIG_NET_DSA_REALTEK_RTL8365MB) - { - .compatible = "realtek,rtl8365mb", - .data = &rtl8365mb_variant, - }, -#endif - { /* sentinel */ }, -}; -MODULE_DEVICE_TABLE(of, realtek_smi_of_match); - -static struct platform_driver realtek_smi_driver = { - .driver = { - .name = "realtek-smi", - .of_match_table = realtek_smi_of_match, - }, - .probe = realtek_smi_probe, - .remove_new = realtek_smi_remove, - .shutdown = realtek_smi_shutdown, -}; -module_platform_driver(realtek_smi_driver); +EXPORT_SYMBOL_NS_GPL(realtek_smi_shutdown, REALTEK_DSA); MODULE_AUTHOR("Linus Walleij "); MODULE_DESCRIPTION("Driver for Realtek ethernet switch connected via SMI interface"); MODULE_LICENSE("GPL"); -MODULE_IMPORT_NS(REALTEK_DSA); - diff --git a/drivers/net/dsa/realtek/realtek-smi.h b/drivers/net/dsa/realtek/realtek-smi.h new file mode 100644 index 000000000000..ea49a2edd3c8 --- /dev/null +++ b/drivers/net/dsa/realtek/realtek-smi.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _REALTEK_SMI_H +#define _REALTEK_SMI_H + +#if IS_ENABLED(CONFIG_NET_DSA_REALTEK_SMI) + +static inline int realtek_smi_driver_register(struct platform_driver *drv) +{ + return platform_driver_register(drv); +} + +static inline void realtek_smi_driver_unregister(struct platform_driver *drv) +{ + platform_driver_unregister(drv); +} + +int realtek_smi_probe(struct platform_device *pdev); +void realtek_smi_remove(struct platform_device *pdev); +void realtek_smi_shutdown(struct platform_device *pdev); + +#else /* IS_ENABLED(CONFIG_NET_DSA_REALTEK_SMI) */ + +static inline int realtek_smi_driver_register(struct platform_driver *drv) +{ + return 0; +} + +static inline void realtek_smi_driver_unregister(struct platform_driver *drv) +{ +} + +static inline int realtek_smi_probe(struct platform_device *pdev) +{ + return -ENOENT; +} + +static inline void realtek_smi_remove(struct platform_device *pdev) +{ +} + +static inline void realtek_smi_shutdown(struct platform_device *pdev) +{ +} + +#endif /* IS_ENABLED(CONFIG_NET_DSA_REALTEK_SMI) */ + +#endif /* _REALTEK_SMI_H */ diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c index 462d5a9a280e..bd76bcf5fa44 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -101,6 +101,8 @@ #include #include "realtek.h" +#include "realtek-smi.h" +#include "realtek-mdio.h" /* Family-specific data and limits */ #define RTL8365MB_PHYADDRMAX 7 @@ -2172,7 +2174,57 @@ const struct realtek_variant rtl8365mb_variant = { .cmd_write = 0xb8, .chip_data_sz = sizeof(struct rtl8365mb), }; -EXPORT_SYMBOL_GPL(rtl8365mb_variant); + +static const struct of_device_id rtl8365mb_of_match[] = { + { .compatible = "realtek,rtl8365mb", .data = &rtl8365mb_variant, }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, rtl8365mb_of_match); + +static struct platform_driver rtl8365mb_smi_driver = { + .driver = { + .name = "rtl8365mb-smi", + .of_match_table = rtl8365mb_of_match, + }, + .probe = realtek_smi_probe, + .remove_new = realtek_smi_remove, + .shutdown = realtek_smi_shutdown, +}; + +static struct mdio_driver rtl8365mb_mdio_driver = { + .mdiodrv.driver = { + .name = "rtl8365mb-mdio", + .of_match_table = rtl8365mb_of_match, + }, + .probe = realtek_mdio_probe, + .remove = realtek_mdio_remove, + .shutdown = realtek_mdio_shutdown, +}; + +static int rtl8365mb_init(void) +{ + int ret; + + ret = realtek_mdio_driver_register(&rtl8365mb_mdio_driver); + if (ret) + return ret; + + ret = realtek_smi_driver_register(&rtl8365mb_smi_driver); + if (ret) { + realtek_mdio_driver_unregister(&rtl8365mb_mdio_driver); + return ret; + } + + return 0; +} +module_init(rtl8365mb_init); + +static void __exit rtl8365mb_exit(void) +{ + realtek_smi_driver_unregister(&rtl8365mb_smi_driver); + realtek_mdio_driver_unregister(&rtl8365mb_mdio_driver); +} +module_exit(rtl8365mb_exit); MODULE_AUTHOR("Alvin Šipraga "); MODULE_DESCRIPTION("Driver for RTL8365MB-VC ethernet switch"); diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c index baeab5445d99..74e14b73a1ec 100644 --- a/drivers/net/dsa/realtek/rtl8366rb.c +++ b/drivers/net/dsa/realtek/rtl8366rb.c @@ -23,6 +23,8 @@ #include #include "realtek.h" +#include "realtek-smi.h" +#include "realtek-mdio.h" #define RTL8366RB_PORT_NUM_CPU 5 #define RTL8366RB_NUM_PORTS 6 @@ -1933,7 +1935,57 @@ const struct realtek_variant rtl8366rb_variant = { .cmd_write = 0xa8, .chip_data_sz = sizeof(struct rtl8366rb), }; -EXPORT_SYMBOL_GPL(rtl8366rb_variant); + +static const struct of_device_id rtl8366rb_of_match[] = { + { .compatible = "realtek,rtl8366rb", .data = &rtl8366rb_variant, }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, rtl8366rb_of_match); + +static struct platform_driver rtl8366rb_smi_driver = { + .driver = { + .name = "rtl8366rb-smi", + .of_match_table = rtl8366rb_of_match, + }, + .probe = realtek_smi_probe, + .remove_new = realtek_smi_remove, + .shutdown = realtek_smi_shutdown, +}; + +static struct mdio_driver rtl8366rb_mdio_driver = { + .mdiodrv.driver = { + .name = "rtl8366rb-mdio", + .of_match_table = rtl8366rb_of_match, + }, + .probe = realtek_mdio_probe, + .remove = realtek_mdio_remove, + .shutdown = realtek_mdio_shutdown, +}; + +static int rtl8366rb_init(void) +{ + int ret; + + ret = realtek_mdio_driver_register(&rtl8366rb_mdio_driver); + if (ret) + return ret; + + ret = realtek_smi_driver_register(&rtl8366rb_smi_driver); + if (ret) { + realtek_mdio_driver_unregister(&rtl8366rb_mdio_driver); + return ret; + } + + return 0; +} +module_init(rtl8366rb_init); + +static void __exit rtl8366rb_exit(void) +{ + realtek_smi_driver_unregister(&rtl8366rb_smi_driver); + realtek_mdio_driver_unregister(&rtl8366rb_mdio_driver); +} +module_exit(rtl8366rb_exit); MODULE_AUTHOR("Linus Walleij "); MODULE_DESCRIPTION("Driver for RTL8366RB ethernet switch"); From patchwork Tue Jan 23 21:44:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 13528170 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 7130D3FB3E for ; Tue, 23 Jan 2024 21:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046287; cv=none; b=OFOMgUyIp9IIaUyXtUFW0G45rh+D5wHeeHwUptlkQ/NXPI4ql8MaGMYXFZPL6SbGMB7W4NUHQ78KE1TtUVvjZK2U5vPtDk27IRMqjj+zKkOE3yoz9sIKHpffB13b1aF6OKCRlkxIVMpmuSIpkFZSTXtEAEPBRKP/CEq8WH+Ht3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046287; c=relaxed/simple; bh=vmYSQ06z2z9jiayeX1kvZ5B4z6AIoWWtEQhcjBq46Lw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s/LGKeL1GP0It4AUgdgwyV8dFS0z+JTZjZ9qk/AIOcAi6/z+iuAO0fOEQzCPJi8hzp4tt86K4WdA3Vzt/FINY8aDbGAIsqmYxQKGNAXyyrle8pE0AG0tMwXP/cFARrBidE8mJeEbhqxcMCKyrWu89amCTmXoUv3vfPirYiq5A+w= 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=bNiG96RU; arc=none smtp.client-ip=209.85.214.177 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="bNiG96RU" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1d71c844811so24047825ad.3 for ; Tue, 23 Jan 2024 13:44:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706046285; x=1706651085; 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=LX9ADtJkoKGNgdaN0isjkP2bY8ZIr+bXaw3HXIowkks=; b=bNiG96RU52iRpOr/kb1+5P8gel5Ij/7uO9fNiJJepB2HxsgSVr1NnH/gN+VGwy/qHu bXybxxKncDkgmnsniiuJAkQOx+5TLj2mrDiRRh/IiGo18lQOx6y5v0zYL0ljeBnm0JC1 9tQ1oPl2ZDrhT34TrysD2q1c/UCbC0iA4s7XubHiL8ll9rY4zkyBUSzrCa07ABe5CboW ditYSdliLusVt63P26f6zEJibL/jghC0X5lzlJRt1I2UPI1j1qcmWBmAsBRAcCbpbDwg bkxBh8UlqMYlAyVRJ+wKk+SLAcc11DYSBnEo6Wm0J1tOcC/YYsCWsHT3N3pe85NdUl1J CTUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706046285; x=1706651085; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LX9ADtJkoKGNgdaN0isjkP2bY8ZIr+bXaw3HXIowkks=; b=pObwwBjHPQURWQN8vSAINJ6JYuAhIyOlRNT9jbEftpoWA+lZsFpcJK6/2mVn9vynTs SEJ++GAbv16hxGio8yLqEAyFyj6g87NH9XABf2REY6ASO7m958ecfIcZR+eDanoKDufZ oslJUJaBoeo5JWOSWbRv7aSIEebPjs0Y0dQj9xbZCA7gNoBCu/R/ru9wigu7hgibei9I 6SdxRQxy9de2enbhHCe0cVxhOdgKGaIrP0aGCa2cD7fY1Kk8RCH0okWSpeC8chtWDI80 TXvC1WuvWurRVi6nSiji/RgIGMyOJbcwMahpptV6bMabalmMH074f6RelxrZuUoaiRt8 rL8Q== X-Gm-Message-State: AOJu0YwYz90o2XtjHMAUG9EN9Vf/kXYyDFz+g2uCaHikl3esqB+ljfg9 6dfgENPq/74kanYCesZMgRT5EQeRx+Rza8I5oKff8Vm1uY3WNMxUps9cNFWIZvU= X-Google-Smtp-Source: AGHT+IEGRrb4ch/UvxwrUY/ti5jt49T7hUoVs7MWUiiytB/SHFhHhzpPOeP3FlYB8HCBu4X00fuCcw== X-Received: by 2002:a17:903:120b:b0:1d4:e0e6:693 with SMTP id l11-20020a170903120b00b001d4e0e60693mr4910833plh.35.1706046284906; Tue, 23 Jan 2024 13:44:44 -0800 (PST) Received: from tresc054937.tre-sc.gov.br ([187.94.103.218]) by smtp.gmail.com with ESMTPSA id t10-20020a170902bc4a00b001d714a1530bsm8108858plz.176.2024.01.23.13.44.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:44:44 -0800 (PST) From: Luiz Angelo Daros de Luca To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, arinc.unal@arinc9.com, ansuelsmth@gmail.com, Luiz Angelo Daros de Luca Subject: [PATCH 04/11] net: dsa: realtek: keep variant reference in realtek_priv Date: Tue, 23 Jan 2024 18:44:12 -0300 Message-ID: <20240123214420.25716-5-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123214420.25716-1-luizluca@gmail.com> References: <20240123214420.25716-1-luizluca@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Instead of copying values from the variant, we can keep a reference in realtek_priv. This is a preliminary change for sharing code betwen interfaces. It will allow to move most of the probe into a common module while still allow code specific to each interface to read variant fields. Signed-off-by: Luiz Angelo Daros de Luca --- drivers/net/dsa/realtek/realtek-mdio.c | 4 +--- drivers/net/dsa/realtek/realtek-smi.c | 10 ++++------ drivers/net/dsa/realtek/realtek.h | 5 ++--- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c index 22a63f41e3f2..57bd5d8814c2 100644 --- a/drivers/net/dsa/realtek/realtek-mdio.c +++ b/drivers/net/dsa/realtek/realtek-mdio.c @@ -197,9 +197,7 @@ int realtek_mdio_probe(struct mdio_device *mdiodev) priv->dev = &mdiodev->dev; priv->chip_data = (void *)priv + sizeof(*priv); - priv->clk_delay = var->clk_delay; - priv->cmd_read = var->cmd_read; - priv->cmd_write = var->cmd_write; + priv->variant = var; priv->ops = var->ops; priv->write_reg_noack = realtek_mdio_write; diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c index 618547befa13..274dd96b099c 100644 --- a/drivers/net/dsa/realtek/realtek-smi.c +++ b/drivers/net/dsa/realtek/realtek-smi.c @@ -46,7 +46,7 @@ static inline void realtek_smi_clk_delay(struct realtek_priv *priv) { - ndelay(priv->clk_delay); + ndelay(priv->variant->clk_delay); } static void realtek_smi_start(struct realtek_priv *priv) @@ -209,7 +209,7 @@ static int realtek_smi_read_reg(struct realtek_priv *priv, u32 addr, u32 *data) realtek_smi_start(priv); /* Send READ command */ - ret = realtek_smi_write_byte(priv, priv->cmd_read); + ret = realtek_smi_write_byte(priv, priv->variant->cmd_read); if (ret) goto out; @@ -250,7 +250,7 @@ static int realtek_smi_write_reg(struct realtek_priv *priv, realtek_smi_start(priv); /* Send WRITE command */ - ret = realtek_smi_write_byte(priv, priv->cmd_write); + ret = realtek_smi_write_byte(priv, priv->variant->cmd_write); if (ret) goto out; @@ -460,9 +460,7 @@ int realtek_smi_probe(struct platform_device *pdev) /* Link forward and backward */ priv->dev = dev; - priv->clk_delay = var->clk_delay; - priv->cmd_read = var->cmd_read; - priv->cmd_write = var->cmd_write; + priv->variant = var; priv->ops = var->ops; priv->setup_interface = realtek_smi_setup_mdio; diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h index e9ee778665b2..0c51b5132c61 100644 --- a/drivers/net/dsa/realtek/realtek.h +++ b/drivers/net/dsa/realtek/realtek.h @@ -58,9 +58,6 @@ struct realtek_priv { struct mii_bus *bus; int mdio_addr; - unsigned int clk_delay; - u8 cmd_read; - u8 cmd_write; spinlock_t lock; /* Locks around command writes */ struct dsa_switch *ds; struct irq_domain *irqdomain; @@ -79,6 +76,8 @@ struct realtek_priv { int vlan_enabled; int vlan4k_enabled; + const struct realtek_variant *variant; + char buf[4096]; void *chip_data; /* Per-chip extra variant data */ }; From patchwork Tue Jan 23 21:44:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 13528171 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 0D4B04EB29 for ; Tue, 23 Jan 2024 21:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046293; cv=none; b=hyWDxDmziR9fgqa6V3xY8uhTxRw8sDAtbEDwaULSw/nWNl6/2hSA4z/OInuTVKP1VHoOEqtat3RUwKfGec6AvGXIA/bvPuk520wAYtsI5aIf73ID0DymDPTMm63LR8mGDIfyx8kX5F+NR5+jdDJlGmMTMi8bk+yeebLj7BG3aTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046293; c=relaxed/simple; bh=pswhXqnecuEGZaOGOSQ8njyGIX8bIkw41ZaBGJlgM5w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SsUWIMZmt5lxdXP6Vg3GL+RGe9JysZagvy8eyGlA6ORfnfdz545VKc7liObzRmaRqzC8QrPjeBBkAqmwQ61vm7ZnVpjjciKXqstMHtm8GRBHrXsrwbOwP8ViaeCwlbrLe/zA3xu8rCPHw3nNvxrTNCVQPXfgpzBG+eSpdEb23Hg= 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=D1cdMm3h; arc=none smtp.client-ip=209.85.214.179 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="D1cdMm3h" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1d750660a0aso13791765ad.0 for ; Tue, 23 Jan 2024 13:44:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706046289; x=1706651089; 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=ALi6K9jI/Xw4oB+TdMlVvsDXkVqF1LgbvaH562oL+Ak=; b=D1cdMm3hY8UaapFiAape50Pb1zo1RSrCrCs7vCNheLoOTdHDDr0s8MxbKZ0iZbFiSz iKkFh2dWEeezahg9WyP+jNF0g0dBv1KO0wSK1vnR3Cc76Ha1Cx7QZWZ9t7BBv3/2+YAG mwJ6Lh7eXmlmY7Urx1AS+CXHe5SyDUp5rFk81Joe86JTT+AA+gZXH2x7HV3RY7FNIRjc LrfXT7cy/T4L8yh7DL3+LMuIEUZW2JjlHCfVmMYDqGYJ/VjIf0kZotdRWu6mJATvSOOG 3CYGwEWM9dvAjRW9AzXtwM4MoBJ4iG0GCSRmMcJ77lw04vLt0/bjrh39FDRyXCnQc8LO 5Nmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706046289; x=1706651089; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ALi6K9jI/Xw4oB+TdMlVvsDXkVqF1LgbvaH562oL+Ak=; b=WWAG2AJOpnko/S84RDKMzF8L/2+WxbCV7INaxEeLxgjg7qxoSJg+OlWDtT1UXxuIO5 eS2yWzec/Up4ZohldeJi0yLOQwJBZuh+o77idL/amoMwHqSA378PYxmMbBBzR4bN9bRL hFcVlp7rldgC0fThl0I7tPKkzR4uvq9mXcAVTuCo6dKA2KqNXjtVAQ1LB5m2rGHlvcu1 iszsbhr7Di5zM4u8kWR+9Q1L1riLvtjwk9QraMPrnd5T6YZpjy8Nqg6TZnxHm6BA8pra AoSTGLAJYxmpJcOpDZZGz96w6Z8s989K6ddkvhXhebT4MDYInToxdTK561sDlckbaPVI ahUA== X-Gm-Message-State: AOJu0YwDM9eqVQcirhGqUzPmZptbkc+SOWN2KcYtGMvlxmGCCoTlp99t ydEZYJHYic7vQDeFcyEO/utM6JZZxlGbYyXNLFCnauCVhAYAvjJTEVLB0lYRRmk= X-Google-Smtp-Source: AGHT+IEtnHw0Hr8bK5l1hBcWXHxSRd2lCCgyo5//wtA8tehRs/B7PazECxpx3jkOH5g2/jVu873Ebg== X-Received: by 2002:a17:902:b781:b0:1d4:751d:7bf2 with SMTP id e1-20020a170902b78100b001d4751d7bf2mr3933822pls.35.1706046289157; Tue, 23 Jan 2024 13:44:49 -0800 (PST) Received: from tresc054937.tre-sc.gov.br ([187.94.103.218]) by smtp.gmail.com with ESMTPSA id t10-20020a170902bc4a00b001d714a1530bsm8108858plz.176.2024.01.23.13.44.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:44:48 -0800 (PST) From: Luiz Angelo Daros de Luca To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, arinc.unal@arinc9.com, ansuelsmth@gmail.com, Luiz Angelo Daros de Luca Subject: [PATCH 05/11] net: dsa: realtek: common rtl83xx module Date: Tue, 23 Jan 2024 18:44:13 -0300 Message-ID: <20240123214420.25716-6-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123214420.25716-1-luizluca@gmail.com> References: <20240123214420.25716-1-luizluca@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Some code can be shared between both interface modules (MDIO and SMI) and among variants. These interface functions migrated to a common module: - rtl83xx_lock - rtl83xx_unlock - rtl83xx_probe - rtl83xx_register_switch - rtl83xx_remove The reset during probe was moved to the end of the common probe. This way, we avoid a reset if anything else fails. Signed-off-by: Luiz Angelo Daros de Luca --- drivers/net/dsa/realtek/Makefile | 2 + drivers/net/dsa/realtek/realtek-mdio.c | 145 +++--------------- drivers/net/dsa/realtek/realtek-smi.c | 150 +++--------------- drivers/net/dsa/realtek/realtek.h | 1 + drivers/net/dsa/realtek/rtl8365mb.c | 9 +- drivers/net/dsa/realtek/rtl8366rb.c | 9 +- drivers/net/dsa/realtek/rtl83xx.c | 201 +++++++++++++++++++++++++ drivers/net/dsa/realtek/rtl83xx.h | 21 +++ 8 files changed, 279 insertions(+), 259 deletions(-) create mode 100644 drivers/net/dsa/realtek/rtl83xx.c create mode 100644 drivers/net/dsa/realtek/rtl83xx.h diff --git a/drivers/net/dsa/realtek/Makefile b/drivers/net/dsa/realtek/Makefile index 0aab57252a7c..67b5ee1c43a9 100644 --- a/drivers/net/dsa/realtek/Makefile +++ b/drivers/net/dsa/realtek/Makefile @@ -1,4 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_NET_DSA_REALTEK) += realtek-dsa.o +realtek-dsa-objs := rtl83xx.o obj-$(CONFIG_NET_DSA_REALTEK_MDIO) += realtek-mdio.o obj-$(CONFIG_NET_DSA_REALTEK_SMI) += realtek-smi.o obj-$(CONFIG_NET_DSA_REALTEK_RTL8366RB) += rtl8366.o diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c index 57bd5d8814c2..26b8371ecc87 100644 --- a/drivers/net/dsa/realtek/realtek-mdio.c +++ b/drivers/net/dsa/realtek/realtek-mdio.c @@ -26,6 +26,7 @@ #include "realtek.h" #include "realtek-mdio.h" +#include "rtl83xx.h" /* Read/write via mdiobus */ #define REALTEK_MDIO_CTRL0_REG 31 @@ -100,55 +101,19 @@ static int realtek_mdio_read(void *ctx, u32 reg, u32 *val) return ret; } -static void realtek_mdio_lock(void *ctx) -{ - struct realtek_priv *priv = ctx; - - mutex_lock(&priv->map_lock); -} - -static void realtek_mdio_unlock(void *ctx) -{ - struct realtek_priv *priv = ctx; - - mutex_unlock(&priv->map_lock); -} - -static const struct regmap_config realtek_mdio_regmap_config = { - .reg_bits = 10, /* A4..A0 R4..R0 */ - .val_bits = 16, - .reg_stride = 1, - /* PHY regs are at 0x8000 */ - .max_register = 0xffff, - .reg_format_endian = REGMAP_ENDIAN_BIG, - .reg_read = realtek_mdio_read, - .reg_write = realtek_mdio_write, - .cache_type = REGCACHE_NONE, - .lock = realtek_mdio_lock, - .unlock = realtek_mdio_unlock, -}; - -static const struct regmap_config realtek_mdio_nolock_regmap_config = { - .reg_bits = 10, /* A4..A0 R4..R0 */ - .val_bits = 16, - .reg_stride = 1, - /* PHY regs are at 0x8000 */ - .max_register = 0xffff, - .reg_format_endian = REGMAP_ENDIAN_BIG, +static const struct realtek_interface_info realtek_mdio_info = { .reg_read = realtek_mdio_read, .reg_write = realtek_mdio_write, - .cache_type = REGCACHE_NONE, - .disable_locking = true, }; /** * realtek_mdio_probe() - Probe a platform device for an MDIO-connected switch * @pdev: platform_device to probe on. * - * This function should be used as the .probe in an mdio_driver. It - * initializes realtek_priv and read data from the device-tree node. The switch - * is hard resetted if a method is provided. It checks the switch chip ID and, - * finally, a DSA switch is registered. + * This function should be used as the .probe in an mdio_driver. After + * calling the common probe function for both interfaces, it initializes the + * values specific for MDIO-connected devices. Finally, it calls a common + * function to register the DSA switch. * * Context: Any context. Takes and releases priv->map_lock. * Return: Returns 0 on success, a negative error on failure. @@ -156,94 +121,22 @@ static const struct regmap_config realtek_mdio_nolock_regmap_config = { */ int realtek_mdio_probe(struct mdio_device *mdiodev) { - struct realtek_priv *priv; struct device *dev = &mdiodev->dev; - const struct realtek_variant *var; - struct regmap_config rc; - struct device_node *np; + struct realtek_priv *priv; int ret; - var = of_device_get_match_data(dev); - if (!var) - return -EINVAL; - - priv = devm_kzalloc(&mdiodev->dev, - size_add(sizeof(*priv), var->chip_data_sz), - GFP_KERNEL); - if (!priv) - return -ENOMEM; - - mutex_init(&priv->map_lock); - - rc = realtek_mdio_regmap_config; - rc.lock_arg = priv; - priv->map = devm_regmap_init(dev, NULL, priv, &rc); - if (IS_ERR(priv->map)) { - ret = PTR_ERR(priv->map); - dev_err(dev, "regmap init failed: %d\n", ret); - return ret; - } - - rc = realtek_mdio_nolock_regmap_config; - priv->map_nolock = devm_regmap_init(dev, NULL, priv, &rc); - if (IS_ERR(priv->map_nolock)) { - ret = PTR_ERR(priv->map_nolock); - dev_err(dev, "regmap init failed: %d\n", ret); - return ret; - } + priv = rtl83xx_probe(dev, &realtek_mdio_info); + if (IS_ERR(priv)) + return PTR_ERR(priv); - priv->mdio_addr = mdiodev->addr; priv->bus = mdiodev->bus; - priv->dev = &mdiodev->dev; - priv->chip_data = (void *)priv + sizeof(*priv); - - priv->variant = var; - priv->ops = var->ops; - + priv->mdio_addr = mdiodev->addr; priv->write_reg_noack = realtek_mdio_write; + priv->ds_ops = priv->variant->ds_ops_mdio; - np = dev->of_node; - - dev_set_drvdata(dev, priv); - - /* TODO: if power is software controlled, set up any regulators here */ - priv->leds_disabled = of_property_read_bool(np, "realtek,disable-leds"); - - priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); - if (IS_ERR(priv->reset)) { - dev_err(dev, "failed to get RESET GPIO\n"); - return PTR_ERR(priv->reset); - } - - if (priv->reset) { - gpiod_set_value(priv->reset, 1); - dev_dbg(dev, "asserted RESET\n"); - msleep(REALTEK_HW_STOP_DELAY); - gpiod_set_value(priv->reset, 0); - msleep(REALTEK_HW_START_DELAY); - dev_dbg(dev, "deasserted RESET\n"); - } - - ret = priv->ops->detect(priv); - if (ret) { - dev_err(dev, "unable to detect switch\n"); - return ret; - } - - priv->ds = devm_kzalloc(dev, sizeof(*priv->ds), GFP_KERNEL); - if (!priv->ds) - return -ENOMEM; - - priv->ds->dev = dev; - priv->ds->num_ports = priv->num_ports; - priv->ds->priv = priv; - priv->ds->ops = var->ds_ops_mdio; - - ret = dsa_register_switch(priv->ds); - if (ret) { - dev_err(priv->dev, "unable to register switch ret = %d\n", ret); + ret = rtl83xx_register_switch(priv); + if (ret) return ret; - } return 0; } @@ -254,8 +147,8 @@ EXPORT_SYMBOL_NS_GPL(realtek_mdio_probe, REALTEK_DSA); * @pdev: platform_device to probe on. * * This function should be used as the .remove_new in an mdio_driver. First - * it unregisters the DSA switch and cleans internal data. If a method is - * provided, the hard reset is asserted to avoid traffic leakage. + * it unregisters the DSA switch and cleans internal data. Finally, it calls + * the common remove function. * * Context: Any context. * Return: Nothing. @@ -270,9 +163,7 @@ void realtek_mdio_remove(struct mdio_device *mdiodev) dsa_unregister_switch(priv->ds); - /* leave the device reset asserted */ - if (priv->reset) - gpiod_set_value(priv->reset, 1); + rtl83xx_remove(priv); } EXPORT_SYMBOL_NS_GPL(realtek_mdio_remove, REALTEK_DSA); @@ -303,3 +194,5 @@ EXPORT_SYMBOL_NS_GPL(realtek_mdio_shutdown, REALTEK_DSA); MODULE_AUTHOR("Luiz Angelo Daros de Luca "); MODULE_DESCRIPTION("Driver for Realtek ethernet switch connected via MDIO interface"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(REALTEK_DSA); + diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c index 274dd96b099c..840b1a835d07 100644 --- a/drivers/net/dsa/realtek/realtek-smi.c +++ b/drivers/net/dsa/realtek/realtek-smi.c @@ -41,6 +41,7 @@ #include "realtek.h" #include "realtek-smi.h" +#include "rtl83xx.h" #define REALTEK_SMI_ACK_RETRY_COUNT 5 @@ -311,47 +312,6 @@ static int realtek_smi_read(void *ctx, u32 reg, u32 *val) return realtek_smi_read_reg(priv, reg, val); } -static void realtek_smi_lock(void *ctx) -{ - struct realtek_priv *priv = ctx; - - mutex_lock(&priv->map_lock); -} - -static void realtek_smi_unlock(void *ctx) -{ - struct realtek_priv *priv = ctx; - - mutex_unlock(&priv->map_lock); -} - -static const struct regmap_config realtek_smi_regmap_config = { - .reg_bits = 10, /* A4..A0 R4..R0 */ - .val_bits = 16, - .reg_stride = 1, - /* PHY regs are at 0x8000 */ - .max_register = 0xffff, - .reg_format_endian = REGMAP_ENDIAN_BIG, - .reg_read = realtek_smi_read, - .reg_write = realtek_smi_write, - .cache_type = REGCACHE_NONE, - .lock = realtek_smi_lock, - .unlock = realtek_smi_unlock, -}; - -static const struct regmap_config realtek_smi_nolock_regmap_config = { - .reg_bits = 10, /* A4..A0 R4..R0 */ - .val_bits = 16, - .reg_stride = 1, - /* PHY regs are at 0x8000 */ - .max_register = 0xffff, - .reg_format_endian = REGMAP_ENDIAN_BIG, - .reg_read = realtek_smi_read, - .reg_write = realtek_smi_write, - .cache_type = REGCACHE_NONE, - .disable_locking = true, -}; - static int realtek_smi_mdio_read(struct mii_bus *bus, int addr, int regnum) { struct realtek_priv *priv = bus->priv; @@ -409,14 +369,19 @@ static int realtek_smi_setup_mdio(struct dsa_switch *ds) return ret; } +static const struct realtek_interface_info realtek_smi_info = { + .reg_read = realtek_smi_read, + .reg_write = realtek_smi_write, +}; + /** * realtek_smi_probe() - Probe a platform device for an SMI-connected switch * @pdev: platform_device to probe on. * - * This function should be used as the .probe in a platform_driver. It - * initializes realtek_priv and read data from the device-tree node. The switch - * is hard resetted if a method is provided. It checks the switch chip ID and, - * finally, a DSA switch is registered. + * This function should be used as the .probe in a platform_driver. After + * calling the common probe function for both interfaces, it initializes the + * values specific for SMI-connected devices. Finally, it calls a common + * function to register the DSA switch. * * Context: Any context. Takes and releases priv->map_lock. * Return: Returns 0 on success, a negative error on failure. @@ -424,97 +389,31 @@ static int realtek_smi_setup_mdio(struct dsa_switch *ds) */ int realtek_smi_probe(struct platform_device *pdev) { - const struct realtek_variant *var; struct device *dev = &pdev->dev; struct realtek_priv *priv; - struct regmap_config rc; - struct device_node *np; int ret; - var = of_device_get_match_data(dev); - np = dev->of_node; - - priv = devm_kzalloc(dev, sizeof(*priv) + var->chip_data_sz, GFP_KERNEL); - if (!priv) - return -ENOMEM; - priv->chip_data = (void *)priv + sizeof(*priv); - - mutex_init(&priv->map_lock); - - rc = realtek_smi_regmap_config; - rc.lock_arg = priv; - priv->map = devm_regmap_init(dev, NULL, priv, &rc); - if (IS_ERR(priv->map)) { - ret = PTR_ERR(priv->map); - dev_err(dev, "regmap init failed: %d\n", ret); - return ret; - } - - rc = realtek_smi_nolock_regmap_config; - priv->map_nolock = devm_regmap_init(dev, NULL, priv, &rc); - if (IS_ERR(priv->map_nolock)) { - ret = PTR_ERR(priv->map_nolock); - dev_err(dev, "regmap init failed: %d\n", ret); - return ret; - } - - /* Link forward and backward */ - priv->dev = dev; - priv->variant = var; - priv->ops = var->ops; - - priv->setup_interface = realtek_smi_setup_mdio; - priv->write_reg_noack = realtek_smi_write_reg_noack; - - dev_set_drvdata(dev, priv); - spin_lock_init(&priv->lock); - - /* TODO: if power is software controlled, set up any regulators here */ - - priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); - if (IS_ERR(priv->reset)) { - dev_err(dev, "failed to get RESET GPIO\n"); - return PTR_ERR(priv->reset); - } - if (priv->reset) { - gpiod_set_value(priv->reset, 1); - dev_dbg(dev, "asserted RESET\n"); - msleep(REALTEK_HW_STOP_DELAY); - gpiod_set_value(priv->reset, 0); - msleep(REALTEK_HW_START_DELAY); - dev_dbg(dev, "deasserted RESET\n"); - } + priv = rtl83xx_probe(dev, &realtek_smi_info); + if (IS_ERR(priv)) + return PTR_ERR(priv); /* Fetch MDIO pins */ priv->mdc = devm_gpiod_get_optional(dev, "mdc", GPIOD_OUT_LOW); if (IS_ERR(priv->mdc)) return PTR_ERR(priv->mdc); + priv->mdio = devm_gpiod_get_optional(dev, "mdio", GPIOD_OUT_LOW); if (IS_ERR(priv->mdio)) return PTR_ERR(priv->mdio); - priv->leds_disabled = of_property_read_bool(np, "realtek,disable-leds"); + priv->write_reg_noack = realtek_smi_write_reg_noack; + priv->setup_interface = realtek_smi_setup_mdio; + priv->ds_ops = priv->variant->ds_ops_smi; - ret = priv->ops->detect(priv); - if (ret) { - dev_err(dev, "unable to detect switch\n"); + ret = rtl83xx_register_switch(priv); + if (ret) return ret; - } - - priv->ds = devm_kzalloc(dev, sizeof(*priv->ds), GFP_KERNEL); - if (!priv->ds) - return -ENOMEM; - priv->ds->dev = dev; - priv->ds->num_ports = priv->num_ports; - priv->ds->priv = priv; - - priv->ds->ops = var->ds_ops_smi; - ret = dsa_register_switch(priv->ds); - if (ret) { - dev_err_probe(dev, ret, "unable to register switch\n"); - return ret; - } return 0; } EXPORT_SYMBOL_NS_GPL(realtek_smi_probe, REALTEK_DSA); @@ -524,8 +423,8 @@ EXPORT_SYMBOL_NS_GPL(realtek_smi_probe, REALTEK_DSA); * @pdev: platform_device to probe on. * * This function should be used as the .remove_new in a platform_driver. First - * it unregisters the DSA switch and cleans internal data. If a method is - * provided, the hard reset is asserted to avoid traffic leakage. + * it unregisters the DSA switch and cleans internal data. Finally, it calls + * the common remove function. * * Context: Any context. * Return: Nothing. @@ -539,12 +438,11 @@ void realtek_smi_remove(struct platform_device *pdev) return; dsa_unregister_switch(priv->ds); + if (priv->user_mii_bus) of_node_put(priv->user_mii_bus->dev.of_node); - /* leave the device reset asserted */ - if (priv->reset) - gpiod_set_value(priv->reset, 1); + rtl83xx_remove(priv); } EXPORT_SYMBOL_NS_GPL(realtek_smi_remove, REALTEK_DSA); @@ -575,3 +473,5 @@ EXPORT_SYMBOL_NS_GPL(realtek_smi_shutdown, REALTEK_DSA); MODULE_AUTHOR("Linus Walleij "); MODULE_DESCRIPTION("Driver for Realtek ethernet switch connected via SMI interface"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(REALTEK_DSA); + diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h index 0c51b5132c61..fbd0616c1df3 100644 --- a/drivers/net/dsa/realtek/realtek.h +++ b/drivers/net/dsa/realtek/realtek.h @@ -60,6 +60,7 @@ struct realtek_priv { spinlock_t lock; /* Locks around command writes */ struct dsa_switch *ds; + const struct dsa_switch_ops *ds_ops; struct irq_domain *irqdomain; bool leds_disabled; diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c index bd76bcf5fa44..97a41ba73718 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -103,6 +103,7 @@ #include "realtek.h" #include "realtek-smi.h" #include "realtek-mdio.h" +#include "rtl83xx.h" /* Family-specific data and limits */ #define RTL8365MB_PHYADDRMAX 7 @@ -691,7 +692,7 @@ static int rtl8365mb_phy_ocp_read(struct realtek_priv *priv, int phy, u32 val; int ret; - mutex_lock(&priv->map_lock); + rtl83xx_lock(priv); ret = rtl8365mb_phy_poll_busy(priv); if (ret) @@ -724,7 +725,7 @@ static int rtl8365mb_phy_ocp_read(struct realtek_priv *priv, int phy, *data = val & 0xFFFF; out: - mutex_unlock(&priv->map_lock); + rtl83xx_unlock(priv); return ret; } @@ -735,7 +736,7 @@ static int rtl8365mb_phy_ocp_write(struct realtek_priv *priv, int phy, u32 val; int ret; - mutex_lock(&priv->map_lock); + rtl83xx_lock(priv); ret = rtl8365mb_phy_poll_busy(priv); if (ret) @@ -766,7 +767,7 @@ static int rtl8365mb_phy_ocp_write(struct realtek_priv *priv, int phy, goto out; out: - mutex_unlock(&priv->map_lock); + rtl83xx_unlock(priv); return 0; } diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c index 74e14b73a1ec..ec7a55d70bad 100644 --- a/drivers/net/dsa/realtek/rtl8366rb.c +++ b/drivers/net/dsa/realtek/rtl8366rb.c @@ -25,6 +25,7 @@ #include "realtek.h" #include "realtek-smi.h" #include "realtek-mdio.h" +#include "rtl83xx.h" #define RTL8366RB_PORT_NUM_CPU 5 #define RTL8366RB_NUM_PORTS 6 @@ -1720,7 +1721,7 @@ static int rtl8366rb_phy_read(struct realtek_priv *priv, int phy, int regnum) if (phy > RTL8366RB_PHY_NO_MAX) return -EINVAL; - mutex_lock(&priv->map_lock); + rtl83xx_lock(priv); ret = regmap_write(priv->map_nolock, RTL8366RB_PHY_ACCESS_CTRL_REG, RTL8366RB_PHY_CTRL_READ); @@ -1748,7 +1749,7 @@ static int rtl8366rb_phy_read(struct realtek_priv *priv, int phy, int regnum) phy, regnum, reg, val); out: - mutex_unlock(&priv->map_lock); + rtl83xx_unlock(priv); return ret; } @@ -1762,7 +1763,7 @@ static int rtl8366rb_phy_write(struct realtek_priv *priv, int phy, int regnum, if (phy > RTL8366RB_PHY_NO_MAX) return -EINVAL; - mutex_lock(&priv->map_lock); + rtl83xx_lock(priv); ret = regmap_write(priv->map_nolock, RTL8366RB_PHY_ACCESS_CTRL_REG, RTL8366RB_PHY_CTRL_WRITE); @@ -1779,7 +1780,7 @@ static int rtl8366rb_phy_write(struct realtek_priv *priv, int phy, int regnum, goto out; out: - mutex_unlock(&priv->map_lock); + rtl83xx_unlock(priv); return ret; } diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c new file mode 100644 index 000000000000..57d185226b03 --- /dev/null +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -0,0 +1,201 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include "realtek.h" +#include "rtl83xx.h" + +/** + * rtl83xx_lock() - Locks the mutex used by regmaps + * @ctx: realtek_priv pointer + * + * This function is passed to regmap to be used as the lock function. + * It is also used externally to block regmap before executing multiple + * operations that must happen in sequence (which will use + * realtek_priv.map_nolock instead). + * + * Context: Any context. Holds priv->map_lock lock. + * Return: nothing + */ +void rtl83xx_lock(void *ctx) +{ + struct realtek_priv *priv = ctx; + + mutex_lock(&priv->map_lock); +} +EXPORT_SYMBOL_NS_GPL(rtl83xx_lock, REALTEK_DSA); + +/** + * rtl83xx_unlock() - Unlocks the mutex used by regmaps + * @ctx: realtek_priv pointer + * + * This function unlocks the lock acquired by rtl83xx_lock. + * + * Context: Any context. Releases priv->map_lock lock + * Return: nothing + */ +void rtl83xx_unlock(void *ctx) +{ + struct realtek_priv *priv = ctx; + + mutex_unlock(&priv->map_lock); +} +EXPORT_SYMBOL_NS_GPL(rtl83xx_unlock, REALTEK_DSA); + +/** + * rtl83xx_probe() - probe a Realtek switch + * @dev: the device being probed + * @interface_info: reg read/write methods for a specific management interface. + * + * This function initializes realtek_priv and read data from the device-tree + * node. The switch is hard resetted if a method is provided. + * + * Context: Any context. + * Return: Pointer to the realtek_priv or ERR_PTR() in case of failure. + * + * The realtek_priv pointer does not need to be freed as it is controlled by + * devres. + * + */ +struct realtek_priv * +rtl83xx_probe(struct device *dev, + const struct realtek_interface_info *interface_info) +{ + const struct realtek_variant *var; + struct realtek_priv *priv; + struct regmap_config rc = { + .reg_bits = 10, /* A4..A0 R4..R0 */ + .val_bits = 16, + .reg_stride = 1, + .max_register = 0xffff, + .reg_format_endian = REGMAP_ENDIAN_BIG, + .reg_read = interface_info->reg_read, + .reg_write = interface_info->reg_write, + .cache_type = REGCACHE_NONE, + .lock = rtl83xx_lock, + .unlock = rtl83xx_unlock, + }; + int ret; + + var = of_device_get_match_data(dev); + if (!var) + return ERR_PTR(-EINVAL); + + priv = devm_kzalloc(dev, size_add(sizeof(*priv), var->chip_data_sz), + GFP_KERNEL); + if (!priv) + return ERR_PTR(-ENOMEM); + + mutex_init(&priv->map_lock); + + rc.lock_arg = priv; + priv->map = devm_regmap_init(dev, NULL, priv, &rc); + if (IS_ERR(priv->map)) { + ret = PTR_ERR(priv->map); + dev_err(dev, "regmap init failed: %d\n", ret); + return ERR_PTR(ret); + } + + rc.disable_locking = true; + priv->map_nolock = devm_regmap_init(dev, NULL, priv, &rc); + if (IS_ERR(priv->map_nolock)) { + ret = PTR_ERR(priv->map_nolock); + dev_err(dev, "regmap init failed: %d\n", ret); + return ERR_PTR(ret); + } + + /* Link forward and backward */ + priv->dev = dev; + priv->variant = var; + priv->ops = var->ops; + priv->chip_data = (void *)priv + sizeof(*priv); + + dev_set_drvdata(dev, priv); + spin_lock_init(&priv->lock); + + priv->leds_disabled = of_property_read_bool(dev->of_node, + "realtek,disable-leds"); + + /* TODO: if power is software controlled, set up any regulators here */ + + priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); + if (IS_ERR(priv->reset)) { + dev_err(dev, "failed to get RESET GPIO\n"); + return ERR_CAST(priv->reset); + } + if (priv->reset) { + gpiod_set_value(priv->reset, 1); + dev_dbg(dev, "asserted RESET\n"); + msleep(REALTEK_HW_STOP_DELAY); + gpiod_set_value(priv->reset, 0); + msleep(REALTEK_HW_START_DELAY); + dev_dbg(dev, "deasserted RESET\n"); + } + + return priv; +} +EXPORT_SYMBOL_NS_GPL(rtl83xx_probe, REALTEK_DSA); + +/** + * rtl83xx_register_switch() - detects and register a switch + * @priv: realtek_priv pointer + * + * This function first checks the switch chip ID and register a DSA + * switch. + * + * Context: Any context. Takes and releases priv->map_lock. + * Return: 0 on success, negative value for failure. + */ +int rtl83xx_register_switch(struct realtek_priv *priv) +{ + int ret; + + ret = priv->ops->detect(priv); + if (ret) { + dev_err_probe(priv->dev, ret, "unable to detect switch\n"); + return ret; + } + + priv->ds = devm_kzalloc(priv->dev, sizeof(*priv->ds), GFP_KERNEL); + if (!priv->ds) + return -ENOMEM; + + priv->ds->priv = priv; + priv->ds->dev = priv->dev; + priv->ds->ops = priv->ds_ops; + priv->ds->num_ports = priv->num_ports; + + ret = dsa_register_switch(priv->ds); + if (ret) { + dev_err_probe(priv->dev, ret, "unable to register switch\n"); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_NS_GPL(rtl83xx_register_switch, REALTEK_DSA); + +/** + * rtl83xx_remove() - Cleanup a realtek switch driver + * @ctx: realtek_priv pointer + * + * If a method is provided, this function asserts the hard reset of the switch + * in order to avoid leaking traffic when the driver is gone. + * + * Context: Any context. + * Return: nothing + */ +void rtl83xx_remove(struct realtek_priv *priv) +{ + if (!priv) + return; + + /* leave the device reset asserted */ + if (priv->reset) + gpiod_set_value(priv->reset, 1); +} +EXPORT_SYMBOL_NS_GPL(rtl83xx_remove, REALTEK_DSA); + +MODULE_AUTHOR("Luiz Angelo Daros de Luca "); +MODULE_DESCRIPTION("Realtek DSA switches common module"); +MODULE_LICENSE("GPL"); diff --git a/drivers/net/dsa/realtek/rtl83xx.h b/drivers/net/dsa/realtek/rtl83xx.h new file mode 100644 index 000000000000..9eb8197a58fa --- /dev/null +++ b/drivers/net/dsa/realtek/rtl83xx.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _RTL83XX_H +#define _RTL83XX_H + +#include + +struct realtek_interface_info { + int (*reg_read)(void *ctx, u32 reg, u32 *val); + int (*reg_write)(void *ctx, u32 reg, u32 val); +}; + +void rtl83xx_lock(void *ctx); +void rtl83xx_unlock(void *ctx); +struct realtek_priv * +rtl83xx_probe(struct device *dev, + const struct realtek_interface_info *interface_info); +int rtl83xx_register_switch(struct realtek_priv *priv); +void rtl83xx_remove(struct realtek_priv *priv); + +#endif /* _RTL83XX_H */ From patchwork Tue Jan 23 21:44:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 13528172 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 096F738F9E for ; Tue, 23 Jan 2024 21:44:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046296; cv=none; b=QmkJjREiMq0U9gmJoyxVexJefb+tyRhfWNfVJIBLt4xFB6TUMmd1VYsQ/BBROgsqnmW9q1qZCYOl6CV//Z6FtL8qpd26gD2VuVl50Sawv1gd209ij8JyQLU8yopqwS4QEwf1C9a2E8EKqg5qyrfivNaT2K+Z2O1UyTYyxjV6vB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046296; c=relaxed/simple; bh=NNoKHD0txK9XjZJh4xAMvaK9JGPuX0fSNDrccFFMa5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QghqidaLLWdbI+uQfYt4hViiIR8AxsP3OqwLYI6wrPpg+CPfRL+c98+JhncMUmjHZJtfEO3GQu4f1sm9nNEigB6VTiRjHBH08Zz9yNN+tK4yV5ch6ZAY0Q167LbtgzW2B6P0cx+YxkXyBGHUeDo84A707/6vJrijVFEAnH6hFf8= 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=OJ5RTaxV; arc=none smtp.client-ip=209.85.214.174 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="OJ5RTaxV" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1d51ba18e1bso43069445ad.0 for ; Tue, 23 Jan 2024 13:44:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706046293; x=1706651093; 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=lcTmuPDVM8skyCnFNVXCfMdNDXeWIVyP1PNNN8ZLF/c=; b=OJ5RTaxVdKCdKlkg57c3CdHcTbOD1KyTfPiP6Y2jOKmBxbYCO789OAn4WHqJBOe3iF v6xFi/yZD2BMfZY1i7w/L6zZQGhvDnE3BgtMlMSL8tDjfNdyVKqWo7JbmK/H+/hOi30s i1goA9iskxYMD0VrFPyTRuPwcD2qUzr/8BQK8g9Q+3EK8JMbKTtbRRFhjn7gizh8hiis m1whssWWG7Zgcvc68vRxWcmHk+S2Qy4R1JGGs27Y1sA0GaVKl3v3fof39A3cdPInbGT9 QkJv2Zo+7MIGrsEqGXAuH9YJdyFJ+nrBZ+7zlhwY1G3CUMe0/XirAugJCBrHA3tCSGAq S7Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706046293; x=1706651093; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lcTmuPDVM8skyCnFNVXCfMdNDXeWIVyP1PNNN8ZLF/c=; b=kaFcyPIM1lS9vuTzpIYuXdU5j2iMhM7SebE0Kwa2YQo0eCzw7mj+UFR0qNkhuaeAv7 2ByzQ9g0+xk4edSl/id89O8iLIY2KRGTLtj76aqFq0KVQsRJZzxeZWYYsjxlJNCIStOG 9Y9DdFoM2OdLuxuTiQad2SrFHJ3hefdwnEXi0HBA62j0iAYjKZw0ocf3ILqJC+KuYqeV TzCwnJYb4Llc5EsIFcSxvtsLh0ZqBkcDQTShFOgGYuG0/BkicPDiyQwKxhawVmiN5pKl E4K3IPK1dLU9ATuBaHKryVF656xJnLu3ia5wTM3EdVlCk/1+Cxd1dBopwxDhmBFOYfNg xxaA== X-Gm-Message-State: AOJu0YydgWuATyxyemAtPPGmMGYS+Eg9GTprHs3lHuNGFADPFmLGOj6S 2SdN4Vj9ATFmwkmTWN2qdKIDh/cLGusDPLPtHH4Se4aAtnDiFQN3J0r/tDIcXGY= X-Google-Smtp-Source: AGHT+IG6C4BJoncPprjUeLhl9nwImNIKhB9Hh2onBAqzw0pXyTBpa3IsJt8Kv4Sf9GIOizVTsNj9UQ== X-Received: by 2002:a17:902:9893:b0:1d4:cd41:e44b with SMTP id s19-20020a170902989300b001d4cd41e44bmr7157678plp.124.1706046293427; Tue, 23 Jan 2024 13:44:53 -0800 (PST) Received: from tresc054937.tre-sc.gov.br ([187.94.103.218]) by smtp.gmail.com with ESMTPSA id t10-20020a170902bc4a00b001d714a1530bsm8108858plz.176.2024.01.23.13.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:44:52 -0800 (PST) From: Luiz Angelo Daros de Luca To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, arinc.unal@arinc9.com, ansuelsmth@gmail.com, Luiz Angelo Daros de Luca Subject: [PATCH 06/11] net: dsa: realtek: merge rtl83xx and interface modules into realtek-dsa Date: Tue, 23 Jan 2024 18:44:14 -0300 Message-ID: <20240123214420.25716-7-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123214420.25716-1-luizluca@gmail.com> References: <20240123214420.25716-1-luizluca@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Since rtl83xx and realtek-{smi,mdio} are always loaded together, we can optimize resource usage by consolidating them into a single module. Signed-off-by: Luiz Angelo Daros de Luca --- drivers/net/dsa/realtek/Kconfig | 4 ++-- drivers/net/dsa/realtek/Makefile | 11 +++++++++-- drivers/net/dsa/realtek/realtek-mdio.c | 5 ----- drivers/net/dsa/realtek/realtek-smi.c | 5 ----- drivers/net/dsa/realtek/rtl83xx.c | 1 + 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/net/dsa/realtek/Kconfig b/drivers/net/dsa/realtek/Kconfig index 9d182fde11b4..6989972eebc3 100644 --- a/drivers/net/dsa/realtek/Kconfig +++ b/drivers/net/dsa/realtek/Kconfig @@ -16,14 +16,14 @@ menuconfig NET_DSA_REALTEK if NET_DSA_REALTEK config NET_DSA_REALTEK_MDIO - tristate "Realtek MDIO interface support" + bool "Realtek MDIO interface support" depends on OF help Select to enable support for registering switches configured through MDIO. config NET_DSA_REALTEK_SMI - tristate "Realtek SMI interface support" + bool "Realtek SMI interface support" depends on OF help Select to enable support for registering switches connected diff --git a/drivers/net/dsa/realtek/Makefile b/drivers/net/dsa/realtek/Makefile index 67b5ee1c43a9..6ed6b4598d2e 100644 --- a/drivers/net/dsa/realtek/Makefile +++ b/drivers/net/dsa/realtek/Makefile @@ -1,8 +1,15 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_NET_DSA_REALTEK) += realtek-dsa.o realtek-dsa-objs := rtl83xx.o -obj-$(CONFIG_NET_DSA_REALTEK_MDIO) += realtek-mdio.o -obj-$(CONFIG_NET_DSA_REALTEK_SMI) += realtek-smi.o + +ifdef CONFIG_NET_DSA_REALTEK_MDIO +realtek-dsa-objs += realtek-mdio.o +endif + +ifdef CONFIG_NET_DSA_REALTEK_SMI +realtek-dsa-objs += realtek-smi.o +endif + obj-$(CONFIG_NET_DSA_REALTEK_RTL8366RB) += rtl8366.o rtl8366-objs := rtl8366-core.o rtl8366rb.o obj-$(CONFIG_NET_DSA_REALTEK_RTL8365MB) += rtl8365mb.o diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c index 26b8371ecc87..0171185ec665 100644 --- a/drivers/net/dsa/realtek/realtek-mdio.c +++ b/drivers/net/dsa/realtek/realtek-mdio.c @@ -191,8 +191,3 @@ void realtek_mdio_shutdown(struct mdio_device *mdiodev) } EXPORT_SYMBOL_NS_GPL(realtek_mdio_shutdown, REALTEK_DSA); -MODULE_AUTHOR("Luiz Angelo Daros de Luca "); -MODULE_DESCRIPTION("Driver for Realtek ethernet switch connected via MDIO interface"); -MODULE_LICENSE("GPL"); -MODULE_IMPORT_NS(REALTEK_DSA); - diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c index 840b1a835d07..5533b79d67f5 100644 --- a/drivers/net/dsa/realtek/realtek-smi.c +++ b/drivers/net/dsa/realtek/realtek-smi.c @@ -470,8 +470,3 @@ void realtek_smi_shutdown(struct platform_device *pdev) } EXPORT_SYMBOL_NS_GPL(realtek_smi_shutdown, REALTEK_DSA); -MODULE_AUTHOR("Linus Walleij "); -MODULE_DESCRIPTION("Driver for Realtek ethernet switch connected via SMI interface"); -MODULE_LICENSE("GPL"); -MODULE_IMPORT_NS(REALTEK_DSA); - diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c index 57d185226b03..3d07c5662fa4 100644 --- a/drivers/net/dsa/realtek/rtl83xx.c +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -197,5 +197,6 @@ void rtl83xx_remove(struct realtek_priv *priv) EXPORT_SYMBOL_NS_GPL(rtl83xx_remove, REALTEK_DSA); MODULE_AUTHOR("Luiz Angelo Daros de Luca "); +MODULE_AUTHOR("Linus Walleij "); MODULE_DESCRIPTION("Realtek DSA switches common module"); MODULE_LICENSE("GPL"); From patchwork Tue Jan 23 21:44:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 13528173 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 446ED38F9E for ; Tue, 23 Jan 2024 21:44:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046300; cv=none; b=k3qa266Yxfiy/lq8gw3xR326e1sa3ht4xkx32jpW6lDShIPxQVrYHQyjfyNtBeS6/W7wrJFvPqfbOEf1DRPFY7EDtatSKSf31nSh4fX878AzYr0qUv/ZU6382bMLcHrIswaAQmagJnOzUQT+KMMNNmrxVuXClTK+pJf1QtXwAFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046300; c=relaxed/simple; bh=qWeXnCBQSx9ijJmNkUoRa2Lf4+X7HfzKD4B4uSdXYsg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JzdyKh57zIywP2PoufGIg39GKqv4N20zuoezhYjw1wBRXeDzqAkZY+tfER4YF9pxnBcQOz8JY9rl4tFBUmwJLXUAMjwxvsuSVHCeqdkCfdz7DgRUMdz/lg4EdA6AGdGUOaV2dLXWUc4X4dpqnAbV7vC8b4QcPaTH0VTiAHnBlEI= 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=D2ub8z9F; arc=none smtp.client-ip=209.85.214.174 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="D2ub8z9F" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1d731314e67so14623055ad.1 for ; Tue, 23 Jan 2024 13:44:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706046298; x=1706651098; 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=JpzISrELLh4FOhQZGr6OH/1pWfA/oXb4P+4EgI1bf+k=; b=D2ub8z9FtefRZflVHK1BL/MVJlDCVY98Hrt53o/HZCx2pcCO3Hcv40X+7oT+qyu4vX 5wn1lOr+0QM+uN9HcFRjj4oZLYCN+4J3S5+qh1giIJRQ07DyBkZUWQSwXLHAXNPvD/4D gW6xzs2oPxeRa/XvpB8hYL8+8J12AbMMyBdVZ8U1MOT90t0JpjBrJYZwp/YkUCniGpjF WAEGfxTgz21BanvVCi7adnWdwniaYEzD63CU9fFz761hnVTiUoj8NLjL5UeQ146yJum+ gMnBQeWdfEviarn0fezxROmCLoadoMVg+fi+djEEmILW5y11yDl8nLZSD7VUEhN6coN6 5rMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706046298; x=1706651098; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JpzISrELLh4FOhQZGr6OH/1pWfA/oXb4P+4EgI1bf+k=; b=MCwLgai4s3s20Jxy8rGsrE0sPnHydQ5u1tA0dz6/Qi/ilK+rzQOnOrY8O5Gh+tZrjw xtCAEdKw9sE7FemaUbFpOwaf3z3uago8GV2uIQDPRy5JBvI2OrT5+xZUF7CnKFH24C9H Gl0t+LE/1Bhe4+gBmfGmHymD8MElNWX9MEqm4GUUa351I33JHZtxDDePTlldGu4QuPwL UG1XUT+uTprZ4yqymlyw+uS1JsBkBWn/vGDryUu3daPpTuqZqTgKWf7PwtNYHKVK3FA8 FwYsE3DnJJ3KGGGT+TM/Zg+j1soTXuD0CYCAuIR6ItaycPfkiUC7Kfm4Yut8QWwzfwG9 roNQ== X-Gm-Message-State: AOJu0Yw0yWI4ijix7vi5ZGROwkPyt8KHopdZLf3jvXQg0z9lJMPqQB7c Ss1UevUUzdEBbd4tzOdB3Q+zf4Wq5DE+GYMLgjj1OJFEEB4CHL3F0UC0/rlfuKA= X-Google-Smtp-Source: AGHT+IEMP9hL0weuIWrWslnxpHJ/CS8zHRzK71B/JhNo6LdDoAc7W2QUYxclCNA0VSwe6ShfuxfRdA== X-Received: by 2002:a17:903:2450:b0:1d4:b60f:1de5 with SMTP id l16-20020a170903245000b001d4b60f1de5mr4533912pls.26.1706046297697; Tue, 23 Jan 2024 13:44:57 -0800 (PST) Received: from tresc054937.tre-sc.gov.br ([187.94.103.218]) by smtp.gmail.com with ESMTPSA id t10-20020a170902bc4a00b001d714a1530bsm8108858plz.176.2024.01.23.13.44.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:44:57 -0800 (PST) From: Luiz Angelo Daros de Luca To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, arinc.unal@arinc9.com, ansuelsmth@gmail.com, Luiz Angelo Daros de Luca Subject: [PATCH 07/11] net: dsa: realtek: get internal MDIO node by name Date: Tue, 23 Jan 2024 18:44:15 -0300 Message-ID: <20240123214420.25716-8-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123214420.25716-1-luizluca@gmail.com> References: <20240123214420.25716-1-luizluca@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The binding docs requires for SMI-connected devices that the switch must have a child node named "mdio" and with a compatible string of "realtek,smi-mdio". Meanwile, for MDIO-connected switches, the binding docs only requires a child node named "mdio". This patch changes the driver to use the common denominator for both interfaces, looking for the MDIO node by name, ignoring the compatible string. Signed-off-by: Luiz Angelo Daros de Luca Reviewed-by: Vladimir Oltean --- drivers/net/dsa/realtek/realtek-smi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c index 5533b79d67f5..0ccb2a6059a6 100644 --- a/drivers/net/dsa/realtek/realtek-smi.c +++ b/drivers/net/dsa/realtek/realtek-smi.c @@ -333,7 +333,7 @@ static int realtek_smi_setup_mdio(struct dsa_switch *ds) struct device_node *mdio_np; int ret; - mdio_np = of_get_compatible_child(priv->dev->of_node, "realtek,smi-mdio"); + mdio_np = of_get_child_by_name(priv->dev->of_node, "mdio"); if (!mdio_np) { dev_err(priv->dev, "no MDIO bus node\n"); return -ENODEV; From patchwork Tue Jan 23 21:44:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 13528174 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 9E51848CCC for ; Tue, 23 Jan 2024 21:45:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046305; cv=none; b=krazT4hduXFnNT5AoyRBOeaTggnJ3UFgqs7cYCqAJzG0Y7lIRCFU/q7S0c0xpxSLDWeOdT8aDJy0m0x9CpBT7mNkqavqu0TaYhkBVzJ2ffCpDZ72CzVSo6e0Yv6sEFkubcGKyWcfT/MPQDZVo16AF5xLQ1qXkRasB5/chxQlI+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046305; c=relaxed/simple; bh=w74fOcwrINSkbZMdiX9RtKnM4jtf3uz6a5JcZn2ZHQg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MKi1iL8A2ZEFuI5y2xAPWhy1wyVzhPXNFAa7PA0nB/ScgxQIcSDnbx/AhO+S+vX1UXdcJ1rXay9gmvX1TIXHEjqM8nmbnv9PjjZaQYrsiGlubA4JUAYJqCe6HY2XLfiUMF+Gbw3z04RZM/RaKHQYxAD5u/Biz9tTEvsRcctv440= 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=ZWX5zCtu; arc=none smtp.client-ip=209.85.214.179 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="ZWX5zCtu" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1d751bc0c15so23104225ad.2 for ; Tue, 23 Jan 2024 13:45:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706046302; x=1706651102; 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=Up5tu1AXyDQ5HW0X8xCfGNx0W8oL51e+Y390jsXpzwI=; b=ZWX5zCtubZ4Cqwj8jsp/p0PkDteviPKchRNBEwXwDBJxOOOhELlb3Luau6AF0lf/J+ /0/1dsXURqdd+0quSUZMdkxuIJX0oN3Y6+hOXztbIZcW0n0rkgK1tQZhIQir6mRrrMQ2 wWsXr2Mb/OB4tRC5GS0ItRKE7z6GqEcm6isvt54CZ+BF5/sXgk0cUOyeWVO3JTt3hTWa 8oELUhKw/Yj/NS5N9jOwSMfpNVAb90wsLWOsPcp1hGpiK78HKELNfAasC1CUvcvk3mU+ mI7uouzFTUC3cI1fxq3Zjs2/H5bQdZpdqPb9P1vEIybAkWz6n7pYI/MFqAiJpaJJ42jx ZMmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706046302; x=1706651102; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Up5tu1AXyDQ5HW0X8xCfGNx0W8oL51e+Y390jsXpzwI=; b=nnqUZCSzAZKabqZ1EpggYtxSrYSnRFldbL78CpgSEdksj7aqUO73iUTAdw0R8yJPsM BugXGHWwCvDtmmObGbRQHd4Ejalb0uVv0/RZ+akPxQ059/F1JgXSbRthcCh5fbQTdGzQ vryiVHEU+RVTpACnlOYDJIFhAWi/egJhBsHdoj7pvNzDeIKXe/7vtAczNumlM72n0PcC /ay5QwKuRYZ08PVS9pi4XZMEzz69kqekBYhX5MOteQ3NNuuRcQ+hPt+2q7U5mT91nC/L FrVFYyRvFFzib/xdjwBG6nwsTINdyHf9XAg0yDCqGPFJLne58ev+MFzh4VzKmJKZmgxr MqKQ== X-Gm-Message-State: AOJu0YxDvKzXfQzA65SHvr3F0RBG+Aar/FgGsQ8v2V0zqi0vGMyHzU4c drb51tqZCe0sr8SxdW/JfzZzJhvxAZedYt/W1EW6zxb8WNj9tQxwhbKUOKwaR5w= X-Google-Smtp-Source: AGHT+IFD/6YmHn07zUaV+BjpIlDtRD/1KzfQfLAXvDHzLvjpCPOqHPzGioDV/W3DK6Kq4quiA/0D5g== X-Received: by 2002:a17:902:db02:b0:1d7:467b:f488 with SMTP id m2-20020a170902db0200b001d7467bf488mr5648466plx.114.1706046302192; Tue, 23 Jan 2024 13:45:02 -0800 (PST) Received: from tresc054937.tre-sc.gov.br ([187.94.103.218]) by smtp.gmail.com with ESMTPSA id t10-20020a170902bc4a00b001d714a1530bsm8108858plz.176.2024.01.23.13.44.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:45:01 -0800 (PST) From: Luiz Angelo Daros de Luca To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, arinc.unal@arinc9.com, ansuelsmth@gmail.com, Luiz Angelo Daros de Luca Subject: [PATCH 08/11] net: dsa: realtek: clean user_mii_bus setup Date: Tue, 23 Jan 2024 18:44:16 -0300 Message-ID: <20240123214420.25716-9-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123214420.25716-1-luizluca@gmail.com> References: <20240123214420.25716-1-luizluca@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The line assigning dev.of_node in mdio_bus has been removed since the subsequent of_mdiobus_register will always overwrite it. ds->user_mii_bus is not assigned anymore[1]. It should work as before as long as the switch ports have a valid phy-handle property. Since commit 3b73a7b8ec38 ("net: mdio_bus: add refcounting for fwnodes to mdiobus"), we can put the "mdio" node just after the MDIO bus registration. The switch unregistration was moved into realtek_common_remove() as both interfaces now use the same code path. [1] https://lkml.kernel.org/netdev/20231213120656.x46fyad6ls7sqyzv@skbuf/T/#u Signed-off-by: Luiz Angelo Daros de Luca --- drivers/net/dsa/realtek/realtek-mdio.c | 5 ----- drivers/net/dsa/realtek/realtek-smi.c | 15 ++------------- drivers/net/dsa/realtek/rtl83xx.c | 2 ++ 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c index 0171185ec665..c75b4550802c 100644 --- a/drivers/net/dsa/realtek/realtek-mdio.c +++ b/drivers/net/dsa/realtek/realtek-mdio.c @@ -158,11 +158,6 @@ void realtek_mdio_remove(struct mdio_device *mdiodev) { struct realtek_priv *priv = dev_get_drvdata(&mdiodev->dev); - if (!priv) - return; - - dsa_unregister_switch(priv->ds); - rtl83xx_remove(priv); } EXPORT_SYMBOL_NS_GPL(realtek_mdio_remove, REALTEK_DSA); diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c index 0ccb2a6059a6..a89813e527d2 100644 --- a/drivers/net/dsa/realtek/realtek-smi.c +++ b/drivers/net/dsa/realtek/realtek-smi.c @@ -331,7 +331,7 @@ static int realtek_smi_setup_mdio(struct dsa_switch *ds) { struct realtek_priv *priv = ds->priv; struct device_node *mdio_np; - int ret; + int ret = 0; mdio_np = of_get_child_by_name(priv->dev->of_node, "mdio"); if (!mdio_np) { @@ -344,15 +344,14 @@ static int realtek_smi_setup_mdio(struct dsa_switch *ds) ret = -ENOMEM; goto err_put_node; } + priv->user_mii_bus->priv = priv; priv->user_mii_bus->name = "SMI user MII"; priv->user_mii_bus->read = realtek_smi_mdio_read; priv->user_mii_bus->write = realtek_smi_mdio_write; snprintf(priv->user_mii_bus->id, MII_BUS_ID_SIZE, "SMI-%d", ds->index); - priv->user_mii_bus->dev.of_node = mdio_np; priv->user_mii_bus->parent = priv->dev; - ds->user_mii_bus = priv->user_mii_bus; ret = devm_of_mdiobus_register(priv->dev, priv->user_mii_bus, mdio_np); if (ret) { @@ -361,8 +360,6 @@ static int realtek_smi_setup_mdio(struct dsa_switch *ds) goto err_put_node; } - return 0; - err_put_node: of_node_put(mdio_np); @@ -434,14 +431,6 @@ void realtek_smi_remove(struct platform_device *pdev) { struct realtek_priv *priv = platform_get_drvdata(pdev); - if (!priv) - return; - - dsa_unregister_switch(priv->ds); - - if (priv->user_mii_bus) - of_node_put(priv->user_mii_bus->dev.of_node); - rtl83xx_remove(priv); } EXPORT_SYMBOL_NS_GPL(realtek_smi_remove, REALTEK_DSA); diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c index 3d07c5662fa4..53bacbacc82e 100644 --- a/drivers/net/dsa/realtek/rtl83xx.c +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -190,6 +190,8 @@ void rtl83xx_remove(struct realtek_priv *priv) if (!priv) return; + dsa_unregister_switch(priv->ds); + /* leave the device reset asserted */ if (priv->reset) gpiod_set_value(priv->reset, 1); From patchwork Tue Jan 23 21:44:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 13528175 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.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 73E854A987 for ; Tue, 23 Jan 2024 21:45:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046309; cv=none; b=e0vgFO3FhyvfizSjyk8AFQeJVzlqsjrt60M66NLG1fdkazElRNMK2yJ44mc+nu9LR4Ow5hT5nDZZCW4eOwx802R4e9Y2gnebsRe3uS5K/JNb6JD6CjPsnpnZrX3H0ZU72tvk39R6AHgokuxFDCP8FA+eSmy2r1YfjmWG2DcKhxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046309; c=relaxed/simple; bh=J3Nh1N/06LdYOJxcnZT42tewbtJ1miuDdNVw8UlyqGQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cvOwR7YY2fCH6dk/H68Hr19XVOaMpaPJQC0s8DYVk3sE07TFWeFh7iCsJa+R8TW/bJxaDMSHCkKDSOzGjY6TAg/A9beoqERVxM0cz/pdGfmonAulmPDtL7PmCDm4QxJ5THDkaLHJm0oSMbEkXV1CZqLQp+TraH8XLp7Z2SGJ7z0= 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=FJYRYX1W; arc=none smtp.client-ip=209.85.214.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="FJYRYX1W" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1d70b0e521eso34965615ad.1 for ; Tue, 23 Jan 2024 13:45:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706046307; x=1706651107; 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=y8D+hyr3W1+WSBWvCgRlvhdImoyDjgQTkdmQzjRW/9U=; b=FJYRYX1Wkw89GG3P6Nl4/26YbRBD3AKOeMfaYdon6EVqXv+qdE7N3vO8DAoJfHtbhj WKpv5/oNQyRKJ5JKLVi+Fdo7kpEM40rPFEQ+IQ5ZadrFfOfijXfKMe1pLwb0GIOc2oFy k2drosnlmrfm9cZNhcbYEtRBc+1fMM7mAzoiPii47kahVLVjuFW1VJ460izapn++grGm k+FUK8/jOvdxsAzicfWYIpWVQHVFkqLkH5dbJvM8rjWSCJUc4V3FrBWw7S1og1pWiNIx Uedd5SNjq8+mzwhzVGPhbK8VqmNXKBJQobZxQfYFJ+FzvVVvkbXbZTqvgA5nzCZoCGEk TFfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706046307; x=1706651107; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y8D+hyr3W1+WSBWvCgRlvhdImoyDjgQTkdmQzjRW/9U=; b=noTRsrOEs/Z17UIuzoJysaKO4DuwLqegOapG87wIwEgHUYP08vgsQrgowhQkSX/Z9n KH42cDMNVVWV9uhI0OdieonHoqQTbwcPAYysi3WrkxJn4Ji7TusXHZS0Swh+tYZUPInw rjZ15iju+Fzt7yLkFHKmw71FykofCE7tj+ia40BSVPLI+k+BUhgAlwx+QAwtb73Fv60l UbmY3fu6J0gy8Lapx2QbCK4/e6QX6BYxwd+9saFMRxb0iTFiBwydy0QIVVX1xQ855IEQ rhV7P5jmHHHuJCrXdpOVluQrCYuylHDT9ZsV6g+uwjA+pC0Z2He23zJtP6TkrJw2UWQx 8z7A== X-Gm-Message-State: AOJu0Yyaj9XWIRb6PxoIBgk3WlGC6zdojl2nOUZyITofUQdnbtnikznX nEHZXYWj8mu+BGJSDqbI+sk5SV4FlXyu7yMx0iRBOWiiSOLDiCQSnHXJ3vW0kdo= X-Google-Smtp-Source: AGHT+IEDIvgsrgm/zjsOH22L7ltuahXhwsVpexSWl738Q2CkVzwTT/c80sEkaznUrihzjVzbtN8HiQ== X-Received: by 2002:a17:902:f684:b0:1d7:3100:9f8a with SMTP id l4-20020a170902f68400b001d731009f8amr8280302plg.43.1706046306744; Tue, 23 Jan 2024 13:45:06 -0800 (PST) Received: from tresc054937.tre-sc.gov.br ([187.94.103.218]) by smtp.gmail.com with ESMTPSA id t10-20020a170902bc4a00b001d714a1530bsm8108858plz.176.2024.01.23.13.45.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:45:06 -0800 (PST) From: Luiz Angelo Daros de Luca To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, arinc.unal@arinc9.com, ansuelsmth@gmail.com, Luiz Angelo Daros de Luca Subject: [PATCH 09/11] net: dsa: realtek: migrate user_mii_bus setup to realtek-dsa Date: Tue, 23 Jan 2024 18:44:17 -0300 Message-ID: <20240123214420.25716-10-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123214420.25716-1-luizluca@gmail.com> References: <20240123214420.25716-1-luizluca@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org In the user MDIO driver, despite numerous references to SMI, including its compatible string, there's nothing inherently specific about the SMI interface in the user MDIO bus. Consequently, the code has been migrated to the rtl83xx module. All references to SMI have been eliminated. Signed-off-by: Luiz Angelo Daros de Luca --- drivers/net/dsa/realtek/realtek-smi.c | 57 +---------------------- drivers/net/dsa/realtek/rtl83xx.c | 67 +++++++++++++++++++++++++++ drivers/net/dsa/realtek/rtl83xx.h | 1 + 3 files changed, 69 insertions(+), 56 deletions(-) diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c index a89813e527d2..70f3967e56e8 100644 --- a/drivers/net/dsa/realtek/realtek-smi.c +++ b/drivers/net/dsa/realtek/realtek-smi.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -312,60 +311,6 @@ static int realtek_smi_read(void *ctx, u32 reg, u32 *val) return realtek_smi_read_reg(priv, reg, val); } -static int realtek_smi_mdio_read(struct mii_bus *bus, int addr, int regnum) -{ - struct realtek_priv *priv = bus->priv; - - return priv->ops->phy_read(priv, addr, regnum); -} - -static int realtek_smi_mdio_write(struct mii_bus *bus, int addr, int regnum, - u16 val) -{ - struct realtek_priv *priv = bus->priv; - - return priv->ops->phy_write(priv, addr, regnum, val); -} - -static int realtek_smi_setup_mdio(struct dsa_switch *ds) -{ - struct realtek_priv *priv = ds->priv; - struct device_node *mdio_np; - int ret = 0; - - mdio_np = of_get_child_by_name(priv->dev->of_node, "mdio"); - if (!mdio_np) { - dev_err(priv->dev, "no MDIO bus node\n"); - return -ENODEV; - } - - priv->user_mii_bus = devm_mdiobus_alloc(priv->dev); - if (!priv->user_mii_bus) { - ret = -ENOMEM; - goto err_put_node; - } - - priv->user_mii_bus->priv = priv; - priv->user_mii_bus->name = "SMI user MII"; - priv->user_mii_bus->read = realtek_smi_mdio_read; - priv->user_mii_bus->write = realtek_smi_mdio_write; - snprintf(priv->user_mii_bus->id, MII_BUS_ID_SIZE, "SMI-%d", - ds->index); - priv->user_mii_bus->parent = priv->dev; - - ret = devm_of_mdiobus_register(priv->dev, priv->user_mii_bus, mdio_np); - if (ret) { - dev_err(priv->dev, "unable to register MDIO bus %s\n", - priv->user_mii_bus->id); - goto err_put_node; - } - -err_put_node: - of_node_put(mdio_np); - - return ret; -} - static const struct realtek_interface_info realtek_smi_info = { .reg_read = realtek_smi_read, .reg_write = realtek_smi_write, @@ -404,7 +349,7 @@ int realtek_smi_probe(struct platform_device *pdev) return PTR_ERR(priv->mdio); priv->write_reg_noack = realtek_smi_write_reg_noack; - priv->setup_interface = realtek_smi_setup_mdio; + priv->setup_interface = rtl83xx_setup_user_mdio; priv->ds_ops = priv->variant->ds_ops_smi; ret = rtl83xx_register_switch(priv); diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c index 53bacbacc82e..525d8c014136 100644 --- a/drivers/net/dsa/realtek/rtl83xx.c +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ #include +#include #include "realtek.h" #include "rtl83xx.h" @@ -42,6 +43,72 @@ void rtl83xx_unlock(void *ctx) } EXPORT_SYMBOL_NS_GPL(rtl83xx_unlock, REALTEK_DSA); +static int rtl83xx_user_mdio_read(struct mii_bus *bus, int addr, int regnum) +{ + struct realtek_priv *priv = bus->priv; + + return priv->ops->phy_read(priv, addr, regnum); +} + +static int rtl83xx_user_mdio_write(struct mii_bus *bus, int addr, int regnum, + u16 val) +{ + struct realtek_priv *priv = bus->priv; + + return priv->ops->phy_write(priv, addr, regnum, val); +} + +/** + * rtl83xx_setup_user_mdio() - register the user mii bus driver + * @ds: DSA switch associated with this user_mii_bus + * + * This function first gets and mdio node under the dev OF node, aborting + * if missing. That mdio node describing an mdio bus is used to register a + * new mdio bus. + * + * Context: Any context. + * Return: 0 on success, negative value for failure. + */ +int rtl83xx_setup_user_mdio(struct dsa_switch *ds) +{ + struct realtek_priv *priv = ds->priv; + struct device_node *mdio_np; + int ret = 0; + + mdio_np = of_get_child_by_name(priv->dev->of_node, "mdio"); + if (!mdio_np) { + dev_err(priv->dev, "no MDIO bus node\n"); + return -ENODEV; + } + + priv->user_mii_bus = devm_mdiobus_alloc(priv->dev); + if (!priv->user_mii_bus) { + ret = -ENOMEM; + goto err_put_node; + } + + priv->user_mii_bus->priv = priv; + priv->user_mii_bus->name = "Realtek user MII"; + priv->user_mii_bus->read = rtl83xx_user_mdio_read; + priv->user_mii_bus->write = rtl83xx_user_mdio_write; + snprintf(priv->user_mii_bus->id, MII_BUS_ID_SIZE, "Realtek-%d", + ds->index); + priv->user_mii_bus->parent = priv->dev; + + ret = devm_of_mdiobus_register(priv->dev, priv->user_mii_bus, mdio_np); + if (ret) { + dev_err(priv->dev, "unable to register MDIO bus %s\n", + priv->user_mii_bus->id); + goto err_put_node; + } + +err_put_node: + of_node_put(mdio_np); + + return ret; +} +EXPORT_SYMBOL_NS_GPL(rtl83xx_setup_user_mdio, REALTEK_DSA); + /** * rtl83xx_probe() - probe a Realtek switch * @dev: the device being probed diff --git a/drivers/net/dsa/realtek/rtl83xx.h b/drivers/net/dsa/realtek/rtl83xx.h index 9eb8197a58fa..b5d464bb850d 100644 --- a/drivers/net/dsa/realtek/rtl83xx.h +++ b/drivers/net/dsa/realtek/rtl83xx.h @@ -12,6 +12,7 @@ struct realtek_interface_info { void rtl83xx_lock(void *ctx); void rtl83xx_unlock(void *ctx); +int rtl83xx_setup_user_mdio(struct dsa_switch *ds); struct realtek_priv * rtl83xx_probe(struct device *dev, const struct realtek_interface_info *interface_info); From patchwork Tue Jan 23 21:44:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 13528176 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 87E893D3A7 for ; Tue, 23 Jan 2024 21:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046314; cv=none; b=rx9raqHOt7ilJE1OkkJUpkpF/W8mITPjeoYOzlSruWiS/wL79o03gZp+53tDT3/UD7tPGOtF3VFZrkToKutHZN0WDnmtDYrO1bgVTHCf8qI1YFKAvMoigR0ZFxKU/r08XwjIlq56dXwSExarspwjaTU7ia93DhpN4l4manPwdd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046314; c=relaxed/simple; bh=MqEmtnzVL6rRdFNLH4nFRtPUxGWmQx4poxAzzED5uyU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZAdk5jdBGNjbYrH23IqPLEZLNgRQ/CILfhUxMDyQ+ZH4iMe+NmtDV2ZLe7HM9vBKCvpc1aQMUvViNgdR1MDVSR0FboVVx0h9FKRPC64nKU7KcJb19LWCfqVTxTVlUHn16fgZZKY+BrIe7FtrNZoMskTACHG5SYQRq+/bQON6HIo= 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=VSvR9HsF; arc=none smtp.client-ip=209.85.214.181 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="VSvR9HsF" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1d7232dcb3eso21854025ad.2 for ; Tue, 23 Jan 2024 13:45:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706046311; x=1706651111; 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=FPKwFAPd5SH+8GvsG8BVZVczl3fT+affPAFyaag5CQ0=; b=VSvR9HsFPkm0UwqJbVvsbAbSDcLCfmb2uKXQe1EJesN7UYQmdNcQfJaXXOc4NfgzEF r9w4UAuh6ewv9Dz5Eu0NnHU38xMYM8LBXk606zHOTzDeQNaMmw0ALzaj/k3M4lQTWsC5 fisyR41S2QmLwWjhiXYA928tk1rxYhhqCVl+wZgiMQmakshctjtI4it+xxXdTJK1q1ku 93wp+HdHs/SW8FGRccOI5SnIxY6bsgEVTWL+/XPOBOz0LCXQ0WPY6DhtXBwyfcdoMou9 7nP+uqpzKqAcCebvE6S5tNNt704xCIly9vnS45beX9W+DFo9stVhbKtnRGj0CuP5Q4rC 99pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706046311; x=1706651111; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FPKwFAPd5SH+8GvsG8BVZVczl3fT+affPAFyaag5CQ0=; b=reQmZa40m8CONDwE46HND7yxzmsOzGSbz5zu1xzIEcvVyWWRTx/YelrZp3Ep/4SJ8f 38z3KxY8VJECmL1gG1g4n8UWPH5HPmwHsrx8oWHSeNc5Ng7fQnmBXXRwIUEeUIZ0mHJQ AIjLfYwG5aJj50s76QLAmEO1RPD+yoL8ZGjJZvTQgFZypeVrVV7XW07Jt4pfVYbUXA5V ZguyZoJfnuh68vJOw88BEk9S98eNfYRNK1Wipb86Z1BEAO8Sduf93GMELAnHL2zAAuV1 jDiRGq2jV615xgM2pByWTTVBT8vKXS51PN8HH23UAWKD+Z/NGQ+FX44SxpJrvDOzKcuZ bFPQ== X-Gm-Message-State: AOJu0YxH8a44O46yaF+Fyq6zuyRTP3fs+pTGeUCQaCu141gihBRNtuMo YvazSnn9/RDoG1lZPHk2s6nvuV2LAUBGcoLpoYXHoNcxbMG9fFcGmj+uzhUfrq8= X-Google-Smtp-Source: AGHT+IF4n0x5tXyB6PnAT0yRUoT91mHtaME6v7tTlMpk4Nit9rqmyHhRuNMpRWlRbGfiOU31SOkuZQ== X-Received: by 2002:a17:902:e5cd:b0:1d4:a179:e68b with SMTP id u13-20020a170902e5cd00b001d4a179e68bmr4940133plf.19.1706046310924; Tue, 23 Jan 2024 13:45:10 -0800 (PST) Received: from tresc054937.tre-sc.gov.br ([187.94.103.218]) by smtp.gmail.com with ESMTPSA id t10-20020a170902bc4a00b001d714a1530bsm8108858plz.176.2024.01.23.13.45.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:45:10 -0800 (PST) From: Luiz Angelo Daros de Luca To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, arinc.unal@arinc9.com, ansuelsmth@gmail.com, Luiz Angelo Daros de Luca Subject: [PATCH 10/11] net: dsa: realtek: use the same mii bus driver for both interfaces Date: Tue, 23 Jan 2024 18:44:18 -0300 Message-ID: <20240123214420.25716-11-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123214420.25716-1-luizluca@gmail.com> References: <20240123214420.25716-1-luizluca@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The realtek-mdio will now use this driver instead of the generic DSA driver ("dsa user smi"), which should not be used with OF[1]. With a single ds_ops for both interfaces, the ds_ops in realtek_priv is no longer necessary. Now, the realtek_variant.ds_ops can be used directly. The realtek_priv.setup_interface() has been removed as we can directly call the new common function. [1] https://lkml.kernel.org/netdev/20220630200423.tieprdu5fpabflj7@bang-olufsen.dk/T/ Signed-off-by: Luiz Angelo Daros de Luca --- drivers/net/dsa/realtek/realtek-mdio.c | 1 - drivers/net/dsa/realtek/realtek-smi.c | 2 - drivers/net/dsa/realtek/realtek.h | 5 +-- drivers/net/dsa/realtek/rtl8365mb.c | 49 +++--------------------- drivers/net/dsa/realtek/rtl8366rb.c | 52 +++----------------------- drivers/net/dsa/realtek/rtl83xx.c | 2 +- 6 files changed, 14 insertions(+), 97 deletions(-) diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c index c75b4550802c..6415408c337d 100644 --- a/drivers/net/dsa/realtek/realtek-mdio.c +++ b/drivers/net/dsa/realtek/realtek-mdio.c @@ -132,7 +132,6 @@ int realtek_mdio_probe(struct mdio_device *mdiodev) priv->bus = mdiodev->bus; priv->mdio_addr = mdiodev->addr; priv->write_reg_noack = realtek_mdio_write; - priv->ds_ops = priv->variant->ds_ops_mdio; ret = rtl83xx_register_switch(priv); if (ret) diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c index 70f3967e56e8..b9523ebc7413 100644 --- a/drivers/net/dsa/realtek/realtek-smi.c +++ b/drivers/net/dsa/realtek/realtek-smi.c @@ -349,8 +349,6 @@ int realtek_smi_probe(struct platform_device *pdev) return PTR_ERR(priv->mdio); priv->write_reg_noack = realtek_smi_write_reg_noack; - priv->setup_interface = rtl83xx_setup_user_mdio; - priv->ds_ops = priv->variant->ds_ops_smi; ret = rtl83xx_register_switch(priv); if (ret) diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h index fbd0616c1df3..7af6dcc1bb24 100644 --- a/drivers/net/dsa/realtek/realtek.h +++ b/drivers/net/dsa/realtek/realtek.h @@ -60,7 +60,6 @@ struct realtek_priv { spinlock_t lock; /* Locks around command writes */ struct dsa_switch *ds; - const struct dsa_switch_ops *ds_ops; struct irq_domain *irqdomain; bool leds_disabled; @@ -71,7 +70,6 @@ struct realtek_priv { struct rtl8366_mib_counter *mib_counters; const struct realtek_ops *ops; - int (*setup_interface)(struct dsa_switch *ds); int (*write_reg_noack)(void *ctx, u32 addr, u32 data); int vlan_enabled; @@ -115,8 +113,7 @@ struct realtek_ops { }; struct realtek_variant { - const struct dsa_switch_ops *ds_ops_smi; - const struct dsa_switch_ops *ds_ops_mdio; + const struct dsa_switch_ops *ds_ops; const struct realtek_ops *ops; unsigned int clk_delay; u8 cmd_read; diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c index 97a41ba73718..d7d3ae4746f6 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -828,17 +828,6 @@ static int rtl8365mb_phy_write(struct realtek_priv *priv, int phy, int regnum, return 0; } -static int rtl8365mb_dsa_phy_read(struct dsa_switch *ds, int phy, int regnum) -{ - return rtl8365mb_phy_read(ds->priv, phy, regnum); -} - -static int rtl8365mb_dsa_phy_write(struct dsa_switch *ds, int phy, int regnum, - u16 val) -{ - return rtl8365mb_phy_write(ds->priv, phy, regnum, val); -} - static const struct rtl8365mb_extint * rtl8365mb_get_port_extint(struct realtek_priv *priv, int port) { @@ -2017,12 +2006,10 @@ static int rtl8365mb_setup(struct dsa_switch *ds) if (ret) goto out_teardown_irq; - if (priv->setup_interface) { - ret = priv->setup_interface(ds); - if (ret) { - dev_err(priv->dev, "could not set up MDIO bus\n"); - goto out_teardown_irq; - } + ret = rtl83xx_setup_user_mdio(ds); + if (ret) { + dev_err(priv->dev, "could not set up MDIO bus\n"); + goto out_teardown_irq; } /* Start statistics counter polling */ @@ -2116,28 +2103,7 @@ static int rtl8365mb_detect(struct realtek_priv *priv) return 0; } -static const struct dsa_switch_ops rtl8365mb_switch_ops_smi = { - .get_tag_protocol = rtl8365mb_get_tag_protocol, - .change_tag_protocol = rtl8365mb_change_tag_protocol, - .setup = rtl8365mb_setup, - .teardown = rtl8365mb_teardown, - .phylink_get_caps = rtl8365mb_phylink_get_caps, - .phylink_mac_config = rtl8365mb_phylink_mac_config, - .phylink_mac_link_down = rtl8365mb_phylink_mac_link_down, - .phylink_mac_link_up = rtl8365mb_phylink_mac_link_up, - .port_stp_state_set = rtl8365mb_port_stp_state_set, - .get_strings = rtl8365mb_get_strings, - .get_ethtool_stats = rtl8365mb_get_ethtool_stats, - .get_sset_count = rtl8365mb_get_sset_count, - .get_eth_phy_stats = rtl8365mb_get_phy_stats, - .get_eth_mac_stats = rtl8365mb_get_mac_stats, - .get_eth_ctrl_stats = rtl8365mb_get_ctrl_stats, - .get_stats64 = rtl8365mb_get_stats64, - .port_change_mtu = rtl8365mb_port_change_mtu, - .port_max_mtu = rtl8365mb_port_max_mtu, -}; - -static const struct dsa_switch_ops rtl8365mb_switch_ops_mdio = { +static const struct dsa_switch_ops rtl8365mb_switch_ops = { .get_tag_protocol = rtl8365mb_get_tag_protocol, .change_tag_protocol = rtl8365mb_change_tag_protocol, .setup = rtl8365mb_setup, @@ -2146,8 +2112,6 @@ static const struct dsa_switch_ops rtl8365mb_switch_ops_mdio = { .phylink_mac_config = rtl8365mb_phylink_mac_config, .phylink_mac_link_down = rtl8365mb_phylink_mac_link_down, .phylink_mac_link_up = rtl8365mb_phylink_mac_link_up, - .phy_read = rtl8365mb_dsa_phy_read, - .phy_write = rtl8365mb_dsa_phy_write, .port_stp_state_set = rtl8365mb_port_stp_state_set, .get_strings = rtl8365mb_get_strings, .get_ethtool_stats = rtl8365mb_get_ethtool_stats, @@ -2167,8 +2131,7 @@ static const struct realtek_ops rtl8365mb_ops = { }; const struct realtek_variant rtl8365mb_variant = { - .ds_ops_smi = &rtl8365mb_switch_ops_smi, - .ds_ops_mdio = &rtl8365mb_switch_ops_mdio, + .ds_ops = &rtl8365mb_switch_ops, .ops = &rtl8365mb_ops, .clk_delay = 10, .cmd_read = 0xb9, diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c index ec7a55d70bad..5084ad151f0f 100644 --- a/drivers/net/dsa/realtek/rtl8366rb.c +++ b/drivers/net/dsa/realtek/rtl8366rb.c @@ -1033,12 +1033,10 @@ static int rtl8366rb_setup(struct dsa_switch *ds) if (ret) dev_info(priv->dev, "no interrupt support\n"); - if (priv->setup_interface) { - ret = priv->setup_interface(ds); - if (ret) { - dev_err(priv->dev, "could not set up MDIO bus\n"); - return -ENODEV; - } + ret = rtl83xx_setup_user_mdio(ds); + if (ret) { + dev_err(priv->dev, "could not set up MDIO bus\n"); + return -ENODEV; } return 0; @@ -1785,17 +1783,6 @@ static int rtl8366rb_phy_write(struct realtek_priv *priv, int phy, int regnum, return ret; } -static int rtl8366rb_dsa_phy_read(struct dsa_switch *ds, int phy, int regnum) -{ - return rtl8366rb_phy_read(ds->priv, phy, regnum); -} - -static int rtl8366rb_dsa_phy_write(struct dsa_switch *ds, int phy, int regnum, - u16 val) -{ - return rtl8366rb_phy_write(ds->priv, phy, regnum, val); -} - static int rtl8366rb_reset_chip(struct realtek_priv *priv) { int timeout = 10; @@ -1861,35 +1848,9 @@ static int rtl8366rb_detect(struct realtek_priv *priv) return 0; } -static const struct dsa_switch_ops rtl8366rb_switch_ops_smi = { - .get_tag_protocol = rtl8366_get_tag_protocol, - .setup = rtl8366rb_setup, - .phylink_get_caps = rtl8366rb_phylink_get_caps, - .phylink_mac_link_up = rtl8366rb_mac_link_up, - .phylink_mac_link_down = rtl8366rb_mac_link_down, - .get_strings = rtl8366_get_strings, - .get_ethtool_stats = rtl8366_get_ethtool_stats, - .get_sset_count = rtl8366_get_sset_count, - .port_bridge_join = rtl8366rb_port_bridge_join, - .port_bridge_leave = rtl8366rb_port_bridge_leave, - .port_vlan_filtering = rtl8366rb_vlan_filtering, - .port_vlan_add = rtl8366_vlan_add, - .port_vlan_del = rtl8366_vlan_del, - .port_enable = rtl8366rb_port_enable, - .port_disable = rtl8366rb_port_disable, - .port_pre_bridge_flags = rtl8366rb_port_pre_bridge_flags, - .port_bridge_flags = rtl8366rb_port_bridge_flags, - .port_stp_state_set = rtl8366rb_port_stp_state_set, - .port_fast_age = rtl8366rb_port_fast_age, - .port_change_mtu = rtl8366rb_change_mtu, - .port_max_mtu = rtl8366rb_max_mtu, -}; - -static const struct dsa_switch_ops rtl8366rb_switch_ops_mdio = { +static const struct dsa_switch_ops rtl8366rb_switch_ops = { .get_tag_protocol = rtl8366_get_tag_protocol, .setup = rtl8366rb_setup, - .phy_read = rtl8366rb_dsa_phy_read, - .phy_write = rtl8366rb_dsa_phy_write, .phylink_get_caps = rtl8366rb_phylink_get_caps, .phylink_mac_link_up = rtl8366rb_mac_link_up, .phylink_mac_link_down = rtl8366rb_mac_link_down, @@ -1928,8 +1889,7 @@ static const struct realtek_ops rtl8366rb_ops = { }; const struct realtek_variant rtl8366rb_variant = { - .ds_ops_smi = &rtl8366rb_switch_ops_smi, - .ds_ops_mdio = &rtl8366rb_switch_ops_mdio, + .ds_ops = &rtl8366rb_switch_ops, .ops = &rtl8366rb_ops, .clk_delay = 10, .cmd_read = 0xa9, diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c index 525d8c014136..2f39472a44d2 100644 --- a/drivers/net/dsa/realtek/rtl83xx.c +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -229,7 +229,7 @@ int rtl83xx_register_switch(struct realtek_priv *priv) priv->ds->priv = priv; priv->ds->dev = priv->dev; - priv->ds->ops = priv->ds_ops; + priv->ds->ops = priv->variant->ds_ops; priv->ds->num_ports = priv->num_ports; ret = dsa_register_switch(priv->ds); From patchwork Tue Jan 23 21:44:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 13528177 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 6D9A941742 for ; Tue, 23 Jan 2024 21:45:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046317; cv=none; b=Fuz8Zmc3GSaHX0gYAvS66R52F8e9w4i0kYCCOkn7Y/IbYpdntQso3RLfoG4eZ+NOQqEvvsYDg3acHygSvkEtqrCITPJqz0t9QCdN9bohavCLvDmwqZ8WngW2+ey/osSjGJTiGFc7uhx4RZePgPSfvU8ahmfgwj6/QDIyPLqoAKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706046317; c=relaxed/simple; bh=rQ95yVJFqylTALu1gdEHyaUYJGg4ZYRQB8hCxjrmITc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C3UGxrnw6tOCfVfOf6tdSVuK44kFNCDRVVmwlXmtW2+P9/YR5gq8xfPov3UwSciIJ81ArCOweJyZcyBAAqx+k0wkS3CUw0j3V6wnOOazf8k4y6u84pdHHBqziyrLpGiHUsUcgBY6yVt5H/K5b6nsLrxllJqPRfHAQPT6WaJOG9A= 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=lGHzI2AW; arc=none smtp.client-ip=209.85.214.172 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="lGHzI2AW" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1d75ea3a9b6so19405905ad.2 for ; Tue, 23 Jan 2024 13:45:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706046315; x=1706651115; 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=XPphyBFl2ZkZLekwDj2ZKLqYREeo0SxOjMGIDks01l0=; b=lGHzI2AWN9BvN6k0OsjkKuRRD2Wm19807S28gecz6UKWekRe3O3GKIa5dwb7gxuVk6 DRd5CHkygMkB81l7QN0/q56WKDljfIEzJkjBPq5ZovVBeg+FisCSkHdqawti517Jwfdb fkuU0wUtVtUga/qY3RXCVXe4yUkHKYUnpp4LTW1nKSMPU4nsFMlyTXSzOm9+PM/0iAhx c+s7T8sVB6AQDcuziNwzkLjQg8gWj04JOum1oDIArK/MXg0TUwcwLJuyso6hzz+U01Nn C8hyPJr67mKy8vutR7FkdviTK7phLEdqz/j65vFcWT1D2VnZbZBQZWcQ51CVQdjqWpuS Daaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706046315; x=1706651115; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XPphyBFl2ZkZLekwDj2ZKLqYREeo0SxOjMGIDks01l0=; b=hzyIwMPyaNaPez/xm10KGb+MhRU9JhahJnlMFcRLx3AoS15TRjWMm79JpFbaSR9g9i 05waNULGU/FD2G9oU7s3Qc0pAWXaZ8A2efLSFCHswULcXaKIxgIN5bJv5vbPcvqRSm/z c7cBfVOeF5XFurX1DLOafWCpnFx80n7gD+j5u7KhofJD0yX/4PrFOX/roll/I67Up/uR gJ6DFc9D8Y1wwOYGYySwCtMrHHHwFFBRK+AlnXmaP+6e03pByYe+NHnJdKpY0m/whTNp 9Msn0I7xChEl0qTpl9IoBC70e/siN18wKL8te0qT2uuHwJVI2rzwhaXk8HdDe4m3M0iW E5Mg== X-Gm-Message-State: AOJu0Yx+xLeNazW/3oQ7kku7dAdAAMzWbJ+qIMu5+K411Mc16hfstYp7 lCgTEnT88e0uDQnIXigd010w5GyUmz+baLjo7+V2TY9cybdCNY/03ORrKd2GQrA= X-Google-Smtp-Source: AGHT+IGQrBu307+d7tpVdKSdeaA2/lDmkK7W/19coCli5lJT2pTBuQ7ioE7zNvHRJqFO+6Erehiuug== X-Received: by 2002:a17:902:9306:b0:1d5:a279:242b with SMTP id bc6-20020a170902930600b001d5a279242bmr6234466plb.28.1706046315273; Tue, 23 Jan 2024 13:45:15 -0800 (PST) Received: from tresc054937.tre-sc.gov.br ([187.94.103.218]) by smtp.gmail.com with ESMTPSA id t10-20020a170902bc4a00b001d714a1530bsm8108858plz.176.2024.01.23.13.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:45:14 -0800 (PST) From: Luiz Angelo Daros de Luca To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, alsi@bang-olufsen.dk, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, arinc.unal@arinc9.com, ansuelsmth@gmail.com, Luiz Angelo Daros de Luca Subject: [PATCH 11/11] net: dsa: realtek: embed dsa_switch into realtek_priv Date: Tue, 23 Jan 2024 18:44:19 -0300 Message-ID: <20240123214420.25716-12-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123214420.25716-1-luizluca@gmail.com> References: <20240123214420.25716-1-luizluca@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org To eliminate the need for a second memory allocation for dsa_switch, it has been embedded within realtek_priv. Suggested-by: Alvin Šipraga Signed-off-by: Luiz Angelo Daros de Luca --- drivers/net/dsa/realtek/realtek-mdio.c | 2 +- drivers/net/dsa/realtek/realtek-smi.c | 2 +- drivers/net/dsa/realtek/realtek.h | 2 +- drivers/net/dsa/realtek/rtl8365mb.c | 12 ++++++------ drivers/net/dsa/realtek/rtl8366rb.c | 2 +- drivers/net/dsa/realtek/rtl83xx.c | 16 ++++++---------- 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c index 6415408c337d..cb3bc6219c6c 100644 --- a/drivers/net/dsa/realtek/realtek-mdio.c +++ b/drivers/net/dsa/realtek/realtek-mdio.c @@ -179,7 +179,7 @@ void realtek_mdio_shutdown(struct mdio_device *mdiodev) if (!priv) return; - dsa_switch_shutdown(priv->ds); + dsa_switch_shutdown(&priv->ds); dev_set_drvdata(&mdiodev->dev, NULL); } diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c index b9523ebc7413..eac9ce5d6ae0 100644 --- a/drivers/net/dsa/realtek/realtek-smi.c +++ b/drivers/net/dsa/realtek/realtek-smi.c @@ -396,7 +396,7 @@ void realtek_smi_shutdown(struct platform_device *pdev) if (!priv) return; - dsa_switch_shutdown(priv->ds); + dsa_switch_shutdown(&priv->ds); platform_set_drvdata(pdev, NULL); } diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h index 7af6dcc1bb24..0217b8032c01 100644 --- a/drivers/net/dsa/realtek/realtek.h +++ b/drivers/net/dsa/realtek/realtek.h @@ -59,7 +59,7 @@ struct realtek_priv { int mdio_addr; spinlock_t lock; /* Locks around command writes */ - struct dsa_switch *ds; + struct dsa_switch ds; struct irq_domain *irqdomain; bool leds_disabled; diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c index d7d3ae4746f6..c9dbe0240ab7 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -880,7 +880,7 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port, if (!extint) return -ENODEV; - dp = dsa_to_port(priv->ds, port); + dp = dsa_to_port(&priv->ds, port); dn = dp->dn; /* Set the RGMII TX/RX delay @@ -1543,7 +1543,7 @@ static void rtl8365mb_stats_setup(struct realtek_priv *priv) for (i = 0; i < priv->num_ports; i++) { struct rtl8365mb_port *p = &mb->ports[i]; - if (dsa_is_unused_port(priv->ds, i)) + if (dsa_is_unused_port(&priv->ds, i)) continue; /* Per-port spinlock to protect the stats64 data */ @@ -1564,7 +1564,7 @@ static void rtl8365mb_stats_teardown(struct realtek_priv *priv) for (i = 0; i < priv->num_ports; i++) { struct rtl8365mb_port *p = &mb->ports[i]; - if (dsa_is_unused_port(priv->ds, i)) + if (dsa_is_unused_port(&priv->ds, i)) continue; cancel_delayed_work_sync(&p->mib_work); @@ -1963,7 +1963,7 @@ static int rtl8365mb_setup(struct dsa_switch *ds) dev_info(priv->dev, "no interrupt support\n"); /* Configure CPU tagging */ - dsa_switch_for_each_cpu_port(cpu_dp, priv->ds) { + dsa_switch_for_each_cpu_port(cpu_dp, &priv->ds) { cpu->mask |= BIT(cpu_dp->index); if (cpu->trap_port == RTL8365MB_MAX_NUM_PORTS) @@ -1978,7 +1978,7 @@ static int rtl8365mb_setup(struct dsa_switch *ds) for (i = 0; i < priv->num_ports; i++) { struct rtl8365mb_port *p = &mb->ports[i]; - if (dsa_is_unused_port(priv->ds, i)) + if (dsa_is_unused_port(&priv->ds, i)) continue; /* Forward only to the CPU */ @@ -1995,7 +1995,7 @@ static int rtl8365mb_setup(struct dsa_switch *ds) * ports will still forward frames to the CPU despite being * administratively down by default. */ - rtl8365mb_port_stp_state_set(priv->ds, i, BR_STATE_DISABLED); + rtl8365mb_port_stp_state_set(&priv->ds, i, BR_STATE_DISABLED); /* Set up per-port private data */ p->priv = priv; diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c index 5084ad151f0f..30ae30cdbea5 100644 --- a/drivers/net/dsa/realtek/rtl8366rb.c +++ b/drivers/net/dsa/realtek/rtl8366rb.c @@ -1675,7 +1675,7 @@ static int rtl8366rb_set_mc_index(struct realtek_priv *priv, int port, int index * not drop any untagged or C-tagged frames. Make sure to update the * filtering setting. */ - if (dsa_port_is_vlan_filtering(dsa_to_port(priv->ds, port))) + if (dsa_port_is_vlan_filtering(dsa_to_port(&priv->ds, port))) ret = rtl8366rb_drop_untagged(priv, port, !pvid_enabled); return ret; diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c index 2f39472a44d2..ac8c632263c6 100644 --- a/drivers/net/dsa/realtek/rtl83xx.c +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -223,16 +223,12 @@ int rtl83xx_register_switch(struct realtek_priv *priv) return ret; } - priv->ds = devm_kzalloc(priv->dev, sizeof(*priv->ds), GFP_KERNEL); - if (!priv->ds) - return -ENOMEM; + priv->ds.priv = priv; + priv->ds.dev = priv->dev; + priv->ds.ops = priv->variant->ds_ops; + priv->ds.num_ports = priv->num_ports; - priv->ds->priv = priv; - priv->ds->dev = priv->dev; - priv->ds->ops = priv->variant->ds_ops; - priv->ds->num_ports = priv->num_ports; - - ret = dsa_register_switch(priv->ds); + ret = dsa_register_switch(&priv->ds); if (ret) { dev_err_probe(priv->dev, ret, "unable to register switch\n"); return ret; @@ -257,7 +253,7 @@ void rtl83xx_remove(struct realtek_priv *priv) if (!priv) return; - dsa_unregister_switch(priv->ds); + dsa_unregister_switch(&priv->ds); /* leave the device reset asserted */ if (priv->reset)