当前位置: 首页>>代码示例>>C++>>正文


C++ regulator_count_voltages函数代码示例

本文整理汇总了C++中regulator_count_voltages函数的典型用法代码示例。如果您正苦于以下问题:C++ regulator_count_voltages函数的具体用法?C++ regulator_count_voltages怎么用?C++ regulator_count_voltages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了regulator_count_voltages函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: bmp18x_config_regulator

static int bmp18x_config_regulator(struct i2c_client *client, bool on)
{
	int rc = 0, i;
	int num_vreg = ARRAY_SIZE(bmp_vreg);

	if (on) {
		for (i = 0; i < num_vreg; i++) {
			bmp_vreg[i].vreg = regulator_get(&client->dev,
					bmp_vreg[i].name);
			if (IS_ERR(bmp_vreg[i].vreg)) {
				rc = PTR_ERR(bmp_vreg[i].vreg);
				dev_err(&client->dev, "%s:regulator get failed rc=%d\n",
						__func__, rc);
				bmp_vreg[i].vreg = NULL;
				goto error_vdd;
			}
			if (regulator_count_voltages(bmp_vreg[i].vreg) > 0) {
				rc = regulator_set_voltage(bmp_vreg[i].vreg,
					bmp_vreg[i].min_uV, bmp_vreg[i].max_uV);
				if (rc) {
					dev_err(&client->dev, "%s:set_voltage failed rc=%d\n",
							__func__, rc);
					regulator_put(bmp_vreg[i].vreg);
					bmp_vreg[i].vreg = NULL;
					goto error_vdd;
				}
			}
			rc = regulator_enable(bmp_vreg[i].vreg);
			if (rc) {
				dev_err(&client->dev, "%s: regulator_enable failed rc =%d\n",
						__func__, rc);
				if (regulator_count_voltages(bmp_vreg[i].vreg)
						> 0) {
					regulator_set_voltage(bmp_vreg[i].vreg,
							0, bmp_vreg[i].max_uV);
				}
				regulator_put(bmp_vreg[i].vreg);
				bmp_vreg[i].vreg = NULL;
				goto error_vdd;
			}
		}
		return rc;
	} else {
		i = num_vreg;
	}
error_vdd:
	while (--i >= 0) {
		if (!IS_ERR_OR_NULL(bmp_vreg[i].vreg)) {
			if (regulator_count_voltages(
				bmp_vreg[i].vreg) > 0) {
				regulator_set_voltage(bmp_vreg[i].vreg, 0,
						bmp_vreg[i].max_uV);
			}
			regulator_disable(bmp_vreg[i].vreg);
			regulator_put(bmp_vreg[i].vreg);
			bmp_vreg[i].vreg = NULL;
		}
	}
	return rc;
}
开发者ID:98416,项目名称:Z7Max_NX505J_H129_kernel,代码行数:60,代码来源:bmp18x-i2c.c

示例2: max98504_regulator_config

static int max98504_regulator_config(struct i2c_client *i2c, bool pullup, bool on)
{
	int rc;
    #define VCC_I2C_MIN_UV	1800000
    #define VCC_I2C_MAX_UV	1800000
	#define I2C_LOAD_UA		300000

	//pr_info("[RYAN] %s\n", __func__);

	if (pullup) {
		//pr_info("[RYAN] %s I2C PULL UP.\n", __func__);

		max98504_vcc_i2c = regulator_get(&i2c->dev, "vcc_i2c");
		if (IS_ERR(max98504_vcc_i2c)) {
			rc = PTR_ERR(max98504_vcc_i2c);
			pr_info("Regulator get failed rc=%d\n",	rc);
			goto error_get_vtg_i2c;
		}
		if (regulator_count_voltages(max98504_vcc_i2c) > 0) {
			rc = regulator_set_voltage(max98504_vcc_i2c,
				VCC_I2C_MIN_UV, VCC_I2C_MAX_UV);
			if (rc) {
				pr_info("regulator set_vtg failed rc=%d\n", rc);
				goto error_set_vtg_i2c;
			}
		}

		rc = reg_set_optimum_mode_check(max98504_vcc_i2c, I2C_LOAD_UA);
		if (rc < 0) {
			pr_info("Regulator vcc_i2c set_opt failed rc=%d\n", rc);
			goto error_reg_opt_i2c;
		}
		
		rc = regulator_enable(max98504_vcc_i2c);
		if (rc) {
			pr_info("Regulator vcc_i2c enable failed rc=%d\n", rc);
			goto error_reg_en_vcc_i2c;
		}

	}
	//pr_info("[RYAN] %s OUT\n", __func__);

	return 0;

error_reg_en_vcc_i2c:
	if(pullup) reg_set_optimum_mode_check(max98504_vcc_i2c, 0);
error_reg_opt_i2c:
	regulator_disable(max98504_vcc_i2c);
error_set_vtg_i2c:
	if (regulator_count_voltages(max98504_vcc_i2c) > 0)
		regulator_set_voltage(max98504_vcc_i2c, 0,
			VCC_I2C_MAX_UV);
error_get_vtg_i2c:
	regulator_put(max98504_vcc_i2c);

	//pr_info("[RYAN] %s OUT WITH ERROR.\n", __func__);


	return rc;
}
开发者ID:LGaljo,项目名称:android_kernel_samsung_s3ve3g,代码行数:60,代码来源:max98504.c

