コード例 #1
0
ファイル: qcedev.c プロジェクト: CL0SeY/i957kernel
static int qcedev_lock_ce(struct qcedev_control *podev)
{
	int ret = 0;

	mutex_lock(&send_cmd_lock);
	if (podev->ce_lock_count == 0) {
		int response = -CE_BUSY;
		int i = 0;

		do {
			if (qcedev_scm_cmd(
				podev->ce_hw_support.shared_ce_resource,
				QCEDEV_CE_LOCK_CMD, &response)) {
				response = -EINVAL;
				break;
			}
		} while ((response == -CE_BUSY) && (i++ < NUM_RETRY));

		if ((response == -CE_BUSY) && (i >= NUM_RETRY)) {
			ret = -EUSERS;
		} else {
			if (response < 0)
				ret = -EINVAL;
		}
	}
	if (ret == 0)
		podev->ce_lock_count++;
	mutex_unlock(&send_cmd_lock);
	return ret;
}
コード例 #2
0
static int qcedev_lock_ce(struct qcedev_control *podev)
{
	if ((podev->ce_hw_support.ce_shared) && (podev->ce_locked == false)) {
		int response = -CE_BUSY;
		int i = 0;

		do {
			if (qcedev_scm_cmd(
				podev->ce_hw_support.shared_ce_resource,
				QCEDEV_CE_LOCK_CMD, &response)) {
				response = -EINVAL;
				break;
			}
		} while ((response == -CE_BUSY) && (i++ < NUM_RETRY));

		if ((response == -CE_BUSY) && (i >= NUM_RETRY))
			return -EUSERS;
		if (response < 0)
			return -EINVAL;

		podev->ce_locked = true;
	}

	return 0;
}
コード例 #3
0
ファイル: qcedev.c プロジェクト: CL0SeY/i957kernel
static int qcedev_unlock_ce(struct qcedev_control *podev)
{
	int ret = 0;

	mutex_lock(&send_cmd_lock);
	if (podev->ce_lock_count == 1) {
		int response = 0;

		if (qcedev_scm_cmd(podev->ce_hw_support.shared_ce_resource,
					QCEDEV_CE_UNLOCK_CMD, &response)) {
			pr_err("Failed to release CE lock\n");
			ret = -EIO;
		}
	}
	if (ret == 0) {
		if (podev->ce_lock_count)
			podev->ce_lock_count--;
		else {
			/* We should never be here */
			ret = -EIO;
			pr_err("CE hardware is already unlocked\n");
		}
	}
	mutex_unlock(&send_cmd_lock);

	return ret;
}
コード例 #4
0
static int qcedev_unlock_ce(struct qcedev_control *podev)
{
	if ((podev->ce_hw_support.ce_shared) && (podev->ce_locked == true)) {
		int response = 0;

		if (qcedev_scm_cmd(podev->ce_hw_support.shared_ce_resource,
					QCEDEV_CE_UNLOCK_CMD, &response)) {
			printk(KERN_ERR "%s Failed to release CE lock\n",
				__func__);
			return -EUSERS;
		}
		podev->ce_locked = false;
	}
	return 0;
}