wifi: cfg80211: move away from using a fake platform device
PATCH v5 1/1 wifi: cfg80211: move away from using a fake platform device
Downloading regulatory "firmware" needs a device to hang off of, and so a platform device seemed like the simplest way to do this. Now that we have a faux device interface, use that instead as this "regulatory device" is not anything resembling a platform device at all.
---
v5: - rebase against 6.16-rc4 and actually cc: the relevant maintainers
and mailing lists this time, doh!
v4: - api tweaked due to parent pointer added to faux_device create
function.
v3: - no change
v2: - new example patch in a larger series
net/wireless/reg.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
net/wireless/reg.c +14 -14
@@ -53,7 +53,7 @@#include <linux/list.h> #include <linux/ctype.h> #include <linux/nl80211.h> -#include <linux/platform_device.h> +#include <linux/device/faux.h> #include <linux/verification.h> #include <linux/moduleparam.h> #include <linux/firmware.h>
@@ -105,7 +105,7 @@ static struct regulatory_request __rcu *last_request = (void __force __rcu *)&core_request_world;/* To trigger userspace events and load firmware */ -static struct platform_device *reg_pdev; +static struct faux_device *reg_fdev;/* * Central wireless core regulatory domains, we only need two,
@@ -583,7 +583,7 @@ static int call_crda(const char *alpha2)else pr_debug ("Calling CRDA to update world regulatory domain\n" ); - ret =kobject_uevent_env (®_pdev->dev.kobj,KOBJ_CHANGE , env); + ret =kobject_uevent_env (®_fdev->dev.kobj,KOBJ_CHANGE , env);if (ret)return ret;
@@ -779,7 +779,7 @@ static bool regdb_has_valid_signature(const u8 *data, unsigned int size)const struct firmware *sig;bool result; -if (request_firmware (&sig,"regulatory.db.p7s" , ®_pdev->dev)) +if (request_firmware (&sig,"regulatory.db.p7s" , ®_fdev->dev))return false; result = verify_pkcs7_signature(data, size, sig->data, sig->size,
@@ -1061,7 +1061,7 @@ static int query_regdb_file(const char *alpha2)return -ENOMEM ; err =request_firmware_nowait (THIS_MODULE , true,"regulatory.db" , - ®_pdev->dev,GFP_KERNEL , + ®_fdev->dev,GFP_KERNEL , (void *)alpha2, regdb_fw_cb);if (err)kfree (alpha2);
@@ -1077,7 +1077,7 @@ int reg_reload_regdb(void)const struct ieee80211_regdomain *current_regdomain;struct regulatory_request *request; - err =request_firmware (&fw,"regulatory.db" , ®_pdev->dev); + err =request_firmware (&fw,"regulatory.db" , ®_fdev->dev);if (err)return err;
@@ -4300,12 +4300,12 @@ static int __init regulatory_init_db(void)* in that case, don't try to do any further work here as * it's doomed to lead to crashes. */ -if (IS_ERR_OR_NULL (reg_pdev)) +if (!reg_fdev)return -EINVAL ; err =load_builtin_regdb_keys ();if (err) { -platform_device_unregister (reg_pdev); +faux_device_destroy (reg_fdev);return err; }
@@ -4313,7 +4313,7 @@ static int __init regulatory_init_db(void) err =regulatory_hint_core (cfg80211_world_regdom->alpha2);if (err) {if (err == -ENOMEM ) { -platform_device_unregister (reg_pdev); +faux_device_destroy (reg_fdev);return err; }/*
@@ -4342,9 +4342,9 @@ late_initcall(regulatory_init_db);int __init regulatory_init (void ) { - reg_pdev =platform_device_register_simple ("regulatory" ,0 ,NULL ,0 ); -if (IS_ERR (reg_pdev)) -return PTR_ERR (reg_pdev); + reg_fdev =faux_device_create ("regulatory" ,NULL ,NULL ); +if (!reg_fdev) +return -ENODEV ;rcu_assign_pointer (cfg80211_regdomain, cfg80211_world_regdom);
@@ -4372,9 +4372,9 @@ void regulatory_exit(void)reset_regdomains (true,NULL );rtnl_unlock (); -dev_set_uevent_suppress (®_pdev->dev, true); +dev_set_uevent_suppress (®_fdev->dev, true); -platform_device_unregister (reg_pdev); +faux_device_destroy (reg_fdev);list_for_each_entry_safe (reg_beacon, btmp, ®_pending_beacons, list) {list_del (®_beacon->list);
Signature · 1 line
2.50.0
Johannes Berg
maintainerQuoted 11 lines · Greg Kroah-Hartman
Downloading regulatory "firmware" needs a device to hang off of, and so a platform device seemed like the simplest way to do this. Now that we have a faux device interface, use that instead as this "regulatory device" is not anything resembling a platform device at all.
Cc Johannes Berg <[email protected]>Cc <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
v5: - rebase against 6.16-rc4 and actually cc: the relevant maintainers
and mailing lists this time, doh!
I did wonder for a second why it's v5 and I never saw it ;-)
net/wireless/reg.c late_initcall(regulatory_init_db); · line 4347
Quoted 8 lines
int
__initregulatory_init(void)
{net/wireless/reg.c +3
-3- reg_pdev =platform_device_register_simple ("regulatory" ,0 ,NULL ,0 ); -if (IS_ERR (reg_pdev)) -return PTR_ERR (reg_pdev); + reg_fdev =faux_device_create ("regulatory" ,NULL ,NULL ); +if (!reg_fdev) +return -ENODEV ;
Is that really -ENODEV rather than say -ENOMEM? Having a hard time imagining how a faux device creation would end up failing in any other case, there's no underlying device to bind to, after all? :)
Anyway, that's not really all that relevant. I assume you want me to merge it through wireless-next, since we have faux.h in the tree now?
johannes
Quoted 15 lines · Johannes Berg
Quoted 11 lines · Greg Kroah-Hartman
Downloading regulatory "firmware" needs a device to hang off of, and so a platform device seemed like the simplest way to do this. Now that we have a faux device interface, use that instead as this "regulatory device" is not anything resembling a platform device at all.
Cc Johannes Berg <[email protected]>Cc <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
v5: - rebase against 6.16-rc4 and actually cc: the relevant maintainers
and mailing lists this time, doh!I did wonder for a second why it's v5 and I never saw it ;-)
Quoted 12 lines
net/wireless/reg.c late_initcall(regulatory_init_db); · line 4347
Quoted 8 lines
int
__initregulatory_init(void)
{net/wireless/reg.c +3
-3- reg_pdev =platform_device_register_simple ("regulatory" ,0 ,NULL ,0 ); -if (IS_ERR (reg_pdev)) -return PTR_ERR (reg_pdev); + reg_fdev =faux_device_create ("regulatory" ,NULL ,NULL ); +if (!reg_fdev) +return -ENODEV ;Is that really
-ENODEVrather than say-ENOMEM? Having a hard time imagining how a faux device creation would end up failing in any other case, there's no underlying device to bind to, after all? :)
There are some low-level functions that could fail, but the error that I thought should be told to init would be "no device" as the device was not created which is what really matters :)
Quoted 2 lines
Anyway, that's not really all that relevant. I assume you want me to merge it through wireless-next, since we have
faux.hin the tree now?
Please do, thanks!
greg k-h