示例3: mma8x5x_config_regulator

static int mma8x5x_config_regulator(struct i2c_client *client, bool on)
{
	int rc = 0, i;
	int num_vreg = sizeof(mma_vreg)/sizeof(struct sensor_regulator);

	if (on) {
		for (i = 0; i < num_vreg; i++) {
			mma_vreg[i].vreg = regulator_get(&client->dev,
					mma_vreg[i].name);
			if (IS_ERR(mma_vreg[i].vreg)) {
				rc = PTR_ERR(mma_vreg[i].vreg);
				dev_err(&client->dev, "%s:regulator get failed rc=%d\n",
						__func__, rc);
				mma_vreg[i].vreg = NULL;
				goto error_vdd;
			}
			if (regulator_count_voltages(mma_vreg[i].vreg) > 0) {
				rc = regulator_set_voltage(mma_vreg[i].vreg,
					mma_vreg[i].min_uV, mma_vreg[i].max_uV);
				if (rc) {
					dev_err(&client->dev, "%s:set_voltage failed rc=%d\n",
							__func__, rc);
					regulator_put(mma_vreg[i].vreg);
					mma_vreg[i].vreg = NULL;
					goto error_vdd;
				}
			}
			rc = regulator_enable(mma_vreg[i].vreg);
			if (rc) {
				dev_err(&client->dev, "%s: regulator_enable failed rc =%d\n",
						__func__, rc);
				if (regulator_count_voltages(mma_vreg[i].vreg)
						> 0) {
					regulator_set_voltage(mma_vreg[i].vreg,
							0, mma_vreg[i].max_uV);
				}
				regulator_put(mma_vreg[i].vreg);
				mma_vreg[i].vreg = NULL;
				goto error_vdd;
			}
		}
		return rc;
	} else {
		i = num_vreg;
	}
error_vdd:
	while (--i >= 0) {
		if (!IS_ERR_OR_NULL(mma_vreg[i].vreg)) {
			if (regulator_count_voltages(
				mma_vreg[i].vreg) > 0) {
				regulator_set_voltage(mma_vreg[i].vreg, 0,
						mma_vreg[i].max_uV);
			}
			regulator_disable(mma_vreg[i].vreg);
			regulator_put(mma_vreg[i].vreg);
			mma_vreg[i].vreg = NULL;
		}
	}
	return rc;
}
开发者ID:AndroPlus-org,项目名称:android_kernel_sony_msm8974ac,代码行数:60,代码来源:mma8x5x.c

示例4: capsensor_power_init

static int capsensor_power_init(struct device *dev, bool on)
{
	int rc;

	if (!on) {
		if (regulator_count_voltages(g_capsensor_pdata->vdd) > 0)
			regulator_set_voltage(g_capsensor_pdata->vdd, 0, CAP_VDD_MAX_UV);

		regulator_put(g_capsensor_pdata->vdd);

	} else {
		g_capsensor_pdata->vdd = regulator_get(dev, "vdd");
		if (IS_ERR(g_capsensor_pdata->vdd)) {
			rc = PTR_ERR(g_capsensor_pdata->vdd);
			printk(KERN_ERR"Regulator get failed vdd rc=%d\n", rc);
			return rc;
		}

		if (regulator_count_voltages(g_capsensor_pdata->vdd) > 0) {
			rc = regulator_set_voltage(g_capsensor_pdata->vdd, CAP_VDD_MIN_UV,
						   CAP_VDD_MAX_UV);
			if (rc) {
				printk(KERN_ERR"Regulator set failed vdd rc=%d\n",rc);
				goto reg_vdd_put;
			}
		}
	}

	return 0;

reg_vdd_put:
	regulator_put(g_capsensor_pdata->vdd);
	return rc;
}
开发者ID:silversderek,项目名称:msm8909_kernel_lenovo,代码行数:34,代码来源:capsensor.c

