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

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

Merge "swr-wcd-ctrl: update soundwire slave logical device number"

parents fac3091d 39a430ca
Loading
Loading
Loading
Loading
+22 −11
Original line number Diff line number Diff line
@@ -1291,6 +1291,7 @@ static int swrm_get_logical_dev_num(struct swr_master *mstr, u64 dev_id,
	u64 id = 0;
	int ret = -EINVAL;
	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(mstr);
	struct swr_device *swr_dev;

	if (!swrm) {
		pr_err("%s: Invalid handle to swr controller\n",
@@ -1304,20 +1305,30 @@ static int swrm_get_logical_dev_num(struct swr_master *mstr, u64 dev_id,
			    SWRM_ENUMERATOR_SLAVE_DEV_ID_2(i))) << 32);
		id |= swrm->read(swrm->handle,
			    SWRM_ENUMERATOR_SLAVE_DEV_ID_1(i));
		/*
		 * As pm_runtime_get_sync() brings all slaves out of reset
		 * update logical device number for all slaves.
		 */
		list_for_each_entry(swr_dev, &mstr->devices, dev_list) {
			if (swr_dev->addr == (id & SWR_DEV_ID_MASK)) {
				u32 status = swrm_get_device_status(swrm, i);

				if ((status == 0x01) || (status == 0x02)) {
					swr_dev->dev_num = i;
					if ((id & SWR_DEV_ID_MASK) == dev_id) {
			if (swrm_get_device_status(swrm, i) == 0x01) {
						*dev_num = i;
						ret = 0;
			} else {
				dev_err(swrm->dev, "%s: device is not ready\n",
					 __func__);
					}
			goto found;
					dev_dbg(swrm->dev, "%s: devnum %d is assigned for dev addr %lx\n",
						__func__, i, swr_dev->addr);
				}
			}
		}
	}
	dev_err(swrm->dev, "%s: device id 0x%llx does not match with 0x%llx\n",
		__func__, id, dev_id);
found:
	if (ret)
		dev_err(swrm->dev, "%s: device 0x%llx is not ready\n",
			__func__, dev_id);

	pm_runtime_mark_last_busy(&swrm->pdev->dev);
	pm_runtime_put_autosuspend(&swrm->pdev->dev);
	return ret;