Skip to contentSkip to conversation

mac802154_hwsim: allow users to specify the number of simulated radios dynamically instead of the previously hardcoded value of 2

PATCH In review Ramon Fontes 2 participants 2 messages Jun 9, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac802154_hwsim: allow users to specify the number of simulated radios dynamically instead of the previously hardcoded value of 2

Add a module parameter radios to allow users to configure the number of virtual radios created by mac802154_hwsim at module load time. This replaces the previously hardcoded value of 2.

* Added a new module parameter radios
* Modified the loop in hwsim_probe()
* Updated log message in hwsim_probe()

---
 drivers/net/ieee802154/mac802154_hwsim.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ieee802154/mac802154_hwsim.c +6 -2
index 1cab20b5a..1740abe1a 100644
@@ -27,6 +27,10 @@
 MODULE_DESCRIPTION("Software simulator of IEEE 802.15.4 radio(s) for mac802154");
 MODULE_LICENSE("GPL");
 
+static unsigned int radios = 2;
+module_param(radios, int, 0444);
+MODULE_PARM_DESC(radios, "Number of simulated radios");
+
 static LIST_HEAD(hwsim_phys);
 static DEFINE_MUTEX(hwsim_phys_lock);
 
@@ -1018,13 +1022,13 @@ static int hwsim_probe(struct platform_device *pdev)
 	struct hwsim_phy *phy, *tmp;
 	int err, i;
 
-	for (i = 0; i < 2; i++) {
+	for (i = 0; i < radios; i++) {
 		err = hwsim_add_one(NULL, &pdev->dev, true);
 		if (err < 0)
 			goto err_slave;
 	}
 
-	dev_info(&pdev->dev, "Added 2 mac802154 hwsim hardware radios\n");
+	dev_info(&pdev->dev, "Added %u mac802154 hwsim hardware radios\n", radios);
 	return 0;
 
 err_slave:
Signature · 1 line
2.43.0
#1 lore raw

Hi,

Quoted 19 lines · Ramon Fontes

Add a module parameter radios to allow users to configure the number of virtual radios created by mac802154_hwsim at module load time. This replaces the previously hardcoded value of 2.

* Added a new module parameter radios
* Modified the loop in hwsim_probe()
* Updated log message in hwsim_probe()

---
 drivers/net/ieee802154/mac802154_hwsim.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ieee802154/mac802154_hwsim.c +0 -0
index 1cab20b5a..1740abe1a 100644

drivers/net/ieee802154/mac802154_hwsim.c line 31

Quoted 5 lines
drivers/net/ieee802154/mac802154_hwsim.c +2 -0
@@ -27,6 +27,10 @@
 MODULE_DESCRIPTION("Software simulator of IEEE 802.15.4 radio(s) for mac802154");
 MODULE_LICENSE("GPL");
 
+static unsigned int radios = 2;
+module_param(radios, int, 0444);

uint? I can swear I saw that in an earlier patch.

drivers/net/ieee802154/mac802154_hwsim.c static int hwsim_probe(struct platform_device *pdev) · line 1025

Quoted 11 lines
drivers/net/ieee802154/mac802154_hwsim.c +3 -1
+MODULE_PARM_DESC(radios, "Number of simulated radios");
+
 static LIST_HEAD(hwsim_phys);
 static DEFINE_MUTEX(hwsim_phys_lock);
 
@@ -1018,13 +1022,13 @@ static int hwsim_probe(struct platform_device *pdev)
        struct hwsim_phy *phy, *tmp;
        int err, i;
 
-       for (i = 0; i < 2; i++) {
+       for (i = 0; i < radios; i++) {

The iterator needs to be unsigned now?

- Alex