From patchwork Tue Jan 23 21:55:53 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: 13528183 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.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 80587487AE for ; Tue, 23 Jan 2024 21:56:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047014; cv=none; b=D66yS3M5tqse1aO1o5x1arPK3b1pGe42XdwDf/GMZfRDnY1pOkW9fM+2WEzC4ctVfspf8t0lvsQkNlnMPBhbSw0W3bqZ2h+F1KtigR8onnHAExUkpd859hpM5wDtYpzhaDzfvUz6TEdmBPSAn2GI11gf3efR0HMo7fEzjA3TWgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047014; 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=nHZVOVDHrsKL/q9Pk6U/77wF00JdPCVvaDX5pCw5mbxEDZ/1m/PCdvV0zm8LxdF91jP2WNpDZjdg0JsfIYLUPfHEl8qSaZbFoc1OV4OwQvgyf9EUB/yaxtbcS/UZa6QWk/mvi7XW+aiOdAv7vt9NsOI2bu5whQ8INFkldEFNOLw= 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=Ea35Vkei; arc=none smtp.client-ip=209.85.210.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="Ea35Vkei" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6dd7b525cd6so916944b3a.2 for ; Tue, 23 Jan 2024 13:56:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706047012; x=1706651812; 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=Ea35VkeisjSks13O/CDyE/05cSdshyiamlJAsHKi4nfgsyxBKFXnDGQlLo9OEYwFQ3 +F+j08xsrUlRe0oFkyGosJAuStdUBRKphe1z1+Xvc0thsLoX101uGTX/hMKjZjYZ64SO cw5TlSE72iS6zGZR02l2/8jQxZW8SYw/EjM99I6y1avF8+LcymyTU2auF15xTSRpUMxz dlcVbs62QxE31/oRhjtKTKwKF0Vy28WLnAispOq17vFxRvBoXk2jOp23RlJjRxCKDPsz y2Eq5MGDUoIaoTcW4Y4VMMolnMKpxajofv8qRQ9TXfAjNHVJ/m/CyqbWofPVrFOdvJ1e sCeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706047012; x=1706651812; 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=SWYtm4NDtDg+toSlAyPsGNL2kBs+ZZrXcOVPKgYtaZIp67IqrlUuRUrfRcbIWcQUcS Z8jy/vEjEj+esoe53BMwSypF9GQgkxoZwxHa6hbRKhQglQLtimUj59CHINhjIvH6GFnU qU0qibgLulLB4DenncZz70+5PxcexxBvqRQoiFc4ZtktrJYSIsfzmQNrJQzMGOJvtlRn b/kFKO0VWM+Oqc9swSEkzXB36P4zpbO6dNf8S+q61sgWCXBpf0d96XjRyuzvixbA4Zp5 XQ6pLtmDpltrNvKbHp3RBWyJ0IQUpSN+CKiJfUBkO1GEAmhWy8njCDz9nWQOTnXdINGV mioQ== X-Gm-Message-State: AOJu0YxGMGxUkyvgTdlxT0wBzapLYXFfBMs6mJ8+3/2cu5NkOo65ylGX 5gR8KxxqpQgjVFLQpQgfEvJZANGM6evBOzHXaKGKG/m6lhNJG3I4QuITupArgMI= X-Google-Smtp-Source: AGHT+IEB8oHdNs2KIA/e3/fmkYwnZP2g98IKR2XL7CINA+bv+NqoaMq03aOudnpg428BRtmuNdee7g== X-Received: by 2002:a05:6a00:1812:b0:6db:e54d:3ae6 with SMTP id y18-20020a056a00181200b006dbe54d3ae6mr3469237pfa.42.1706047011812; Tue, 23 Jan 2024 13:56:51 -0800 (PST) Received: from tresc054937.tre-sc.gov.br (177-131-126-82.acessoline.net.br. [177.131.126.82]) by smtp.gmail.com with ESMTPSA id q17-20020a637511000000b005d43d5a9678sm693738pgc.35.2024.01.23.13.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:56:51 -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 net-next v4 01/11] net: dsa: realtek: drop cleanup from realtek_ops Date: Tue, 23 Jan 2024 18:55:53 -0300 Message-ID: <20240123215606.26716-2-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123215606.26716-1-luizluca@gmail.com> References: <20240123215606.26716-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:55:54 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: 13528184 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.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 705BC487AE for ; Tue, 23 Jan 2024 21:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047019; cv=none; b=GCuknoxr56SFjiH3bjQ5NeDwVK/+YcYAOtiduA4IRGSxE8Kr4aXacvDcJABqK9z0AOpzq9Gfq90yMmb2rlLvVWlUwkxONHIboWJwN02cbPl9a6jArwM0HqHZACJpZuvbEZKroydtxHK6qA8dbdod4tAsv9kT0lyleGGWA6+aiLE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047019; c=relaxed/simple; bh=JxlhgfKDAH9pG+T7CbuWIczAu124O8TR8etJzIuzVIc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mGQUZc7UrCk4kped3Kl47qXO8M6yIqWfCRyrbOCMRz/mswfZAlFZjTRXzjXmldS9iOpGmuLssoBSHPX/ijbZepGPnpvvBR5na8WQvSbNgR1TDXZE5EHaaqduxG4mvoLsMLZjp/WJmFNWiZusPmZp5MEzbc0+5/WKo43e4o1GSHI= 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=jNoTbq3s; arc=none smtp.client-ip=209.85.166.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="jNoTbq3s" Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-3627e9f1b40so12017705ab.1 for ; Tue, 23 Jan 2024 13:56:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706047016; x=1706651816; 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=jNoTbq3sIjomgB5b6pPywuob+8xavc3Y5ffg/ferUPBz5MlS8iX3Fj2h2FOYIYTOSh 0kAKEfuhDHDXPMU+LVthzJCUtUhZEnaw7PeqUsm19BHmAfN5+3SEeLO3SLvjUNPLRsz7 NnDI9pAZ3PVwwNgyJ9FpZjb7Wdu8ONgLQpYz5KTuWOakgLCjDqve3AoefaRxlaNypUxd bZGVTRBYHeEgG1ZHH2YgbW7uAzEjedLhIISeQzaIVCzl29mEzgWT3lxcGT2pJPrPkYAe mTtACLyfglzDBseGK/Pj7EHYgt1HBI07IexlYbr53M/GUHO2z0jfXBmuDpmmI45BQr3y 0cGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706047016; x=1706651816; 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=PvoxVKReeZ4v4sfq9XD9l9DCJDcUPHznWMzzAJePJcZ1myN87D97Z1WjpafahySNRh 3+sb+Snh0MttJMNMyzggPso32zRpvuBNZFKPWafih/QQK1b0aOoCzL0URYFxnWUUy1Rs zYbHLY10fG1/DggyQulzg++FQ19H6wGQg82/V9cIid50bylka/RD2UhghHD0E7LO1boy zjwfZfsXv2GYfZ+MsnBPVMjcXBeQbmQ9qsWuVvD43p9t8VzAheD1RB81nuAQDZbJJGNj BmXre2GCmhQADaDecab4WrLFHMWz/pSjwThZLVmY+Tlvn/jQ2iAvORoH/anUVcmG36cn LKYQ== X-Gm-Message-State: AOJu0Yw+oGBP5s+qlB6IvIh+NaKWFMlgW/nWFCJaetOlWH81FnOoEshG 63QO3ECG8C+sPzVeIoibAiGlJZvgRdU329caW0s8rGgMOTX9YHdYaYCeQPrIKNo= X-Google-Smtp-Source: AGHT+IFjvWlVF5jYNXkSr+otgd1Lc+b1W4omhXkT4Nqy45p5Hz5eMimf/IPPgLshJ4vyQ1VGfPNZAw== X-Received: by 2002:a92:cc49:0:b0:360:a340:dae5 with SMTP id t9-20020a92cc49000000b00360a340dae5mr486271ilq.31.1706047016652; Tue, 23 Jan 2024 13:56:56 -0800 (PST) Received: from tresc054937.tre-sc.gov.br (177-131-126-82.acessoline.net.br. [177.131.126.82]) by smtp.gmail.com with ESMTPSA id q17-20020a637511000000b005d43d5a9678sm693738pgc.35.2024.01.23.13.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:56:56 -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 net-next v4 02/11] net: dsa: realtek: introduce REALTEK_DSA namespace Date: Tue, 23 Jan 2024 18:55:54 -0300 Message-ID: <20240123215606.26716-3-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123215606.26716-1-luizluca@gmail.com> References: <20240123215606.26716-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 Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- 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:55:55 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: 13528185 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (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 4B4EC495E4 for ; Tue, 23 Jan 2024 21:57:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047025; cv=none; b=VrvR8V/fAhRM543zaJuCrt1WwKEgT2gdADTC0rEEVySvP46llxoICpEuS0IagSs/GW1Ob/HCD2WfM5Klb8OLBgXZSTe/D4QmSHuBixcJ8ZHXK5yq0yTQN6pqJ8v8y0g/Bb5yqJnZIbgaOBmW2Fz4bqUjhnoaKHrt3v9fXucYrcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047025; 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=OMgbj2aOcpZN4WYHFxzWrRDCwjxUwb+OmphwhQRRQtyc6v+PzcS7m2MR/ZyuX4Oq4PlLdC2nzu/iQBFSmrmeqInDZ3m0Xfs/AmE/Uv80uRj2e42BLEIYxsekFds1BMEvPKWVMof6VfHEtexIEnKo4jx67Fl+Oq4i0oCDAvSuAXk= 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=bu2ShPTE; arc=none smtp.client-ip=209.85.215.175 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="bu2ShPTE" Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-5cfb81124ecso3439787a12.2 for ; Tue, 23 Jan 2024 13:57:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706047022; x=1706651822; 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=bu2ShPTEbY1t2Kx9d6yHIarPKVLds8adpHjg9Zny1n8NxjNbjn0Xp7RbiuYNx6rFJz t2Pbsm4hgXTZDlKf0i30+HGDW05BPs3cBlCVPRAJd6Cp/xFmC/iW2DLX/3x7A+34m4Xg z+EfveqVfIS0LQ5e4MrEtejXtqmpHAp52HUY4Q9/EeDPCxJBmmfqIegGMqS5egW//T8k KDQzFbIDiond2a0TVcaAHI4vEJVAwi0P6yrCYwemDHQXha906NlOXTU1aD1ETonN+w0q MnDv5uZzcLayn8YxZK0+OohT/qzZToQ2GF5TAlplfenWqvLkznFUqqiwCeVpfae03xG5 IQ8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706047022; x=1706651822; 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=KV5JKBwAlMX+Wn76MzgLMKZWis0le2aImJfQzyAVGhPZgP5bQ3XSjPzEhg1gE6MFbw dkddNPIv1ndgOB8udIopzkI0+s7C+lQ0ToM8u/a0fd9Oyz3n79SJtUoqSfVpKi3aZKQ2 h3DDjNnANzGkV7q5d7yl2TeAVhdXMj0JKNjvyWrQDVSVUSyNfuQLTgzXvMIGYnJcVBdG zweHVJOcvEuoNputRIhcDhMKTYNSzhcazsm6TeG+J5Sjb8x+MAgEEnphNxJwbzQUW585 FupnRjtVpdK+gIW6XwTRaxxxtPkZ5PPKkG0pcsjQZt+kf/UhiObwJU7P1m/TYtiBzY+e +epw== X-Gm-Message-State: AOJu0YwB5u4lVXZO24G+08vHjNNGyEJxaBxbKCcUDUN3YvZPyyR18+vE vrR5f+8lybV3oB/OIbQCNbrPSq5bLmxmmeUjT3uXg5nMsBq6vVSk/r2KZzud7LU= X-Google-Smtp-Source: AGHT+IETZY3yj2iuTVLhtsnR2ER77G5SpqVf8wuy8gIzwqZDfKsq0gQmHSzKuAb8UBiebcIWyjdbZw== X-Received: by 2002:a05:6a20:8f01:b0:19c:4c51:6588 with SMTP id b1-20020a056a208f0100b0019c4c516588mr3440258pzk.77.1706047021648; Tue, 23 Jan 2024 13:57:01 -0800 (PST) Received: from tresc054937.tre-sc.gov.br (177-131-126-82.acessoline.net.br. [177.131.126.82]) by smtp.gmail.com with ESMTPSA id q17-20020a637511000000b005d43d5a9678sm693738pgc.35.2024.01.23.13.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:57: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 net-next v4 03/11] net: dsa: realtek: convert variants into real drivers Date: Tue, 23 Jan 2024 18:55:55 -0300 Message-ID: <20240123215606.26716-4-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123215606.26716-1-luizluca@gmail.com> References: <20240123215606.26716-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:55:56 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: 13528186 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.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 879F54E1CB for ; Tue, 23 Jan 2024 21:57:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047029; cv=none; b=MjTqeu3meWdM3ccSuLs2HhlAQ3G5bu0bQx7qhWXj+3TSbapsyn0bqDKmAwSlFkrcdk83VHvfGlokxGZ6lK5k0mpb+fkBB9Uuo3Wm16lAU+AMZLJ9RKTnWEokHY8IChO9NVRC+tu6HN4fzpFuy+DhIqNaZ859dmXAWd6Vcs4Ki2g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047029; c=relaxed/simple; bh=vmYSQ06z2z9jiayeX1kvZ5B4z6AIoWWtEQhcjBq46Lw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q+o57VUNg8Qf5JLeqXI9mcFLewoCskT5bcIrahlxuEpV9uybCZUmXg1nX010vbUp9GT4wMuy7WkE9rh98M6P5yE5Bp1JkTyUeMIVDyaSh3VaDpikGUH/iBPJCsiPKHx8lzLiuum9dXOMVRo/UPtKIqnJcIgiRmw/cMGi3s9SyXc= 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=DFHtSZGC; arc=none smtp.client-ip=209.85.210.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="DFHtSZGC" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6dd7c194bb2so770531b3a.0 for ; Tue, 23 Jan 2024 13:57:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706047026; x=1706651826; 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=DFHtSZGC16yW3DPAhUT64AEZyf92jlYrjmniYoucsJLky9oKoLIU7PdmRA2H64S4Pl i2GP1T/NvlBCXpGmI2A/GZxhmb1tw6UCI38Yn3y7zPAXqFaYCMBvnP6nSgx2fctLvurZ rX4kAK8X1b5nrj0rQGIJML9LW30EpYFVImaLMsemo5Tugz5J/herG2Qb8xYynK2BlRLh 7a07MLyPWMmeOrAPbLC/03sDh3lr11NZQSHMyyAISrEvQMVGsQOAHWqR5yzU7EH7XvfP 0HPLxGvbXSIzc3e3nfu119qLg4Tqyv+MHXi7tbZjnOmicjxbzhoyLGBToeUIBcCrTt0T MXkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706047026; x=1706651826; 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=qFEC7u8fxnev8PKcPtCxT18eammbOtlDd/Z1DQnWq6ETaD3Ul6WxreYf5DA2BuxvGh 4FcMvy2QFSo/BCtxW5nJDpyd4rMhrGH3DmWurX0LxkCLZMZMjBSfYoT/C92ffh3vzL5o B1grmDSuKjNeBYlcbEPtTStRMbNsKm5rgV1rYjD+ec+ZsjA37fPHgK8zoCwRUL/4Yg6M DraiUKD0+edPTMDRfIM6ER8MQtWhwFQBM3m9uI5kMCIR2DOo4gfbp8nnbmzlgbcpy97O ZaS9Ja6sNSBNOrBSt702TVxvSV402nYsa0G0DW58KAFXKdMmoBizc361LJBLI/io8kPs imdg== X-Gm-Message-State: AOJu0YwV5AEhadzUFmXxyj/QUH7j+0DITDA9j+eze4I2nXVGExQgmbxz WrXfWtKcLVmSZO4HMDRSZzMgLrdKFqMARc1pD0Y4SDyitEx5BF928lsygE5+LDE= X-Google-Smtp-Source: AGHT+IH8dmMlFzjy4F/190hMOtYk2XuqQDSRLoqw+p0FTmQLImbniafiylG0YtFVS4yR8pFh3HxWfw== X-Received: by 2002:aa7:8885:0:b0:6db:d5b9:7b4c with SMTP id z5-20020aa78885000000b006dbd5b97b4cmr295782pfe.25.1706047026080; Tue, 23 Jan 2024 13:57:06 -0800 (PST) Received: from tresc054937.tre-sc.gov.br (177-131-126-82.acessoline.net.br. [177.131.126.82]) by smtp.gmail.com with ESMTPSA id q17-20020a637511000000b005d43d5a9678sm693738pgc.35.2024.01.23.13.57.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:57:05 -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 net-next v4 04/11] net: dsa: realtek: keep variant reference in realtek_priv Date: Tue, 23 Jan 2024 18:55:56 -0300 Message-ID: <20240123215606.26716-5-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123215606.26716-1-luizluca@gmail.com> References: <20240123215606.26716-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 Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- 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:55:57 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: 13528187 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.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 B5A014EB29 for ; Tue, 23 Jan 2024 21:57:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047035; cv=none; b=mb/XYoExvMC/MacKx0ARcIKgoeJyNG/0ISszmsloBIDrUSHQkQHKWDxjFkAc4x0M3V0Yu4PVrJJLYRCDemZLJeSpYIR5tChWf+wl/nK0hi4llHEG/8Lv8oo4pqnSVM4Z0N32UwHHHjKqhblIIff7sCa9Md0FK0vGHajta3GjMHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047035; c=relaxed/simple; bh=pswhXqnecuEGZaOGOSQ8njyGIX8bIkw41ZaBGJlgM5w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SdYm5st0h4pEFD/rvjhublAlwHZM9KOIfsgI/+TeZUyjOty0yoTS9IL66YgxJ6KTaHC4EMhII3SZ0T8XxX+jJ51sWCUAHQp/7dab3OkAs9F8xrFJD/IZFt6wih1CTxq5Zr4Oy0dS/rfGGHXYXNuPw5CUpgRaO4fjHtjvug2gMPg= 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=LfUosGGJ; arc=none smtp.client-ip=209.85.166.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="LfUosGGJ" Received: by mail-il1-f180.google.com with SMTP id e9e14a558f8ab-36278a62926so8062395ab.3 for ; Tue, 23 Jan 2024 13:57:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706047031; x=1706651831; 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=LfUosGGJ4dC6YRoe5Z107wGBxMlgYMWBFkplx7LkAA+0donjodqCEeCXmbjRZbtu2N wX8ThXKhHSm5x3dD0WdS/bX6zthIkE4ALv+TM4CNOvOiJ6uxXD8/f1Ihhff7L+lB2DPS cAMKn7ulTjVtW5+Gdq0jUpuDdrw0qz+Nk5qVIVTSYRmk1r5RbnYv1fPW/vFP6PaBxa7A jzssQiFNF9lnSJIrb2lFkFcY30PkoKkbGLoIftI640HDRCGvX13JLw0LHanP+vULnb77 HH+qEJaKAbS6xEhNjO1W4ihIlUH7vk7AScGZuRRrN/boFSBMo/xXaa6OzucymQpZ+Qvd MSCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706047031; x=1706651831; 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=KrLR+L4s+zAIR6Qo1KmYuHIKU+miHV1+c5CEMAv/AYxc+2nXYRdX/uMLlAwE0ChN5r T5wtawZXn9PpUVlleb2aepUgFEC5fkkpGPnT4B2DMPShnTNnfzePaKoZ5Iwzb5Ef9wwl uP1nRMHfgAdL5JezlbZUJ+xwIDTU3xYKsffjQUfJKKX00oBfiLwcvbNUgy70Ey4/PO61 +wwXvHJf4E2dEhflRKG5beavMOttDyLUiaVMovzEolXdicoXaC6X358dlwCeExWb7vs9 uG0SqyY2tfSXvhzr0h0NXFbP7aNTYSiJRkuptDCzyjcpvJkXp9b8W5xeW07gZW4XTf6T Cd4Q== X-Gm-Message-State: AOJu0YwJ7ls2+b9yG2rwam3mN8T0it3FeC7cYfrvMSN0Lgs/j3uUsHkw 4PMAyc0TvT9D9uV3QY+zuxxF/pwacNkfKZeAtn7YdczIKCaU+TcBVkDClWylRYk= X-Google-Smtp-Source: AGHT+IEXf28aALna45PYOvhgrs6oSt2vRJo7ll2vIf9QFlJq+w3xRNXxNmRsyY5mfP8DZhD62iKiLQ== X-Received: by 2002:a92:cad1:0:b0:361:8f10:1a01 with SMTP id m17-20020a92cad1000000b003618f101a01mr526632ilq.18.1706047030718; Tue, 23 Jan 2024 13:57:10 -0800 (PST) Received: from tresc054937.tre-sc.gov.br (177-131-126-82.acessoline.net.br. [177.131.126.82]) by smtp.gmail.com with ESMTPSA id q17-20020a637511000000b005d43d5a9678sm693738pgc.35.2024.01.23.13.57.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:57: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 net-next v4 05/11] net: dsa: realtek: common rtl83xx module Date: Tue, 23 Jan 2024 18:55:57 -0300 Message-ID: <20240123215606.26716-6-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123215606.26716-1-luizluca@gmail.com> References: <20240123215606.26716-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:55:58 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: 13528188 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (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 6F5224A987 for ; Tue, 23 Jan 2024 21:57:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047038; cv=none; b=sfQoZzsMzgnP2QKV/WsA88sNlIGG4SCLOND/OX27WzFWxLmz86VvoNCp/jK7uRDmXVnuTlh8MKKfq/6lbrbiVsl7/jfldDiQ1elkJ+l4Hr+WG45K/dmOkr63KH7iWE3DiQPjGnfzHnIfKwM+jQu3GUAxE33rzVniXE8knOImbH8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047038; c=relaxed/simple; bh=NNoKHD0txK9XjZJh4xAMvaK9JGPuX0fSNDrccFFMa5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gLN9Cxn/Fv4E9wyhSIhpc22Sv+5Esu7pCuc/L56R9fIx8vGVFViEjDkx4/RO6tWo56kZbL8TX7Nc6rSxZdKFRRiSDZJL2ZvCZBOWOrwToAcskHA2EgOD7xOl18y55pdlFVVvAE1UhswLbnXbdVNTnoayzj5EHDBIYzhUKOVfAos= 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=ZFChOyfl; arc=none smtp.client-ip=209.85.160.43 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="ZFChOyfl" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-2046b2cd2d3so3571884fac.0 for ; Tue, 23 Jan 2024 13:57:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706047035; x=1706651835; 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=ZFChOyflsoTKBCZlD6h7LgrbcFDvG/XNNS9Ka/4BNipckAshGQUq3zhcKEQV+qc+8K cycj+BVOuV2tctz9JJRNkts00VCjBy4Fg665UCXVRRUWBnXUhqCOKpMJaQPY4Kh0O5mG s8AMjqW47HgCIHDi3DbB2HugpxqF43NUaM18Jg2t2hZw+vpsGl752FcGUvlkCzDOTpOG H2CK0MR36Tx8kJGpIPZ5Z8NcVoMA12gnmf7MDeEYMNKMPgn5G3DKI28IZQ4a8e5CEZ9H 6EpiGk3KeK7sL633/11QNYTWNTkC0YMXtTH/xY8qJ/loBhs+Ibn4iA+0B0JVYn9KsIox /IcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706047035; x=1706651835; 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=l2fu6dvlLU20/lydjk8286euQazRvG3rjMiTXBH168X89vGB1BFM+rm3B/LWUkj5hC eE9XpPje47GyudTUXF38nhL17wYooLLxlGvShhVtpFUO48OBaTIZJJOb61QUpgu0WGOo SLacsFfcRIcNEgtmv3ceeMvWUjZNqedj15jRrdg52amzash+qMRe8eRXYUCSNLLKa9KV oazm7q0MCMPXA/y4ODaypq5ty8zsP/31O9V+CjZ4/SOdjU+0McduAJZINHceVd1/Nbq8 k4TVNIs5VnxxlyAe67jaxu9ba7EJ7JxhS1MYWMmBzkEYnlInaYM9JxbHyi/UiQcpHG/s vskA== X-Gm-Message-State: AOJu0YzQu0jqzWs8b3uFl0GxF67TTm9qKz3bKepxEWG2Hb+1yqqbDytk 69Jihhb9h5GZTC/6I9YQcsz5/sXZKgG10qn0ZoZVhufWyxTtv9wvRF9KDPSQwfg= X-Google-Smtp-Source: AGHT+IEWyYuqrkP4MdtFab8m7Hop6ZGiRrssswsvtgR7wxJbqPuxMBKrZEygVAjKb064jtnAXwR8Dg== X-Received: by 2002:a05:6870:2a48:b0:214:2972:f268 with SMTP id jd8-20020a0568702a4800b002142972f268mr2610423oab.45.1706047035483; Tue, 23 Jan 2024 13:57:15 -0800 (PST) Received: from tresc054937.tre-sc.gov.br (177-131-126-82.acessoline.net.br. [177.131.126.82]) by smtp.gmail.com with ESMTPSA id q17-20020a637511000000b005d43d5a9678sm693738pgc.35.2024.01.23.13.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:57: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 net-next v4 06/11] net: dsa: realtek: merge rtl83xx and interface modules into realtek-dsa Date: Tue, 23 Jan 2024 18:55:58 -0300 Message-ID: <20240123215606.26716-7-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123215606.26716-1-luizluca@gmail.com> References: <20240123215606.26716-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 Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- 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:55:59 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: 13528189 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.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 7C16C48CCF for ; Tue, 23 Jan 2024 21:57:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047042; cv=none; b=ZOSRaP8lQf6Ro8zco31tJQIr4FlEXIO8cH5GEyGyLs6FkXJ2ENtL2iUto/YTm7iRAwsGCf02u1Coq9xa+b1PEgvPmpGA+caQn/dK1O0vP3f1lHW+QBCKxgDgtjWEW/wSUPqFE01WT7U4vQxQEdZjVP2/LJbnS8iJP1hfNqy36P8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047042; c=relaxed/simple; bh=qWeXnCBQSx9ijJmNkUoRa2Lf4+X7HfzKD4B4uSdXYsg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=deGXk4G8N2kQslmgWanynCN2OeJ1lEqwCE8EGctkr7eNtysHtTgQWWb3bAVWTmeu8P2auNc86g1OriYY6k0it1yj0ybD2YQc5Umttw2prLxR7fXIOT2O/9Bcme327WUpr3KLeUVgxeiIXpt0osz5K8CJTMO1Fs7jD6gxJgkzFlo= 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=SF3AOsqw; arc=none smtp.client-ip=209.85.215.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="SF3AOsqw" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-5c66b093b86so4192886a12.0 for ; Tue, 23 Jan 2024 13:57:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706047040; x=1706651840; 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=SF3AOsqwkfBt9urIMlTJtVQf82zGlEbc4txQyXOXiVrV9gAkOVloKvOFBGcTq6JQA3 n5gIVZi3Jf9O3y4jfE6HdsgeHD45w5tNewgZjvvi1S1lbqVb+si2oS3/lqpqHmG3E85N yGdRwwrHeJRMqzIyTiASgUSHF6GbO/4S8kR9NqATK1GGNFPOuFSk5iA59YwFHHj/ybz0 1QrbOhFNkZHCrOvnd7Ki6cvT4/T/jIU0iT6aB6Soac/YyzGHnu3nooDAcCGx5S/inAs2 /Bk0OAyjQJjbzr8RJJauNY5sD0ub2Uk1spsa7QDAHILSxCsGNaGsEaE/ZvPSLUQvOYkh j0wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706047040; x=1706651840; 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=E2ZoMJhgreutuHpnNc7+wA90Ps6mkxTuckzY+2ejnwa6BVvmKxvgpat5eToXu3J2PS JCHlpi6riQeyCJUwmxp6PU2l8uC4i9z0ne633rWH5OQmLxZ93ioGB+ydKmMom45E3c00 mHWv2D1Zgsa5NnVpGApfGbZn3bubIEP7PUf6avN+0fAHz+iHjkajX9LAc3+ZOYVp0R/j QVfnSSBGidx+M2VV1ub7/jTbfLT4ewDeyV3VWXr7OiTt8XzWs3syij36Fe6bnmRkBu2I 1jSWn4OeJxPWY1oL0v6Zt0XUEXwlFpQmfDgxmiDJMkkhxniBqLkS8JMZKfj0Ct0N3sa6 BANA== X-Gm-Message-State: AOJu0Yw9tMwpB6u9o7ZOT8ei+tjPwB4/g2+XyECwVcVWctvxyEOSmL0z QJrG6QK17udu9GcBBuuVH5j/YXwA13kPArm5zXQQd2KEptO28wbRdtCcL8b0ZJQ= X-Google-Smtp-Source: AGHT+IG6LEKhsDUjB73EyQXEAgb1kTw1tlyyrnCReGpDjvFG84vojMcvnfVi2NusiybZrQxiNkW0JA== X-Received: by 2002:a05:6a20:9192:b0:199:29c4:b4b2 with SMTP id v18-20020a056a20919200b0019929c4b4b2mr308044pzd.29.1706047039967; Tue, 23 Jan 2024 13:57:19 -0800 (PST) Received: from tresc054937.tre-sc.gov.br (177-131-126-82.acessoline.net.br. [177.131.126.82]) by smtp.gmail.com with ESMTPSA id q17-20020a637511000000b005d43d5a9678sm693738pgc.35.2024.01.23.13.57.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:57:19 -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 net-next v4 07/11] net: dsa: realtek: get internal MDIO node by name Date: Tue, 23 Jan 2024 18:55:59 -0300 Message-ID: <20240123215606.26716-8-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123215606.26716-1-luizluca@gmail.com> References: <20240123215606.26716-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 Reviewed-by: Florian Fainelli --- 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:56:00 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: 13528190 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 BDC6F48CCF for ; Tue, 23 Jan 2024 21:57:25 +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=1706047047; cv=none; b=DHwx2Tz6yf8ZwALLu0bGg5CCxt9m9kRyaSw4nLCYQlLNMPVlA53A8S6iYXcYuiTxQlNLj+PGTWn9bZ6AgmZRPoK3ViC1VM/hOBN2sKnt9vIJT2ZNMTJbrJ2VGyTXyq3XNZHpyJpPsNIIxgXlvIdSLiPn9x/A75+D0oUtH75wDEM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047047; c=relaxed/simple; bh=w74fOcwrINSkbZMdiX9RtKnM4jtf3uz6a5JcZn2ZHQg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qyAhSiTEyapwhXPoTgf/+cvbaYR7F9e7QqG7xOxM+MatTVkVmzNXjURJNfkTWjUJdU4PoSoNnLoWumxF6s+GeXD1mIZcCWul8UolkNBmjQCjjM8mvaUCDa6Uoyjb2RpC9azhvvEXVFMjTv9HLEQu3nzUNGl+AQrWp5Y+0w4EUMU= 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=H462F2bG; 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="H462F2bG" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1d71207524dso19774495ad.1 for ; Tue, 23 Jan 2024 13:57:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706047044; x=1706651844; 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=H462F2bG8RIcLGZD0/yWofuAe+/P4EreluhUMX8QOJFfGnZbNvrP7EPB/1v38wVbBF 041mZ5rE2D7HylkovyB40AWocdATIDTwn6n/WN+GecHuQBWg4BoMG21uwzwwmxRX4ZYC zdeaPDIEzfI25Cho4wlAxupdmtK8DpDDDsQnNGbrmtCPZHyXipsyKuT1HROl5SKEShYY ZQtkx+LXV1/tLIJzoyQjmxnFu+E+d+R2vZ3djph1n4s6GdE4C5kPUTs+RS9JdSl0af66 mlXFca8Z3Vg2+IGR51YWSMEMKoC/z9xgI9MMzz3nf6ZjOT2Gb/XyQvdoBcl1sRyEtz1i UuCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706047044; x=1706651844; 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=MhubvjidXeW8HrCgG0TORIQr5G8wE0mFsu1CL3BR87CRSUzAAbzV4XwgaXDMl9D/+/ zJZyeOUP2pqxD59tvicEzyqpzM3+oLAPidlmLXG+4n7ZjLFmASAuGf4l6x5YcMLbCrV7 onKUHg5ZFl+/9CtMvSDGbxUW3c/k50EBM3OWIhvGZzdnME8Uk+NVi4J0Z+SJ0n7a+ZHJ 48pN7P3x7WwzK57MCGnnVH9BFFo7upWsxLoR6zAAA12tEnEUAIPX0+kQJUdcTAvLSdqS MqfSSeubDck7desHKErfCRe2qFV1EXEBcxIobooEcT5zBFzPmyvX/iZUfN3bJ8pSKD8Y Pq+A== X-Gm-Message-State: AOJu0YzR+0O7kpN9pErb9lo7STTrOaqYj1nWAMJE4xkEq2AypdfwE40s dJo0PPkCgq86sPZDxbzdeHi/PH4jGEXvzkN2JS2LDXI/K8KyQwiuhG64/RLburQ= X-Google-Smtp-Source: AGHT+IF28k30B49XISUgaqwcAVHeYaS8ehw/hVXw90mf7T16C4QAsN7Z704hTrGtuPRsk4TOo+nvXg== X-Received: by 2002:a17:902:ea01:b0:1d3:eea7:9268 with SMTP id s1-20020a170902ea0100b001d3eea79268mr5176227plg.97.1706047044326; Tue, 23 Jan 2024 13:57:24 -0800 (PST) Received: from tresc054937.tre-sc.gov.br (177-131-126-82.acessoline.net.br. [177.131.126.82]) by smtp.gmail.com with ESMTPSA id q17-20020a637511000000b005d43d5a9678sm693738pgc.35.2024.01.23.13.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:57:23 -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 net-next v4 08/11] net: dsa: realtek: clean user_mii_bus setup Date: Tue, 23 Jan 2024 18:56:00 -0300 Message-ID: <20240123215606.26716-9-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123215606.26716-1-luizluca@gmail.com> References: <20240123215606.26716-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:56:01 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: 13528191 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.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 809FC48CC5 for ; Tue, 23 Jan 2024 21:57:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047052; cv=none; b=Zq2mxN6gC/ZC75b1hOBngGTcWJa1KYOgJ4BwOHgOTiX7D224dTnxo+GDpqKe8nOT/EWRNIoQfVOYT8dJB+VCkSGElRNYMNuD/xcHgcuvCXcPk4/OoYCEhyFq/KJTrrM7cQYFTn9tnQvppvljIJK+zqB+V7F+64hUwu625TL/Gjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047052; c=relaxed/simple; bh=J3Nh1N/06LdYOJxcnZT42tewbtJ1miuDdNVw8UlyqGQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jSgdS47/uqhxAqpBhc8A7JltEdYaMaetlRJLZ4qLw35nNpDDNn7vXJWq9wB4RSjIgk2QWStXZ1YCO4iOnEheJW+6C7chUVODHYWACzXbBJ2GYChBXLZRPqcoXUdLEuh/oFwAKbNA2ImHT6tgYeMAp8K2JcIfOklkxJAo90guIJc= 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=EGn5p1LO; arc=none smtp.client-ip=209.85.210.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="EGn5p1LO" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6dd7debc476so705657b3a.3 for ; Tue, 23 Jan 2024 13:57:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706047049; x=1706651849; 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=EGn5p1LO6bVDsE3A6mIB6DqWSF6sugkOyTVdgMiltk7DPcybAseYBdWQChfy4wnNRK GlQagZLRkWaX7hnXrsIdQqPMjtvbWgTnixf24yeKMzK82C3l+5CxmeB+ajv1tGxcLtf9 u7nMZI42l8GYSonNuHDEIYncpmjQdfscws8MuRAS5E7EI1oBcXnU6out6palLPyLWsdt WpoeJXSoOVCLjbNByDzq11nzE4HQ6r+piHZfh3HlL6Fodmp4NE5wcnTkeIW9hk9yBspj ej5lR9d70u9PVi0fMKY6RoMdYjigX1dyTaxY88VWeZxA09Dkw7w3SKCUEDfYDn6WaRK8 QFbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706047049; x=1706651849; 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=LXWcKfE2ONvoOKCVKK7r3cJqNzpAnLdNk1wfMZ+yXh3rqErs6PpIcWFcsEVDJRVtfC Ep1csEWN+ntF3bVsk1xZ/fxwJoaTK2qvxoinoxD7tj0cSIA3MNxDsdJdhjZ/VR6UQgDs ELWGrPfgpA8/XH098Hn6rkSNzJcga4TXiX311ejdqcohCIKuoJFHK+QDis28zsYVX2KL sIPDA7uyP8jrnYhc636dKeS0xE8+hcQWjWLmTrs03DgdX/ivvDOlP8BVFkMykC82JnPw MhA7q5qjiarO2ZL2ziXFVRu/kpWi42ZriK3+flicVnuzA1WuXV2NFjfg3qv321IdfysE SUVA== X-Gm-Message-State: AOJu0YwGqto3gu7+LiVX3m9kYxUbv7JhUIev4J9teB4hLrjzRoMQUQQq lp7KyTDGbjyWbfXAjeKv8GLxe9fYdSGjdFcMHCLSG6jScYifRQ2x2o2bkmszuZ4= X-Google-Smtp-Source: AGHT+IH8xMb9bnQwbIiSbX/1Q2ZNSo/A7YoSHmC7RbuQEOcmFfsqZAInE8rR+lwI58mK2/0gMMCdkQ== X-Received: by 2002:a05:6a20:4315:b0:199:96a4:b6b9 with SMTP id h21-20020a056a20431500b0019996a4b6b9mr4433395pzk.38.1706047048913; Tue, 23 Jan 2024 13:57:28 -0800 (PST) Received: from tresc054937.tre-sc.gov.br (177-131-126-82.acessoline.net.br. [177.131.126.82]) by smtp.gmail.com with ESMTPSA id q17-20020a637511000000b005d43d5a9678sm693738pgc.35.2024.01.23.13.57.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:57:28 -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 net-next v4 09/11] net: dsa: realtek: migrate user_mii_bus setup to realtek-dsa Date: Tue, 23 Jan 2024 18:56:01 -0300 Message-ID: <20240123215606.26716-10-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123215606.26716-1-luizluca@gmail.com> References: <20240123215606.26716-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:56:02 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: 13528192 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.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 238E648CCF for ; Tue, 23 Jan 2024 21:57:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047056; cv=none; b=GhxiR8ybaB5WAYsFZlag+antY0EglE6gJnpaumVnYCKUsxicMVbopyMWUqPOuft1QLSyAAhD/lVkCrqzIy9fbJJpp742o0ys8XaKPmo9cc+w1C2O1XvLCmzu2PNOJQJgovfKrHLKAVtobM1a8JoZREWI+ZT8onTi2V+TnawrnJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047056; c=relaxed/simple; bh=MqEmtnzVL6rRdFNLH4nFRtPUxGWmQx4poxAzzED5uyU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iAVF9RsfjNexxg3Nx7bCLURyLUMOjr8a6THnLgNfkoTimS77uC3C3fKNIzW+TwJAhVasZi38vsPesQny7hYbVMzgA9EMcL7DiJCkhMhffxqIt/nFwWKOLo6CC11vrypuuqcO4bNkLE7RlPIRvptyJcNzVlkQ/jM8tKuP1wwTbeU= 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=PMzezvhZ; arc=none smtp.client-ip=209.85.166.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="PMzezvhZ" Received: by mail-il1-f169.google.com with SMTP id e9e14a558f8ab-361bcabedd7so18097365ab.3 for ; Tue, 23 Jan 2024 13:57:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706047054; x=1706651854; 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=PMzezvhZ9ZucAls0pCCy5QQQhdjr5zo0J3Yb3gseRSGEZmtr0HynVFONGvHK+Ifujz CTcasVLRndE4Ej8qFhqmT9aT8b8PpHSMKF38iYLd/MXOzYjyWJgA46TaJpBvQRjz4VWU 4W3tv2psoFOm+OIHSmK2Ds7L5Wz+3EXjmQHGuKQgfEpGtzbObq39bdfIt8/+vIAK0NGK x5DQS1V0FM44OtZ2TV0aTF9W5lGfT/6UpJ4J6w15ENC2zGD8C4kaHpcDrEopv6wy6x3k Qb1L1KSA6QfGzfr6acWa6F2DmJ8Bc+kM5o+9m+xWDKnTsa941DQuoGziEg7AUbshFIAF I5hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706047054; x=1706651854; 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=h+5fgKyX6lCifRJNxA5hfOYCFSWhIHaRKWCSZwXGtOGeeVFtxFR/eLoNKYrRzdOCpd NDp+e4M1ekf4/Mwte7fC1uf9WiqBcz9B8BSeaF0HMEhpH8ow9D48ajLq9iosDKs7v4NT vgmIqwUcb0RiMoAIthsyBrKSJ92CuLOopgYgauDxgFi0STHcvHWy0tMCKf0FCbB58hDo HDDVrrmyXfox14zndJRdZssrU7ZqfMHPq4kkYy1zPK7xS+TEYTfMko6UJP4Jo8wAg2wv N6+9TV0t8EDpiLmeFAc2WnUyviGCiBTi1pZv1oq3qsx3VFfQKc9oNRmvNuaKXd1bTOPN 4ynw== X-Gm-Message-State: AOJu0YyNKnsBnJWBD6Z34dogjIQ77NFHaT+5Z7r3BF16KwyIaqSe6puX 8o83MFNlWgQMiR+bsMwsarA2/JkJ1Y7K1WfbWuLqpmlk7H56/S37Gm+nxZv9Hyw= X-Google-Smtp-Source: AGHT+IF1IzsPGnOsMckV8azbZ9Cn558a7J7NqZ+sCATUUIHfa4Wzj5pQtoiIMf5RmhD1L61CZaPXUw== X-Received: by 2002:a92:c9c6:0:b0:361:a5a6:aa7b with SMTP id k6-20020a92c9c6000000b00361a5a6aa7bmr398262ilq.38.1706047053887; Tue, 23 Jan 2024 13:57:33 -0800 (PST) Received: from tresc054937.tre-sc.gov.br (177-131-126-82.acessoline.net.br. [177.131.126.82]) by smtp.gmail.com with ESMTPSA id q17-20020a637511000000b005d43d5a9678sm693738pgc.35.2024.01.23.13.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:57:32 -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 net-next v4 10/11] net: dsa: realtek: use the same mii bus driver for both interfaces Date: Tue, 23 Jan 2024 18:56:02 -0300 Message-ID: <20240123215606.26716-11-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123215606.26716-1-luizluca@gmail.com> References: <20240123215606.26716-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:56:03 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: 13528193 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (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 6EF604F605 for ; Tue, 23 Jan 2024 21:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047064; cv=none; b=jiJ04TNtwqA3sdrXW2P87sjqNKXEOLFzXbeKP9sKLQ7TaxgRwehsxdtPbbRe67Ov/wT+lAz8modWm833ze2hDm5prm13cyP7PPZ8bNGuX9WEK5sLPqkraq8O/ct52GB0PDaDHozpvOGEAD8PLa/fEaWsLlgnyseUDv76f2kKuYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706047064; c=relaxed/simple; bh=rQ95yVJFqylTALu1gdEHyaUYJGg4ZYRQB8hCxjrmITc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BBLHsRlZJ+wI793W1NoJguYQtDZLXUGTMt9lZhphWF9fdpWn4az/Sro1NHmwarSWbTmXcpL08gPGqtl/Au3N7G9rLsv3WgWbkKeteXo9crqT1/eiD1q+dLiuAfMNrobDvM2UhBQ/MLSdgvf3E5LfYHItsHERGA8mmfckrUzP8I4= 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=j7CdFSw5; arc=none smtp.client-ip=209.85.160.43 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="j7CdFSw5" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-20503dc09adso2959368fac.2 for ; Tue, 23 Jan 2024 13:57:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706047058; x=1706651858; 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=j7CdFSw5Rb2OA+cdTPCtWRmmYC5CyLI3I42Ljq7lzh5gK1oA9d40+ncL8lQF7UrKlK kUAvt53SQCXWdkXqRw9CsZSZ6luZGlB7g5KR0WgGc+jfs+eyW3DYLMTIYGVky3kKFz6z ExypjfDLCqvEvVVLVuK63QoxBEb3I1MFT9MsoW6w05L83UhU7Rxt6wOLoSuLMjH2Dk0X VIEjk/fDtDMyLGLGRKx89/D+OMiKv4UaVjfHxVKXw4f3BIMcCwF+LWwa8hIwOdE97q+o IjD+QhXBKKHQ19Nfsq85HQ0UUiuy0u5WlE1zZSzX/w+1NygssoU98O6YKHM/OuZMIiLB WXIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706047058; x=1706651858; 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=fWndVxFJMKvRtxAbEV+5XoLji5gGaPUtKwa8cxeqWnzy1ldDmKqFuujZLoxyTNB2mf /962lUtknLKa8h99NBi8mNhrUYUuEfxdJmKiz9VmeF/e5NPKwVLdIGAsCW1RfG8Avn+F fmb1QyRrlwZAxxiShHDd5W5ywTLlkJghUSUYzVCLiDzz8qIZb+qG3o8xr75iU378MGBw LkI7TLnCdsqAwHutRrwehrf3AebPaUGbx2/GSiM10iRJ23U/biNnUULC9EBpl7U6DXaW DdI0YhEdTayhrDoXyFxAkLsiybeDVzYtdugK6RuCwwOGf4aRHqu1waXmg6pNUDcLX1Zy rQqQ== X-Gm-Message-State: AOJu0YxzV4ibN8SwoyzDwxQRsmxNEQm592Izi2bG9pU5zpeBCjH0Uu9h s5pv/IbzRCLtnUa0j+ioYfpfhxlB7Aeu66jksqaguoeznDY1pENfPvkVtn/hdvc= X-Google-Smtp-Source: AGHT+IEwjCtnU8c1WBu09AOyU6D6JCRi+x8GDQMgyntn8cUUCA392/XldVxZvMuJiojwUvsdMx9gIQ== X-Received: by 2002:a05:6870:344c:b0:210:8e39:9a6c with SMTP id i12-20020a056870344c00b002108e399a6cmr2082787oah.84.1706047058584; Tue, 23 Jan 2024 13:57:38 -0800 (PST) Received: from tresc054937.tre-sc.gov.br (177-131-126-82.acessoline.net.br. [177.131.126.82]) by smtp.gmail.com with ESMTPSA id q17-20020a637511000000b005d43d5a9678sm693738pgc.35.2024.01.23.13.57.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 13:57:37 -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 net-next v4 11/11] net: dsa: realtek: embed dsa_switch into realtek_priv Date: Tue, 23 Jan 2024 18:56:03 -0300 Message-ID: <20240123215606.26716-12-luizluca@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123215606.26716-1-luizluca@gmail.com> References: <20240123215606.26716-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)