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

Commit 5bea73a3 authored by Jeyaprakash Soundrapandian's avatar Jeyaprakash Soundrapandian Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: sensor: Add lock procetion for pinctrl operation" into dev/msm-4.14-camx

parents 3616118a ae7c45aa
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -178,8 +178,10 @@ int cam_res_mgr_shared_pinctrl_init(void)
		return 0;
	}

	mutex_lock(&cam_res->gpio_res_lock);
	if (cam_res->pstatus != PINCTRL_STATUS_PUT) {
		CAM_DBG(CAM_RES, "The shared pinctrl already been got.");
		mutex_unlock(&cam_res->gpio_res_lock);
		return 0;
	}

@@ -190,6 +192,7 @@ int cam_res_mgr_shared_pinctrl_init(void)
	if (IS_ERR_OR_NULL(pinctrl_info->pinctrl)) {
		CAM_ERR(CAM_RES, "Pinctrl not available");
		cam_res->shared_gpio_enabled = false;
		mutex_unlock(&cam_res->gpio_res_lock);
		return -EINVAL;
	}

@@ -200,6 +203,7 @@ int cam_res_mgr_shared_pinctrl_init(void)
		CAM_ERR(CAM_RES,
			"Failed to get the active state pinctrl handle");
		cam_res->shared_gpio_enabled = false;
		mutex_unlock(&cam_res->gpio_res_lock);
		return -EINVAL;
	}

@@ -210,10 +214,10 @@ int cam_res_mgr_shared_pinctrl_init(void)
		CAM_ERR(CAM_RES,
			"Failed to get the active state pinctrl handle");
		cam_res->shared_gpio_enabled = false;
		mutex_unlock(&cam_res->gpio_res_lock);
		return -EINVAL;
	}

	mutex_lock(&cam_res->gpio_res_lock);
	cam_res->pstatus = PINCTRL_STATUS_GOT;
	mutex_unlock(&cam_res->gpio_res_lock);

@@ -313,6 +317,7 @@ int cam_res_mgr_shared_pinctrl_select_state(bool active)
			pinctrl_info->gpio_state_suspend);
		cam_res->pstatus = PINCTRL_STATUS_SUSPEND;
	}

	mutex_unlock(&cam_res->gpio_res_lock);

	return rc;
@@ -379,12 +384,14 @@ static bool cam_res_mgr_gpio_is_shared(uint gpio)
	bool found = false;
	struct cam_res_mgr_dt *dt = &cam_res->dt;

	mutex_lock(&cam_res->gpio_res_lock);
	for (; index < dt->num_shared_gpio; index++) {
		if (gpio == dt->shared_gpio[index]) {
			found = true;
			break;
		}
	}
	mutex_unlock(&cam_res->gpio_res_lock);

	return found;
}
@@ -441,13 +448,14 @@ int cam_res_mgr_gpio_request(struct device *dev, uint gpio,
		INIT_LIST_HEAD(&gpio_res->list);
		INIT_LIST_HEAD(&gpio_res->dev_list);

		mutex_lock(&cam_res->gpio_res_lock);
		rc = cam_res_mgr_add_device(dev, gpio_res);
		if (rc) {
			kfree(gpio_res);
			mutex_unlock(&cam_res->gpio_res_lock);
			return rc;
		}

		mutex_lock(&cam_res->gpio_res_lock);
		list_add_tail(&gpio_res->list, &cam_res->gpio_res_list);
		mutex_unlock(&cam_res->gpio_res_lock);
	}