summaryrefslogtreecommitdiff
path: root/sound/pci/hda/patch_cs8409.c
diff options
context:
space:
mode:
authorStefan Binding <sbinding@opensource.cirrus.com>2021-08-11 21:56:51 +0300
committerTakashi Iwai <tiwai@suse.de>2021-08-12 14:41:58 +0300
commit928adf0ebc7893ee228a06479b1b797779fd41a9 (patch)
tree388195a96249ae501637d126a8d2d6c52c6f2b10 /sound/pci/hda/patch_cs8409.c
parentfed0aaca0b0f204ca40b89b22b0e493ceb27d48e (diff)
downloadlinux-928adf0ebc7893ee228a06479b1b797779fd41a9.tar.xz
ALSA: hda/cs8409: Use timeout rather than retries for I2C transaction waits
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com> Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210811185654.6837-25-vitalyr@opensource.cirrus.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_cs8409.c')
-rw-r--r--sound/pci/hda/patch_cs8409.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c
index 897c48140d8b..9f6c51a5835a 100644
--- a/sound/pci/hda/patch_cs8409.c
+++ b/sound/pci/hda/patch_cs8409.c
@@ -140,24 +140,14 @@ static void cs8409_enable_i2c_clock(struct hda_codec *codec)
* @codec: the codec instance
*
* Wait for I2C transaction to complete.
- * Return -1 if transaction wait times out.
+ * Return -ETIMEDOUT if transaction wait times out.
*/
static int cs8409_i2c_wait_complete(struct hda_codec *codec)
{
- int repeat = 5;
unsigned int retval;
- do {
- retval = cs8409_vendor_coef_get(codec, CS8409_I2C_STS);
- if ((retval & 0x18) != 0x18) {
- usleep_range(2000, 4000);
- --repeat;
- } else
- return 0;
-
- } while (repeat);
-
- return -1;
+ return read_poll_timeout(cs8409_vendor_coef_get, retval, retval & 0x18,
+ CS42L42_I2C_SLEEP_US, CS42L42_I2C_TIMEOUT_US, false, codec, CS8409_I2C_STS);
}
/**