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

Commit a81bbb3a authored by Kiran Gunda's avatar Kiran Gunda
Browse files

leds: qpnp-wled: Do not program the hybrid dimming register always



Currently hybrid dimming register is programmed always
irrespective of the dim_mode, which is not required. Also make
sure to initialize num_strings variable to '0' when the
led-string-list is empty.

Change-Id: I9a98767d79aabc3826831e378879cdff27f18a6b
Signed-off-by: default avatarKiran Gunda <kgunda@codeaurora.org>
parent 30545cd5
Loading
Loading
Loading
Loading
+21 −16
Original line number Diff line number Diff line
@@ -2090,22 +2090,26 @@ static int qpnp_wled_config(struct qpnp_wled *wled)
		return rc;

	/* Configure the HYBRID THRESHOLD register */
	if (wled->dim_mode == QPNP_WLED_DIM_HYBRID) {
		if (wled->hyb_thres < QPNP_WLED_HYB_THRES_MIN)
			wled->hyb_thres = QPNP_WLED_HYB_THRES_MIN;
		else if (wled->hyb_thres > QPNP_WLED_HYB_THRES_MAX)
			wled->hyb_thres = QPNP_WLED_HYB_THRES_MAX;

	rc = qpnp_wled_read_reg(wled, QPNP_WLED_HYB_THRES_REG(wled->sink_base),
		rc = qpnp_wled_read_reg(wled,
				QPNP_WLED_HYB_THRES_REG(wled->sink_base),
				&reg);
		if (rc < 0)
			return rc;
		reg &= QPNP_WLED_HYB_THRES_MASK;
		temp = fls(wled->hyb_thres / QPNP_WLED_HYB_THRES_MIN) - 1;
		reg |= temp;
	rc = qpnp_wled_write_reg(wled, QPNP_WLED_HYB_THRES_REG(wled->sink_base),
		rc = qpnp_wled_write_reg(wled,
				QPNP_WLED_HYB_THRES_REG(wled->sink_base),
				reg);
		if (rc)
			return rc;
	}

	/* Configure TEST5 register */
	if (wled->dim_mode == QPNP_WLED_DIM_DIGITAL) {
@@ -2642,9 +2646,10 @@ static int qpnp_wled_parse_dt(struct qpnp_wled *wled)
	else
		wled->max_strings = QPNP_WLED_MAX_STRINGS;

	temp_val = 0;
	prop = of_find_property(pdev->dev.of_node,
			"qcom,led-strings-list", &temp_val);
	if (!prop || !temp_val || temp_val > QPNP_WLED_MAX_STRINGS) {
	if (!prop || temp_val > QPNP_WLED_MAX_STRINGS) {
		dev_err(&pdev->dev, "Invalid strings info, use default");
		wled->num_strings = wled->max_strings;
		for (i = 0; i < wled->num_strings; i++)