OSDN Git Service

wcnss: update the regulator parsing and config method
authorSarada Prasanna Garnayak <sgarna@codeaurora.org>
Tue, 3 Apr 2018 11:10:49 +0000 (16:40 +0530)
committerGerrit - the friendly Code Review server <code-review@localhost>
Tue, 3 Apr 2018 11:35:33 +0000 (04:35 -0700)
Use the resource managed regulator API for the wcnss
regulator parsing and configuration.

CRs-Fixed: 2214888
Change-Id: Ib376893c26bb9aa797e7e9df25cc7302a84a3726
Signed-off-by: Sarada Prasanna Garnayak <sgarna@codeaurora.org>
drivers/net/wireless/wcnss/wcnss_vreg.c
drivers/net/wireless/wcnss/wcnss_wlan.c
include/linux/wcnss_wlan.h

index 28cf4b7..1be4c65 100644 (file)
@@ -194,27 +194,6 @@ int validate_iris_chip_id(u32 reg)
        }
 }
 
-void wcnss_free_regulator(void)
-{
-       int vreg_i;
-
-       /* Free pronto voltage regulators from device node */
-       for (vreg_i = 0; vreg_i < PRONTO_REGULATORS; vreg_i++) {
-               if (pronto_vregs[vreg_i].state) {
-                       regulator_put(pronto_vregs[vreg_i].regulator);
-                       pronto_vregs[vreg_i].state = VREG_NULL_CONFIG;
-               }
-       }
-
-       /* Free IRIS voltage regulators from device node */
-       for (vreg_i = 0; vreg_i < IRIS_REGULATORS; vreg_i++) {
-               if (iris_vregs[vreg_i].state) {
-                       regulator_put(iris_vregs[vreg_i].regulator);
-                       iris_vregs[vreg_i].state = VREG_NULL_CONFIG;
-               }
-       }
-}
-
 static int
 wcnss_dt_parse_vreg_level(struct device *dev, int index,
                          const char *current_vreg_name, const char *vreg_name,
@@ -257,13 +236,14 @@ wcnss_parse_voltage_regulator(struct wcnss_wlan_config *wlan_config,
        /* Parse pronto voltage regulators from device node */
        for (vreg_i = 0; vreg_i < PRONTO_REGULATORS; vreg_i++) {
                pronto_vregs[vreg_i].regulator =
-                       regulator_get(dev, pronto_vregs[vreg_i].name);
+                       devm_regulator_get_optional(dev,
+                                                   pronto_vregs[vreg_i].name);
                if (IS_ERR(pronto_vregs[vreg_i].regulator)) {
                        if (pronto_vregs[vreg_i].required) {
                                rc = PTR_ERR(pronto_vregs[vreg_i].regulator);
                                dev_err(dev, "regulator get of %s failed (%d)\n",
                                        pronto_vregs[vreg_i].name, rc);
-                               goto wcnss_vreg_get_err;
+                               return rc;
                        } else {
                                dev_dbg(dev, "Skip optional regulator configuration: %s\n",
                                        pronto_vregs[vreg_i].name);
@@ -271,27 +251,28 @@ wcnss_parse_voltage_regulator(struct wcnss_wlan_config *wlan_config,
                        }
                }
 
-               pronto_vregs[vreg_i].state |= VREG_GET_REGULATOR_MASK;
                rc = wcnss_dt_parse_vreg_level(dev, vreg_i,
                                               pronto_vregs[vreg_i].curr,
                                               pronto_vregs[vreg_i].volt,
                                               wlan_config->pronto_vlevel);
                if (rc) {
                        dev_err(dev, "error reading voltage-level property\n");
-                       goto wcnss_vreg_get_err;
+                       return rc;
                }
+               pronto_vregs[vreg_i].state |= VREG_GET_REGULATOR_MASK;
        }
 
        /* Parse iris voltage regulators from device node */
        for (vreg_i = 0; vreg_i < IRIS_REGULATORS; vreg_i++) {
                iris_vregs[vreg_i].regulator =
-                       regulator_get(dev, iris_vregs[vreg_i].name);
+                       devm_regulator_get_optional(dev,
+                                                   iris_vregs[vreg_i].name);
                if (IS_ERR(iris_vregs[vreg_i].regulator)) {
                        if (iris_vregs[vreg_i].required) {
                                rc = PTR_ERR(iris_vregs[vreg_i].regulator);
                                dev_err(dev, "regulator get of %s failed (%d)\n",
                                        iris_vregs[vreg_i].name, rc);
-                               goto wcnss_vreg_get_err;
+                               return rc;
                        } else {
                                dev_dbg(dev, "Skip optional regulator configuration: %s\n",
                                        iris_vregs[vreg_i].name);
@@ -299,22 +280,18 @@ wcnss_parse_voltage_regulator(struct wcnss_wlan_config *wlan_config,
                        }
                }
 
-               iris_vregs[vreg_i].state |= VREG_GET_REGULATOR_MASK;
                rc = wcnss_dt_parse_vreg_level(dev, vreg_i,
                                               iris_vregs[vreg_i].curr,
                                               iris_vregs[vreg_i].volt,
                                               wlan_config->iris_vlevel);
                if (rc) {
                        dev_err(dev, "error reading voltage-level property\n");
-                       goto wcnss_vreg_get_err;
+                       return rc;
                }
+               iris_vregs[vreg_i].state |= VREG_GET_REGULATOR_MASK;
        }
 
        return 0;
-
-wcnss_vreg_get_err:
-       wcnss_free_regulator();
-       return rc;
 }
 
 void  wcnss_iris_reset(u32 reg, void __iomem *pmu_conf_reg)
index 0aa7ba0..13ae5c3 100644 (file)
@@ -3465,7 +3465,6 @@ wcnss_wlan_probe(struct platform_device *pdev)
 static int
 wcnss_wlan_remove(struct platform_device *pdev)
 {
-       wcnss_free_regulator();
        if (penv->wcnss_notif_hdle)
                subsys_notif_unregister_notifier(penv->wcnss_notif_hdle, &wnb);
        wcnss_remove_sysfs(&pdev->dev);
index 6cb6be7..7389fff 100644 (file)
@@ -130,7 +130,6 @@ int wcnss_is_hw_pronto_ver3(void);
 int wcnss_device_ready(void);
 bool wcnss_cbc_complete(void);
 int wcnss_device_is_shutdown(void);
-void wcnss_free_regulator(void);
 void wcnss_riva_dump_pmic_regs(void);
 int wcnss_xo_auto_detect_enabled(void);
 u32 wcnss_get_wlan_rx_buff_count(void);