示例5: max98506_regulator_config

static int max98506_regulator_config(struct device *dev)
{
	struct regulator *max98506_vcc_i2c;
	int ret;

	max98506_vcc_i2c = regulator_get(dev, "vcc_i2c");
	if (IS_ERR(max98506_vcc_i2c)) {
		ret = PTR_ERR(max98506_vcc_i2c);
		dev_err(dev, "%s: regulator get failed ret=%d\n",
				__func__, ret);
		goto err_get_vtg_i2c;
	}
	if (regulator_count_voltages(max98506_vcc_i2c) > 0) {
		ret = regulator_set_voltage(max98506_vcc_i2c,
				VCC_I2C_MIN_UV, VCC_I2C_MAX_UV);
		if (ret) {
			dev_err(dev, "%s: regulator set_vtg failed ret=%d\n",
					__func__, ret);
			goto err_set_vtg_i2c;
		}
	}

	ret = reg_set_optimum_mode_check(max98506_vcc_i2c, I2C_LOAD_UA);
	if (ret < 0) {
		dev_err(dev, "%s: regulator vcc_i2c set_opt failed ret=%d\n",
				__func__, ret);
		goto err_reg_opt_i2c;
	}

	ret = regulator_enable(max98506_vcc_i2c);
	if (ret) {
		dev_err(dev, "%s: regulator vcc_i2c enable failed ret=%d\n",
				__func__, ret);
		goto err_reg_en_vcc_i2c;
	}

	msg_maxim("min_uv:%d max_uv:%d load_ua:%d",
		VCC_I2C_MIN_UV, VCC_I2C_MAX_UV, I2C_LOAD_UA);

	return 0;

err_set_vtg_i2c:
	regulator_put(max98506_vcc_i2c);

err_get_vtg_i2c:
	if (regulator_count_voltages(max98506_vcc_i2c) > 0)
		regulator_set_voltage(max98506_vcc_i2c, 0, VCC_I2C_MAX_UV);

err_reg_en_vcc_i2c:
	reg_set_optimum_mode_check(max98506_vcc_i2c, 0);

err_reg_opt_i2c:
	regulator_disable(max98506_vcc_i2c);

	return ret;
}
开发者ID:davidmueller13,项目名称:davidskernel_lt03lte_tw_5.1.1,代码行数:56,代码来源:max98506.c

示例6: drv2667_vreg_config

static int drv2667_vreg_config(struct drv2667_data *data, bool on)
{
	int rc = 0;

	if (!on)
		goto deconfig_vreg;

	data->vdd = regulator_get(&data->client->dev, "vdd");
	if (IS_ERR(data->vdd)) {
		rc = PTR_ERR(data->vdd);
		dev_err(&data->client->dev, "unable to request vdd\n");
		return rc;
	}

	if (regulator_count_voltages(data->vdd) > 0) {
		rc = regulator_set_voltage(data->vdd,
				DRV2667_VTG_MIN_UV, DRV2667_VTG_MAX_UV);
		if (rc < 0) {
			dev_err(&data->client->dev,
				"vdd set voltage failed(%d)\n", rc);
			goto put_vdd;
		}
	}

	data->vdd_i2c = regulator_get(&data->client->dev, "vdd-i2c");
	if (IS_ERR(data->vdd_i2c)) {
		rc = PTR_ERR(data->vdd_i2c);
		dev_err(&data->client->dev, "unable to request vdd for i2c\n");
		goto reset_vdd_volt;
	}

	if (regulator_count_voltages(data->vdd_i2c) > 0) {
		rc = regulator_set_voltage(data->vdd_i2c,
			DRV2667_I2C_VTG_MIN_UV, DRV2667_I2C_VTG_MAX_UV);
		if (rc < 0) {
			dev_err(&data->client->dev,
				"vdd_i2c set voltage failed(%d)\n", rc);
			goto put_vdd_i2c;
		}
	}

	return rc;

deconfig_vreg:
	if (regulator_count_voltages(data->vdd_i2c) > 0)
		regulator_set_voltage(data->vdd_i2c, 0, DRV2667_I2C_VTG_MAX_UV);
put_vdd_i2c:
	regulator_put(data->vdd_i2c);
reset_vdd_volt:
	if (regulator_count_voltages(data->vdd) > 0)
		regulator_set_voltage(data->vdd, 0, DRV2667_VTG_MAX_UV);
put_vdd:
	regulator_put(data->vdd);
	return rc;
}
开发者ID:98416,项目名称:Z7Max_NX505J_H129_kernel,代码行数:55,代码来源:ti_drv2667.c

