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

Commit 3ae0fd9f authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

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

parents a1ba6206 c455f79f
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018, 2021, The Linux Foundation. All rights reserved.
 */

#include <linux/module.h>
@@ -11,6 +11,8 @@
#include <linux/component.h>
#include <soc/soundwire.h>

#define SWR_MAX_RETRY 5

struct wcd937x_slave_priv {
	struct swr_device *swr_slave;
};
@@ -22,6 +24,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__);
@@ -37,7 +40,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",