Since 2b0996c7646 , all of this platform code became no-op with no OF
replacement. Not only that, there are no users of AHB here. Add an OF
match table that mostly mirrors the original platform device id table.
Use a qca prefix as is done for the only other property: qca,no-eeprom.
Also used qca prefix for ar9530 as the latter seems to be a mistake.
This will be used to add ath9k support for the various ath79 devices
here.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/net/wireless/ath/ath9k/ahb.c | 47 ++++++++--------------------
1 file changed, 13 insertions(+), 34 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/ahb.c b/drivers/net/wireless/ath/ath9k/ahb.c
index 1ffec827ed87..c5e36f9e7390 100644
--- a/drivers/net/wireless/ath/ath9k/ahb.c
+++ b/drivers/net/wireless/ath/ath9k/ahb.c
@@ -19,35 +19,18 @@
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/nl80211.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include "ath9k.h"
-static const struct platform_device_id ath9k_platform_id_table[] = {
- {
- .name = "ath9k",
- .driver_data = AR5416_AR9100_DEVID,
- },
- {
- .name = "ar933x_wmac",
- .driver_data = AR9300_DEVID_AR9330,
- },
- {
- .name = "ar934x_wmac",
- .driver_data = AR9300_DEVID_AR9340,
- },
- {
- .name = "qca955x_wmac",
- .driver_data = AR9300_DEVID_QCA955X,
- },
- {
- .name = "qca953x_wmac",
- .driver_data = AR9300_DEVID_AR953X,
- },
- {
- .name = "qca956x_wmac",
- .driver_data = AR9300_DEVID_QCA956X,
- },
+static const struct of_device_id ath9k_of_match_table[] = {
+ { .compatible = "qcom,ar9130-wifi", .data = (void *)AR5416_AR9100_DEVID },
+ { .compatible = "qcom,ar9330-wifi", .data = (void *)AR9300_DEVID_AR9330 },
+ { .compatible = "qcom,ar9340-wifi", .data = (void *)AR9300_DEVID_AR9340 },
+ { .compatible = "qcom,qca9530-wifi", .data = (void *)AR9300_DEVID_AR953X },
+ { .compatible = "qcom,qca9550-wifi", .data = (void *)AR9300_DEVID_QCA955X },
+ { .compatible = "qcom,qca9560-wifi", .data = (void *)AR9300_DEVID_QCA956X },
{},
};
@@ -72,20 +55,15 @@ static const struct ath_bus_ops ath_ahb_bus_ops = {
static int ath_ahb_probe(struct platform_device *pdev)
{
- const struct platform_device_id *id = platform_get_device_id(pdev);
struct ieee80211_hw *hw;
struct ath_softc *sc;
struct ath_hw *ah;
void __iomem *mem;
char hw_name[64];
+ u16 dev_id;
int irq;
int ret;
- if (!dev_get_platdata(&pdev->dev)) {
- dev_err(&pdev->dev, "no platform data specified\n");
- return -EINVAL;
- }
-
mem = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(mem)) {
dev_err(&pdev->dev, "ioremap failed\n");
@@ -118,7 +96,8 @@ static int ath_ahb_probe(struct platform_device *pdev)
goto err_free_hw;
}
- ret = ath9k_init_device(id->driver_data, sc, &ath_ahb_bus_ops);
+ dev_id = (u16)(kernel_ulong_t)of_device_get_match_data(&pdev->dev);
+ ret = ath9k_init_device(dev_id, sc, &ath_ahb_bus_ops);
if (ret) {
dev_err(&pdev->dev, "failed to initialize device\n");
goto err_irq;
@@ -156,11 +135,11 @@ static struct platform_driver ath_ahb_driver = {
.remove = ath_ahb_remove,
.driver = {
.name = "ath9k",
+ .of_match_table = ath9k_of_match_table,
},
- .id_table = ath9k_platform_id_table,
};
-MODULE_DEVICE_TABLE(platform, ath9k_platform_id_table);
+MODULE_DEVICE_TABLE(of, ath9k_of_match_table);
int ath_ahb_init(void)
{
--
2.49.0
On 25/05/2025 23:42, Rosen Penev wrote: > Since 2b0996c7646 , all of this platform code became no-op with no OF > replacement. Not only that, there are no users of AHB here. Add an OF > match table that mostly mirrors the original platform device id table. > Use a qca prefix as is done for the only other property: qca,no-eeprom. > Also used qca prefix for ar9530 as the latter seems to be a mistake. > > This will be used to add ath9k support for the various ath79 devices > here. > > Signed-off-by: Rosen Penev <rosenp@gmail.com> > --- Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Best regards, Krzysztof
On 25/05/2025 23:42, Rosen Penev wrote:
> @@ -72,20 +55,15 @@ static const struct ath_bus_ops ath_ahb_bus_ops = {
>
> static int ath_ahb_probe(struct platform_device *pdev)
> {
> - const struct platform_device_id *id = platform_get_device_id(pdev);
> struct ieee80211_hw *hw;
> struct ath_softc *sc;
> struct ath_hw *ah;
> void __iomem *mem;
> char hw_name[64];
> + u16 dev_id;
I don't think these are u16 in the headers, but unsigned int.
> int irq;
> int ret;
>
> - if (!dev_get_platdata(&pdev->dev)) {
> - dev_err(&pdev->dev, "no platform data specified\n");
> - return -EINVAL;
> - }
> -
> mem = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(mem)) {
> dev_err(&pdev->dev, "ioremap failed\n");
> @@ -118,7 +96,8 @@ static int ath_ahb_probe(struct platform_device *pdev)
> goto err_free_hw;
> }
>
> - ret = ath9k_init_device(id->driver_data, sc, &ath_ahb_bus_ops);
> + dev_id = (u16)(kernel_ulong_t)of_device_get_match_data(&pdev->dev);
u16 cast looks not needed.
> + ret = ath9k_init_device(dev_id, sc, &ath_ahb_bus_ops);
> if (ret) {
> dev_err(&pdev->dev, "failed to initialize device\n");
> goto err_irq;
Best regards,
Krzysztof
On Sun, May 25, 2025 at 9:30 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On 25/05/2025 23:42, Rosen Penev wrote:
> > @@ -72,20 +55,15 @@ static const struct ath_bus_ops ath_ahb_bus_ops = {
> >
> > static int ath_ahb_probe(struct platform_device *pdev)
> > {
> > - const struct platform_device_id *id = platform_get_device_id(pdev);
> > struct ieee80211_hw *hw;
> > struct ath_softc *sc;
> > struct ath_hw *ah;
> > void __iomem *mem;
> > char hw_name[64];
> > + u16 dev_id;
>
> I don't think these are u16 in the headers, but unsigned int.
Sure. I can change to int or kernel_ulong_t. It doesn't matter much.
The function that uses this has an int parameter, so might make sense
to use that.
>
> > int irq;
> > int ret;
> >
> > - if (!dev_get_platdata(&pdev->dev)) {
> > - dev_err(&pdev->dev, "no platform data specified\n");
> > - return -EINVAL;
> > - }
> > -
> > mem = devm_platform_ioremap_resource(pdev, 0);
> > if (IS_ERR(mem)) {
> > dev_err(&pdev->dev, "ioremap failed\n");
> > @@ -118,7 +96,8 @@ static int ath_ahb_probe(struct platform_device *pdev)
> > goto err_free_hw;
> > }
> >
> > - ret = ath9k_init_device(id->driver_data, sc, &ath_ahb_bus_ops);
> > + dev_id = (u16)(kernel_ulong_t)of_device_get_match_data(&pdev->dev);
>
> u16 cast looks not needed.
Correct. It's placed for extra clarity, although probably not needed.
>
>
> > + ret = ath9k_init_device(dev_id, sc, &ath_ahb_bus_ops);
> > if (ret) {
> > dev_err(&pdev->dev, "failed to initialize device\n");
> > goto err_irq;
> Best regards,
> Krzysztof
On 26/05/2025 06:59, Rosen Penev wrote:
> On Sun, May 25, 2025 at 9:30 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>>
>> On 25/05/2025 23:42, Rosen Penev wrote:
>>> @@ -72,20 +55,15 @@ static const struct ath_bus_ops ath_ahb_bus_ops = {
>>>
>>> static int ath_ahb_probe(struct platform_device *pdev)
>>> {
>>> - const struct platform_device_id *id = platform_get_device_id(pdev);
>>> struct ieee80211_hw *hw;
>>> struct ath_softc *sc;
>>> struct ath_hw *ah;
>>> void __iomem *mem;
>>> char hw_name[64];
>>> + u16 dev_id;
>>
>> I don't think these are u16 in the headers, but unsigned int.
> Sure. I can change to int or kernel_ulong_t. It doesn't matter much.
> The function that uses this has an int parameter, so might make sense
> to use that.
Ah, ok, that's fine then. Ignore both comments.
Best regards,
Krzysztof
© 2016 - 2025 Red Hat, Inc.