Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4712602pxt; Wed, 11 Aug 2021 12:15:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUOGXkuz2Y15MwD6CeqNc2nJmgBo2VXb4mQ9r7kMggzRxbT5MUsnlaUvl/lSFM7qrktn8k X-Received: by 2002:a6b:e00c:: with SMTP id z12mr106484iog.27.1628709355584; Wed, 11 Aug 2021 12:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628709355; cv=none; d=google.com; s=arc-20160816; b=jvHpwxMXM8H11j+12OAW5S1783KEV7cXF6E2BzKrq9KWyzMgoO2h7J2hNHKA8ovdTR VkLfQGAT9ow624M7MAK6hzyO0thVZvi0o2MRwKtXkEbzWHx5VnPsbXE03tFGrE09u+On GR8oPsX+q2bwOe8/yKyatz63zprPt+g22SkRyP5DGX0ii0FmOuf5BF+TV8EKU6ECWPLK 4E79OdcuWuyU15czI79kBYwMKYd4kAXIxl5K0Jqlrqls5yriBcrFcMRa2qSR/Fn3gDyp KHrN2281ULpyklKsDxOz3gCtB7SpLLxgTpLJc1tlNo6YsbJA5+/Ui0KIs4wLL9AtRmwM RVOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=W5yQLmZCTpE/L0nB3SnuFh8y1PcoLQ4rGuID/c2G9Lo=; b=X8VJxPBPKjYG6GEJb7e9y9ceEtTpaZQT0oEyllC6t4zX1ey16YbrT4xzvBfvhLo9WE 24P6d+qmZVooJpbW/BkTBGMw+0w8wrmV5zgUGqVh3lvKcwEXx+gxzWK3AYtVAaAvDx2p yN3UIdUiQCN5FlCGS3ybw+Lwg90QbZT9EeU4AneAaeEI34RYFjYoAl0q1cvS65N7nD2R 5ytISeNKQdxt5RyBP9VVm/orCa0CJ3QyvkJ4bhq8QyfsK9KWd8bCZ+8Ad9nBGWGr7PaS mM2+YUuy7I9Xkh4aDtE6HXK/34NHJLwgw1ULDmcKLAiZuGO+h3NyIFRDI6C8WKLjTe+h ZZZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=NXnx8vlG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g6si299632ilf.57.2021.08.11.12.15.44; Wed, 11 Aug 2021 12:15:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=NXnx8vlG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231786AbhHKTNw (ORCPT + 99 others); Wed, 11 Aug 2021 15:13:52 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:4830 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231760AbhHKTNu (ORCPT ); Wed, 11 Aug 2021 15:13:50 -0400 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 17B9hd04013981; Wed, 11 Aug 2021 14:12:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=W5yQLmZCTpE/L0nB3SnuFh8y1PcoLQ4rGuID/c2G9Lo=; b=NXnx8vlGr56nhE4O1EgwCwxRkvxFe7Hh6IdVFmv5inLBDbGrpM7lxiXkYXu5hWIv+dMv NUVVF59STPKF/1jVuyt8Ordv2vXzXV+ZTGTErlFTLqAFpFAQz0cFdCJoDdBk1K56zrsi KvBurdU+pizVNu9nERgVkRzz2sTGQ7EUCXo0qDejLu0SlvIkOykcuXu6E50EjgOqkjyE HT3P4xS13TmB845LskEmEkDz4WYGQ+MKxRcUhAcDM9w3VFba2s1sgx0UpmO5MbZSfE2o P+pqlx2k011pHDwZ0aDjnhK76Z48wUlZ6TTLFIwzhaw5f6RK8yTOcjn7hx1ks7jfMNJR Ug== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 3acc5ngpgw-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 11 Aug 2021 14:12:42 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Wed, 11 Aug 2021 19:57:32 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.12 via Frontend Transport; Wed, 11 Aug 2021 19:57:32 +0100 Received: from vitaly-Inspiron-5415.ad.cirrus.com (unknown [198.90.238.180]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 5CA3946E; Wed, 11 Aug 2021 18:57:32 +0000 (UTC) From: Vitaly Rodionov To: Jaroslav Kysela , Takashi Iwai CC: , , , Stefan Binding Subject: [PATCH v4 24/27] ALSA: hda/cs8409: Use timeout rather than retries for I2C transaction waits Date: Wed, 11 Aug 2021 19:56:51 +0100 Message-ID: <20210811185654.6837-25-vitalyr@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210811185654.6837-1-vitalyr@opensource.cirrus.com> References: <20210811185654.6837-1-vitalyr@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: AaBnK1JW3IFpeGoo_jDhfYGK90bG7LPX X-Proofpoint-GUID: AaBnK1JW3IFpeGoo_jDhfYGK90bG7LPX X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 phishscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 impostorscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108110132 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Binding Signed-off-by: Stefan Binding Signed-off-by: Vitaly Rodionov --- Changes in v2: - No changes Changes in v3: - No changes Changes in v4: - No changes sound/pci/hda/patch_cs8409.c | 16 +++------------- sound/pci/hda/patch_cs8409.h | 2 ++ 2 files changed, 5 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); } /** diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h index 2208be2ffad1..71dbbd8e2f3b 100644 --- a/sound/pci/hda/patch_cs8409.h +++ b/sound/pci/hda/patch_cs8409.h @@ -231,6 +231,8 @@ enum cs8409_coefficient_index_registers { #define CS42L42_HSTYPE_MASK (0x03) #define CS42L42_JACK_INSERTED (0x0C) #define CS42L42_JACK_REMOVED (0x00) +#define CS42L42_I2C_TIMEOUT_US (20000) +#define CS42L42_I2C_SLEEP_US (2000) /* Dell BULLSEYE / WARLOCK / CYBORG Specific Definitions */ -- 2.25.1