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

Commit 52b8b3ff authored by Vatsal Bucha's avatar Vatsal Bucha Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: wcd937x_slave: Add retry while getting logical addr for wcd937x slave



Add retry while getting logical addr for wcd937x slave.

Change-Id: Iff3f6a071c13f8bdccc72da69e95432be2d4f90a
Signed-off-by: default avatarVatsal Bucha <vbucha@codeaurora.org>
parent 6fec0645
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -9,6 +9,8 @@
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
 */

#include <linux/module.h>
@@ -18,6 +20,8 @@
#include <linux/kernel.h>
#include <linux/component.h>
#include <soc/soundwire.h>
#include <linux/delay.h>
#define SWR_MAX_RETRY 5

struct wcd937x_slave_priv {
	struct swr_device *swr_slave;
@@ -30,6 +34,7 @@ static int wcd937x_slave_bind(struct device *dev,
	struct wcd937x_slave_priv *wcd937x_slave = NULL;
	uint8_t devnum = 0;
	struct swr_device *pdev = to_swr_device(dev);
	int retry = SWR_MAX_RETRY;

	if (pdev == NULL) {
		dev_err(dev, "%s: pdev is NULL\n", __func__);
@@ -45,7 +50,12 @@ static int wcd937x_slave_bind(struct device *dev,

	wcd937x_slave->swr_slave = pdev;

	do {
		/* Add delay for soundwire enumeration */
		usleep_range(100, 110);
		ret = swr_get_logical_dev_num(pdev, pdev->addr, &devnum);
	} while (ret && --retry);

	if (ret) {
		dev_dbg(&pdev->dev,
				"%s get devnum %d for dev addr %lx failed\n",