wifi: rt2800: move 2x00soc to 2800soc
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 <rosenp@gmail.com> Acked-by: Stanislaw Gruszka <stf_xl@wp.pl> Reviewed-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Link: https://patch.msgid.link/20250722212856.11343-5-rosenp@gmail.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
committed by
Johannes Berg
parent
708e88b9d4
commit
7f6109086c
@@ -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
|
||||
|
||||
config RT2X00_LIB_SOC
|
||||
tristate
|
||||
select RT2X00_LIB
|
||||
|
||||
config RT2X00_LIB_USB
|
||||
tristate
|
||||
select RT2X00_LIB
|
||||
|
||||
@@ -12,7 +12,6 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_LEDS) += rt2x00leds.o
|
||||
obj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o
|
||||
obj-$(CONFIG_RT2X00_LIB_MMIO) += rt2x00mmio.o
|
||||
obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.o
|
||||
obj-$(CONFIG_RT2X00_LIB_SOC) += rt2x00soc.o
|
||||
obj-$(CONFIG_RT2X00_LIB_USB) += rt2x00usb.o
|
||||
obj-$(CONFIG_RT2800_LIB) += rt2800lib.o
|
||||
obj-$(CONFIG_RT2800_LIB_MMIO) += rt2800mmio.o
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
static void rt2x00soc_free_reg(struct rt2x00_dev *rt2x00dev)
|
||||
{
|
||||
kfree(rt2x00dev->rf);
|
||||
rt2x00dev->rf = NULL;
|
||||
|
||||
kfree(rt2x00dev->eeprom);
|
||||
rt2x00dev->eeprom = NULL;
|
||||
|
||||
iounmap(rt2x00dev->csr.base);
|
||||
}
|
||||
|
||||
static int rt2x00soc_alloc_reg(struct rt2x00_dev *rt2x00dev)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(rt2x00dev->dev);
|
||||
struct resource *res;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res)
|
||||
return -ENODEV;
|
||||
|
||||
rt2x00dev->csr.base = ioremap(res->start, resource_size(res));
|
||||
if (!rt2x00dev->csr.base)
|
||||
return -ENOMEM;
|
||||
|
||||
rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL);
|
||||
if (!rt2x00dev->eeprom)
|
||||
goto exit;
|
||||
|
||||
rt2x00dev->rf = 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 rt2x00_ops *ops)
|
||||
{
|
||||
struct ieee80211_hw *hw;
|
||||
struct rt2x00_dev *rt2x00dev;
|
||||
int retval;
|
||||
|
||||
hw = 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 = hw->priv;
|
||||
rt2x00dev->dev = &pdev->dev;
|
||||
rt2x00dev->ops = ops;
|
||||
rt2x00dev->hw = hw;
|
||||
rt2x00dev->irq = platform_get_irq(pdev, 0);
|
||||
rt2x00dev->name = pdev->dev.driver->name;
|
||||
|
||||
rt2x00dev->clk = clk_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(rt2x00dev->clk))
|
||||
rt2x00dev->clk = NULL;
|
||||
|
||||
rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);
|
||||
|
||||
retval = rt2x00soc_alloc_reg(rt2x00dev);
|
||||
if (retval)
|
||||
goto exit_free_device;
|
||||
|
||||
retval = 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 = platform_get_drvdata(pdev);
|
||||
struct rt2x00_dev *rt2x00dev = 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 state)
|
||||
{
|
||||
struct ieee80211_hw *hw = platform_get_drvdata(pdev);
|
||||
struct rt2x00_dev *rt2x00dev = hw->priv;
|
||||
|
||||
return rt2x00lib_suspend(rt2x00dev);
|
||||
}
|
||||
|
||||
static int rt2x00soc_resume(struct platform_device *pdev)
|
||||
{
|
||||
struct ieee80211_hw *hw = platform_get_drvdata(pdev);
|
||||
struct rt2x00_dev *rt2x00dev = hw->priv;
|
||||
|
||||
return rt2x00lib_resume(rt2x00dev);
|
||||
}
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
static const struct ieee80211_ops rt2800soc_mac80211_ops = {
|
||||
.add_chanctx = ieee80211_emulate_add_chanctx,
|
||||
.remove_chanctx = ieee80211_emulate_remove_chanctx,
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
|
||||
Copyright (C) 2004 - 2009 Felix Fietkau <nbd@openwrt.org>
|
||||
<http://rt2x00.serialmonkey.com>
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
Module: rt2x00soc
|
||||
Abstract: rt2x00 generic soc device routines.
|
||||
*/
|
||||
|
||||
#include <linux/bug.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "rt2x00.h"
|
||||
#include "rt2x00soc.h"
|
||||
|
||||
static void rt2x00soc_free_reg(struct rt2x00_dev *rt2x00dev)
|
||||
{
|
||||
kfree(rt2x00dev->rf);
|
||||
rt2x00dev->rf = NULL;
|
||||
|
||||
kfree(rt2x00dev->eeprom);
|
||||
rt2x00dev->eeprom = NULL;
|
||||
|
||||
iounmap(rt2x00dev->csr.base);
|
||||
}
|
||||
|
||||
static int rt2x00soc_alloc_reg(struct rt2x00_dev *rt2x00dev)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(rt2x00dev->dev);
|
||||
struct resource *res;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res)
|
||||
return -ENODEV;
|
||||
|
||||
rt2x00dev->csr.base = ioremap(res->start, resource_size(res));
|
||||
if (!rt2x00dev->csr.base)
|
||||
return -ENOMEM;
|
||||
|
||||
rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL);
|
||||
if (!rt2x00dev->eeprom)
|
||||
goto exit;
|
||||
|
||||
rt2x00dev->rf = 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 = 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 = hw->priv;
|
||||
rt2x00dev->dev = &pdev->dev;
|
||||
rt2x00dev->ops = ops;
|
||||
rt2x00dev->hw = hw;
|
||||
rt2x00dev->irq = platform_get_irq(pdev, 0);
|
||||
rt2x00dev->name = pdev->dev.driver->name;
|
||||
|
||||
rt2x00dev->clk = clk_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(rt2x00dev->clk))
|
||||
rt2x00dev->clk = NULL;
|
||||
|
||||
rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);
|
||||
|
||||
retval = rt2x00soc_alloc_reg(rt2x00dev);
|
||||
if (retval)
|
||||
goto exit_free_device;
|
||||
|
||||
retval = 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 = platform_get_drvdata(pdev);
|
||||
struct rt2x00_dev *rt2x00dev = 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 = platform_get_drvdata(pdev);
|
||||
struct rt2x00_dev *rt2x00dev = hw->priv;
|
||||
|
||||
return rt2x00lib_suspend(rt2x00dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rt2x00soc_suspend);
|
||||
|
||||
int rt2x00soc_resume(struct platform_device *pdev)
|
||||
{
|
||||
struct ieee80211_hw *hw = platform_get_drvdata(pdev);
|
||||
struct rt2x00_dev *rt2x00dev = 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");
|
||||
@@ -1,29 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
|
||||
<http://rt2x00.serialmonkey.com>
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
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 */
|
||||
Reference in New Issue
Block a user