From patchwork Fri Feb 9 05:03:37 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: 198742 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp635956dyd; Thu, 8 Feb 2024 21:05:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX9UWfGJSdHhk5wMsd/sFH42j/V61dbyc6LgonFPurgbxYWfhqLKhXEwgoek6qcdZpcGO2aQzAimmEiJgdUIa5ZyvCG8g== X-Google-Smtp-Source: AGHT+IEpJD34chaAzG6hfLL1sCBVzaEIQX3j6k5WcuPIYkPIY+2VGP227VU0w3EIiku8j+D7aAW/ X-Received: by 2002:a17:906:3b4a:b0:a3b:d8c3:ec3c with SMTP id h10-20020a1709063b4a00b00a3bd8c3ec3cmr338331ejf.31.1707455104321; Thu, 08 Feb 2024 21:05:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707455104; cv=pass; d=google.com; s=arc-20160816; b=GDL+uDKqUPDeZ8FSVdlOFAd9THMtcrf6GK3cA8g5cO/rkZHbLDeJhTLCUJKykv2w8y YR5uq98V0JB7Apw+g7VuNWUz33IrqKbEOfmll9zCEoLsa78oPpi8bET8CycljdG917GI X7wqB6VaPK619rfPB6JxFt39RzZAcdNsph1rIOQWBqPnEGzpql6WimIF/pnmE8ev56w1 03VYl5Frx1k3iMsoXqMZj96tGPZKgdA2rfmd8sQo0Rr0SJtfh2SZoiHuFThsdihZIp05 n85pUdyCpPAgClR2CxISnSuKE+oiE2jCAeNVPY3CQMUZf5EW+F83YcKwutvNW1fScdA4 /g9Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=g7MTZBCKHzjhM18x+n8O/DVUc7G/XYEcwU6xuwWh9ZA=; fh=+/5H7S1nSXkkxtXZXHjzW8/0ykT8OWezZI1G/tKqvd0=; b=k32fddlOFHiiyvQLZkiXeJCa8LUqA7BDLl7tgw0NuP5xaG3jZ4119gpUJETB6zGcgx 5XukXnzLjgZAP8xuD41X84VkAhaYCgTFlxTRKxMOOaN5Gv9uEv+5qVPFvjDtw9gYYygp w5zFnmq4x/4nTeory38qtthjniNdwf69eAjfWKHGnsbOEVQRtLtfe37X20h8tPaRslZh aUkLNAeZKjQkOU/WOLZu7GZ1Lx6PVfc6BIrz4w83tNlEMHFDyM6YYXQimEEt5bUeMi+j 4gxF1tNCiP8cA1gsLMVG3LXrY9ay+D/p1OLnapC4u7cQZ5TSRVL6SirYRKYtAW4nQDmM sSXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bK9JklZS; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59004-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59004-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCV0m/Ti2ClY7UK/7ctC690NlshxpXFoCic2og2jqeSgP6ETpS+jPrdoGnnckVSvo9me0hJbO7QkLmI+wryiT0rqT+Ucag== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a13-20020a170906468d00b00a3847a4c8d5si431206ejr.538.2024.02.08.21.05.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:05:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59004-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bK9JklZS; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59004-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59004-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E8B5F1F2342A for ; Fri, 9 Feb 2024 05:05:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76C7057336; Fri, 9 Feb 2024 05:04:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bK9JklZS" Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.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 3D3CD56B82; Fri, 9 Feb 2024 05:04:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455063; cv=none; b=S7h+7ggZ9OCxUkxxKL0x5TOjcOntzBrDuAmCSueVhjQdyOhqTpGqxYMkOMXBW3Xp5RuAIEpGb162iv8FcLAVzUjq4EcgPPiZg1HqJNCID5Rb2W45La87qH00gHJXOQr67PKCdB/kpD7qC940yIsPtPWISSyydb/RB5ecHRDuFSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455063; c=relaxed/simple; bh=iMZJiu/bnxPiAITK7fctYgy8EgGCASzYGj8tEvNQlZU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OaotZoRzNZ8B0vLA44ZVgSoCGx4Cc4pBlLk+Iv9ZsoulR1g35vYN26xXbBKjwTqU3Fkj56H6K4qvf5GyxOWB3KlGjtzDh3LrjdnujDvZ5+UurEsOBh3v+Gb40YNH+iAn2se7CscfkrGvuL2ZhlJcVtHDaJ67+kUeLCpguYnTf/Y= 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=bK9JklZS; arc=none smtp.client-ip=209.85.161.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 Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-59a146e8c85so303815eaf.0; Thu, 08 Feb 2024 21:04:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707455061; x=1708059861; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=g7MTZBCKHzjhM18x+n8O/DVUc7G/XYEcwU6xuwWh9ZA=; b=bK9JklZSAs+6o0thVRjU8DDE4spoM3ItVr6kM9Dq0Vca1KvSW4AVK9Fo7nE+5cWzjt Uuee/QwBgsx3BKUKaIaayKrJra9NN5CVclHR2rRrfsrYf8UEVORwkCV8NLWW38IXPzwm hYB8zloDTg7i6bGfZiy0H5abNyOiBRxqNufXIo4lHbGPUYzw8zqIUFP3b6UpXfkq2ZnE UeYsAxQhOUNNvZ9M97XWs3v5A+EPOV3VqCKRJGTxaIeasnNqZ6GXQL3DipZa5stRfAO9 BtYfLoEVjyUr2H2qSkx24zsW+p8Y4JSumeeoQ3nMIN/UFEteVjfAek5vtMQVWFrcuDKi sb8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707455061; x=1708059861; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g7MTZBCKHzjhM18x+n8O/DVUc7G/XYEcwU6xuwWh9ZA=; b=L9HEHckZR+JbMXUG+8gmVMNtA49cxZhggkiyYs3ldZowxhLOp2IMyL2i6aKKHfbHdT 0SJrvhr+t2J71hV0we6xCQrxch3KQky5zs5MxeGoykQeL2cfJwqnm9H4qFGvBxo0bcwd 9XOYuwfb9yNSgbzCg0vzgN6GgyxTL+5m/Wx6wDRuXdutJ39YlrPJJjgMnZ/dMfKf2lCf ACOf7dx6s3fa5P+k7YzAKvYbSFKdIFCl1iFwYZzTmBHSF8Gf6aSe1WlnUPpG0GJwXqzb WupERSUIUqpkgW+xbAkZe6z1h31fkKaDIhaLTPHiaTyE/TQ19SgddrEMVLhu3XvlcSO+ TQNQ== X-Forwarded-Encrypted: i=1; AJvYcCVjZuSoopqnR5gqwpMpj8soPghPX3dn6FR25RqOX9SmxCwOQRC3H4Urj8TFo6ggYKRQ45MEAhDmRY9wh90wQOcgxsDXLFbF7ZZRKIcn X-Gm-Message-State: AOJu0Ywaa3KM5u2PRrfIKLnAddX/oQ5eMurSF2/mPbpnC7MRpfzBuMuJ ARjrrEwhmp7YQj1JCgtjAUmQOl6IlvQsgaJODpJLJ302erEvumsN X-Received: by 2002:a05:6358:9986:b0:178:7540:999 with SMTP id j6-20020a056358998600b0017875400999mr502758rwb.3.1707455061077; Thu, 08 Feb 2024 21:04:21 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUKtQfOnpUHSaPvXR1U2hUbTvxqzIqzZprJ73VjB8ujdVw6vJ/y8i0LKLb9iv27dehJZFQlu485Dbm9ezac45vVz6COmzMZ9cEVyCkOTsVGstE1vNXe4kC/LOuhfFYNd1jUgIpGmtJlPDKJIwJtTcoEnQ6gWOJqUUdqVofCSmQ49Y6H/GCYtfkbYfWuWOrHa+07P1haswfwCOEtKYD/oAKGy7oULsYSTMJVUfF7VXEn/6xqtGmf8VfGBikqL0kucCSF6/2scOYBV0wDf4IMX01bZ7is5SHequV5ZxZmnAvrZTYsHIDbfIszfOgCa1lX55qIlOboiVr+6IALrVk8l+45O6ymIM6Q6FpnWkzihztz3aDVsQQgBQBs/x1gGXLO5w/p/1abpyrMP6HFtq5pu++1acXa Received: from tresc054937.tre-sc.gov.br ([2804:3b0:4104:200:2be:43ff:febc:c2fb]) by smtp.gmail.com with ESMTPSA id d1-20020a634f01000000b005cda7a1d72dsm793616pgb.74.2024.02.08.21.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:04:20 -0800 (PST) From: Luiz Angelo Daros de Luca Date: Fri, 09 Feb 2024 02:03:37 -0300 Subject: [PATCH net-next v6 01/11] net: dsa: realtek: drop cleanup from realtek_ops Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240209-realtek_reverse-v6-1-0662f8cbc7b5@gmail.com> References: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> In-Reply-To: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> To: Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Luiz Angelo Daros de Luca , Florian Fainelli X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=968; i=luizluca@gmail.com; h=from:subject:message-id; bh=iMZJiu/bnxPiAITK7fctYgy8EgGCASzYGj8tEvNQlZU=; b=owEBbQGS/pANAwAIAbsR27rRBztWAcsmYgBlxbJLy4TTFFHnoKpMhmPmsVw71Ws4vHVm5R50e F4tqNBaK6qJATMEAAEIAB0WIQQRByhHhc1bOhL6L/i7Edu60Qc7VgUCZcWySwAKCRC7Edu60Qc7 VunvB/90ufR+wgtQ+49IsDa23xE8afdXbAPBqjhMGssi21dNhzSrypcFip+Uwdnjg/JdNolhXYF Y36mU0E8IsTjTT/wLZKnpmhjpT8H17Tj+pSsafci17ASGX1rRX2L4/Y0LC0eMqa141/lfIe8WX1 r3s9cq2bLQWhZi0D86D9+dbj529Bz6Se1rVex6b/C7l80eQGaa/Ie4KNxvebzAovlZN5m0bJq1V UDPTMevSrArsopTF6oO2bdu78KtxAobfXuRCZC5cCMVCzVmFRXFX60o6rjj8hAlml5NzMfwD010 7U/zSBMewcpaJgotaF4X9mO79EoNqiJPmusCfhMLkFALQe2k X-Developer-Key: i=luizluca@gmail.com; a=openpgp; fpr=1107284785CD5B3A12FA2FF8BB11DBBAD1073B56 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790396443250054681 X-GMAIL-MSGID: 1790396443250054681 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 Reviewed-by: Vladimir Oltean --- 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 Fri Feb 9 05:03:39 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: 198750 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp637401dyd; Thu, 8 Feb 2024 21:09:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfZJUEw2EVuET7G6gCMLilL9WHntFWFGCW2ddosQK2kcqNebGR1ds2mZlnBZjkmOzCejsZ X-Received: by 2002:a05:6808:1155:b0:3be:bfdf:52f1 with SMTP id u21-20020a056808115500b003bebfdf52f1mr807814oiu.57.1707455350973; Thu, 08 Feb 2024 21:09:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707455350; cv=pass; d=google.com; s=arc-20160816; b=QrDlGW0pJ1bc9VBDsofcFXfYsir3oXeK5IQhaXW1tm2bee68H/Tu093u6sSDnXDRzv E8njJ2miVmZKAX3FQ0M3WvIyOGEN4ivqQcr+5uiJUn14+jalP0LAExFwWoJHttfRoZJf p/uSmq1FVB/OO6es23doKwg0lH2P8tcCcVwEsAkbRXFiYYdq2QZ13BAU1HQrEk7ELgL5 icYQfsq1zmBTWuAOpnq2FIXPeKXucbqNShsJ1/k5XpAaG1GEqDwjnf3yWdwmZXQ9Re8L pOwctu7LLHjCgPjYbnlpOgGiZqa33eHrZnHxpjbLIJDYSd33ccc53USsVsL649u3u53y kmZQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=QcnVvSvxpwClpAlB8qpRfcCVPoPOGOK+ZxWD1m2YSYM=; fh=xtqoJ+0z1yAsiHvGj5AMibEZzodS492vxgoCXM8iZZk=; b=LCaJNSgxgGlBml0uhSyQM05q3muqsbajhnNlUN8KhlZb4xcqcZPlicP3No09S22n60 laGawcRD8XnfgyUb7wuqA8iHFAujTk9gwR7NZInXrswkZ4i8U3KbLjWpIe2OJtYE27KL tPfU316odqcMfRIQF48guNB4MB4rOzEJr2Dhhv1HRXKHCridLGUb9t6+xoi+rpyxIkVE nBEX7RnYT+3QkWWK23oo3CLksRqj2TaAJKXwkjazOAmxCKlCg6KUESS9JgXh6LhCHg8U ofDIOCvrR55vEjS+Z9bnH72gIlk+FcrreM/61oa3MH57DIWXyOvZoFkf9Ag5Zgbvcki8 Q3fg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=T6XQlgLu; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59006-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59006-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCXhYVZH3XKzrH7gHVRk0Oqai/jM32Z5bkCyBDenNWf5TrhF7kxCm1YzTaOPOmsB3oqCjkN7p3CpYMJ4/9Q+Of0Dqw448Q== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id dq11-20020a056a020f8b00b005db76738ae1si1084922pgb.229.2024.02.08.21.09.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:09:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59006-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=T6XQlgLu; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59006-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59006-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9F098B24DBE for ; Fri, 9 Feb 2024 05:06:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 842A65812F; Fri, 9 Feb 2024 05:04:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T6XQlgLu" Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 655EA57880; Fri, 9 Feb 2024 05:04:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455073; cv=none; b=qUxJRgD1cgKC8UfnMXlBvvyOcQu+kJou1FciCvWt87DDJcyHzRzTLe1SXSFwTVRJHwJH5z3Xq2LT0n2d1w1UV+MMyu44ACyyzwij9h61NDTP8VTzJ9sbyVCOXm4qMFT+ATct68BYGqhfNN8HVSjrqGis6U4YCqCVkGp+g92WMn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455073; c=relaxed/simple; bh=x4wAU7R5xjM4+lxKEHM12l7yL064SMJqGv7TPMgDom8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A8nmu8GZ7bSUKtYOITLMZFf5S2bmM+QO0/qlPjMbtgTl53JE5CxzZA6EIdAOAjaFm2799mtcSrPS09m8I+fRU9xwlZ2N35HLA5QoUCoC6WuTNTTatt7Yx6af31INI36+dBg4R9AAuZUwftqS0iYR2k93HW1wTW2cJoJSpKAExQ8= 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=T6XQlgLu; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6e05f6c7f50so375304b3a.3; Thu, 08 Feb 2024 21:04:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707455070; x=1708059870; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=QcnVvSvxpwClpAlB8qpRfcCVPoPOGOK+ZxWD1m2YSYM=; b=T6XQlgLuW33DprQC0gAzydaMsbe0zfJ5w4nSjIjorphxZyn7EFV/1Bn4OvdLYrBObx fkFAURKYtllBxh8WMZMLa5d2f8/ErgP5aT4jBq0yOOq+2CHkHHrMPxUm6GMLw0zShPeh fxPIocLdoVACM7TPrIWt+2U8hHDG2AGGq7OIrge4OsGz8VXZSSyc9e3wDj2yH+y7ezqI waTYYcklc3NSqaJl1ejkvsNpSDg2/1ctPEZs3akPQePFpaWNlZfInRoFW6ciDI76ljBb Emy1h1FUPcw7kMjPVYStvl/EMiWybSGjSJkWn0OIo2mPKaewEKbQpHPQ/32MqusNfUQa c91A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707455070; x=1708059870; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QcnVvSvxpwClpAlB8qpRfcCVPoPOGOK+ZxWD1m2YSYM=; b=DASIemEDPpCmFoiTHsDolcvyMltZ5gC+4j5WtpjhMOGnMNUYzVbt3cTfwxD9zs2Tma FftLvBts/sqO3Den6rSfV3TVPvZd7jF0tHC6ykgGom2zVawuO1pfoFYFUuqZV0WiSoqU n9gax4/PRQPrkdcSVGSO+GJ+dGZHXVcjc/TW/17Rzsfg2Svm/2AWrlcRHFXROWHZIr9a AsAGuzP7gveKh6wScR2YH2Jz4Xnr1v0Bdy+JVHeh84vOQL/r8umtBoeE576xXzRdh0FC ZLt79+mYWTQw+9jkYEnbnbIllQ1o0xVQyp0gXcX9WfRvwTqbGJkWe5wsYrw7FNBeTI16 3pew== X-Gm-Message-State: AOJu0Yw45dxDiyjwdla10+IJnCgHq0U2hWNMUgQ1dciy1p6en3T8I76/ 75syO77KnvQYlX03kgD0XQ4YLRnD8bf6alAKlFsoNN+oJTwDmKvs X-Received: by 2002:a05:6a00:1c9b:b0:6e0:7249:3712 with SMTP id y27-20020a056a001c9b00b006e072493712mr697729pfw.30.1707455069917; Thu, 08 Feb 2024 21:04:29 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU9CQxf3/OG1NJqNLFgjhtp8SL8QWqX5OQoQftbdqEQa4jgWr3yaAeEVpwa7zcRHUTXY0pBFqG1PwPN9IHC5xms4HKH2PqmFRh9EtCF7az3zMiXJVIkxJ3686uwPHljXLV3jG+bfgQgro0RDMR2L7y254fXFgc5ionfWRvW7ndsXzUm+RM9gRcK87N0eOr+l8uztoHlwPERIMkQUITa9kP3/K4V349ROetoB21/rLBxR2iBF5ZSH72cv0lrw6yBq5CG8xAHSfDsVmcGGkHIoIrduLC09L0D+HyjfaS/LIbZypeeZz4ZTY6dqz07Bt91y+YJAzJr6pJBpQxTBORgBe/4pNER/B3Nxr4Oxtp3qhiPREnPe5w= Received: from tresc054937.tre-sc.gov.br ([2804:3b0:4104:200:2be:43ff:febc:c2fb]) by smtp.gmail.com with ESMTPSA id d1-20020a634f01000000b005cda7a1d72dsm793616pgb.74.2024.02.08.21.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:04:29 -0800 (PST) From: Luiz Angelo Daros de Luca Date: Fri, 09 Feb 2024 02:03:39 -0300 Subject: [PATCH net-next v6 03/11] net: dsa: realtek: convert variants into real drivers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240209-realtek_reverse-v6-3-0662f8cbc7b5@gmail.com> References: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> In-Reply-To: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> To: Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Luiz Angelo Daros de Luca X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=17785; i=luizluca@gmail.com; h=from:subject:message-id; bh=x4wAU7R5xjM4+lxKEHM12l7yL064SMJqGv7TPMgDom8=; b=owEBbQGS/pANAwAIAbsR27rRBztWAcsmYgBlxbJLUN1cNWKlicFHnPIM5InJNhwVmktsd8GaI 0Rix365DlKJATMEAAEIAB0WIQQRByhHhc1bOhL6L/i7Edu60Qc7VgUCZcWySwAKCRC7Edu60Qc7 VkY2B/0ROtE/i7xKMelDNxIGTdKPdgFNyxa/JoJVnx2zkgCI4NOE6eKMU0MkPwhjBxauF5/dFd4 0rrqFw0VpJzB2/ISjvzNcvvqZGvFCrJWCg9Hvyj8kgIlIY+EKq4qRHv5x9W1+4X19e4zeWFre2S 93rhHjTZ3R8acBJHtDvu4PDjXqy1PIaKKnyMJ2OBn5+sJ7pE6Bi3ZCTzLaVwYqOPxfwPTwhxXwU LFFGGHJHSc9v20ATiMiuQw1oY3w1NBgca65o12bWZfSByH4O7HenwL8Gx3OGeciMGWltBYz7nPt H37NIUqctFYxaXREwWGa4jWqVqdd/Pk3qJC3oESllHUEH8PD X-Developer-Key: i=luizluca@gmail.com; a=openpgp; fpr=1107284785CD5B3A12FA2FF8BB11DBBAD1073B56 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790396702069656821 X-GMAIL-MSGID: 1790396702069656821 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 Reviewed-by: Vladimir Oltean Reviewed-by: Linus Walleij --- drivers/net/dsa/realtek/Kconfig | 20 +++------- drivers/net/dsa/realtek/realtek-mdio.c | 68 +++++++++++++++++++------------ drivers/net/dsa/realtek/realtek-mdio.h | 48 ++++++++++++++++++++++ drivers/net/dsa/realtek/realtek-smi.c | 73 +++++++++++++++++++--------------- 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, 292 insertions(+), 73 deletions(-) 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 c2572463679f..7c5372561587 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,19 @@ 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 + * @mdiodev: mdio_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 reset if a method is provided. It checks the switch chip ID and, + * finally, a DSA switch is registered. + * + * Context: Can sleep. 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 +248,20 @@ 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 + * @mdiodev: mdio_device to be removed. + * + * 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: Can sleep. + * Return: Nothing. + */ +void realtek_mdio_remove(struct mdio_device *mdiodev) { struct realtek_priv *priv = dev_get_drvdata(&mdiodev->dev); @@ -249,8 +274,21 @@ 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 + * @mdiodev: mdio_device shutting down. + * + * This function should be used as the .shutdown in an mdio_driver. It shuts + * down the DSA switch and cleans the platform driver data, to prevent + * realtek_mdio_remove() from running afterwards, which is possible if the + * parent bus implements its own .shutdown() as .remove(). + * + * Context: Can sleep. + * Return: Nothing. + */ +void realtek_mdio_shutdown(struct mdio_device *mdiodev) { struct realtek_priv *priv = dev_get_drvdata(&mdiodev->dev); @@ -261,29 +299,7 @@ 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"); 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 668336515119..2a6a884bb45e 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,19 @@ 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 reset if a method is provided. It checks the switch chip ID and, + * finally, a DSA switch is registered. + * + * Context: Can sleep. 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 +518,20 @@ 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 be removed. + * + * 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: Can sleep. + * Return: Nothing. + */ +void realtek_smi_remove(struct platform_device *pdev) { struct realtek_priv *priv = platform_get_drvdata(pdev); @@ -521,8 +546,21 @@ 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 shutting down. + * + * This function should be used as the .shutdown in a platform_driver. It shuts + * down the DSA switch and cleans the platform driver data, to prevent + * realtek_smi_remove() from running afterwards, which is possible if the + * parent bus implements its own .shutdown() as .remove(). + * + * Context: Can sleep. + * Return: Nothing. + */ +void realtek_smi_shutdown(struct platform_device *pdev) { struct realtek_priv *priv = platform_get_drvdata(pdev); @@ -533,34 +571,7 @@ 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"); 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 c42ee8241ca2..e67c4562f5db 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 6661d4ba6882..747407ae8225 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 Fri Feb 9 05:03:40 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: 198743 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp636479dyd; Thu, 8 Feb 2024 21:06:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUZGeXEGz7DjGqKc5DynXT3oEXUBZmKx4M7sL4bCPaN/4gCXQpsyq/lZTEX1KSbC/q0GEiVIiTHalTNBMrL4xAvW0YrSw== X-Google-Smtp-Source: AGHT+IGYogreadQnig7nGKymhFWvMIBQmycqmvAy/PMEFHmtFftKhDqkCr3iu1sbb6T4qk4JbgyS X-Received: by 2002:a05:6870:3a25:b0:219:6eeb:c724 with SMTP id du37-20020a0568703a2500b002196eebc724mr454869oab.20.1707455190280; Thu, 08 Feb 2024 21:06:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707455190; cv=pass; d=google.com; s=arc-20160816; b=Ax9EA67YiS8zOfCgXabyG7JPn4m8hWO57dX0mgW7NkoPs+ZMjfgU3Ns+7ult14cKo2 bZvM9+xPMs88B1NNdxmrIBj5ublXflt1C1AcCXn/d+OJ8Li31CTXzu20WQoJbL2Vcw88 ZZ1GMGVOHSElKnIILv+0uBKdyd4m9Gzj3RLH1Dd7vBIMyb5tNhYlDO5Kl6vJaeT8qfZ4 w8ECI4L12KgxY6L2+fVQC+auBGjcZh0jGL5f/ZAf7DE+pfUHI8nbEkHP52Fntv1SKe3Z nZSVloLJaljaXeqiolzYqw7DaKUQImPtHr87KSgwlUoM/9+6yeGz/j9efi0rXiSfHKOS 0CKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=DjZFEhta82MOtciRGbl6T2FR/OOl48rGzrVvDiOd70Q=; fh=JhXOn2qvjRRtx7fHmFVjvZN/NCcxx1qzC43D00XovZk=; b=N3/7yKmVtmNv1V2s/5SpnvE0Y8ugBQ1Xi9e7gSPquz7c+R8E6AmmGSltCTDNNBJQFK fd+rFTyXspEvgznHhO6sgekN2iw6iqwWfNxZvpzofy5DgIbKaBbYTQ4hfi9GEMceiefh HRKKLQAnLUVSDL6PwBzvvxXSUN5pPrmWeZMrSIVHj+I+qnNT0i0aU/1ee5/0k+u2pktV WOROPO4n1bgmQWwIXHNNyJ7jFr8pu6VRJ91FDt7dfH8lG1mIDopcwkWBlwPcedrGOpQw v1FCrmjw9e//fwmGWPenGYbwLrE41lMn0QC0Qbnbo21I/YQ6G/1iNEepXZmpQ88Y59/z YstQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cAvoLxEL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59007-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59007-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCWCvd6gsBZgxNezBozL/VTgHOH9CJwvig58RTKpwb53md7M5aJwT0eJgycD626ymkkF539ekWHcGMPOx50juPPP0rOmOQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p26-20020a63951a000000b005cee03a1bf9si1048996pgd.448.2024.02.08.21.06.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:06:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59007-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cAvoLxEL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59007-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59007-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0D2A028AF53 for ; Fri, 9 Feb 2024 05:06:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74AE056B86; Fri, 9 Feb 2024 05:04:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cAvoLxEL" Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CF5C5788F; Fri, 9 Feb 2024 05:04:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455077; cv=none; b=MwZ04jVwNQv134cDmVR7TA0Fxcvh4GkUX2iC3frWHh3hqtobTMHDWjZP1JltK0Ahr/MTtz3fV+gicGN5nLRTn/JkWbcjDthSt3WyFBjUnm9/azTbve9YJTKiprVRViccj6x09/rtvNUIw6UK0lVb+a+aX6M3MWs6q0ezU9N/9QU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455077; c=relaxed/simple; bh=A/i5C+haAyk33PdSAUkRgcW9VpEkLWcEh+Fkl5NMbtk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qWF7RaWSD43D4aLivKNibUURCIDK4bEyIYLzaX1aUOSLN+hVIXz8Rol4oySfoIgaf/QZYt1cREm1KBUe/j91KDHtUKw5Hcn/dBePKQRZTHGitlqf/t5fS5VhzaCmHtTS5VZtBGL+BTENFFJzlaiQVfhNmoaKlOlWYZixzBYe920= 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=cAvoLxEL; arc=none smtp.client-ip=209.85.167.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3bff5e9ccdeso153046b6e.3; Thu, 08 Feb 2024 21:04:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707455074; x=1708059874; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=DjZFEhta82MOtciRGbl6T2FR/OOl48rGzrVvDiOd70Q=; b=cAvoLxELzt2Rr1Hs9EXguYd9lpOYqZYZxyzjE21vOWyPDOs/YqIaFq11WpWwLAsjFI KyObQBaAmGjOKLW2SN6Dfxjw+WaMJMrgBsrCtVvi2j4Of8oF5jMRhXsKBl2P0yX+7Xd3 IT0UIpNjZSxxF6W53bE86cSa08de2FYuQ/Aq3HBdazcvK5BT7m2E4B4CRJEtN3MYmZMF SG2KfLCX1n18aviZSTXOpA4k2uy3YUo/MlyvjxBnFtUvaB2sA/monWaFg2/LwvjU5JrY TWFS+lmAFXdUUnJgy2f1SrSeVHFncXUjTPH6o3Y5CmugKulyIieV+1e/dwOlMlgLkE4Z rmyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707455074; x=1708059874; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DjZFEhta82MOtciRGbl6T2FR/OOl48rGzrVvDiOd70Q=; b=qTLx8EkO/SjgDxo5kI75MuGAeXVZNW/+Fc9MCWCW6y2rVErezqfhQ9xl+dX1S32Meu aOmlSDrqXwUxJ/jFvBkBa1qC+2LWEntWa0QUJXuNqHIu3u4mnDJ6++msumxjly642Aob PgBuKjrVejuMePs9bl4MygkCHzkwgirPN9Uc6oEPlf/UeCfeXSxaZVOr1/DWQN95B4OS fRXLKAJTYSMo6l+QwNysGGTJKbvubv4tRsd7FUfVApId4tKo5YtVwGOyjnMFFd5qRair JI7ew6eIBrYliYJnD6fFXT5P9AUxieITyVEhfeoJOTIcuIRBBpmwz6fO5LWXaycoDPUc Zf5w== X-Forwarded-Encrypted: i=1; AJvYcCUBcPWYBw8r5pCKEBN/Vf+F1jMjYnIXyU+uRSOhE4rsUQl1O6z/lct1MMgudSyALqE4lpSlpfnrZNgnbyncxyNk+Js7VwqMvHvdXZme X-Gm-Message-State: AOJu0YwVZfyTYEYvjdsd1mp3nm4X0TNWp0PrS0kU12D/etYgO0Eokm/K yyTJ6Pfn1bn43hLeRhpzyKX9k0fwqShIHXEvsbgzFUGUB72m/tyUYOScUyWwZ98= X-Received: by 2002:a05:6808:1a22:b0:3bd:cd55:d320 with SMTP id bk34-20020a0568081a2200b003bdcd55d320mr645768oib.47.1707455074417; Thu, 08 Feb 2024 21:04:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUSERD4SauKvBcEzPT69VFBN5d60cxzNYSDss+5B26n28GIXMZm6cEmZ4S8smV1qyLMGLOcp8PQE2+Hs4NtUe3ZgYvXRsxaEJd+HoGwXa9mhiUKVRf9gWZupzEj0f9XxwdGiJA0UQTq7zoq+sZtm8Oz5XK2fgViD1M7RvMR+uiXM1679AsuT2w9HMzYg1v1anJ5uhGeshqa2/fSg4xBlFpKav6XQD4IStSuolOe6ZaTkZFpm22SgVB5AqUL/BS29AxTTH4v5hHNAIDHWUiNPldMV+JRrpgL/J+GrroXZ3xqebine+GcVgB6Ow/O7s/XUBR/VIzy73ZEFjL1nMGDH6nxPHOBxHMErcwq9EO1yt8JAIRv6SaSxUKSi2prFSMsFE8uIuKsqIyA6bNRF+RTbpmyulA5 Received: from tresc054937.tre-sc.gov.br ([2804:3b0:4104:200:2be:43ff:febc:c2fb]) by smtp.gmail.com with ESMTPSA id d1-20020a634f01000000b005cda7a1d72dsm793616pgb.74.2024.02.08.21.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:04:33 -0800 (PST) From: Luiz Angelo Daros de Luca Date: Fri, 09 Feb 2024 02:03:40 -0300 Subject: [PATCH net-next v6 04/11] net: dsa: realtek: keep variant reference in realtek_priv Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240209-realtek_reverse-v6-4-0662f8cbc7b5@gmail.com> References: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> In-Reply-To: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> To: Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Luiz Angelo Daros de Luca , Florian Fainelli X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=3206; i=luizluca@gmail.com; h=from:subject:message-id; bh=A/i5C+haAyk33PdSAUkRgcW9VpEkLWcEh+Fkl5NMbtk=; b=owEBbQGS/pANAwAIAbsR27rRBztWAcsmYgBlxbJLqGye92Vdwna3jCsp6pzE9QD0R25YKHWKm FV3NCQyDMyJATMEAAEIAB0WIQQRByhHhc1bOhL6L/i7Edu60Qc7VgUCZcWySwAKCRC7Edu60Qc7 VviEB/4vm6/Fdpi+O5IFH7QDkqjArSMhL3hYUJ3v4EB+Z1qDy2FVeg2mP3yAQM20DB1jY1KwvDm +CLhA7evVjOM5CUEz8sPidpv+9Z84jPLWqbf/4JDKX8s1TPwJxzPUw+hDqoBiCzqQ/dnaHch3ZX EBh1VQ0WN7nMOp7uOcwXQc3LPrZIAWsYC9wWtBVngZ5QsGElefNwe+5ekZXUaJjTR4nQ4MVltNq ZbZQQxQW8rX9X7lapQMwISdtMEGgV+1T+4SCJItACp2YobLWq3IaR00IYpIesYbx5PqRDEmhk9F ogwKif6Q5Qck3vYAmuSoPzRYURZU6xkqXzmaXdg6CdDiI6lj X-Developer-Key: i=luizluca@gmail.com; a=openpgp; fpr=1107284785CD5B3A12FA2FF8BB11DBBAD1073B56 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790396533659396259 X-GMAIL-MSGID: 1790396533659396259 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 Reviewed-by: Linus Walleij --- 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 7c5372561587..7be00aa2a9e7 100644 --- a/drivers/net/dsa/realtek/realtek-mdio.c +++ b/drivers/net/dsa/realtek/realtek-mdio.c @@ -196,9 +196,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 2a6a884bb45e..ad3b57311015 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; @@ -459,9 +459,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..c7d5ef99e9db 100644 --- a/drivers/net/dsa/realtek/realtek.h +++ b/drivers/net/dsa/realtek/realtek.h @@ -58,9 +58,8 @@ struct realtek_priv { struct mii_bus *bus; int mdio_addr; - unsigned int clk_delay; - u8 cmd_read; - u8 cmd_write; + const struct realtek_variant *variant; + spinlock_t lock; /* Locks around command writes */ struct dsa_switch *ds; struct irq_domain *irqdomain; From patchwork Fri Feb 9 05:03:41 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: 198745 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp636661dyd; Thu, 8 Feb 2024 21:07:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWpqLr2xcbvJTzX5XiVLgQGIskbxi9XlbBosGG3+1NPCg+jd/0UOPrHVvgU/+eR70eMIBJFMqJZGUtiqfvA+ri1H+Gvsg== X-Google-Smtp-Source: AGHT+IEYzcJu26PNxykGdMGGm9GlMzo8PZ1uUT9+RhvEjOu+Gmtee7CUaKg0pvFQVWRoWxWtVyEE X-Received: by 2002:a05:6a21:1646:b0:19e:3006:5dc5 with SMTP id no6-20020a056a21164600b0019e30065dc5mr885939pzb.3.1707455221151; Thu, 08 Feb 2024 21:07:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707455221; cv=pass; d=google.com; s=arc-20160816; b=WXv3EJDxTXyW6MCP6MEgX18QMHjITO+Mdwx49BuujsnOKfSJp3lpUcl5dkQ4EbkfHv g+v0oMGYht6vESLvuFqKg4ZS1hPNrBz6KwC40wVicDUtuFQZLPmjNVur7QtRxkaUC+zY Ekinr7fQ6T/2jcPJIWsf0Ht5T4bQBaqTWPEQtxQdyvqFmsVWLQ6BOMHWPs7oA6sDCHjn sE8p+r0ghxH/M202DYIlmoCdTlRY/EJVPdmh/3avI1B1wnVEuKT0ilk4jVngLvtYB8U3 mOC1RNm2QKlBlpIyCtJVZ2UyMbwGyKxQ03SjtPSUDgNqgmHddLN+LWuQtPxKYI5y1uOb 283w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=QO4Ry7kvRIzLLQF7E33i4/x/m3CKHgGMzMktOiu6/Eo=; fh=52DLoC5YWFO6Pf67j7kuCV/VrV7u6tP8vj5IYJVm7jY=; b=kx3sb1GTKNdHd4OAzphj1T6jeMiU6ZIZtkjVl24lt5OBUuXB7ht05/Dr04WNEzKqxU WKY8yNzgyolJTZ1Y1kAbq8Crmhid5EaLKQ0HkAT2fLEc78fax94HSzKtUVwvJ1F/utm6 gZLPInohbL49Z0hZbYDviUx681g5S0uCa4uv8WBu1xy9hB8aYkmTYTSvoUTyWNrx1eez G/FgY/5TYd+eSSr+q+NP1Fn/4Ek4W7KBEV8DafyJRLYS0W7bdZ7hsFiJiQB9e09gqsq/ izACjX0344uRIEdcVuL+AnVyrY9jhkOCh4QtsLmvPy5ccxlQcf+optJ9/s2LhBzIZCN4 Ak0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GOyn6gDn; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59008-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59008-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCUR27+9lylKB029Pl9hw1FmRaG0woYm6l3fMTojpxHkhyVPi7hRVAI7X0jdqaqICxSpA/HPDCe/TjiatBEw+ip/3mlXFg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id kx9-20020a17090b228900b002967b83619fsi971537pjb.85.2024.02.08.21.07.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:07:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59008-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GOyn6gDn; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59008-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59008-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 730DE287B85 for ; Fri, 9 Feb 2024 05:06:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13D2E58AB4; Fri, 9 Feb 2024 05:04:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GOyn6gDn" Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (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 320AC58139; Fri, 9 Feb 2024 05:04:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455082; cv=none; b=ObsH9pZTMqLTy4a6r57gGw5MvxNSLZ3jpda/B+9MdccxxImQ2ytozRRcTReLBI/vObkw9gftC2FYOdj5uixE45pDmVIHT5hODu7fn1OZUoRCCwcuCrdKHyqXquePg4wCeS1cGsyvNy0ndqniOnb7oJKkUA7weWITUMHU0yGpVvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455082; c=relaxed/simple; bh=baCHYu3lUoAm9OmUdcjhgQtmp/3g3SLNPUPQxd6A1uo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oUQq/ytfjcl9buJvy7VLZkQc/1q0PpVCTnzTrWj3ewv4+MYMCB77RXUA7YgY+a+rBtq19WVdmiv5bF43qs1Mb132HH3Ez1pCNWtPPns9RVzIdHmOhjzKwfGIYQ70Ux+D8A5OFVhzX/bHlAgFFkcRf8NNHUy4QaYTR4dOLxYIXGA= 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=GOyn6gDn; arc=none smtp.client-ip=209.85.210.54 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 Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-6e2c4866b33so256160a34.2; Thu, 08 Feb 2024 21:04:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707455079; x=1708059879; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=QO4Ry7kvRIzLLQF7E33i4/x/m3CKHgGMzMktOiu6/Eo=; b=GOyn6gDn4tHGeR4X9NXC7YqP5jPPUl1J2cRJxcm8WcxhAjb7XLcrDl1i+mzOWFk3Ls SKIo1odTqKcbhhE8GpbX4esjuGowBSHOsygl9iv5KcDJUq1Z+6l8DSXx8ia9PFAoM+bf vz1PiZncELETD5ba2kjEt3ve8IRuggnsQ2ijgIQC7s1vtSBvK6ZeJPLUZnGljmsIVMZK 6lpAgRC1iwW//bjzllBq6Rhz7wuEF65EJH1EdhvEs2O0sO37GeqtuIKZJ+S1ELn3orV8 NvQJN+y/sn5XV7Nfda2/qTGoPJtxFai0P43YHLduXoLGwmX7D526z/gRCi6BOTwZNV6w Pnng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707455079; x=1708059879; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QO4Ry7kvRIzLLQF7E33i4/x/m3CKHgGMzMktOiu6/Eo=; b=CjImWCCza7Mn3wpfpm4SgYhHwiQU10rP2q9zRy1v1YaQe4yW+355cZHoaYJABO3Oao sleipFB3+TxATKbXB3i9g2QpHk/6WIlcRlRhNMICe1ZTmpWex84A6uknqREgvfE9auuL 71YkmZRsJDSMG9nuQ9Twy9Ti9VeqQcvm/SiIuSaFdOOe9c7AkPTPautY6Ot2sElVkA/0 lmLtzGX9QG7yV3NjFbIPAd37gYv/Z6mna95yqLngVVKD4TDyDWtdDYXhVdG25d1DCHzt bmL8TD6GzpryQYXKV4dTjTzG+nbWHHFJJ7y9KGbQSesFoYUapPQfRSHe28baO09fCQqg K8Vg== X-Forwarded-Encrypted: i=1; AJvYcCWXnDevfd2xwRNA0jb/lVSLt8R8Jfl053vHRS0mnvXyC0KZ3KqBW/qzTrq9IV7N9foLfw7mM0Pxoy6qEo2hZ2v0RE6RMC3NQPCXFaPW X-Gm-Message-State: AOJu0YyeCLwUw9GDOZZEy1FyWCqIP8aCTwKp4H9NPy5yETsiUCi1Ge+r l6wLKQq9Byv4ogl57hd/z8GjgjaMsXprmGf8zmCNtE7uS+HNABEyDj1/yeSdiWw= X-Received: by 2002:a9d:6c59:0:b0:6dd:ed61:546a with SMTP id g25-20020a9d6c59000000b006dded61546amr444639otq.31.1707455078958; Thu, 08 Feb 2024 21:04:38 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUBTfuzcEI+w1S/kB/IWCo665I3l4mSPq78EvUmiIpt2uD6lOwi2AE0Q60/ZvXyKmHG+MyOM4pf5qGHo4MyXzFMcpZPEZS0kOenskl6NRnrreXf9+RWMBWG2u4trx407+3BKIzqCZRbULYGS1GtsD82CvhEfGKC58J2ls+5HMnizEx799e9s4FTMA4OdB/Nav1STdGksGhZFpPbJWnRq8jT8yYof7tBpAjW0NFYgYVAX9ZArqe2IFB92tSUo84RfyMCTv9Zh7BXGqKTSup7oshqdQn4iSB+JTevhEkvXTNZrilBt8OCJRVUxxzzHcA9JEU+5jdGavMed1jRTRjrR/8E+Ys/1tQqwTEJrHWDe4XD/SdpN60= Received: from tresc054937.tre-sc.gov.br ([2804:3b0:4104:200:2be:43ff:febc:c2fb]) by smtp.gmail.com with ESMTPSA id d1-20020a634f01000000b005cda7a1d72dsm793616pgb.74.2024.02.08.21.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:04:38 -0800 (PST) From: Luiz Angelo Daros de Luca Date: Fri, 09 Feb 2024 02:03:41 -0300 Subject: [PATCH net-next v6 05/11] net: dsa: realtek: common rtl83xx module Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240209-realtek_reverse-v6-5-0662f8cbc7b5@gmail.com> References: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> In-Reply-To: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> To: Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Luiz Angelo Daros de Luca X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=27025; i=luizluca@gmail.com; h=from:subject:message-id; bh=baCHYu3lUoAm9OmUdcjhgQtmp/3g3SLNPUPQxd6A1uo=; b=owEBbQGS/pANAwAIAbsR27rRBztWAcsmYgBlxbJL5qUSASUO3EixHoM3uIshfVM/rGQLRx4xe Y+fgDgA6MOJATMEAAEIAB0WIQQRByhHhc1bOhL6L/i7Edu60Qc7VgUCZcWySwAKCRC7Edu60Qc7 VuopB/0bn0+meCoaQB0UlgWk9Vxn5ZpoPPpg/L+5jOpqyDQRxes/FRKeroAQlurj7hwijkmgqye i7LbdysLW369fnA5AFubD8ggAhmA+HFvupEuR/s54GVca97q/UFc2R2a3zYJyEfMF2tlWMIa1BW KlsVpz4yeV3X74kTKe/wERdMHXoMtymWQeiy97hzV5DwjHcHlnfQof6kPocbiF/quQztbDrx67j hL4rsY2ukoDDJ4FkRzJ3ayCeEMtXpaVpu09J4OmFehY+jokdAre1LHC9er4b6EkTh7J2NkMdros MLV8CIXo/rrpdTFanhLvi7WQP9/zCAfWGHVwrXqucy/uaeuS X-Developer-Key: i=luizluca@gmail.com; a=openpgp; fpr=1107284785CD5B3A12FA2FF8BB11DBBAD1073B56 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790396565923065012 X-GMAIL-MSGID: 1790396565923065012 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_unregister_switch - rtl83xx_shutdown - 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 Reviewed-by: Linus Walleij --- drivers/net/dsa/realtek/Makefile | 2 + drivers/net/dsa/realtek/realtek-mdio.c | 152 +++------------------ drivers/net/dsa/realtek/realtek-smi.c | 166 +++++------------------ 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 | 235 +++++++++++++++++++++++++++++++++ drivers/net/dsa/realtek/rtl83xx.h | 21 +++ 8 files changed, 322 insertions(+), 273 deletions(-) diff --git a/drivers/net/dsa/realtek/Makefile b/drivers/net/dsa/realtek/Makefile index 0aab57252a7c..d579127f05f7 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 7be00aa2a9e7..90a017cbe168 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,147 +101,41 @@ 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 * @mdiodev: mdio_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 reset 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: Can sleep. 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; - 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; - } + priv = rtl83xx_probe(dev, &realtek_mdio_info); + if (IS_ERR(priv)) + return PTR_ERR(priv); - 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->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); + ret = rtl83xx_register_switch(priv); if (ret) { - dev_err(priv->dev, "unable to register switch ret = %d\n", ret); + rtl83xx_remove(priv); return ret; } @@ -253,8 +148,7 @@ EXPORT_SYMBOL_NS_GPL(realtek_mdio_probe, REALTEK_DSA); * @mdiodev: mdio_device to be removed. * * 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 then it calls the common remove function. * * Context: Can sleep. * Return: Nothing. @@ -266,11 +160,9 @@ void realtek_mdio_remove(struct mdio_device *mdiodev) if (!priv) return; - dsa_unregister_switch(priv->ds); + rtl83xx_unregister_switch(priv); - /* 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); @@ -278,10 +170,8 @@ EXPORT_SYMBOL_NS_GPL(realtek_mdio_remove, REALTEK_DSA); * realtek_mdio_shutdown() - Shutdown the driver of a MDIO-connected switch * @mdiodev: mdio_device shutting down. * - * This function should be used as the .shutdown in an mdio_driver. It shuts - * down the DSA switch and cleans the platform driver data, to prevent - * realtek_mdio_remove() from running afterwards, which is possible if the - * parent bus implements its own .shutdown() as .remove(). + * This function should be used as the .shutdown in a platform_driver. It calls + * the common shutdown function. * * Context: Can sleep. * Return: Nothing. @@ -293,9 +183,7 @@ void realtek_mdio_shutdown(struct mdio_device *mdiodev) if (!priv) return; - dsa_switch_shutdown(priv->ds); - - dev_set_drvdata(&mdiodev->dev, NULL); + rtl83xx_shutdown(priv); } EXPORT_SYMBOL_NS_GPL(realtek_mdio_shutdown, REALTEK_DSA); diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c index ad3b57311015..d676cc44d517 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,111 +369,56 @@ 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 reset 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: Can sleep. 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; 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)) + if (IS_ERR(priv->mdc)) { + rtl83xx_remove(priv); return PTR_ERR(priv->mdc); + } + priv->mdio = devm_gpiod_get_optional(dev, "mdio", GPIOD_OUT_LOW); - if (IS_ERR(priv->mdio)) + if (IS_ERR(priv->mdio)) { + rtl83xx_remove(priv); return PTR_ERR(priv->mdio); - - priv->leds_disabled = of_property_read_bool(np, "realtek,disable-leds"); - - 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->write_reg_noack = realtek_smi_write_reg_noack; + priv->setup_interface = realtek_smi_setup_mdio; + priv->ds_ops = priv->variant->ds_ops_smi; - priv->ds->ops = var->ds_ops_smi; - ret = dsa_register_switch(priv->ds); + ret = rtl83xx_register_switch(priv); if (ret) { - dev_err_probe(dev, ret, "unable to register switch\n"); + rtl83xx_remove(priv); return ret; } + return 0; } EXPORT_SYMBOL_NS_GPL(realtek_smi_probe, REALTEK_DSA); @@ -523,8 +428,8 @@ EXPORT_SYMBOL_NS_GPL(realtek_smi_probe, REALTEK_DSA); * @pdev: platform_device to be removed. * * 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: Can sleep. * Return: Nothing. @@ -536,13 +441,12 @@ void realtek_smi_remove(struct platform_device *pdev) if (!priv) return; - dsa_unregister_switch(priv->ds); + rtl83xx_unregister_switch(priv); + 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); @@ -550,10 +454,8 @@ EXPORT_SYMBOL_NS_GPL(realtek_smi_remove, REALTEK_DSA); * realtek_smi_shutdown() - Shutdown the driver of a SMI-connected switch * @pdev: platform_device shutting down. * - * This function should be used as the .shutdown in a platform_driver. It shuts - * down the DSA switch and cleans the platform driver data, to prevent - * realtek_smi_remove() from running afterwards, which is possible if the - * parent bus implements its own .shutdown() as .remove(). + * This function should be used as the .shutdown in a platform_driver. It calls + * the common shutdown function. * * Context: Can sleep. * Return: Nothing. @@ -565,9 +467,7 @@ void realtek_smi_shutdown(struct platform_device *pdev) if (!priv) return; - dsa_switch_shutdown(priv->ds); - - platform_set_drvdata(pdev, NULL); + rtl83xx_shutdown(priv); } EXPORT_SYMBOL_NS_GPL(realtek_smi_shutdown, REALTEK_DSA); diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h index c7d5ef99e9db..e9e28b189509 100644 --- a/drivers/net/dsa/realtek/realtek.h +++ b/drivers/net/dsa/realtek/realtek.h @@ -62,6 +62,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 e67c4562f5db..60f826a5a00a 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 747407ae8225..a0c365325b4a 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..0f628065f456 --- /dev/null +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -0,0 +1,235 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#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: Can sleep. 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: 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: specific management interface info. + * + * This function initializes realtek_priv and reads data from the device tree + * node. The switch is hard resetted if a method is provided. + * + * Context: Can sleep. + * 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); + + 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); + } + + dev_set_drvdata(dev, priv); + + 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: Can sleep. Takes and releases priv->map_lock. + * Return: 0 on success, negative value for failure. + */ +int rtl83xx_register_switch(struct realtek_priv *priv) +{ + struct dsa_switch *ds; + int ret; + + ret = priv->ops->detect(priv); + if (ret) { + dev_err_probe(priv->dev, ret, "unable to detect switch\n"); + return ret; + } + + ds = devm_kzalloc(priv->dev, sizeof(*ds), GFP_KERNEL); + if (!ds) + return -ENOMEM; + + ds->priv = priv; + ds->dev = priv->dev; + ds->ops = priv->ds_ops; + ds->num_ports = priv->num_ports; + priv->ds = ds; + + ret = dsa_register_switch(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_unregister_switch() - unregister a switch + * @priv: realtek_priv pointer + * + * This function unregister a DSA switch. + * + * Context: Can sleep. + * Return: Nothing. + */ +void rtl83xx_unregister_switch(struct realtek_priv *priv) +{ + dsa_unregister_switch(priv->ds); +} +EXPORT_SYMBOL_NS_GPL(rtl83xx_unregister_switch, REALTEK_DSA); + +/** + * rtl83xx_shutdown() - shutdown a switch + * @priv: realtek_priv pointer + * + * This function shuts down the DSA switch and cleans the platform driver data, + * to prevent realtek_{smi,mdio}_remove() from running afterwards, which is + * possible if the parent bus implements its own .shutdown() as .remove(). + * + * Context: Can sleep. + * Return: Nothing. + */ +void rtl83xx_shutdown(struct realtek_priv *priv) +{ + dsa_switch_shutdown(priv->ds); + + dev_set_drvdata(priv->dev, NULL); +} +EXPORT_SYMBOL_NS_GPL(rtl83xx_shutdown, REALTEK_DSA); + +/** + * rtl83xx_remove() - Cleanup a realtek switch driver + * @priv: 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: Might sleep if priv->gdev->chip->can_sleep. + * Return: nothing + */ +void rtl83xx_remove(struct realtek_priv *priv) +{ + /* 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..a8eed92bce1a --- /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 + +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_unregister_switch(struct realtek_priv *priv); +void rtl83xx_shutdown(struct realtek_priv *priv); +void rtl83xx_remove(struct realtek_priv *priv); + +#endif /* _RTL83XX_H */ From patchwork Fri Feb 9 05:03:42 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: 198744 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp636583dyd; Thu, 8 Feb 2024 21:06:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVj9bpN27FfqOoM3FG8lhZpKI4up0k2oV5aRjwhmLbWprsZpEfHMQll4SAVLwt5dhpyOeD58b0qQoOWUcxvKtXBEWZdqw== X-Google-Smtp-Source: AGHT+IFFZiv04xQtsUlYlBRi1TwHuGduK1VsSCr3y0o9TTJzXNI69lT5CRcHL6FQi3lAuzIZhirR X-Received: by 2002:a17:906:891:b0:a39:34bc:4942 with SMTP id n17-20020a170906089100b00a3934bc4942mr264568eje.1.1707455207713; Thu, 08 Feb 2024 21:06:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707455207; cv=pass; d=google.com; s=arc-20160816; b=cwDcicdJcztvrIvK3XO5zMgW/vTkNGKhKedTwLxMMAEpftkFALBB9yY7hhjopFRZ9z R2kiATGfKHE6tjPMRI5D1k6n7qIHbxrT3F3KuAGZO9/xztU5h+SriIMA1XaYxhokNkEK fsfO2MF8/+DoCtvPVhW4lBp+LvnZt0C+SRMQJgylrvCENJLJ+akVbOhAmop7YNpyxov0 EZc6+09cLNcpk2GdseSd0W1fpiCNkOiNpXt+feGCp2VKRe/hecPYQ0zS8KckVGjtWomg L40Dio4hG1VxE1tnKlgWvLZ9LYUYOXKwcA8VjBhOXINiRy9EswVfABCPPppdguFi3bh5 A9Eg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=U20uA94KDzmtdzL0Pvmh3qCzwQnio/F6nNOPO+lS/4s=; fh=uaWRY6b+xB0Wc1cTTWc4yk2mzT5isO0oAXdZ+crTVns=; b=UTEFxFtS3UcySi2yvl5Zc8kkOlcDH+4g+Eg/KkwoiJfyFYMw1yoDqd/tz5pL7zhPFY DWnpS+H64bu3a1uWz25A4hWWk+VxTM/FMgRWEUNvOMq2AveHTKL9XBEOwkpzzX+5UU8t AzHJtu92pWV2UyXEISzncrCF1orN94eQJ6GyHtzqPd5oOxX7d3DVtCW8elVms0TnABed y8zBUx3XDVMMkudU5mAfj5ofMSisl8AWOEkJDiP7BNDfF3P0NizfRyVfV/q+JnUvxi+A sSH42e9y4UH5qrSVBPFuGi+ULEb0/MSklGoS4j758x/Mw6jB7MKmEvN330XNIzDHT7FS X4GQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ht2oTvQU; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59009-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59009-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCXklBfzLhgoRpwtytDru4k6HvCli3WJ4dUxIZy3qe4awIIoY/ErHg5dE9LZOxQ8twTBQouY2d8FDxavuhe4Mgjq8/UQSQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y19-20020a170906559300b00a3723f1f1c3si432406ejp.33.2024.02.08.21.06.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:06:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59009-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ht2oTvQU; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59009-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59009-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 203E51F23A5D for ; Fri, 9 Feb 2024 05:06:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB97858AC3; Fri, 9 Feb 2024 05:04:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ht2oTvQU" Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.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 6660858212; Fri, 9 Feb 2024 05:04:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455086; cv=none; b=kVkqOw9+lrmcY5JxFE8e7ryJK9qjbyaDMxl7EYJ0iKx3qzJr7UxGfNmPqA01o6aPVqk8OJVSiDel2hGo/sk/0Vf5K6OimFmU8tgFVk0qwtkQY1FBLhekW0d+uXJ1t0MiskQdOUzyH8y7kpBgiHrCiFCVMo5nSHPDW0XmTwXnpgk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455086; c=relaxed/simple; bh=uRB/16DuLtBh34jZnH2UtKHsz61uXCD8IYiY4hjgO44=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lie21E32nhQP7qe+9JNl0lpmkAMeNEIjfe78mBXTrV+K1qOPfNXuvukU+DByq4ESb0DmvqNW8OEs703LtAo4JIfJyNhKADp5PLKdQ2bl30h+ojaZVsJEc4OEhgUy59CAchb4WJX6x3WRNThxtiShoL0BaLT2pp2k1j+oVVF8rsc= 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=ht2oTvQU; arc=none smtp.client-ip=209.85.167.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 Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-3bfdd9fa13eso264217b6e.1; Thu, 08 Feb 2024 21:04:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707455083; x=1708059883; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=U20uA94KDzmtdzL0Pvmh3qCzwQnio/F6nNOPO+lS/4s=; b=ht2oTvQUFoSEJQyQR6N9ZhQZmfPJzZLo+KFmmqAb3Phen6fVScGC9KdbAxkQGZljyY yFr7F4P+u2mqm5PRfi4UxjTfMkbGQW72bj+Bt02omcBYnziwME9y23cBN/k5PNtHMhPY xCY+qbWzqYhoeDcLzpL9E9pRkrkgWUv6tf5mxBUGEhACOr1Gv6UQlgImFLW/+OXmxcLg w0khRd1fb5sNxTVIlIdY5GGu7kGIpWUbA3LYHKCLabOe3eiFb7+ikn5wFQQpG/EJlwBN SQSxQUCplLPW/tSuayg7L+Q99eHxT1bVuGUaeeiK+m6aUvhIRsIyrqCYsdTOcmOEDwy/ 0qPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707455083; x=1708059883; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U20uA94KDzmtdzL0Pvmh3qCzwQnio/F6nNOPO+lS/4s=; b=pQl8dM7IQ0FUqhG1TixxmHIXwWvU8YZm0UT9fb87NkMudbA0rPu+vu49vh1c0oeQWA unTiHhDQIKvvtM17ZkjoW3DVwEt5KjzwTZcVVXxYQfzIdgnobrUpF3W1hh5SlDHC1wla 2mPH6QhHF8DW+56Re07h7+oQIyuZIugHNf/ObbAUxOOaMwJ7/CQ3Ixt5ugHXOzf9YK86 BFAuR3yq8fbFEQVdpyTPLVsoR+ZdbUUxaB/hdwS2RI1SC+YAak54iEa0sCfjryknAp57 FqX5ahCfFD20ZagJYAe11n/vCwGlVz7TTWrc1+J/HuYdH9f5AprcbsU/mCvDpSO5RUZ1 MN4A== X-Forwarded-Encrypted: i=1; AJvYcCUiVw6T7ejxr2o8L/KWLNPzdjZub6xaD9tC6pbPZ6jjr42dg1m2qSLTKpctX+QKvWXUYTnhtGXuZGCCse0ISqQipk7hxjk1YqNBrDku X-Gm-Message-State: AOJu0Yz8rCaXLZYjbaHi4yE8YCjSDeonC1y3f+bvDofpyfgBnfxlr8Rj sMeOz8WBJIAdgQ35h9lVRhASwh26WAjm7EFdh+fuFqGV5grv0q0i X-Received: by 2002:a05:6808:1a22:b0:3bd:cd55:d320 with SMTP id bk34-20020a0568081a2200b003bdcd55d320mr646205oib.47.1707455083351; Thu, 08 Feb 2024 21:04:43 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU9V0ObKvp4vvxaA/6YbtSgME2bhbZbr4d8uU9XeesGpPY6yGlMx8TG1pM9djELdNxN1b7a0FnbdqrRcXEu7ru57p+PEwonUb1ZcOOORZebwMI4R0UX9JxG1HgQdfwJQduaYfzSvZMPjSCqTh+9yOPCdom2f/vv4P3cSCucR4Jou6ePXDY/H5TGB1P2MdW64hLEUoRbgpPHY/ktfXO2VImXYUMvrOpjTRs5u2BKXYl2RYlvojHcv0KCIXXy7vboV97wT0iKmDWHtuX/unvQDm2APeDpaQC1U31tUA8AkHFKuoOLM96yWx6tP97X4xuyO6xWV9J7ykBPLTf1AAOYqcsT4q7Pc+y147uoSeorL5L5FY20NuX9h1XyGDns2dRZBe/6eXjaaTVrJHBC/eAGWWzfSkfO Received: from tresc054937.tre-sc.gov.br ([2804:3b0:4104:200:2be:43ff:febc:c2fb]) by smtp.gmail.com with ESMTPSA id d1-20020a634f01000000b005cda7a1d72dsm793616pgb.74.2024.02.08.21.04.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:04:42 -0800 (PST) From: Luiz Angelo Daros de Luca Date: Fri, 09 Feb 2024 02:03:42 -0300 Subject: [PATCH net-next v6 06/11] net: dsa: realtek: merge rtl83xx and interface modules into realtek_dsa Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240209-realtek_reverse-v6-6-0662f8cbc7b5@gmail.com> References: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> In-Reply-To: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> To: Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Luiz Angelo Daros de Luca , Florian Fainelli X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=3898; i=luizluca@gmail.com; h=from:subject:message-id; bh=uRB/16DuLtBh34jZnH2UtKHsz61uXCD8IYiY4hjgO44=; b=owEBbQGS/pANAwAIAbsR27rRBztWAcsmYgBlxbJL8xND5+rbHpTQwP/NWYbwjiZZTGb8top8/ FVieABAxHWJATMEAAEIAB0WIQQRByhHhc1bOhL6L/i7Edu60Qc7VgUCZcWySwAKCRC7Edu60Qc7 VpK/B/9W93jJ0I+CQVtAzBPMkz0wo77tEQxrUjXWRVVxJnuoOJOGI6Ne5AlXJedPwsLdIU120/O uba6Ou2btVRsItynY7pTrlRAO8v822/8rlgk7YQPcMQCV4cdZzkopT/n9eBWKqSZPyRulC/s5Sa sLDgOTFAEOA3LFMz1PE9/AC6ZUpwkj8MYfEtm5fpVhzPs+i28arkLa/OwDZm9zN2cfKP3QkEgcs FkhPa/tQJ9PjM3o0GodqLo4tnAExEZYzY5A+afUDofAEsVZuitttSh/GlVRV/rKhZ0tRtHm5D3W QMWKGevQfK9wt7LrvEZPlP5P66kPV/8qZKaJQtkQioiag0TL X-Developer-Key: i=luizluca@gmail.com; a=openpgp; fpr=1107284785CD5B3A12FA2FF8BB11DBBAD1073B56 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790396551763123898 X-GMAIL-MSGID: 1790396551763123898 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 Reviewed-by: Linus Walleij --- 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 d579127f05f7..35491dc20d6d 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 90a017cbe168..04c65452da0d 100644 --- a/drivers/net/dsa/realtek/realtek-mdio.c +++ b/drivers/net/dsa/realtek/realtek-mdio.c @@ -186,8 +186,3 @@ void realtek_mdio_shutdown(struct mdio_device *mdiodev) rtl83xx_shutdown(priv); } 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 d676cc44d517..10de30d3e044 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) rtl83xx_shutdown(priv); } 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 0f628065f456..e42139f6e685 100644 --- a/drivers/net/dsa/realtek/rtl83xx.c +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -231,5 +231,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 Fri Feb 9 05:03:43 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: 198746 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp636713dyd; Thu, 8 Feb 2024 21:07:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHf7yuPn4gGzZv6o8usIeRz70aQ7cSQ7J/SN7ac+42QXNj/cflbwOaRTX5i9MCPjAmERZCN X-Received: by 2002:a05:6870:d628:b0:219:b896:ce4d with SMTP id a40-20020a056870d62800b00219b896ce4dmr472575oaq.50.1707455231079; Thu, 08 Feb 2024 21:07:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707455231; cv=pass; d=google.com; s=arc-20160816; b=vD3dkPrhi+8Kg++qJl9Sk7T3LnKjXp+DL3qmeK9yO/mnZayKdDSnp94SnHtSsyaJ1f WiH8nriYxkAnT8g+a+1X/dzWiIAlCMC8C1nSe9x0IivuExDFWQlEFGrQaHpPjAFUp+qg imkx0CnRhc1l3uXJgTMtRzRc+MnlVDrNS37WaJU0IC6IM2T9v67WwPsUpmvpj5MAlJSn ZT1gQjlpnN9YvxYdX7nu/IiRKALw1hVj9uGH9YiQbrkzfEWOMqUVj96a7mRV2iQBJVPV /6xBoZqBxvwRqC6PzNKsKxNP9Vi2kKtBWbcehtgmWPfZ/xAlvvqSHFRtb3MvlAIFhqO6 BMpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=/VcEDmubNqh5Qc75TMi6e2g+Prcd3QWY8lbgT5MxNYg=; fh=J8kJ2jD4LUI6oBm/07Z34P90UWOEb+Q7Dj+DPLsIwn8=; b=h4asy2jQth5wBkhyZkgXgtiz0p37UHd9EBabR6abLoKudB2PfxHTgLWHH3vPwjBiG4 Mt2T28ZMbDOsQlidmqmsIN726iS6+snqNA5Yewpi+0kZPko24YQPn7MvdHwAdIQMh6oV 6D+yrRRVnNbEI10oBRQH51e3hcZ3y3B4qrlGNBuC5loI6sNrOdsYkZJezGIYJcS9YbvV mApNWvHhRN38BlMhiEsO7YKN90VhmiN3sgwW9d4ad7b85xGDFmEIvsXd0diSqP7+YACY KNDdmMsXMoQGC8Hd/O7p5CAIOR5bS9ev6YVCAhTN7POLxSbX1cxkRwfdrbVk93XtvwR8 zuiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="FfB/WcQJ"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59010-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59010-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCUgu3TioPDmMHTFTFsqvK+kYEdQuATOOnV8oATtVYY1I4TSKNzLgXc0gYlWi4HzU8SHASAejWkHNg1Bb5uaaw2QGIT59w== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id r9-20020a632b09000000b005d8b313de29si1046515pgr.650.2024.02.08.21.07.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:07:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59010-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="FfB/WcQJ"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59010-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59010-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3B8F3285ADC for ; Fri, 9 Feb 2024 05:07:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42DD359153; Fri, 9 Feb 2024 05:04:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FfB/WcQJ" Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.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 ACF5D58AAC; Fri, 9 Feb 2024 05:04:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455090; cv=none; b=kCGP25nutwty1l1m6hR2eM394xXNK31qEdlmtiLTl8GPsztvir4rih2Mu+Lxfu/XfKr2Ln2Ikc+M7z/e94BUH5OmEVPZREpfk80e0hagOWeKCU6xKJTYBMUkVO/haKp4HjKuulaGlF3PKEXIsQwpF1poukZCkWdTcFwyebEv4o8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455090; c=relaxed/simple; bh=oSljXLwC9HAU2V1FBm+15SBnLdbMf1Dpq4x7+PIoUqo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fI7NejsBmo9X39Z1sYBF2uMMEvlZE7UGQbFlKzRbfmvyq5R8rlP+6Z8zzcl6f4+uQ9TBHIr/WCfNu58v+ocuf73zf1omkX4/QBiJ/aou7VoxGL9G5JbfWrGsssfOVGEzU4qhk/bjx+BRPg+GBRdP79Qhna8AqvOjBtyvQzv49pI= 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=FfB/WcQJ; arc=none smtp.client-ip=209.85.167.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 Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-3bbbc6b4ed1so349590b6e.2; Thu, 08 Feb 2024 21:04:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707455088; x=1708059888; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=/VcEDmubNqh5Qc75TMi6e2g+Prcd3QWY8lbgT5MxNYg=; b=FfB/WcQJDXf6yHAzB2ph8f5vYTzA1hHSo4GAcQG9FVEW9Gv9Y0oSvnDTIH7EdxVWCb YShTLecETDGcBooqCl+gLs7CvwrLD1eNaAufze7A9uH4WHiFGHiZ7FXtmWjdzNlB8odF bXjM1osdzZtie32IiSwkfYXcBHRNy+NIjugeGyrnJi7QRNPSTWLoDhYoOyeZWFmTPtwJ ErA8+ok7MW45JODTJ5/dGDXXTXDZWlsVJ3PSzg0f4uHQY2fjvFShbdO/jxsL8tb9AlmU Q68U2pgcAgHNoFLE3/GFXhDawbA07ufCT92MT60BgYlGSTUeYB3AMnNaKfRbLgUNGuEa adGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707455088; x=1708059888; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/VcEDmubNqh5Qc75TMi6e2g+Prcd3QWY8lbgT5MxNYg=; b=QK4HwCkTV9752b31EOuMC2pEbEkIh5Akwpg8bL0xw8SNP4VL1XKD3n/NQpeMX6GSMZ KSIMA9t3EraS9q1pZg5z39nNalhI1rqOSOjTFrBwU0KfDHE7h1ieoenaNL99GjWuaGj4 PGbfMoGw3YCQ1zF7J8JvL1YRexJJj0U49cqQceWMW3T1GC3OGdcMtECqV9lWngGG/Afc 2oH8MEMHatKpAJcB6AXr1eVcK3fBxfcB8USw2q16554uH6dVTVzzHmEDmuuV9ZI/RIVw BHMIlCP6XkFod5Owy8JE5rzHWAqvRLQZnMAefmpz07NpYdnPAxkt9KxFhfN032qOOyPC yUNg== X-Gm-Message-State: AOJu0YyW5Zg61IRIZlnud0sz6QVS95g8w0tVG9+0JaWQXY3ozHb4YSzL SJv3cyVopnL7Qg1Rqt1o4mHhujg+fSfuQ1BQqIMfnXvUUQl1+wMp X-Received: by 2002:a05:6808:308c:b0:3be:41d5:9510 with SMTP id bl12-20020a056808308c00b003be41d59510mr667581oib.43.1707455087786; Thu, 08 Feb 2024 21:04:47 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWCmXgBkNJ20DJKMjV/HU9XZQQrzyNuxv/DA2/IDODMapA0IX+XRz/QPfMb9ejocAZXyJWWZIKXJRqPzTzLE0kVLSucPIUN68YdSsFBffseCZn2sbwNqTI50OoYx46bTx5egyVRRkbbqwumUCH+gY3EbWFFkbNmbufVhivWoYyLSwdmhMZTKsSS8aAmukBVmz2UxWROAMZr7qy3Ls+LCbf/WQV52TUw4HA7KTqswJhw2N640KuOVOh+71nwTCbuWF3XMPJD0oDN0xb2r17h6diXRfqcXX/r30y1D0NxntZq6Xs/rp9ob/bjQfhYZlp/niF/A9VzBQWa6kBo9C+yWhDNNz8h60/eUBG4lzsyy9DLrfGnjlhdc0Hn9XIvHq6jIzwim6YyD5RLxzxJIawQvsRlI3G/ Received: from tresc054937.tre-sc.gov.br ([2804:3b0:4104:200:2be:43ff:febc:c2fb]) by smtp.gmail.com with ESMTPSA id d1-20020a634f01000000b005cda7a1d72dsm793616pgb.74.2024.02.08.21.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:04:47 -0800 (PST) From: Luiz Angelo Daros de Luca Date: Fri, 09 Feb 2024 02:03:43 -0300 Subject: [PATCH net-next v6 07/11] net: dsa: realtek: get internal MDIO node by name Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240209-realtek_reverse-v6-7-0662f8cbc7b5@gmail.com> References: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> In-Reply-To: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> To: Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Luiz Angelo Daros de Luca , Florian Fainelli X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1279; i=luizluca@gmail.com; h=from:subject:message-id; bh=oSljXLwC9HAU2V1FBm+15SBnLdbMf1Dpq4x7+PIoUqo=; b=owEBbQGS/pANAwAIAbsR27rRBztWAcsmYgBlxbJL++MEDW3ZGpjQEAZLzD4ZGG+zNdIHiRBtb m4cVgZ1pgKJATMEAAEIAB0WIQQRByhHhc1bOhL6L/i7Edu60Qc7VgUCZcWySwAKCRC7Edu60Qc7 Vul+B/9srDuW9N18J8dqLQYLRpFU3RMYWsG+M7AxfoB9dVhlLoMAyWnWOkaHzTe2mUbcZUU8v7n z+67/2jDM9SZrvSEpa+9divndnAn10ZZ6vTatxH3Rj+9CBr8JYWiVN4UcGOinfZsIwMDnu6BEzV h/FQaugLTe3DCdJdzXw99jnU1wuv3KBQ1K+ogaeYcvN/ZDhyyZSAhpHA5h/dX+Ha/ZsdpEpYL7C ElFRicALy0oDLMENyly4WFongA0vGi4afAT1vS9UHptUTk71bOirZ3RahOU6Ee7LrkmdRzlcqfe Pxrc772b8fLTlg312Xgpi3ahncc2g3BWpCV+7XlPzc38eFlu X-Developer-Key: i=luizluca@gmail.com; a=openpgp; fpr=1107284785CD5B3A12FA2FF8BB11DBBAD1073B56 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790396576786730028 X-GMAIL-MSGID: 1790396576786730028 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 Reviewed-by: Linus Walleij --- 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 10de30d3e044..1fa8e9cb1a10 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 Fri Feb 9 05:03:44 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: 198747 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp636793dyd; Thu, 8 Feb 2024 21:07:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhdWzIhA6ugivxCN3jyP2awsblIH6GiOvKk3tieOR1/0auyNCBj5IqCt/2b3TvFDAKJoUg X-Received: by 2002:a05:6358:7e44:b0:179:292:223 with SMTP id p4-20020a0563587e4400b0017902920223mr394431rwm.28.1707455244876; Thu, 08 Feb 2024 21:07:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707455244; cv=pass; d=google.com; s=arc-20160816; b=i09CcluWucVN+EJh9LcojaOVEAcrqeD6Iw/dPAuhSfNhxRwtBy/K4HNkU0ofPFmWZI ILlKUFOgfQKIzd7oqLXmasMLjahfHtJEA7PCyp2/qwDL1aGNHJoDUd+FYpqoUqayFOfr b8zhLVIHwfSyeQ5PkewSX1ayt4ioGLaQjT3D2zfX6uqELCeUIbzjGckh+sG3mPsQ2Njx 9NG5+dr2rc6V1ooomrDTKVMxe5z7D3C4YsnXolZ80p3Ny+RVtSIhYosgnvzo3MgtDIS+ +fT7BuLxMKuRA/ld/8ZpYDCDBGs9QXtZPN0OOVwWlSww+IpaJe1UEx6VbRxdRTbq/Go2 ufdg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=OCZ0u0JMUjeWwMEidR1j+87euhJ3fNtoLBFeSNRekRY=; fh=psCw7SxfV4Hv3NjsPiIYW1iP5kCowcfpcA7zsv2bL2c=; b=mGRyce6NT8BtPEdRXeJTNldv4R9sh9kgp9EPIBZTlDrCSKxhPTVgn29cpmzvGFnx7F mR0oEWeNXtsiHxqc/K0b2mal+UHvUMP45pzs51Am7IowIvDZRkIzNdA2E9qSgENWeSzI P0O4K0iJzEvgLKzJvloqwZKnLnT4Uo2wGN37gQLJRCjpO5WJwzqTDXoNaGtykv6gmuel QutHlqPQVJcSncSSQyYwZMYwHpUZvDLX4ThE72e7rG8LISLpTjLMTcRnqeldE4WqWE73 Y0LXHLtwbUYz3yrT7h8Wb7z3YHtHek71g2rT0X39SkGH+SW5tIPL6RIK6Q7L8bfm4FlW /SRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aRB762+K; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59011-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59011-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCWca6rBAMmKyfYq06cKbZk3NqGYT612RDlwCokFhZKvnJ2pmm01kLwh9Cbyw+fz8L2sSkpvAizI0NwAqLRhzQCeR2V8cw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bw31-20020a056a02049f00b005dbedf04f68si1181687pgb.10.2024.02.08.21.07.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:07:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59011-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aRB762+K; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59011-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59011-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9FFFB288AA7 for ; Fri, 9 Feb 2024 05:07:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AAE8059170; Fri, 9 Feb 2024 05:04:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aRB762+K" Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (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 F17365914D; Fri, 9 Feb 2024 05:04:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455094; cv=none; b=tqYVrOlz0HlyKPGLQ0/miyRBQF2sV9hxeogF+2o/82XcYhsV9MvCC/58IFL8kG6FeR3hmsvEbhmbTggt2J0RszokD5JWHGrU7KpHECcFHmv2/awcp1imvfq8LBSvIWsxAUV+yKt/qJiAa97hhTx8j1pTE0eKeAWvTAh3a54lJdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455094; c=relaxed/simple; bh=th2mXBWQmGcWOhbgTrZmTuITUpx8jFNlm3jTc1Fr7PQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l3IPRX/Pi0cDeU/gKW30zB8hVEi8Ad4DHv7nzmKYbpgIpVBIzY5IG7UWi7MTeJ+IIDDojrW0Dj52aA/SaZ88emrMm0gRFplAe0Uwxbov9C3r656t3Kh7EwbE5pDji3mUEXbhF0WDUnBR/8ZcfwK4aanEhqZ03jwUst8A6q1vVAw= 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=aRB762+K; arc=none smtp.client-ip=209.85.210.49 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 Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-6dc36e501e1so377914a34.1; Thu, 08 Feb 2024 21:04:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707455092; x=1708059892; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=OCZ0u0JMUjeWwMEidR1j+87euhJ3fNtoLBFeSNRekRY=; b=aRB762+KeHvX6wTYchK6PRzH885qv6Ysz7w9w/04eY2KWt+YTagkhGE3T9sFaT6Pf3 IO9aKl3VLmyTa0PZ9NXR8PEmQUGjusQC1JW7E1f8f/sCLRprIvD1Z8J/tjmuboyqRC6t 0hRKCc0Jo3MHH6P5W4lkj1qdU1VGa+XWwk5pv0quKAwfOsaqBe3TyGlYmtjSoz4C1qj7 HOBABiREjLU0wuffmLkOaNpsi+nEc4F/8T9QDKvkJWbhqvoCMoVD9OjEOl27Xw8+mnTb Uvudn/XzkBMxk3Hf+lSnMpD2FohhID3Xfj5mwg7RTt3uTjlfv7JUQm/zSnwtb39qLXMM y66A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707455092; x=1708059892; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OCZ0u0JMUjeWwMEidR1j+87euhJ3fNtoLBFeSNRekRY=; b=AS3HAKPrs+V2QyFsbkgw/Sol6QIYSB1WGszW+qeUGHEVqtYl8BV91DVFzb5b91gSPB MTIZb4ilsc8h0VavHIWvzzbrrPdxDA7RfK/vWvhnbxXYEP0EY5Cfab7ZfL1qg87l2RzB yMWKLOO3CWRkU721ZvJuuoijTwwVFPLAFE2czEEJeD/Ld/gfNZg9epi+vzTXsrcoC0WJ MA5YW3IUtyz4lu1awpAcnCcVxuqdzHpkmR1J8tprlD826Ju/8na2uN6kNxpnDhyCTBci D1L4iFoLBOvLo9wRLEZR53hGaxzp46NxVeIdT65k0JTz/49lLTElY4Y3R0dOiAE0i9e1 tpGQ== X-Gm-Message-State: AOJu0Yy2pHVQIQZTYOcIsiPpCAD9wOFW/ITEchLcXTW02SjvszOxLGsj cuySlHW1ph3LbkIaTvvXe7rH6fLp12l0w6PUTFXdb7iWukRNhKPg X-Received: by 2002:a9d:6282:0:b0:6e1:2e98:e5d9 with SMTP id x2-20020a9d6282000000b006e12e98e5d9mr525721otk.18.1707455092062; Thu, 08 Feb 2024 21:04:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU7P+7zTv3YazljIpn4scNpZrXwKb+52Y+N/I8V8Lgam1KmEm1gHxVQI0PAzbD7Y5iyyoXRfiUXxVv1E3EEMQOVkxysnmLK113xLQqeLJI5e0TjYdbggCW9sI1RFfMvXAFKBmIunlkqUnfvG7UrjH5UnnfjVDAVr8f3MeB0PJt7sVVpUXZOwqa9EQoJmloZHY3btlW0AWE97lO/HfA/wJ7uXCt0du7rzmg7DqP222ZKws+a11jxVRhItQ1qSQpj5b2lvm3uOb8EdHTHbOFhltOfAAGi3jJOuRLW3wJKcmMufli/BUKnrDfhptb54PQvBCbEe3I7nDAS+AaNACvO/pA36zT4mm+MTvQazFZfsCbBVNSM2WM= Received: from tresc054937.tre-sc.gov.br ([2804:3b0:4104:200:2be:43ff:febc:c2fb]) by smtp.gmail.com with ESMTPSA id d1-20020a634f01000000b005cda7a1d72dsm793616pgb.74.2024.02.08.21.04.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:04:51 -0800 (PST) From: Luiz Angelo Daros de Luca Date: Fri, 09 Feb 2024 02:03:44 -0300 Subject: [PATCH net-next v6 08/11] net: dsa: realtek: clean user_mii_bus setup Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240209-realtek_reverse-v6-8-0662f8cbc7b5@gmail.com> References: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> In-Reply-To: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> To: Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Luiz Angelo Daros de Luca X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2768; i=luizluca@gmail.com; h=from:subject:message-id; bh=th2mXBWQmGcWOhbgTrZmTuITUpx8jFNlm3jTc1Fr7PQ=; b=owEBbQGS/pANAwAIAbsR27rRBztWAcsmYgBlxbJL2fi6aiAkCzNNWEVnjtQgEtdkBDdq9NeTe qCNlbDd9CuJATMEAAEIAB0WIQQRByhHhc1bOhL6L/i7Edu60Qc7VgUCZcWySwAKCRC7Edu60Qc7 VsFrB/sHRU4RJC5Q04Uh7cKRAbSKC+DA5EFwMEwL3izidfRxZ5GaAv3E88g0iBTCk7LzIy+VAYQ BFnrwh3pZWSrZTjGOyw7c5bTm7bPzn9OVzUKHC4EI3s4bjC5kRNZlPlF0v0MA4HdKNE3CX787h8 fVrPwNRrcq/q7WLbyuj5hgu5S3/OLFixUy1tQWB//Gw7NJgD9UBnCy6ayCF0U8MBva0KQOMz0af Q4YGKpZe0e4nY+OetoIr41xtE/LkiwMF6/pOyiPB2hnBu75E/i/njQr8uzVA6jClNn8YR0SjL3o RnYkT3uNLAJqZjT7o7G0eO+ExuLVtezDCvHzb/n9K3BR5/59 X-Developer-Key: i=luizluca@gmail.com; a=openpgp; fpr=1107284785CD5B3A12FA2FF8BB11DBBAD1073B56 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790396591001078012 X-GMAIL-MSGID: 1790396591001078012 Remove the line assigning dev.of_node in mdio_bus as subsequent of_mdiobus_register will always overwrite it. As discussed in [1], allow the DSA core to be simplified, by not assigning ds->user_mii_bus when the MDIO bus is described in OF, as it is unnecessary. Since commit 3b73a7b8ec38 ("net: mdio_bus: add refcounting for fwnodes to mdiobus"), we can put the "mdio" node just after the MDIO bus registration. [1] https://lkml.kernel.org/netdev/20231213120656.x46fyad6ls7sqyzv@skbuf/T/#u Signed-off-by: Luiz Angelo Daros de Luca Reviewed-by: Vladimir Oltean Reviewed-by: Linus Walleij --- drivers/net/dsa/realtek/realtek-smi.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c index 1fa8e9cb1a10..0c36b43cd7b3 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); @@ -428,8 +425,7 @@ EXPORT_SYMBOL_NS_GPL(realtek_smi_probe, REALTEK_DSA); * @pdev: platform_device to be removed. * * This function should be used as the .remove_new in a platform_driver. First - * it unregisters the DSA switch and cleans internal data. Finally, it calls - * the common remove function. + * it unregisters the DSA switch and then it calls the common remove function. * * Context: Can sleep. * Return: Nothing. @@ -443,9 +439,6 @@ void realtek_smi_remove(struct platform_device *pdev) rtl83xx_unregister_switch(priv); - 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); From patchwork Fri Feb 9 05:03:45 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: 198751 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp637845dyd; Thu, 8 Feb 2024 21:10:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhYZ0jY+kuBIGa16ZfcsmTkgNRcaqrKTf/oUjmf1Sx7t+F+jI2xaUkz33EgzjiPt5dlwLW X-Received: by 2002:a17:902:7843:b0:1d9:bba8:16f1 with SMTP id e3-20020a170902784300b001d9bba816f1mr440802pln.50.1707455425084; Thu, 08 Feb 2024 21:10:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707455425; cv=pass; d=google.com; s=arc-20160816; b=ydO3zzt0XR4/AfN0jJN1IF+8/JAIEIvJKTAQTpGcGrzCWiOfhmWX5q4duMcr8VVkJ8 7EaS2HeBenDbwLf4fXTOaK4dyFF1jy2HlMcwzIaFHRZFIPGVcHnrJExRuoA1Fg1SDdl/ OYiBEDLrJiVtIxzQIUBabM8uPxmeg72yKUy1jJ+KecTJzoRNUSefPR2ya0aNqe2EEffH whkKs1uv7HUMfxUgnnekbuoczso4V7pRwjOvmobGB5rZtItqbuvT8nECqYOHHwXOFAy5 3FHA2iGdaBnk+F0dPjXCvQzUdrzXvkBXhpdqJ/NPhyHwHdxOeOawDoGuJmxaYrFtYhI3 SgEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=KCL6ldcw1wx2vxFXIvZl2VTSDofc/dNo4LHc4NCeTgY=; fh=LomrULQx4/xYYtuovx0PkeinUJN7JxStNRrgNJ35Vww=; b=EyxlwHeYupTn3JBxFzEVM6lNzK07BpXTk+FyDLx6NvFW4hAeTqGPTR3O7zeN4g9zb5 bKpIk1Tv5zZ4ys+om5R9iIZsYdK6dIYn1g8DBOtSAzNupXRmdoegQPNzqEJK1TA9kvJE nV5qpHUBR4rjSTjLsqyErIaPWenTlsXFFVk3+odKoXKtFJYf+RkGysEXiUyDYVL7F9Gg OJx60hNGwSIqZh7Ok9E/d42vQmKnKbAnUBzzaPirgAkSA1BJghc6pK4Mx3J6X3Z970PV MSVt3n1dmPnJGFY2NQzP63eCsM64PXz7Gs0IOrkBYgcLnAQkFvmj25fBfNTXR5giocZB Nk9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fqe8pDub; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59012-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59012-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCX0VtW6BI9JkcMMtOOFn1MOzFO9R57IQq3SBTxe4S/Y92q0BDCwyNqYOQ+MiJMSdSzmlkPYcIGz9l5Frzu1QEX15wHY0Q== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id f9-20020a17090274c900b001d8d5bd2853si993728plt.30.2024.02.08.21.10.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:10:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59012-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fqe8pDub; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59012-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59012-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7AD90B28453 for ; Fri, 9 Feb 2024 05:07:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F302C59B7F; Fri, 9 Feb 2024 05:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fqe8pDub" Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (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 40BBC5916C; Fri, 9 Feb 2024 05:04:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455098; cv=none; b=br2E92lWN6MXJU9nnS3PcjznB2ZJzCsxvVoI1AvfYWHZnol+5GjdelPJ7T1cqftKPF6/KSGAZHkhX4w2wVL6dW2pVEQaZ5rFogRtiD9PHAK7FyXlEaQLXHPwueZn4FvrvRfTgLWtDaHT/kI5J43Myc4ajUWJZ77igoThMdVLHBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455098; c=relaxed/simple; bh=otUiPYAp9YLv0L+vaSKcddoDDsCwNIuKy7Ob16ptNf0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WAxkBUOIs2uCIKVBwyvx2Nc9c9JgqvJeZs8QFS5WdIfYY5v3UpFWz5OixHH8bZ7LR9DWrJBbvPuwaESKu/0xTc966+KF0QXqphx8ixU4Iv8Q+Rir3KLY6l+5ardAQ3frBvEhSm4PTZlhyGeOs1QuX3qGdCkRm43lL1/hlWHw1Kw= 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=fqe8pDub; arc=none smtp.client-ip=209.85.210.42 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 Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-6e12b58a3beso198061a34.1; Thu, 08 Feb 2024 21:04:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707455096; x=1708059896; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=KCL6ldcw1wx2vxFXIvZl2VTSDofc/dNo4LHc4NCeTgY=; b=fqe8pDubDtPu8I4BJMyZLc61idTbUj5vXJyL3COPEWSN/IaVCAjz57PelLt4c/kOJN +wFgLj0/V64XDD8ngWwjra4VFEegfVyVhLWbkc3NX6WQ1fbRes5qc80IRhR1T4Ymtj8m W1bTLpGaSd0mBHz7RdaYWspdFcLoPhPo0vt/Mu7ZZ6RFvExfg0MchVV5m5sn5U/btNQa 87rBIZrycg5SYqVat4twC380VLi6PlLEIMCFGWD0uaZoJaq4t8/trLiW4s7zeFbusZ+X rclP7yXSghr010aCo4iUz8q9g+/PShdZVYL5bHWtQNrzlNGHqVamRqLYqkpUrHtYbNxR +26w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707455096; x=1708059896; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KCL6ldcw1wx2vxFXIvZl2VTSDofc/dNo4LHc4NCeTgY=; b=SWeWL14N1JeTPHxywRC9s+OA0m6S/rdkXVZ2b4FPsAIsb/fJ7nRL9GIYDwdA4TVgTK iKdmGv5+4e823B4YdDRrgnI8oxzMbmGDDadbw9otVeSSSGDP7fbccjzq9k/YuKtiOVuO 6TJKlfvlxnBZZsNpIlB0HDyut9DE2/12rNJJWR4yD0UtluJbQmND8JLjY+XeI5lr8Uf9 3wKmCpNwrPZ5BcTfU+Ci3bBw3OgUzWv6Pc962JvHs5Osf1MASGM+9AU6WC+M8rp9dxER X4EtgTXLyPJHgMwh4D7QrJByi9RGQUPiFLPKRTYTV0QVCFSv3CXnGGZvjqbBFiB1nDAT pgbg== X-Gm-Message-State: AOJu0YzASzpd7nUxs+0/vGrnAwREpjLjSBkhpcBzMAxQX9KvvZjj56Yv tv3XQ7K87J7CgJMGHcx2F7TKRkzmC32yarL8+6E7/xrALjX3LnKQ X-Received: by 2002:a05:6830:1453:b0:6e2:b5e4:30d4 with SMTP id w19-20020a056830145300b006e2b5e430d4mr494018otp.26.1707455096300; Thu, 08 Feb 2024 21:04:56 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWBgKBiProL8k1jNk6iGPrf26kZKrMsyYP0uM2GPNal0F7JyiuSFqDu+q3a7NO2IuiWKmRds7TaIvMsyezuzlr/DYwgRY4pCrb/r9BM48hvpm2ZK4003GBLfgtcnezw59GRpt0X/wQAITJGZ/E4qexF8xqbuQCC1m05ovI4kvOvouAvCXQCKy1wmAfhlT1S4rtl1TcqrfwkAgVs6xmlBjYkRqUyDrso2x09vkBnF9rxlh64J26Bg8Ue93yLdnaAssuT9EF+NpcO2TAzBomholXcnPFlx5GThBTdGeRM7v1WJYTCXVY7omoWI6A1KtpJcCYkqacXPFZREQ5zla56rusnZF7DTYGoJInKYkjZ6Rdv7CHCuqM= Received: from tresc054937.tre-sc.gov.br ([2804:3b0:4104:200:2be:43ff:febc:c2fb]) by smtp.gmail.com with ESMTPSA id d1-20020a634f01000000b005cda7a1d72dsm793616pgb.74.2024.02.08.21.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:04:55 -0800 (PST) From: Luiz Angelo Daros de Luca Date: Fri, 09 Feb 2024 02:03:45 -0300 Subject: [PATCH net-next v6 09/11] net: dsa: realtek: migrate user_mii_bus setup to realtek_dsa Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240209-realtek_reverse-v6-9-0662f8cbc7b5@gmail.com> References: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> In-Reply-To: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> To: Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Luiz Angelo Daros de Luca X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=6106; i=luizluca@gmail.com; h=from:subject:message-id; bh=otUiPYAp9YLv0L+vaSKcddoDDsCwNIuKy7Ob16ptNf0=; b=owEBbQGS/pANAwAIAbsR27rRBztWAcsmYgBlxbJMiFE+YmY+O46imTLJr0l/9qjoX1kQmVk0B M2/jfbMcDiJATMEAAEIAB0WIQQRByhHhc1bOhL6L/i7Edu60Qc7VgUCZcWyTAAKCRC7Edu60Qc7 Vn1jB/9AEpINM/iamSz7FYJ97GVoTRUPlO8s9nWcFl2c/p6eyX7+l7k8W3T8YFgrVFoWSVHcxBK EBzc2N8li5/aBO1JYQT0J4U3MFsGN99gHauy+lBmw5QMIxNRNE+U8vV3L6KgE/mzf4v0DcK91U6 IC2dBSl/yAlIuMme3DmFfn4YABTlxUzy5ouDVTMKXKKWfZ/uTTN4KOISc5/Jtu290xFYav2h5gA VdqPo4w/ZZUk+ZoDKMfYBC3nF83syMP/1CnN/Y5b++2yYOQNDDYoMRXtTYfmYWwKhNB1jEg0187 sNcNyFALSD1niEijVN8adK39LJM6sMRPUrDaLhPtKcpQgZhF X-Developer-Key: i=luizluca@gmail.com; a=openpgp; fpr=1107284785CD5B3A12FA2FF8BB11DBBAD1073B56 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790396779825915871 X-GMAIL-MSGID: 1790396779825915871 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. The MDIO bus id was changed from Realtek- to the switch devname suffixed with :user_mii, giving more information about the bus it is referencing. Signed-off-by: Luiz Angelo Daros de Luca Reviewed-by: Linus Walleij --- drivers/net/dsa/realtek/realtek-smi.c | 57 +---------------------------- drivers/net/dsa/realtek/rtl83xx.c | 68 +++++++++++++++++++++++++++++++++++ drivers/net/dsa/realtek/rtl83xx.h | 1 + 3 files changed, 70 insertions(+), 56 deletions(-) diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c index 0c36b43cd7b3..bf02276b74d0 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, @@ -407,7 +352,7 @@ int realtek_smi_probe(struct platform_device *pdev) } 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 e42139f6e685..ceb8418dfab7 100644 --- a/drivers/net/dsa/realtek/rtl83xx.c +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -2,6 +2,7 @@ #include #include +#include #include "realtek.h" #include "rtl83xx.h" @@ -43,6 +44,73 @@ 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 + * + * Registers the MDIO bus for built-in Ethernet PHYs, and associates it with + * the mandatory 'mdio' child OF node of the switch. + * + * Context: Can sleep. + * 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; + struct mii_bus *bus; + 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; + } + + bus = devm_mdiobus_alloc(priv->dev); + if (!bus) { + ret = -ENOMEM; + goto err_put_node; + } + + bus->priv = priv; + bus->name = "Realtek user MII"; + bus->read = rtl83xx_user_mdio_read; + bus->write = rtl83xx_user_mdio_write; + snprintf(bus->id, MII_BUS_ID_SIZE, "%s:user_mii", dev_name(priv->dev)); + bus->parent = priv->dev; + + ret = devm_of_mdiobus_register(priv->dev, bus, mdio_np); + if (ret) { + dev_err(priv->dev, "unable to register MDIO bus %s\n", + bus->id); + goto err_put_node; + } + + priv->user_mii_bus = bus; + +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 a8eed92bce1a..0ddff33df6b0 100644 --- a/drivers/net/dsa/realtek/rtl83xx.h +++ b/drivers/net/dsa/realtek/rtl83xx.h @@ -10,6 +10,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 Fri Feb 9 05:03:46 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: 198748 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp637040dyd; Thu, 8 Feb 2024 21:08:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4BXjvF5ihEG6uNKCkc5GUroS1QT18qVgVTiwBNdEyLzwVzgea/GInsB0mj4RKgwM3O3gY X-Received: by 2002:a05:620a:1465:b0:785:ab77:fe6c with SMTP id j5-20020a05620a146500b00785ab77fe6cmr556216qkl.6.1707455289096; Thu, 08 Feb 2024 21:08:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707455289; cv=pass; d=google.com; s=arc-20160816; b=h8x/lb+eX1Xy+wKlkT9oD57BlhP97oqByT9R8eBJSKHe4bYBi754wyZLzPoiFnXsJS EZd1Lf0cNTVGFTobnIqQg2XSwqQ49Dg0JBHimIPZ4SGSLuO+kNwoTqa3FNkAPG3QTHHQ JKQU9gFOYbsVgwtvSZ3ISKqLYQZW2wgT+V5ncuNMSwXHed2pyWZt5zi+uybbI0iPFz+o FwlmAYJhQPotu+mXELDZOjbH+I5EgxZ1q892i4RKGdi8JTQNnNDDpNW2E0I7FhZtM8jz flJ3SEHUt4BPwlGvWUgjCFSg/KgLZLTOXQ9CiWPsW5PYyPik7DEhC2K+ch5AnzhQJkCS 81eg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=SDHXEFZTikwmhTjEOcrYXugCCX9uf2Y9+WgX2fGJ5fM=; fh=WlIcPJKoN4C1bXntIzEeyprqkLGKXSka4/Zqnw/9y7Q=; b=oWStWnG2S08lWfqbpbj6UamvL/cPiaVleSJZY19gfgZRJbrE9pCkxF0yVTW/3vbhXG GBm+MUq8FAppJJlW0iGYvDHFf5VLvliq5+7QyelLzZmPkee51igpecghVGyRpwTi/OMT V33A0fEi3MrhVmhcLoIB5XsBiUtNLlJL4yP1PH4bLWXqf0GyhMZOIxEU/mY5wzbe9Dpf JYupqozQ4DGS+M7RMhmH55Apb9Zz7ysSBhbs8t7aH/hjg1nL0fExA4R/rrN8AIHUxP0A YZ1ZjOYRLNGEpiX67SSNk3rR7n5AtFgMdJ74S7Vwb4UtlcrmRrJClDAT3HCaXUilGJF4 Ds9w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ZRerSew7; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59013-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59013-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCXTq1AzpaPIYYW66JrULyC1h1wsvn/btRnvUvKzFw6n1BCc3F8BXRBmHnBF9qjvzaRJtK5tuL+M/WEyLYNGGw6zZXD87w== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s13-20020a05620a030d00b007855e8d19b2si1202727qkm.711.2024.02.08.21.08.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:08:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59013-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ZRerSew7; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59013-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59013-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BDEF61C23F6B for ; Fri, 9 Feb 2024 05:08:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46E345733B; Fri, 9 Feb 2024 05:05:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZRerSew7" Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (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 A835E59B4F; Fri, 9 Feb 2024 05:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455103; cv=none; b=fBpI+4sbYYRuvvrMMp3jKX5OXcbfdilydFurjHv7tXq5c2HmxXRHhZz7hXTGiNR217E9thgVw3z6vkLPTZghYpKXkELeqOfWi+TuSmAg0jyXI966BFZfic1EZdi/2X3S3ESbdrsUk/aXuaQWQaWGza3jZTEVGY42J+du5R3m1h4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455103; c=relaxed/simple; bh=M7tyFdeNP+I/FIJPD2qDtWuHiq0EsHeuC0IL9G2yMh0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y3yPFssEyosngVS5k34/vIYnhYkTIc1UXJforaiw3JZUd1p3ZmYwxfu/5sUPBIN0/QEu/Uf53w8yESh/fK9mxejqX3xOIOx7dQBzFjL3ba1hJg9fYXFD70xrJ16MddHVO4JLlmyZ0aS4PRhIuydm7QOsaVCksUQUKnSNX7h1HIo= 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=ZRerSew7; arc=none smtp.client-ip=209.85.167.182 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 Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-3be61772d9aso241473b6e.3; Thu, 08 Feb 2024 21:05:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707455101; x=1708059901; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=SDHXEFZTikwmhTjEOcrYXugCCX9uf2Y9+WgX2fGJ5fM=; b=ZRerSew7++2x9QlAgcNRq8in/JPCg5LJOMi0w/jcIxuhq7z6FMg7n5mZcIJBu0bULU lpsADMUCRfh2ixxNTHelIPAtrYpueDR69XvitL10IGKKnEc0MiKs43rt+SXfDWx2oTIE lgxmt/FvptpqfgN1GGZneUpOPINQp1Sm9RRpE48/696tW0DaQubJPELa1bZh5789rzz3 9T0WOkZHR+VG4kryayUcMRU10RRhBQ9N2T6PbNpa1jwZk7d+6f/HkCACR8LcDuoJJJ4M t6xoAGMP1V+D3kmwIp842GYv7QUJG4i0fEg/ydM1zmeSZnu8CHuEDvBac9HxmwvuV+HV u5CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707455101; x=1708059901; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SDHXEFZTikwmhTjEOcrYXugCCX9uf2Y9+WgX2fGJ5fM=; b=M2Nk/JjQK6hWa8obdODD2fgF/XFAPqFQ7dBv5jpBQSsZ4wSTSI6mmZwsezfw3FOOr4 lUqR0OMJP7aXb6T6D3WrgbA1/rkqoh/pNkI7LlKe7TUEUpgjzgtiMTfBhKAQT5M8TMK+ 9Esqy6zzlAXXVKzmZID04ybwOzypoAQsQPAEHdEhBuEcb1+gzRU3Ul/05NxxOtgu5oeU pcbVxAjekuoB0rKDqha+p44vwyob1cIGztbNG5FjmHx8TkwLonD7tssLJxkTs3P5wt48 4uimZAw6BtIXkMj773WBtl5nG24jV/uN/K5ty5LUTEG/vFcyaupncq9M795VS9FCRv7b 1QZA== X-Gm-Message-State: AOJu0Ywnyi2USWoi756GS3dfCLtJ3aBdpK60ynOXf4huATFhz6vfRHX5 tLtDwMSPVMvtuUdlKxyP//HfkKNg7rN4O2NyylkAZDMfpJcQbSfU X-Received: by 2002:a05:6358:63a3:b0:176:40fb:cf3a with SMTP id k35-20020a05635863a300b0017640fbcf3amr416821rwh.14.1707455100607; Thu, 08 Feb 2024 21:05:00 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWihVBS7XcTeXmlU9rvmESkZkdvtCSiV0nw5marxBf4aT8zTFoVMPTeE08n4n+m001X5cQQvvJvF8vHyyyyhZb5lQOpUdetw1ADe22AI8FZ8jRgnLyYjO0jzu/pFOjXmZNGv48/ZN/vRs6w+MSr1mpvjiFDMpioHB60c2h3xZKV+PfufVang8c+4/r/Ppe/RQHt0WHbLaeahkzX91xQvd9LPp/VhRtDlHEdc30anySrzSOWkzmCMt5JTiErWhU/sGDQhoh4kWDN8fsQL/F/WZmgXzRtUXpBrMyeY57Ho0uH3pKnd1k7Hpzy7n6NoPGyykWwTFNh3t4z2TxmyWRWAym3oYlR8Mp2+9ncv9Jj7xv9ib6ecak= Received: from tresc054937.tre-sc.gov.br ([2804:3b0:4104:200:2be:43ff:febc:c2fb]) by smtp.gmail.com with ESMTPSA id d1-20020a634f01000000b005cda7a1d72dsm793616pgb.74.2024.02.08.21.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:04:59 -0800 (PST) From: Luiz Angelo Daros de Luca Date: Fri, 09 Feb 2024 02:03:46 -0300 Subject: [PATCH net-next v6 10/11] net: dsa: realtek: use the same mii bus driver for both interfaces Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240209-realtek_reverse-v6-10-0662f8cbc7b5@gmail.com> References: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> In-Reply-To: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> To: Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Luiz Angelo Daros de Luca X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=9959; i=luizluca@gmail.com; h=from:subject:message-id; bh=M7tyFdeNP+I/FIJPD2qDtWuHiq0EsHeuC0IL9G2yMh0=; b=owEBbQGS/pANAwAIAbsR27rRBztWAcsmYgBlxbJMjzq0uQmWyt8tZZPhBrnuIICvjI32pWo4z vS/JgGFePiJATMEAAEIAB0WIQQRByhHhc1bOhL6L/i7Edu60Qc7VgUCZcWyTAAKCRC7Edu60Qc7 Vj9hB/4uFxPhmqzchHSPq7jIWj48SrRURhjbstYj2iAVwsIfbtFT+e7Fz63wjKYuHZZKNEMqgSs EaKpAfrFfblY+xLihebrVBFhR2JUmaGROpHk0WvT0vbl9JlSfbvTsR8QBmFeaYGDX3hYk4ogJ0u b4ClP2sAiDJqZgpVtWvLU8YKcnsnFaeVAO8K1l5vW6JGao31puCO06XIahc4vfBq8Ck/+3HYX4g dt5qZu9o6JKZRm9m3MUTcBriY5ML15cQLzMCfAXPfaYU0Q5gUzRunNsN8zi8rK/xkuK+tTryuWo fLn8Hidx0ygy1u5uD2DJqfPYIiX7zNbjgvgxd5mNlqhhGePP X-Developer-Key: i=luizluca@gmail.com; a=openpgp; fpr=1107284785CD5B3A12FA2FF8BB11DBBAD1073B56 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790396637019547589 X-GMAIL-MSGID: 1790396637019547589 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 Reviewed-by: Vladimir Oltean Reviewed-by: Linus Walleij --- 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 04c65452da0d..04b758e5a680 100644 --- a/drivers/net/dsa/realtek/realtek-mdio.c +++ b/drivers/net/dsa/realtek/realtek-mdio.c @@ -131,7 +131,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 bf02276b74d0..88590ae95a75 100644 --- a/drivers/net/dsa/realtek/realtek-smi.c +++ b/drivers/net/dsa/realtek/realtek-smi.c @@ -352,8 +352,6 @@ int realtek_smi_probe(struct platform_device *pdev) } 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 e9e28b189509..864bb9a88f14 100644 --- a/drivers/net/dsa/realtek/realtek.h +++ b/drivers/net/dsa/realtek/realtek.h @@ -62,7 +62,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; @@ -73,7 +72,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 60f826a5a00a..778a962727ab 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 a0c365325b4a..54eff9cd0c03 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 ceb8418dfab7..80f2c38ae55a 100644 --- a/drivers/net/dsa/realtek/rtl83xx.c +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -232,7 +232,7 @@ int rtl83xx_register_switch(struct realtek_priv *priv) ds->priv = priv; ds->dev = priv->dev; - ds->ops = priv->ds_ops; + ds->ops = priv->variant->ds_ops; ds->num_ports = priv->num_ports; priv->ds = ds; From patchwork Fri Feb 9 05:03:47 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: 198749 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp637117dyd; Thu, 8 Feb 2024 21:08:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXfd9GSxEZOyZC2i5OpmplEYJm2QRat/sPgtQGF61co6AigKUuFqU/CBN0RMJ1mWi49ju0+sF/QdYkiy+RTod3yhD6RHQ== X-Google-Smtp-Source: AGHT+IHn5WPpnFHStcPh3dHTfScJ7j7Xve07USrh3l4Nteaf1i7cOWb8WLJ1HPotRS+AUYw/ledE X-Received: by 2002:a05:6808:148c:b0:3bf:f4bb:7630 with SMTP id e12-20020a056808148c00b003bff4bb7630mr831547oiw.45.1707455303207; Thu, 08 Feb 2024 21:08:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707455303; cv=pass; d=google.com; s=arc-20160816; b=DKecPk6sUmimbnYHW1H2CBA5jqhi3YB3YN/m0kz/NtYFqa+dmHamlVyODISUBbXXyV 62RBPMWuqGIZQpCUvYC/wt+xoiXafn7iIp4y3kMz69Rdpmzuqk/mqB5VUGkssFgNkVAz 4JFeDdGTJNnlUX0+xhXCXv+e1nVkIFRoyX+sDc7VeMU8ki564LjRctRqhFxvt/h3U3ww RaFFcnpt5qnKAPcXj92PtForIIxudEviZJy2ae8xfew4AVWx0/kyL6bdoBNs4vfLpKpZ cdHprSFQ6WrKKNkRbtGSfIgS6IbvrenGT46zQS7+EivA11vVX8uoZOZlOo2YqToSYBYP 9fwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=CLEgodVgVEHEmGYZZGHP4vAVOUCZMRMnWvIbZqBEda0=; fh=BxOA436yz7/5CC5Utb9hnBhgUVOCCwH8uFwMnTaBaVM=; b=kmF1gQSF/OYKvF8GxhMzTnFoGGnDNintr501opoZgjif06vkfLgv/FmEhH5M8jI3S2 1T2tFbVI2kv1hUNKUdGei0uvG0lrXPxa7EifATQrNjQeApDv4fGk/DdNmybWr10kE8Lf akdHddX4FMvCEm3toiboIrGeTYRv4YMEDp7Utl3D/jXalOnhtJQxQxFMg5cKXhYBB3Pa dyqpHXZOrnWhE4PGkuudVdSVqfsV/m4X4c4CbMvlX3WixtPT9bsdnNpZCW22WAn+907g ccsariKaRsrGbsdRk0OKnZRCobhBnQIt2PomcBp3w/bRxdlfLa1VhdQJ+oliA4JrdPIU Qr+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AveZqPAY; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59014-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59014-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCWMQiwloGIwj9+FvatZB3jVwIiXTpUWrNU97k9gKCcjQlamwQzIsM5v0qy9XaB1YMr8BiQsPcdFj7aBfQkzTBrGOQ6LQw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c64-20020a633543000000b005dbec1a87b2si1082356pga.247.2024.02.08.21.08.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:08:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59014-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AveZqPAY; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-59014-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59014-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E853C2883F7 for ; Fri, 9 Feb 2024 05:08:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A874D5A7A4; Fri, 9 Feb 2024 05:05:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AveZqPAY" Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (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 E34FA5A110; Fri, 9 Feb 2024 05:05:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455107; cv=none; b=T5wNK2/mEwfGy5I4NndMBJxww9DeVwvi3Y0sdewcVVNaxuSSfGJagR/hfCwes9ah3oJddDfEDO2xgDle3RpRBUgm62tIXNosTAwUXgdguJwgPlP8BB+IBSLijrtpBQ4ZiGVwofmt7MB1e+65WDHCpNPK22GjOctNoL4uEPyPxIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707455107; c=relaxed/simple; bh=6WfbnARrC7IV5PUO40jgepRv0kdAsJzb6hqNXDQ8scU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y9UDHUlOJYeHG21BfNEEcMiWAzkKrWBwAMeqok+kc615hkIKm3COXLV3KyX+d6GcVMOBrz8yGXUBUALsN24RQOcmPrj10BaaijdgKKgeH5juhDB0GPFcAmxtlhHBKK5zsKvOntoCbg29j4oYpIgZmL69+qGvuKA6MhdM25QTVk0= 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=AveZqPAY; arc=none smtp.client-ip=209.85.167.178 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 Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3bba50cd318so376285b6e.0; Thu, 08 Feb 2024 21:05:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707455105; x=1708059905; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CLEgodVgVEHEmGYZZGHP4vAVOUCZMRMnWvIbZqBEda0=; b=AveZqPAYTy5dR+NPRMYPa1b29/OTfkIm/Kfr6SbsZwW5DDa25BjKwMzGrHpfzudkv6 Ajwx0osOGFZnaEXOJdesyy2sJMN59XmZtgbTBvipEuR6cqecSG//wi89ozC76CJhhMX4 sXpWIc+UkwUv+h8uSL/e3qaAZkzfdLDKF8W9WsJGnp4grZTFeBoPcLaj+hdloW0xXpkP 2+9t/qmOtIJcVsGl3/BsFNYv9m571waq2aO6gI1kCbbK2RseKruaPwKBDLbn8Y4Wc9Qn P1yX08R5//j3zslKt8U1d4r4iAdLBB6KmLbzhWFnrmBLFvHtJJtiEf3qqCQaSwX2Nbih YCuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707455105; x=1708059905; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CLEgodVgVEHEmGYZZGHP4vAVOUCZMRMnWvIbZqBEda0=; b=hYwvaAx24azA7y72ovgtFg+sJg6/8F0lmMrKFWYy4H/VfOx4O6kGFPWfcgiKCZFjTr a6b68f3wLwPrKDXUQXdmgEnuKQdsMM52CteOJkrFUzfAMHViOhPv+5cnoUt4VL+UZTus jeCZAofo0N2UbXwT5YCc761ND6fUnvGzEEZuL5G39O+5F9G1MNEND7jgYZOVFrRtZCZc Rvz+bPElwyULIlEuxekQItV4bZP3VwnvPVm5lR+TOwKPAtD6yJO3RRhjbfbNxR/8AGCl HheXxyWQeGiS+RaB60MR9FdNJDtHuUbjXd9ngX9okwEZV98AGjt3mjYrG8M7RwhBsm+X e03Q== X-Forwarded-Encrypted: i=1; AJvYcCXPtku42GATJZVgVRDp3SbG+//Pc0C95o8xo+VVgvyQGqHAD0UTp5nBcKlo1uwLTfbksHMDHbKBZGI6FOD8Bmqsj+GEASKRAwKn5tF8 X-Gm-Message-State: AOJu0Yy9FUqhyMn90IjuAYJTxdX7xnFayacUfpCalnMFl5BJjhtsojxV megdXBzNilt/iODC/FEh0mq3VuEjmbJ59mGe+YNHuydNBQyTcFxm X-Received: by 2002:a05:6808:38c8:b0:3bf:e035:db58 with SMTP id el8-20020a05680838c800b003bfe035db58mr986971oib.21.1707455104885; Thu, 08 Feb 2024 21:05:04 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUp90meHD6T3JeZHV9wTEn+Ev6aV+qtT5j6WBfXLl8FHiP5k8hE3DBi4FLvab9wA4HdkehZ7GpCBnsHSTHHmutHZtvVQHjC9CFTEFGBPzad+ndI9cMECoDrTnNbwjEA7hI8Nydus+hEQ4K7GAb/DhlsYuUvKTyzSfUKHv3thmZEL1NC+JqG3V+SrfFe2//Ps7GLXFok1O08rOx4RgwYs8Uz/unhTPmNE0n45hkuWelMtPo14bbRYAbfOyO18Oh6U19VxvXjzMDQGwUundqmjuTpW9l24Mo2iWoOHaPbUSq4P0+5YOXW+5z7ZPNpfK4CvP2llFW1Z4XRVl14aIz5bF9wNTUTi1psZe1Ydp2bnZXWoKMtwhw= Received: from tresc054937.tre-sc.gov.br ([2804:3b0:4104:200:2be:43ff:febc:c2fb]) by smtp.gmail.com with ESMTPSA id d1-20020a634f01000000b005cda7a1d72dsm793616pgb.74.2024.02.08.21.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 21:05:04 -0800 (PST) From: Luiz Angelo Daros de Luca Date: Fri, 09 Feb 2024 02:03:47 -0300 Subject: [PATCH net-next v6 11/11] net: dsa: realtek: embed dsa_switch into realtek_priv Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240209-realtek_reverse-v6-11-0662f8cbc7b5@gmail.com> References: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> In-Reply-To: <20240209-realtek_reverse-v6-0-0662f8cbc7b5@gmail.com> To: Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Luiz Angelo Daros de Luca X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=6289; i=luizluca@gmail.com; h=from:subject:message-id; bh=6WfbnARrC7IV5PUO40jgepRv0kdAsJzb6hqNXDQ8scU=; b=owEBbQGS/pANAwAIAbsR27rRBztWAcsmYgBlxbJMZoIJ4ZBc9ikZISEHiqb3dIJgALj/aZRGq /P0cy6DeJyJATMEAAEIAB0WIQQRByhHhc1bOhL6L/i7Edu60Qc7VgUCZcWyTAAKCRC7Edu60Qc7 VoRDB/0Xcsx+e+naa4CukK12XlsjibXx8lEY0e0aiTmvA/zv6ap6radNgDPIfBTIkoDTpNciYv3 RIkh4/cIpLLBZVIbXE5q30r6Czvr/xUf4wMgfT2gP0AIe0Fkiq2KMyc9ce3gfE/R8RkgbR0CDep P6pemPRD3eB2l6SEvt/wb17asXIY/91PJTWJwl3i2WneU/3FBB3eBOvbpjjcCoi/8Bwz0NT/CZ6 xl13/t8a0VMrBdh9GbYMpIvc+4AaY68ItcxUCTK594+JwL6VrE6CLKguoDNTu5osSaZ5bntDyH+ msjPJDRpJRjJ8NohFq17i3l26aHIAym1kE8CaOBBWD8qgqb+ X-Developer-Key: i=luizluca@gmail.com; a=openpgp; fpr=1107284785CD5B3A12FA2FF8BB11DBBAD1073B56 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790396652090520704 X-GMAIL-MSGID: 1790396652090520704 Embed dsa_switch within realtek_priv to eliminate the need for a second memory allocation. Suggested-by: Alvin Šipraga Signed-off-by: Luiz Angelo Daros de Luca Reviewed-by: Vladimir Oltean Reviewed-by: Linus Walleij --- drivers/net/dsa/realtek/realtek.h | 2 +- drivers/net/dsa/realtek/rtl8365mb.c | 15 +++++++++------ drivers/net/dsa/realtek/rtl8366rb.c | 3 ++- drivers/net/dsa/realtek/rtl83xx.c | 15 +++++++-------- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h index 864bb9a88f14..b80bfde1ad04 100644 --- a/drivers/net/dsa/realtek/realtek.h +++ b/drivers/net/dsa/realtek/realtek.h @@ -61,7 +61,7 @@ struct realtek_priv { const struct realtek_variant *variant; 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 778a962727ab..be56373e9473 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -870,6 +870,7 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port, { const struct rtl8365mb_extint *extint = rtl8365mb_get_port_extint(priv, port); + struct dsa_switch *ds = &priv->ds; struct device_node *dn; struct dsa_port *dp; int tx_delay = 0; @@ -880,7 +881,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(ds, port); dn = dp->dn; /* Set the RGMII TX/RX delay @@ -1533,6 +1534,7 @@ static void rtl8365mb_get_stats64(struct dsa_switch *ds, int port, static void rtl8365mb_stats_setup(struct realtek_priv *priv) { struct rtl8365mb *mb = priv->chip_data; + struct dsa_switch *ds = &priv->ds; int i; /* Per-chip global mutex to protect MIB counter access, since doing @@ -1543,7 +1545,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(ds, i)) continue; /* Per-port spinlock to protect the stats64 data */ @@ -1559,12 +1561,13 @@ static void rtl8365mb_stats_setup(struct realtek_priv *priv) static void rtl8365mb_stats_teardown(struct realtek_priv *priv) { struct rtl8365mb *mb = priv->chip_data; + struct dsa_switch *ds = &priv->ds; int i; 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(ds, i)) continue; cancel_delayed_work_sync(&p->mib_work); @@ -1963,7 +1966,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, ds) { cpu->mask |= BIT(cpu_dp->index); if (cpu->trap_port == RTL8365MB_MAX_NUM_PORTS) @@ -1978,7 +1981,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(ds, i)) continue; /* Forward only to the CPU */ @@ -1995,7 +1998,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(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 54eff9cd0c03..e10ae94cf771 100644 --- a/drivers/net/dsa/realtek/rtl8366rb.c +++ b/drivers/net/dsa/realtek/rtl8366rb.c @@ -1651,6 +1651,7 @@ static int rtl8366rb_get_mc_index(struct realtek_priv *priv, int port, int *val) static int rtl8366rb_set_mc_index(struct realtek_priv *priv, int port, int index) { + struct dsa_switch *ds = &priv->ds; struct rtl8366rb *rb; bool pvid_enabled; int ret; @@ -1675,7 +1676,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(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 80f2c38ae55a..801873754df2 100644 --- a/drivers/net/dsa/realtek/rtl83xx.c +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -217,7 +217,7 @@ EXPORT_SYMBOL_NS_GPL(rtl83xx_probe, REALTEK_DSA); */ int rtl83xx_register_switch(struct realtek_priv *priv) { - struct dsa_switch *ds; + struct dsa_switch *ds = &priv->ds; int ret; ret = priv->ops->detect(priv); @@ -226,15 +226,10 @@ int rtl83xx_register_switch(struct realtek_priv *priv) return ret; } - ds = devm_kzalloc(priv->dev, sizeof(*ds), GFP_KERNEL); - if (!ds) - return -ENOMEM; - ds->priv = priv; ds->dev = priv->dev; ds->ops = priv->variant->ds_ops; ds->num_ports = priv->num_ports; - priv->ds = ds; ret = dsa_register_switch(ds); if (ret) { @@ -257,7 +252,9 @@ EXPORT_SYMBOL_NS_GPL(rtl83xx_register_switch, REALTEK_DSA); */ void rtl83xx_unregister_switch(struct realtek_priv *priv) { - dsa_unregister_switch(priv->ds); + struct dsa_switch *ds = &priv->ds; + + dsa_unregister_switch(ds); } EXPORT_SYMBOL_NS_GPL(rtl83xx_unregister_switch, REALTEK_DSA); @@ -274,7 +271,9 @@ EXPORT_SYMBOL_NS_GPL(rtl83xx_unregister_switch, REALTEK_DSA); */ void rtl83xx_shutdown(struct realtek_priv *priv) { - dsa_switch_shutdown(priv->ds); + struct dsa_switch *ds = &priv->ds; + + dsa_switch_shutdown(ds); dev_set_drvdata(priv->dev, NULL); }