示例7: anx7816_regulator_configure

int anx7816_regulator_configure(
	struct device *dev, struct anx7816_platform_data *pdata)
{
	int rc = 0;
/* To do : regulator control after H/W change */
#if 0
	pdata->avdd_33 = regulator_get(dev, "analogix,vdd_ana");

	pr_err("anx test ");
	if (IS_ERR(pdata->avdd_33)) {
		rc = PTR_ERR(pdata->avdd_33);
		pr_err("%s : Regulator get failed avdd_33 rc=%d\n",
			   __func__, rc);
		return rc;
	}

	if (regulator_count_voltages(pdata->avdd_33) > 0) {
		rc = regulator_set_voltage(pdata->avdd_33, 3300000,
							3300000);
		if (rc) {
			pr_err("%s : Regulator set_vtg failed rc=%d\n",
				   __func__, rc);
			goto error_set_vtg_avdd_33;
		}
	}
#endif

	pdata->dvdd_10 = regulator_get(dev, "analogix,vdd_dig");
	if (IS_ERR(pdata->dvdd_10)) {
		rc = PTR_ERR(pdata->dvdd_10);
		pr_err("%s : Regulator get failed dvdd_10 rc=%d\n",
			   __func__, rc);
		return rc;
	}

	if (regulator_count_voltages(pdata->dvdd_10) > 0) {
		rc = regulator_set_voltage(pdata->dvdd_10, 1000000,
							1000000);
		if (rc) {
			pr_err("%s : Regulator set_vtg failed rc=%d\n",
				   __func__, rc);
			goto error_set_vtg_dvdd_10;
		}
	}

	return 0;

error_set_vtg_dvdd_10:
	regulator_put(pdata->dvdd_10);
#if 0
error_set_vtg_avdd_33:
	regulator_put(pdata->avdd_33);
#endif
	return rc;
}
开发者ID:bju2000,项目名称:kernel_lge_msm8994,代码行数:55,代码来源:slimport7816.c

示例8: mpu6050_power_init

static int mpu6050_power_init(struct platform_device *pdev)
{
	int ret = 0;

	sms_pwr_ctrl->vdd_io = regulator_get(&pdev->dev, "vdd-io");
	if (IS_ERR(sms_pwr_ctrl->vdd_io)) {
		ret = PTR_ERR(sms_pwr_ctrl->vdd_io);
		dev_err(&pdev->dev,
			"Regulator get failed vdd io ret=%d\n", ret);
		goto error;
	}

	if (regulator_count_voltages(sms_pwr_ctrl->vdd_io) > 0) {
		ret = regulator_set_voltage(sms_pwr_ctrl->vdd_io,
				SMS4470_VDD_IO_MIN_UV,
				SMS4470_VDD_IO_MAX_UV);
		if (ret) {
			dev_err(&pdev->dev,
			"Regulator set_vtg failed vdd_io ret=%d\n", ret);
			goto reg_vddio_put;
		}
	}

	sms_pwr_ctrl->vdd_emi= regulator_get(&&pdev->dev, "vdd-emi");
	if (IS_ERR(sms_pwr_ctrl->vdd_emi)) {
		ret = PTR_ERR(sms_pwr_ctrl->vdd_emi);
		dev_err(&pdev->dev,
			"Regulator get failed vdd io ret=%d\n", ret);
		goto reg_vddio_set_vtg;
	}

	if (regulator_count_voltages(sms_pwr_ctrl->vdd_emi) > 0) {
		ret = regulator_set_voltage(sms_pwr_ctrl->vdd_emi,
				SMS4470_VDD_IO_MIN_UV,
				SMS4470_VDD_IO_MAX_UV);
		if (ret) {
			dev_err(&pdev->dev,
			"Regulator set_vtg failed vdd_emi ret=%d\n", ret);
			goto reg_vddemi_put;
		}
	}

	return 0;

reg_vddemi_put:
	regulator_put(sms_power_ctrl->vdd_emi);
reg_vddio_set_vtg:
	if (regulator_count_voltages(sms_power_ctrl->vdd_io) > 0)
		regulator_set_voltage(sms_power_ctrl->vdd_io, 0, SMS4470_VDD_IO_MAX_UV);
reg_vddio_put:
	regulator_put(sms_power_ctrl->vdd_io);	
	return ret;
}
开发者ID:iuncuim,项目名称:A476_V1B_5.1_kernel,代码行数:53,代码来源:smspower_customer.c

