liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

ath9k-ahb-replace-id_table-with-of.patch (8423B)


      1 commit b4206774fe8231187e5863ff861160db77d4960b
      2 Author: Rosen Penev <rosenp@gmail.com>
      3 Date:   Sun Apr 20 21:00:44 2025 -0700
      4 
      5     wifi: ath9k: ahb: do ioremap resource in one step
      6     
      7     Simplifies probe slightly and adds extra error codes.
      8     
      9     Switching from devm_ioremap to the platform variant ends up calling
     10     devm_request_mem_region, which reserves the memory region for the
     11     various wmacs. Per board, there is only one wmac and after some fairly
     12     thorough analysis, there are no overlapping memory regions between wmacs
     13     and other devices on the ahb.
     14     
     15     Tested on a TP-Link Archer C7v2.
     16     
     17     Signed-off-by: Rosen Penev <rosenp@gmail.com>
     18     Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
     19     Link: https://patch.msgid.link/20250421040044.44887-1-rosenp@gmail.com
     20     Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
     21 
     22 diff --git a/drivers/net/wireless/ath/ath9k/ahb.c b/drivers/net/wireless/ath/ath9k/ahb.c
     23 index d4805e02b927..49b7ab26c477 100644
     24 --- a/drivers/net/wireless/ath/ath9k/ahb.c
     25 +++ b/drivers/net/wireless/ath/ath9k/ahb.c
     26 @@ -74,7 +74,6 @@ static int ath_ahb_probe(struct platform_device *pdev)
     27  	void __iomem *mem;
     28  	struct ath_softc *sc;
     29  	struct ieee80211_hw *hw;
     30 -	struct resource *res;
     31  	const struct platform_device_id *id = platform_get_device_id(pdev);
     32  	int irq;
     33  	int ret = 0;
     34 @@ -86,16 +85,10 @@ static int ath_ahb_probe(struct platform_device *pdev)
     35  		return -EINVAL;
     36  	}
     37  
     38 -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
     39 -	if (res == NULL) {
     40 -		dev_err(&pdev->dev, "no memory resource found\n");
     41 -		return -ENXIO;
     42 -	}
     43 -
     44 -	mem = devm_ioremap(&pdev->dev, res->start, resource_size(res));
     45 -	if (mem == NULL) {
     46 +	mem = devm_platform_ioremap_resource(pdev, 0);
     47 +	if (IS_ERR(mem)) {
     48  		dev_err(&pdev->dev, "ioremap failed\n");
     49 -		return -ENOMEM;
     50 +		return PTR_ERR(mem);
     51  	}
     52  
     53  	irq = platform_get_irq(pdev, 0);
     54 
     55 commit 5cbfef9039f61691c87f522f8761d628033bc392
     56 Author: Rosen Penev <rosenp@gmail.com>
     57 Date:   Sun Jun 8 20:08:47 2025 -0700
     58 
     59     wifi: ath9k: ahb: reorder declarations
     60     
     61     Easier to look at. Follows netdev style.
     62     
     63     Also remove ret assignment. Because of all of these devm conversions,
     64     ret = 0 is a path that never gets hit. The first time it does it when
     65     request_irq fails, but that ends up reassigning it.
     66     
     67     Signed-off-by: Rosen Penev <rosenp@gmail.com>
     68     Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
     69     Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
     70     Link: https://patch.msgid.link/20250609030851.17739-2-rosenp@gmail.com
     71     Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
     72 
     73 diff --git a/drivers/net/wireless/ath/ath9k/ahb.c b/drivers/net/wireless/ath/ath9k/ahb.c
     74 index 49b7ab26c477..d2a97e74f451 100644
     75 --- a/drivers/net/wireless/ath/ath9k/ahb.c
     76 +++ b/drivers/net/wireless/ath/ath9k/ahb.c
     77 @@ -71,14 +71,14 @@ static const struct ath_bus_ops ath_ahb_bus_ops  = {
     78  
     79  static int ath_ahb_probe(struct platform_device *pdev)
     80  {
     81 -	void __iomem *mem;
     82 -	struct ath_softc *sc;
     83 -	struct ieee80211_hw *hw;
     84  	const struct platform_device_id *id = platform_get_device_id(pdev);
     85 -	int irq;
     86 -	int ret = 0;
     87 +	struct ieee80211_hw *hw;
     88 +	struct ath_softc *sc;
     89  	struct ath_hw *ah;
     90 +	void __iomem *mem;
     91  	char hw_name[64];
     92 +	int irq;
     93 +	int ret;
     94  
     95  	if (!dev_get_platdata(&pdev->dev)) {
     96  		dev_err(&pdev->dev, "no platform data specified\n");
     97 
     98 commit c8123302c01936d297e22adbd75cad38c5049f92
     99 Author: Rosen Penev <rosenp@gmail.com>
    100 Date:   Sun Jun 8 20:08:48 2025 -0700
    101 
    102     wifi: ath9k: ahb: reorder includes
    103     
    104     Alphabetic includes are easier to look at and to make further changes to
    105     them.
    106     
    107     Signed-off-by: Rosen Penev <rosenp@gmail.com>
    108     Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    109     Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
    110     Link: https://patch.msgid.link/20250609030851.17739-3-rosenp@gmail.com
    111     Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
    112 
    113 diff --git a/drivers/net/wireless/ath/ath9k/ahb.c b/drivers/net/wireless/ath/ath9k/ahb.c
    114 index d2a97e74f451..1ffec827ed87 100644
    115 --- a/drivers/net/wireless/ath/ath9k/ahb.c
    116 +++ b/drivers/net/wireless/ath/ath9k/ahb.c
    117 @@ -16,10 +16,11 @@
    118   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    119   */
    120  
    121 +#include <linux/mod_devicetable.h>
    122 +#include <linux/module.h>
    123  #include <linux/nl80211.h>
    124  #include <linux/platform_device.h>
    125 -#include <linux/module.h>
    126 -#include <linux/mod_devicetable.h>
    127 +
    128  #include "ath9k.h"
    129  
    130  static const struct platform_device_id ath9k_platform_id_table[] = {
    131 
    132 commit 2fa490c0d7591918bed267059700f1c9e505e881
    133 Author: Rosen Penev <rosenp@gmail.com>
    134 Date:   Sun Jun 8 20:08:50 2025 -0700
    135 
    136     wifi: ath9k: ahb: replace id_table with of
    137     
    138     Since 2b0996c7646 , all of this platform code became no-op with no OF
    139     replacement. Not only that, there are no users of AHB here. Add an OF
    140     match table that mostly mirrors the original platform device id table.
    141     Use a qca prefix as is done for the only other property: qca,no-eeprom.
    142     Also used qca prefix for ar9530 as the latter seems to be a mistake.
    143     
    144     This will be used to add ath9k support for the various ath79 devices
    145     here.
    146     
    147     Signed-off-by: Rosen Penev <rosenp@gmail.com>
    148     Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    149     Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
    150     Link: https://patch.msgid.link/20250609030851.17739-5-rosenp@gmail.com
    151     Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
    152 
    153     [ LIMINIX NOTE: this patch was hand-edited for whitespace and to
    154       match .remove_new instead of .remove ]
    155 
    156 
    157 diff --git a/drivers/net/wireless/ath/ath9k/ahb.c b/drivers/net/wireless/ath/ath9k/ahb.c
    158 index 1ffec827ed87..802e6596a6a8 100644
    159 --- a/drivers/net/wireless/ath/ath9k/ahb.c
    160 +++ b/drivers/net/wireless/ath/ath9k/ahb.c
    161 @@ -19,35 +19,18 @@
    162  #include <linux/mod_devicetable.h>
    163  #include <linux/module.h>
    164  #include <linux/nl80211.h>
    165 +#include <linux/of.h>
    166  #include <linux/platform_device.h>
    167  
    168  #include "ath9k.h"
    169  
    170 -static const struct platform_device_id ath9k_platform_id_table[] = {
    171 -	{
    172 -		.name = "ath9k",
    173 -		.driver_data = AR5416_AR9100_DEVID,
    174 -	},
    175 -	{
    176 -		.name = "ar933x_wmac",
    177 -		.driver_data = AR9300_DEVID_AR9330,
    178 -	},
    179 -	{
    180 -		.name = "ar934x_wmac",
    181 -		.driver_data = AR9300_DEVID_AR9340,
    182 -	},
    183 -	{
    184 -		.name = "qca955x_wmac",
    185 -		.driver_data = AR9300_DEVID_QCA955X,
    186 -	},
    187 -	{
    188 -		.name = "qca953x_wmac",
    189 -		.driver_data = AR9300_DEVID_AR953X,
    190 -	},
    191 -	{
    192 -		.name = "qca956x_wmac",
    193 -		.driver_data = AR9300_DEVID_QCA956X,
    194 -	},
    195 +static const struct of_device_id ath9k_of_match_table[] = {
    196 +	{ .compatible = "qca,ar9130-wifi", .data = (void *)AR5416_AR9100_DEVID },
    197 +	{ .compatible = "qca,ar9330-wifi", .data = (void *)AR9300_DEVID_AR9330 },
    198 +	{ .compatible = "qca,ar9340-wifi", .data = (void *)AR9300_DEVID_AR9340 },
    199 +	{ .compatible = "qca,qca9530-wifi", .data = (void *)AR9300_DEVID_AR953X },
    200 +	{ .compatible = "qca,qca9550-wifi", .data = (void *)AR9300_DEVID_QCA955X },
    201 +	{ .compatible = "qca,qca9560-wifi", .data = (void *)AR9300_DEVID_QCA956X },
    202  	{},
    203  };
    204  
    205 @@ -72,20 +55,15 @@ static const struct ath_bus_ops ath_ahb_bus_ops  = {
    206  
    207  static int ath_ahb_probe(struct platform_device *pdev)
    208  {
    209 -	const struct platform_device_id *id = platform_get_device_id(pdev);
    210  	struct ieee80211_hw *hw;
    211  	struct ath_softc *sc;
    212  	struct ath_hw *ah;
    213  	void __iomem *mem;
    214  	char hw_name[64];
    215 +	u16 dev_id;
    216  	int irq;
    217  	int ret;
    218  
    219 -	if (!dev_get_platdata(&pdev->dev)) {
    220 -		dev_err(&pdev->dev, "no platform data specified\n");
    221 -		return -EINVAL;
    222 -	}
    223 -
    224  	mem = devm_platform_ioremap_resource(pdev, 0);
    225  	if (IS_ERR(mem)) {
    226  		dev_err(&pdev->dev, "ioremap failed\n");
    227 @@ -118,7 +96,8 @@ static int ath_ahb_probe(struct platform_device *pdev)
    228  		goto err_free_hw;
    229  	}
    230  
    231 -	ret = ath9k_init_device(id->driver_data, sc, &ath_ahb_bus_ops);
    232 +	dev_id = (u16)(kernel_ulong_t)of_device_get_match_data(&pdev->dev);
    233 +	ret = ath9k_init_device(dev_id, sc, &ath_ahb_bus_ops);
    234  	if (ret) {
    235  		dev_err(&pdev->dev, "failed to initialize device\n");
    236  		goto err_irq;
    237 @@ -156,11 +135,11 @@ static struct platform_driver ath_ahb_driver = {
    238  	.remove_new = ath_ahb_remove,
    239  	.driver 	= {
    240  		.name	= "ath9k",
    241 +		.of_match_table = ath9k_of_match_table,
    242  	},
    243 -	.id_table    = ath9k_platform_id_table,
    244  };
    245  
    246 -MODULE_DEVICE_TABLE(platform, ath9k_platform_id_table);
    247 +MODULE_DEVICE_TABLE(of, ath9k_of_match_table);
    248  
    249  int ath_ahb_init(void)
    250  {