Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a0e8b68 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "leds: leds-qpnp: check if flash_wa regulator is obtained before enabling it"

parents 76a0a75b 01ff8e93
Loading
Loading
Loading
Loading
+40 −21
Original line number Diff line number Diff line
@@ -436,6 +436,7 @@ struct mpp_config_data {
 *  @safety_timer - enable safety timer or watchdog timer
 *  @torch_enable - enable flash LED torch mode
 *  @flash_reg_get - flash regulator attached or not
 *  @flash_wa_reg_get - workaround regulator attached or not
 *  @flash_on - flash status, on or off
 *  @torch_on - torch status, on or off
 *  @vreg_ok - specifies strobe type, sw or hw
@@ -460,6 +461,7 @@ struct flash_config_data {
	bool	safety_timer;
	bool	torch_enable;
	bool	flash_reg_get;
	bool    flash_wa_reg_get;
	bool	flash_on;
	bool	torch_on;
	bool	vreg_ok;
@@ -1122,22 +1124,35 @@ static int qpnp_flash_regulator_operate(struct qpnp_led_data *led, bool on)
	if (!regulator_on && !led->flash_cfg->flash_on) {
		for (i = 0; i < led->num_leds; i++) {
			if (led_array[i].flash_cfg->flash_reg_get) {
				if (led_array[i].flash_cfg->flash_wa_reg_get) {
					rc = regulator_enable(
					led_array[i].flash_cfg->flash_wa_reg);
						led_array[i].flash_cfg->
							flash_wa_reg);
					if (rc) {
						dev_err(&led->spmi_dev->dev,
						"Flash_wa regulator enable failed(%d)\n",
							"Flash wa regulator"
							"enable failed(%d)\n",
							rc);
						return rc;
					}
				}

				rc = regulator_enable(
					led_array[i].flash_cfg->\
					flash_boost_reg);
				if (rc) {
					if (led_array[i].flash_cfg->
							flash_wa_reg_get)
						/* Disable flash wa regulator
						 * when flash boost regulator
						 * enable fails
						 */
						regulator_disable(
							led_array[i].flash_cfg->
								flash_wa_reg);
					dev_err(&led->spmi_dev->dev,
						"Regulator enable failed(%d)\n",
									rc);
						"Flash boost regulator enable"
						"failed(%d)\n", rc);
					return rc;
				}
				led->flash_cfg->flash_on = true;
@@ -1166,18 +1181,22 @@ regulator_turn_off:
							flash_boost_reg);
				if (rc) {
					dev_err(&led->spmi_dev->dev,
						"Regulator disable failed(%d)\n",
									rc);
						"Flash boost regulator disable"
						"failed(%d)\n", rc);
					return rc;
				}
				if (led_array[i].flash_cfg->flash_wa_reg_get) {
					rc = regulator_disable(
					led_array[i].flash_cfg->flash_wa_reg);
						led_array[i].flash_cfg->
							flash_wa_reg);
					if (rc) {
						dev_err(&led->spmi_dev->dev,
						"Flash_wa regulator disable failed(%d)\n",
							"Flash_wa regulator"
							"disable failed(%d)\n",
							rc);
						return rc;
					}
				}
				led->flash_cfg->flash_on = false;
			}
			break;
@@ -3104,16 +3123,16 @@ static int qpnp_get_config_flash(struct qpnp_led_data *led,
	if (of_find_property(of_get_parent(node), "flash-wa-supply",
					NULL) && (!*reg_set)) {
		led->flash_cfg->flash_wa_reg =
			devm_regulator_get(&led->spmi_dev->dev,
					"flash-wa");
			devm_regulator_get(&led->spmi_dev->dev,	"flash-wa");
		if (IS_ERR_OR_NULL(led->flash_cfg->flash_wa_reg)) {
			rc = PTR_ERR(led->flash_cfg->flash_wa_reg);
			if (rc != EPROBE_DEFER) {
				dev_err(&led->spmi_dev->dev,
						"Falsh wa regulator get failed(%d)\n",
						"Flash wa regulator get failed(%d)\n",
						rc);
			}
		}
		led->flash_cfg->flash_wa_reg_get = true;
	}

	if (led->id == QPNP_ID_FLASH1_LED0) {