示例9: fpc1020_io_regulator_configure

int fpc1020_io_regulator_configure(struct fpc1020_data *fpc1020)
{
	int error = 0;

	dev_dbg(&fpc1020->spi->dev, "%s\n", __func__);

	fpc1020->vdd_io = regulator_get(&fpc1020->spi->dev, "vdd_io");
	if (IS_ERR(fpc1020->vdd_io)) {
		error = PTR_ERR(fpc1020->vdd_io);
		dev_err(&fpc1020->spi->dev,
			"vdd_io get failed, error=%d\n", error);
		goto supply_err;
	}

	if (regulator_count_voltages(fpc1020->vdd_io) > 0) {
		error = regulator_set_voltage(fpc1020->vdd_io,
						SUPPLY_TX_MIN, SUPPLY_TX_MAX);
		if (error) {
			dev_err(&fpc1020->spi->dev,
				"vdd_io set(tx) failed, error=%d\n", error);
			goto supply_err;
		}
	}
	return 0;

supply_err:
	fpc1020_io_regulator_release(fpc1020);
	return error;
}
开发者ID:chrisc93,项目名称:android_kernel_bullhead,代码行数:29,代码来源:fpc1020_tee.c

示例10: ufs_qcom_phy_cfg_vreg

static int ufs_qcom_phy_cfg_vreg(struct device *dev,
                                 struct ufs_qcom_phy_vreg *vreg, bool on)
{
    int ret = 0;
    struct regulator *reg = vreg->reg;
    const char *name = vreg->name;
    int min_uV;
    int uA_load;

    if (regulator_count_voltages(reg) > 0) {
        min_uV = on ? vreg->min_uV : 0;
        ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
        if (ret) {
            dev_err(dev, "%s: %s set voltage failed, err=%d\n",
                    __func__, name, ret);
            goto out;
        }
        uA_load = on ? vreg->max_uA : 0;
        ret = regulator_set_load(reg, uA_load);
        if (ret >= 0) {
            /*
             * regulator_set_load() returns new regulator
             * mode upon success.
             */
            ret = 0;
        } else {
            dev_err(dev, "%s: %s set optimum mode(uA_load=%d) failed, err=%d\n",
                    __func__, name, uA_load, ret);
            goto out;
        }
    }
out:
    return ret;
}
开发者ID:kdave,项目名称:btrfs-devel,代码行数:34,代码来源:phy-qcom-ufs.c

示例11: pmu_enable

static int pmu_enable(void)
{
	int rc = 0;

	pn544_dev->vdd = regulator_get(&pn544_dev->client->dev, "vdd");
	if (IS_ERR(pn544_dev->vdd)) {
		rc = PTR_ERR(pn544_dev->vdd);
		printk("Regulator get failed vdd rc=%d\n", rc);
		return rc;
	}else{
		if (regulator_count_voltages(pn544_dev->vdd) > 0) {
		rc = regulator_set_voltage(pn544_dev->vdd,
				PMU_VDD_VALUE, PMU_VDD_VALUE);
		if (rc) {
			printk("Regulator set failed vdd rc=%d\n",
				rc);
			goto reg_vdd_put;
			}
		}

	rc = regulator_enable(pn544_dev->vdd);
	if (rc) {
	printk(
		"Regulator enable vdd failed. rc=%d\n", rc);
	goto reg_vdd_put;
	}
   }
	return 0;

reg_vdd_put:
	regulator_put(pn544_dev->vdd);
	return rc;
}
开发者ID:moonlightly,项目名称:NX523J_kernel,代码行数:33,代码来源:pn547.c

示例12: __ufs_qcom_phy_init_vreg

static int __ufs_qcom_phy_init_vreg(struct device *dev,
                                    struct ufs_qcom_phy_vreg *vreg, const char *name, bool optional)
{
    int err = 0;

    char prop_name[MAX_PROP_NAME];

    vreg->name = devm_kstrdup(dev, name, GFP_KERNEL);
    if (!vreg->name) {
        err = -ENOMEM;
        goto out;
    }

    vreg->reg = devm_regulator_get(dev, name);
    if (IS_ERR(vreg->reg)) {
        err = PTR_ERR(vreg->reg);
        vreg->reg = NULL;
        if (!optional)
            dev_err(dev, "failed to get %s, %d\n", name, err);
        goto out;
    }

