From nobody Mon Oct 6 12:02:05 2025 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (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 8D09B289E15; Tue, 22 Jul 2025 21:29:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753219747; cv=none; b=tksTEB0k3MOCqn184zYr/8lO/21lvH6FpFKQChxtsQOL2Vo0CPozmKmd0DdOsBww18Tpdgj+atLxBFm0yF8k8z0ZmJBoSJhJn7IlaM1VZGrYLTkR85d4pswnnT5eCy1ZTN7SUlb8v7Zw6hP0RVNSkKgKZk0Z2akyKphf8RIZmUg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753219747; c=relaxed/simple; bh=Aa80XevvF/WYV9C6DEfa7EIE+resSTimcKxjZz8Rmus=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ATS8us5NeTMEOdJPiDY0zMY1vJ5TALhw0vGQ4dJ3CSGlP473RMoGpBmNeqUp8nFdMkRg1OnGvLzyrAV/2GpE5aQ6tXtmAonM+iiNV529uAmh7iAIEsDseDGvr4LcAlY+w6xI0QRfZrzPEw5F/bZOjbtupNyVahBjC77caZ9F61A= 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=HpIPLlw/; arc=none smtp.client-ip=209.85.216.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HpIPLlw/" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-315f6b20cf9so6309557a91.2; Tue, 22 Jul 2025 14:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753219745; x=1753824545; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=54mI0ObkBjH1lYyMGNitfchN9lI5jTDKC2QtxudLqYg=; b=HpIPLlw/B7HYlhXfK9I0S5PLP3U7UfGKqWJmEJT3DJdjesnVT6vWWzHIrfazPw90Wj 3YuIyZhXWnaQqh//WJ01rOSbhzk3KNE617HBiQ5o+6Z9sWoDAIW3XWdMw7h8xrXyWglj aoRT5iqj+qsf+Geua6OoVZnu6NLTy3tTsNAJKzIeuHrSjXg6eKXAfwJTvu/K710sUP3f vd1obYNKpTyr6CCexQLUpdWiNgTOf1fRHbWDDBUuREvkCpPQOi9VYOS6mGuWmEcrg/Q+ UPwWY7bbbOTW2f5+824975LbLG8zBrTSsOlUFi1u3w2RWLoskb6s/Zb/qO4YjUSdCRF/ TnBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753219745; x=1753824545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=54mI0ObkBjH1lYyMGNitfchN9lI5jTDKC2QtxudLqYg=; b=U/6Q12m0bE6lhX5NzWoLANZICcj1fD5nSaCB/JRZeaV2u6RV71NJ2OKAJGgHNprr8E FGQAeF6ldU0pv13VQ/0yPnhowMmoKYrb8ipzx0qjJ4H63kqVFUFop4VxQey6prI4d6C1 s6ZzbMnTLk5LQBlX83/gSxmqjWwHwLn1wjVoRpcX6eVCPrT2M8QAwmfLwMrY9rA9vZHQ PxWQgF93iz6JTWNOX3664/hOqXOnPbgNGi6D4zMztNctQhkVxiHTX0pa07eHZcb0piRh CCL6gCCgXCleEaiZY6kzYCrkXjbXtNeFCvIWhmPClLPaC+TQc444LxyHdHot4GrFadaH gE8w== X-Forwarded-Encrypted: i=1; AJvYcCVXXkRKtWAMOCtfo+NHUHXNGz5UVIc4Eg5uqhqJ68jGrmd90Jm49bGsATUTxByE12i22froHK6loM5ZWPf7@vger.kernel.org, AJvYcCWTUylzP2ZipcZIMzK4+Ed+uo8cqGIjKV8ckJdwd7EtaeWQDlmF+lIVEna3w55jNYwSm+IvWt8SZVHBvA==@vger.kernel.org, AJvYcCWXsdub2HsKp1Eua/njGYHau+70lgrF9sfU5M9GRhqQe2MIpADRm4J0NqCuBuuej8QsU5DAAporAffj@vger.kernel.org X-Gm-Message-State: AOJu0Yz/xgiaUdaV2CpEddXxOC9SokGKx348bhydJ+OAdKjETC1SfH5k zJ3SzXLObLdiJNeewsB7m9GrO6VY7UdZnOf14toyWN6VORJnAWmCVlaKLAvreNRt X-Gm-Gg: ASbGncsg0fzA8F6wt/UUx4eEzL5LeU7YaxojJclOtbsVZm+87XjGl5+g4KTgp4ryRo2 iH8wVG6oGFiUHZ+1onY6SnmCcO/6p2TxLnroR4Nd/nhq35LkCa1+ty60XH+w+LIVUaqtVGsYmRt EhLBMYpPzuEvH98/CnCZ10z6zLxZxF+MBqXmHJviiMR1AV8OYg58KORGJngpJ1tO1oy6nb056i3 zvoyCM+4FA6iPsQ+zn/UtO5zcrOqxIzvn0G7JhsWzlRxh8hTcuaxU8DLi5Sz7we7idjv+lLqLmp qMOOAi46Hs8Zk1lPCWV1bHVUfCxdpqDdv58iu77YtcqedGqVfGnf5k2bo8thxD/0AjNkTBr+GSl i6UQ= X-Google-Smtp-Source: AGHT+IGHfUDXifkEChV+h/NeMz/lXM6uxHONaFh2aNcWZWw/clZ+adPxu5+JwCqCFigU0K5aE5eCWA== X-Received: by 2002:a17:90a:fc4e:b0:31e:3f8b:216 with SMTP id 98e67ed59e1d1-31e50735c56mr1186411a91.11.1753219744755; Tue, 22 Jul 2025 14:29:04 -0700 (PDT) Received: from archlinux.lan ([2601:644:8200:dab8::1f6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-31e519ce384sm94942a91.2.2025.07.22.14.29.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Jul 2025 14:29:04 -0700 (PDT) From: Rosen Penev To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thomas Bogendoerfer , Matthias Brugger , AngeloGioacchino Del Regno , Stanislaw Gruszka , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list), linux-mips@vger.kernel.org (open list:MIPS), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC support) Subject: [PATCHv5 wireless-next 4/7] wifi: rt2800: move 2x00soc to 2800soc Date: Tue, 22 Jul 2025 14:28:53 -0700 Message-ID: <20250722212856.11343-5-rosenp@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250722212856.11343-1-rosenp@gmail.com> References: <20250722212856.11343-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This driver was written with multiple SOC platforms in mind. However since Ralink was aquired by Mediatek, it only effectively got used by older platforms. As such, we can slim down the driver slightly by moving all of rt2x00soc to rt2800soc in order to benefit from inlining. Signed-off-by: Rosen Penev Acked-by: Stanislaw Gruszka Reviewed-by: Sergio Paracuellos --- drivers/net/wireless/ralink/rt2x00/Kconfig | 5 - drivers/net/wireless/ralink/rt2x00/Makefile | 1 - .../net/wireless/ralink/rt2x00/rt2800soc.c | 119 +++++++++++++- .../net/wireless/ralink/rt2x00/rt2x00soc.c | 151 ------------------ .../net/wireless/ralink/rt2x00/rt2x00soc.h | 29 ---- 5 files changed, 118 insertions(+), 187 deletions(-) delete mode 100644 drivers/net/wireless/ralink/rt2x00/rt2x00soc.c delete mode 100644 drivers/net/wireless/ralink/rt2x00/rt2x00soc.h diff --git a/drivers/net/wireless/ralink/rt2x00/Kconfig b/drivers/net/wirel= ess/ralink/rt2x00/Kconfig index a0dc9a751234..4d98b7723c56 100644 --- a/drivers/net/wireless/ralink/rt2x00/Kconfig +++ b/drivers/net/wireless/ralink/rt2x00/Kconfig @@ -203,7 +203,6 @@ endif config RT2800SOC tristate "Ralink WiSoC support" depends on OF && (SOC_RT288X || SOC_RT305X || SOC_MT7620 || COMPILE_TEST) - select RT2X00_LIB_SOC select RT2X00_LIB_MMIO select RT2X00_LIB_CRYPTO select RT2X00_LIB_FIRMWARE @@ -231,10 +230,6 @@ config RT2X00_LIB_PCI tristate select RT2X00_LIB =20 -config RT2X00_LIB_SOC - tristate - select RT2X00_LIB - config RT2X00_LIB_USB tristate select RT2X00_LIB diff --git a/drivers/net/wireless/ralink/rt2x00/Makefile b/drivers/net/wire= less/ralink/rt2x00/Makefile index de030ebcdf6e..48d84d243606 100644 --- a/drivers/net/wireless/ralink/rt2x00/Makefile +++ b/drivers/net/wireless/ralink/rt2x00/Makefile @@ -12,7 +12,6 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_LEDS) +=3D rt2x00leds.o obj-$(CONFIG_RT2X00_LIB) +=3D rt2x00lib.o obj-$(CONFIG_RT2X00_LIB_MMIO) +=3D rt2x00mmio.o obj-$(CONFIG_RT2X00_LIB_PCI) +=3D rt2x00pci.o -obj-$(CONFIG_RT2X00_LIB_SOC) +=3D rt2x00soc.o obj-$(CONFIG_RT2X00_LIB_USB) +=3D rt2x00usb.o obj-$(CONFIG_RT2800_LIB) +=3D rt2800lib.o obj-$(CONFIG_RT2800_LIB_MMIO) +=3D rt2800mmio.o diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c b/drivers/net/w= ireless/ralink/rt2x00/rt2800soc.c index 8015089c4a39..4d06f49ec6d2 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c @@ -22,7 +22,6 @@ =20 #include "rt2x00.h" #include "rt2x00mmio.h" -#include "rt2x00soc.h" #include "rt2800.h" #include "rt2800lib.h" #include "rt2800mmio.h" @@ -131,6 +130,124 @@ static int rt2800soc_write_firmware(struct rt2x00_dev= *rt2x00dev, return 0; } =20 +static void rt2x00soc_free_reg(struct rt2x00_dev *rt2x00dev) +{ + kfree(rt2x00dev->rf); + rt2x00dev->rf =3D NULL; + + kfree(rt2x00dev->eeprom); + rt2x00dev->eeprom =3D NULL; + + iounmap(rt2x00dev->csr.base); +} + +static int rt2x00soc_alloc_reg(struct rt2x00_dev *rt2x00dev) +{ + struct platform_device *pdev =3D to_platform_device(rt2x00dev->dev); + struct resource *res; + + res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENODEV; + + rt2x00dev->csr.base =3D ioremap(res->start, resource_size(res)); + if (!rt2x00dev->csr.base) + return -ENOMEM; + + rt2x00dev->eeprom =3D kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL); + if (!rt2x00dev->eeprom) + goto exit; + + rt2x00dev->rf =3D kzalloc(rt2x00dev->ops->rf_size, GFP_KERNEL); + if (!rt2x00dev->rf) + goto exit; + + return 0; + +exit: + rt2x00_probe_err("Failed to allocate registers\n"); + rt2x00soc_free_reg(rt2x00dev); + + return -ENOMEM; +} + +static int rt2x00soc_probe(struct platform_device *pdev, const struct rt2x= 00_ops *ops) +{ + struct ieee80211_hw *hw; + struct rt2x00_dev *rt2x00dev; + int retval; + + hw =3D ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw); + if (!hw) { + rt2x00_probe_err("Failed to allocate hardware\n"); + return -ENOMEM; + } + + platform_set_drvdata(pdev, hw); + + rt2x00dev =3D hw->priv; + rt2x00dev->dev =3D &pdev->dev; + rt2x00dev->ops =3D ops; + rt2x00dev->hw =3D hw; + rt2x00dev->irq =3D platform_get_irq(pdev, 0); + rt2x00dev->name =3D pdev->dev.driver->name; + + rt2x00dev->clk =3D clk_get(&pdev->dev, NULL); + if (IS_ERR(rt2x00dev->clk)) + rt2x00dev->clk =3D NULL; + + rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC); + + retval =3D rt2x00soc_alloc_reg(rt2x00dev); + if (retval) + goto exit_free_device; + + retval =3D rt2x00lib_probe_dev(rt2x00dev); + if (retval) + goto exit_free_reg; + + return 0; + +exit_free_reg: + rt2x00soc_free_reg(rt2x00dev); + +exit_free_device: + ieee80211_free_hw(hw); + + return retval; +} + +static void rt2x00soc_remove(struct platform_device *pdev) +{ + struct ieee80211_hw *hw =3D platform_get_drvdata(pdev); + struct rt2x00_dev *rt2x00dev =3D hw->priv; + + /* + * Free all allocated data. + */ + rt2x00lib_remove_dev(rt2x00dev); + rt2x00soc_free_reg(rt2x00dev); + ieee80211_free_hw(hw); +} + +#ifdef CONFIG_PM +static int rt2x00soc_suspend(struct platform_device *pdev, pm_message_t st= ate) +{ + struct ieee80211_hw *hw =3D platform_get_drvdata(pdev); + struct rt2x00_dev *rt2x00dev =3D hw->priv; + + return rt2x00lib_suspend(rt2x00dev); +} + +static int rt2x00soc_resume(struct platform_device *pdev) +{ + struct ieee80211_hw *hw =3D platform_get_drvdata(pdev); + struct rt2x00_dev *rt2x00dev =3D hw->priv; + + return rt2x00lib_resume(rt2x00dev); +} +#endif /* CONFIG_PM */ + static const struct ieee80211_ops rt2800soc_mac80211_ops =3D { .add_chanctx =3D ieee80211_emulate_add_chanctx, .remove_chanctx =3D ieee80211_emulate_remove_chanctx, diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c b/drivers/net/w= ireless/ralink/rt2x00/rt2x00soc.c deleted file mode 100644 index f7f3a2340c39..000000000000 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c +++ /dev/null @@ -1,151 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - Copyright (C) 2004 - 2009 Ivo van Doorn - Copyright (C) 2004 - 2009 Felix Fietkau - - - */ - -/* - Module: rt2x00soc - Abstract: rt2x00 generic soc device routines. - */ - -#include -#include -#include -#include -#include - -#include "rt2x00.h" -#include "rt2x00soc.h" - -static void rt2x00soc_free_reg(struct rt2x00_dev *rt2x00dev) -{ - kfree(rt2x00dev->rf); - rt2x00dev->rf =3D NULL; - - kfree(rt2x00dev->eeprom); - rt2x00dev->eeprom =3D NULL; - - iounmap(rt2x00dev->csr.base); -} - -static int rt2x00soc_alloc_reg(struct rt2x00_dev *rt2x00dev) -{ - struct platform_device *pdev =3D to_platform_device(rt2x00dev->dev); - struct resource *res; - - res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -ENODEV; - - rt2x00dev->csr.base =3D ioremap(res->start, resource_size(res)); - if (!rt2x00dev->csr.base) - return -ENOMEM; - - rt2x00dev->eeprom =3D kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL); - if (!rt2x00dev->eeprom) - goto exit; - - rt2x00dev->rf =3D kzalloc(rt2x00dev->ops->rf_size, GFP_KERNEL); - if (!rt2x00dev->rf) - goto exit; - - return 0; - -exit: - rt2x00_probe_err("Failed to allocate registers\n"); - rt2x00soc_free_reg(rt2x00dev); - - return -ENOMEM; -} - -int rt2x00soc_probe(struct platform_device *pdev, const struct rt2x00_ops = *ops) -{ - struct ieee80211_hw *hw; - struct rt2x00_dev *rt2x00dev; - int retval; - - hw =3D ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw); - if (!hw) { - rt2x00_probe_err("Failed to allocate hardware\n"); - return -ENOMEM; - } - - platform_set_drvdata(pdev, hw); - - rt2x00dev =3D hw->priv; - rt2x00dev->dev =3D &pdev->dev; - rt2x00dev->ops =3D ops; - rt2x00dev->hw =3D hw; - rt2x00dev->irq =3D platform_get_irq(pdev, 0); - rt2x00dev->name =3D pdev->dev.driver->name; - - rt2x00dev->clk =3D clk_get(&pdev->dev, NULL); - if (IS_ERR(rt2x00dev->clk)) - rt2x00dev->clk =3D NULL; - - rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC); - - retval =3D rt2x00soc_alloc_reg(rt2x00dev); - if (retval) - goto exit_free_device; - - retval =3D rt2x00lib_probe_dev(rt2x00dev); - if (retval) - goto exit_free_reg; - - return 0; - -exit_free_reg: - rt2x00soc_free_reg(rt2x00dev); - -exit_free_device: - ieee80211_free_hw(hw); - - return retval; -} -EXPORT_SYMBOL_GPL(rt2x00soc_probe); - -void rt2x00soc_remove(struct platform_device *pdev) -{ - struct ieee80211_hw *hw =3D platform_get_drvdata(pdev); - struct rt2x00_dev *rt2x00dev =3D hw->priv; - - /* - * Free all allocated data. - */ - rt2x00lib_remove_dev(rt2x00dev); - rt2x00soc_free_reg(rt2x00dev); - ieee80211_free_hw(hw); -} -EXPORT_SYMBOL_GPL(rt2x00soc_remove); - -#ifdef CONFIG_PM -int rt2x00soc_suspend(struct platform_device *pdev, pm_message_t state) -{ - struct ieee80211_hw *hw =3D platform_get_drvdata(pdev); - struct rt2x00_dev *rt2x00dev =3D hw->priv; - - return rt2x00lib_suspend(rt2x00dev); -} -EXPORT_SYMBOL_GPL(rt2x00soc_suspend); - -int rt2x00soc_resume(struct platform_device *pdev) -{ - struct ieee80211_hw *hw =3D platform_get_drvdata(pdev); - struct rt2x00_dev *rt2x00dev =3D hw->priv; - - return rt2x00lib_resume(rt2x00dev); -} -EXPORT_SYMBOL_GPL(rt2x00soc_resume); -#endif /* CONFIG_PM */ - -/* - * rt2x00soc module information. - */ -MODULE_AUTHOR(DRV_PROJECT); -MODULE_VERSION(DRV_VERSION); -MODULE_DESCRIPTION("rt2x00 soc library"); -MODULE_LICENSE("GPL"); diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00soc.h b/drivers/net/w= ireless/ralink/rt2x00/rt2x00soc.h deleted file mode 100644 index d6226b8a10e0..000000000000 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00soc.h +++ /dev/null @@ -1,29 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - Copyright (C) 2004 - 2009 Ivo van Doorn - - - */ - -/* - Module: rt2x00soc - Abstract: Data structures for the rt2x00soc module. - */ - -#ifndef RT2X00SOC_H -#define RT2X00SOC_H - -/* - * SoC driver handlers. - */ -int rt2x00soc_probe(struct platform_device *pdev, const struct rt2x00_ops = *ops); -void rt2x00soc_remove(struct platform_device *pdev); -#ifdef CONFIG_PM -int rt2x00soc_suspend(struct platform_device *pdev, pm_message_t state); -int rt2x00soc_resume(struct platform_device *pdev); -#else -#define rt2x00soc_suspend NULL -#define rt2x00soc_resume NULL -#endif /* CONFIG_PM */ - -#endif /* RT2X00SOC_H */ --=20 2.50.0