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

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

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

parents b8dc6acb bd34b42e
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,