Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3395509pxf; Mon, 15 Mar 2021 08:39:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyutz7fFd/D8o8OodxjHpab0QJve0ZVj+PJB9dW8MU8WuQdj5OZLjVKJ6jrK1E9ZOXJHNF6 X-Received: by 2002:a17:906:1a44:: with SMTP id j4mr24609494ejf.401.1615822779263; Mon, 15 Mar 2021 08:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615822779; cv=none; d=google.com; s=arc-20160816; b=wiAJhZ7ULguuEkrdHK2PEMaPHdqyK+sAkyrWl18fY0ZVm0aP3mzldq6835F0KzZydi 7B756NWYy92GwLqBAy+SxKFrRgZGZ1cDc2Wm4JRleJRN5ozrGI/Ophv/nyBjSe3eeJZW G/LNTubL3KRNqcMuWydONdOolbs+t+pe75hfged2udQCowa12xhznvM2//oT8YgZeKxN Ce4OoZ6b5Wxi3/IwaokV68d/R3RaCu8S/nXEYRD4Dk1/OaZl7+IdjQri8twFtJnbJ46C IX5h8q5tJRoUbVghwTGL7kirE6AyU6PC1HT63MnmvK+CyyAw6PbuRTEizDUCjfY6QnQh ARVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=g8rloe0vgTg2LzKu5YWaK0xwsmf5wmO0oYcImlEhJtw=; b=i9XspPPPyp0hET9XnXQQbAthMQ4+O1qyyZb6Pc49CeAt74dKao/rkTmJDGjNzy1Ip5 p7uP1tGWzyQjk0b7797lwfMvkrYGB5bhNnHRVnbttOIRG/lzTSYTYyxSK/On/YL5wl+p Hpsici8jIiWyPJKttN2BxYgooSPhzG9NFAxQOMFdS04mCzNRrnIELdi6HzsRZvwdP0pm DTQvvhBaLGrnPPwF+YCtVM/cAvyT9IhhHKgKPO1H4l+3QT7vXf+jHa1xNCeO0UnarhSC 3y1KQFTC0uzv7qnkP79xtJqW9ZSV5X0Oi7E1frzI294BSosTVeNEte0yYVL2FgmfggHO jXcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=L9UFULic; 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 q16si11718724ejt.685.2021.03.15.08.39.16; Mon, 15 Mar 2021 08:39:39 -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=L9UFULic; 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 S229764AbhCOPiK (ORCPT + 99 others); Mon, 15 Mar 2021 11:38:10 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:63178 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231785AbhCOPhr (ORCPT ); Mon, 15 Mar 2021 11:37:47 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12FFFxwn008883; Mon, 15 Mar 2021 10:37:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=PODMain02222019; bh=g8rloe0vgTg2LzKu5YWaK0xwsmf5wmO0oYcImlEhJtw=; b=L9UFULicz1nA5C15zBeRwN6+6FTHDu41/15vwQxqkgvHsTSGBmk3f7vNXS6o//R4qaF4 7XxW8Scu3Iv0UDLzLzNfAXGy07A2hHanugY7x+tDx3pIeX7sN+eoUQLchaMydEQzYoIY QPajqtBR9HKaZc7ot1fk8v23eveUaEcibeQVI9dhTera16bGhoeMJvl9KDJTkxSmHTCk BOUuzErKplCYahFhfxI3bGp5f12Na3r7A8WOK5Ue6g9Hyz+cEpwA8Zl/W4UwfG07fLTf KKdnRlcScSKFGvN9hVcNnLUmA0T2CAAZbWJOjet60sbw3lgQG9+qExdgkriNd9vO7WtQ kQ== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 3790bs26vn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 15 Mar 2021 10:37:35 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 15 Mar 2021 15:37:33 +0000 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.2176.2 via Frontend Transport; Mon, 15 Mar 2021 15:37:33 +0000 Received: from [198.90.238.45] (unknown [198.90.238.45]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 1F19B11D6; Mon, 15 Mar 2021 15:37:33 +0000 (UTC) Subject: Re: [PATCH v1 1/4] ALSA: hda/cirrus: Add error handling into CS8409 I2C functions To: Takashi Iwai CC: , , Stefan Binding , Takashi Iwai , References: <20210313113410.90088-1-vitalyr@opensource.cirrus.com> <20210313113410.90088-2-vitalyr@opensource.cirrus.com> From: Vitaly Rodionov Message-ID: Date: Mon, 15 Mar 2021 15:37:32 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 spamscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103150110 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/03/2021 7:45 am, Takashi Iwai wrote: Hi Takashi, Thanks a lot for your comments. > On Sat, 13 Mar 2021 12:34:07 +0100, > Vitaly Rodionov wrote: >> @@ -1508,7 +1508,7 @@ static void cs8409_enable_i2c_clock(struct hda_codec *codec, unsigned int flag) >> static int cs8409_i2c_wait_complete(struct hda_codec *codec) >> { >> int repeat = 5; >> - unsigned int retval = 0; >> + unsigned int retval; >> >> do { >> retval = cs_vendor_coef_get(codec, CIR_I2C_STATUS); >> @@ -1520,78 +1520,82 @@ static int cs8409_i2c_wait_complete(struct hda_codec *codec) >> >> } while (repeat); >> >> - return repeat > 0 ? 0 : -1; >> + return !!repeat; >> } > If the return value of the function has changed, it's nicer to > comment, e.g. a brief function description would be helpful. > Also now this looks rather like a bool? Yes, agreed , we will add comments to describe parameters and return values > > >> @@ -1881,13 +1896,15 @@ static void cs8409_jack_unsol_event(struct hda_codec *codec, unsigned int res) >> reg_hs_status = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1124, 1); >> reg_ts_status = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130f, 1); >> >> - /* Clear interrupts */ >> + /* Clear interrupts, by reading interrupt status registers */ >> cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1b7b, 1); >> - cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1308, 1); >> - cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130f, 1); > Why those two calls are removed? This 2 call are redundant as we already did read these 2 registers in a code few lines above. > >> mutex_unlock(&spec->cs8409_i2c_mux); >> >> + /* If status values are < 0, read error has occurred. */ >> + if ((reg_cdc_status < 0) || (reg_hs_status < 0) || (reg_ts_status < 0)) >> + return; > Parentheses around the comparison are superfluous, you can remove > them. Will fix. > > thanks, > > Takashi