    if (dev->of_node) {
        snprintf(prop_name, MAX_PROP_NAME, "%s-max-microamp", name);
        err = of_property_read_u32(dev->of_node,
                                   prop_name, &vreg->max_uA);
        if (err && err != -EINVAL) {
            dev_err(dev, "%s: failed to read %s\n",
                    __func__, prop_name);
            goto out;
        } else if (err == -EINVAL || !vreg->max_uA) {
            if (regulator_count_voltages(vreg->reg) > 0) {
                dev_err(dev, "%s: %s is mandatory\n",
                        __func__, prop_name);
                goto out;
            }
            err = 0;
        }
        snprintf(prop_name, MAX_PROP_NAME, "%s-always-on", name);
        vreg->is_always_on = of_property_read_bool(dev->of_node,
                             prop_name);
    }

    if (!strcmp(name, "vdda-pll")) {
        vreg->max_uV = VDDA_PLL_MAX_UV;
        vreg->min_uV = VDDA_PLL_MIN_UV;
    } else if (!strcmp(name, "vdda-phy")) {
        vreg->max_uV = VDDA_PHY_MAX_UV;
        vreg->min_uV = VDDA_PHY_MIN_UV;
    } else if (!strcmp(name, "vddp-ref-clk")) {
        vreg->max_uV = VDDP_REF_CLK_MAX_UV;
        vreg->min_uV = VDDP_REF_CLK_MIN_UV;
    }

out:
    if (err)
        kfree(vreg->name);
    return err;
}
开发者ID:kdave,项目名称:btrfs-devel,代码行数:59,代码来源:phy-qcom-ufs.c

示例13: tpiu_reg_set_voltage

static int tpiu_reg_set_voltage(struct regulator *reg, unsigned int reg_low,
				unsigned int reg_high)
{
	if (regulator_count_voltages(reg) <= 0)
		return 0;

	return regulator_set_voltage(reg, reg_low, reg_high);
}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:8,代码来源:coresight-tpiu.c

示例14: tpiu_reg_set_optimum_mode

static int tpiu_reg_set_optimum_mode(struct regulator *reg,
				     unsigned int reg_hpm)
{
	if (regulator_count_voltages(reg) <= 0)
		return 0;

	return regulator_set_optimum_mode(reg, reg_hpm);
}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:8,代码来源:coresight-tpiu.c

示例15: vreg_setup

static int vreg_setup(struct fpc1020_data *fpc1020, const char *name,
	bool enable)
{
	size_t i;
	int rc;
	struct regulator *vreg;
	struct device *dev = fpc1020->dev;

	for (i = 0; i < ARRAY_SIZE(fpc1020->vreg); i++) {
		const char *n = vreg_conf[i].name;
		if (!strncmp(n, name, strlen(n)))
			goto found;
	}
	dev_err(dev, "Regulator %s not found\n", name);
	return -EINVAL;
found:
	vreg = fpc1020->vreg[i];
	if (enable) {
		if (!vreg) {
			vreg = regulator_get(dev, name);
			if (!vreg) {
				dev_err(dev, "Unable to get  %s\n", name);
				return -ENODEV;
			}
		}
		if (regulator_count_voltages(vreg) > 0) {
			rc = regulator_set_voltage(vreg, vreg_conf[i].vmin,
					vreg_conf[i].vmax);
			if (rc)
				dev_err(dev,
					"Unable to set voltage on %s, %d\n",
					name, rc);
		}
		rc = regulator_set_optimum_mode(vreg, vreg_conf[i].ua_load);
		if (rc < 0)
			dev_err(dev, "Unable to set current on %s, %d\n",
					name, rc);
		rc = regulator_enable(vreg);
		if (rc) {
			dev_err(dev, "error enabling %s: %d\n", name, rc);
			regulator_put(vreg);
			vreg = NULL;
		}
		fpc1020->vreg[i] = vreg;
	} else {
		if (vreg) {
			if (regulator_is_enabled(vreg)) {
				regulator_disable(vreg);
				dev_dbg(dev, "disabled %s\n", name);
			}
			regulator_put(vreg);
			fpc1020->vreg[i] = NULL;
		}
		rc = 0;
	}
	return rc;
}
开发者ID:KAsp3rd,项目名称:android_kernel_lge_msm8992,代码行数:57,代码来源:fpc1020_tee.c


注:本文中的regulator_count_voltages函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。