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

Commit bd34b42e authored by Fenglin Wu's avatar Fenglin Wu
Browse files

leds: led-qpnp-flash: Re-check fault status if open fault is detected



If LED open fault is detected, the open_fault flag will be set always
and the flash won't be controlled even if the hardware open fault is
recovered. So check the LED fault status everytime if the open fault
has been detected.

CRs-Fixed: 2093952
Change-Id: I0b449a7d030d091d24aca992cdd7c06150d8ff30
Signed-off-by: default avatarFenglin Wu <fenglinw@codeaurora.org>
parent 27501237
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -1307,7 +1307,7 @@ static void qpnp_flash_led_work(struct work_struct *work)
	int max_curr_avail_ma = 0;
	int total_curr_ma = 0;
	int i;
	u8 val;
	u8 val = 0;

	/* Global lock is to synchronize between the flash leds and torch */
	mutex_lock(&led->flash_led_lock);
@@ -1318,10 +1318,32 @@ static void qpnp_flash_led_work(struct work_struct *work)
	if (!brightness)
		goto turn_off;

	if (led->open_fault) {
		if (flash_node->type == FLASH) {
			dev_dbg(&led->spmi_dev->dev, "Open fault detected\n");
			goto unlock_mutex;
		}
		/*
		 * Checking LED fault status again if open_fault has been
		 * detected previously. Update open_fault status then the
		 * flash leds could be controlled again if the hardware
		 * status is recovered.
		 */
		rc = spmi_ext_register_readl(led->spmi_dev->ctrl,
			led->spmi_dev->sid,
			FLASH_LED_FAULT_STATUS(led->base), &val, 1);
		if (rc) {
			dev_err(&led->spmi_dev->dev,
				"Failed to read out fault status register\n");
			goto unlock_mutex;
		}

		led->open_fault = (val & FLASH_LED_OPEN_FAULT_DETECTED);
		if (led->open_fault) {
			dev_err(&led->spmi_dev->dev, "Open fault detected\n");
			goto unlock_mutex;
		}
	}

	if (!flash_node->flash_on && flash_node->num_regulators > 0) {
		rc = flash_regulator_enable(led, flash_node, true);
@@ -1804,7 +1826,7 @@ turn_off:
			goto exit_flash_led_work;
		}

		led->open_fault |= (val & FLASH_LED_OPEN_FAULT_DETECTED);
		led->open_fault = (val & FLASH_LED_OPEN_FAULT_DETECTED);
	}

	rc = qpnp_led_masked_write(led->spmi_dev,