Browse Source

qcacmn: Add api to get the current country code

Add new api to provide the current country code
is using.

Change-Id: I84682e132fd1e150d7c4f86b04bbfc8c45e2d841
CRs-Fixed: 2175022
Paul Zhang 7 years ago
parent
commit
48884688c3

+ 23 - 1
umac/regulatory/core/src/reg_services.c

@@ -1325,6 +1325,28 @@ QDF_STATUS reg_read_default_country(struct wlan_objmgr_psoc *psoc,
 	return QDF_STATUS_SUCCESS;
 }
 
+QDF_STATUS reg_read_current_country(struct wlan_objmgr_psoc *psoc,
+				    uint8_t *country_code)
+{
+	struct wlan_regulatory_psoc_priv_obj *psoc_reg;
+
+	if (!country_code) {
+		reg_err("country_code is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	psoc_reg = reg_get_psoc_obj(psoc);
+	if (!IS_VALID_PSOC_REG_OBJ(psoc_reg)) {
+		reg_err("psoc reg component is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	qdf_mem_copy(country_code,
+		     psoc_reg->cur_country,
+		     REG_ALPHA2_LEN + 1);
+
+	return QDF_STATUS_SUCCESS;
+}
 /**
  * reg_set_default_country() - Read the default country for the regdomain
  * @country: country code.
@@ -1378,7 +1400,7 @@ QDF_STATUS reg_set_country(struct wlan_objmgr_pdev *pdev,
 	if (!qdf_mem_cmp(psoc_reg->cur_country,
 			country, REG_ALPHA2_LEN)) {
 		reg_err("country is not different");
-		return QDF_STATUS_E_INVAL;
+		return QDF_STATUS_SUCCESS;
 	}
 
 	reg_debug("programming new country:%s to firmware", country);

+ 10 - 0
umac/regulatory/core/src/reg_services.h

@@ -144,6 +144,16 @@ QDF_STATUS reg_set_fcc_constraint(struct wlan_objmgr_pdev *pdev,
 QDF_STATUS reg_read_default_country(struct wlan_objmgr_psoc *psoc,
 				   uint8_t *country_code);
 
+/**
+ * reg_read_current_country() - Get the current regulatory country
+ * @psoc: The physical SoC to get current country from
+ * @country_code: the buffer to populate the country code into
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS reg_read_current_country(struct wlan_objmgr_psoc *psoc,
+				   uint8_t *country_code);
+
 /**
  * reg_set_default_country() - Set the default regulatory country
  * @psoc: The physical SoC to set default country for

+ 10 - 0
umac/regulatory/dispatcher/inc/wlan_reg_services_api.h

@@ -85,6 +85,16 @@ QDF_STATUS wlan_reg_get_channel_list_with_power(struct wlan_objmgr_pdev *pdev,
  */
 QDF_STATUS wlan_reg_read_default_country(struct wlan_objmgr_psoc *psoc,
 				   uint8_t *country);
+
+/**
+ * wlan_reg_read_current_country() - Read the current country for the regdomain
+ * @country: pointer to the country code.
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc,
+				   uint8_t *country);
+
 /**
  * wlan_reg_get_channel_state() - Get channel state from regulatory
  * @ch: channel number.

+ 9 - 0
umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h

@@ -64,6 +64,15 @@ QDF_STATUS ucfg_reg_set_fcc_constraint(struct wlan_objmgr_pdev *pdev,
 QDF_STATUS ucfg_reg_get_default_country(struct wlan_objmgr_psoc *psoc,
 					       uint8_t *country_code);
 
+/**
+ * ucfg_reg_get_current_country() - Get the current regulatory country
+ * @psoc: The physical SoC to get current country from
+ * @country_code: the buffer to populate the country code into
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS ucfg_reg_get_current_country(struct wlan_objmgr_psoc *psoc,
+					       uint8_t *country_code);
 /**
  * ucfg_reg_set_default_country() - Set the default regulatory country
  * @psoc: The physical SoC to set default country for

+ 9 - 0
umac/regulatory/dispatcher/src/wlan_reg_services_api.c

@@ -61,6 +61,15 @@ QDF_STATUS wlan_reg_read_default_country(struct wlan_objmgr_psoc *psoc,
 	return reg_read_default_country(psoc, country);
 }
 
+QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc,
+					 uint8_t *country)
+{
+	/*
+	 * Get the current country information
+	 */
+	return reg_read_current_country(psoc, country);
+}
+
 /**
  * wlan_reg_get_channel_state() - Get channel state from regulatory
  * @ch: channel number.

+ 6 - 1
umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
  *
  *
  * Permission to use, copy, modify, and/or distribute this software for
@@ -141,6 +141,11 @@ QDF_STATUS ucfg_reg_get_default_country(struct wlan_objmgr_psoc *psoc,
 	return reg_read_default_country(psoc, country_code);
 }
 
+QDF_STATUS ucfg_reg_get_current_country(struct wlan_objmgr_psoc *psoc,
+					       uint8_t *country_code)
+{
+	return reg_read_current_country(psoc, country_code);
+}
 /**
  * ucfg_reg_set_default_country() - Set the default regulatory country
  * @psoc: The physical SoC to set default country for