diff mbox series

[2/3] device: Setup regdom when powering up to maintain consistency

Message ID 20231222154645.278128-3-jussi.laakkonen@jolla.com (mailing list archive)
State New
Headers show
Series Ensure resolving and setting of proper ISO3166 code | expand

Commit Message

Jussi Laakkonen Dec. 22, 2023, 3:46 p.m. UTC
If the regdom has been set for the technology or for all the
technologies as a global setting apply it when powering up a device that
supports changing regdom. Otherwise the changes made to regdom may not
have been propagated to the device if the change has been made when the
device was powered off, for instance.
---
 src/device.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/src/device.c b/src/device.c
index 264c5e2d..55670099 100644
--- a/src/device.c
+++ b/src/device.c
@@ -589,6 +589,7 @@  int connman_device_set_powered(struct connman_device *device,
 {
 	struct connman_device_scan_params params;
 	enum connman_service_type type;
+	const char *alpha2;
 	int i;
 
 	DBG("device %p powered %d", device, powered);
@@ -607,6 +608,16 @@  int connman_device_set_powered(struct connman_device *device,
 	if (!device->powered) {
 		__connman_technology_disabled(type);
 		return 0;
+	} else {
+		/*
+		 * Check if the technology has regdom set and apply it for the
+		 * device. Regdom may have been changed when the device was
+		 * powered off and, thus, the new regdom has not been applied
+		 * here.
+		 */
+		alpha2 = __connman_technology_get_regdom(type);
+		if (alpha2)
+			connman_device_set_regdom(device, alpha2);
 	}
 
 	__connman_technology_enabled(type);