Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3092791pxf; Mon, 15 Mar 2021 00:46:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuzLqC+78IQgOqrAglxnkkOjycO60/kAiumC8HATWI584Ica447au45/ZZzR+5bTTc/Y4j X-Received: by 2002:a17:906:130c:: with SMTP id w12mr21978810ejb.253.1615794394598; Mon, 15 Mar 2021 00:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615794394; cv=none; d=google.com; s=arc-20160816; b=kxNsm+5FTKZof/Eqf07yrXfeamWLDQYMyMl0e8W0koW94Yt7dUTXExSqBFDZIBdGYF oM+4FTZ5+CPy+IP3E6IgDKBEFmNGNQBkHz6bnYZ/53BWcfD9nTK56H+vaIMug8vvkki5 AjHsfC795IS9eErRw+UTsHq/IzALuuzh2OJjdltQ9fzyTW9/+0RZMyYWwwmoGBliiCfy /yS+t05UIuqfVHqBapIAjCltcZNFDei+26umsJB+udkRkjySkJK15e4fUkzpAaF9Y5ts B8YBWmgUfzAFMRZ3dgPm10u3TVirD8Xkad+2GR9yI2Te7Pv1iR0LnxGoulA8c1JZmwNZ UECg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=/lHWDcYzjT60Cc8uc6gnjPnXc9dMMTIfCf7KkSV6ulw=; b=o/cdnM/g2FJ2hNp0KBjpl5DIddWnLo4GVEOKccWmzfMaOySelpo/j9KYcKUXfqywz0 C2Nqit+cIRncdNviJ7F73ByZJn5t1aOkht0C3i1t46Vt4kxyDy1NEKHubhnecWAOCX/l MFkEwp0BTKFPxJx3l4vmzpmyCX8tuLUWUY30eQhcFo+1UwYmOVcCy+7OJdtB3Ll05kv/ zV6jUj2RcD4Csi0OSDhChAkx7MXdV7pCF/TgX/bEIOURLEukVZZoN1iShx2mMoy6lWb0 KGpvuG6/5QhL8IVcNQOMMLY3qlRYXJhZ6/9hlQ3mAVgYtl+MZ8oxCdA+aX4Zd9ve7JcQ Vrsw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a4si10535301ejy.263.2021.03.15.00.46.12; Mon, 15 Mar 2021 00:46:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230053AbhCOHpH (ORCPT + 99 others); Mon, 15 Mar 2021 03:45:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:43114 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230159AbhCOHpB (ORCPT ); Mon, 15 Mar 2021 03:45:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B38CBABD7; Mon, 15 Mar 2021 07:45:00 +0000 (UTC) Date: Mon, 15 Mar 2021 08:45:00 +0100 Message-ID: From: Takashi Iwai To: Vitaly Rodionov Cc: Jaroslav Kysela , Takashi Iwai , , , , Stefan Binding Subject: Re: [PATCH v1 1/4] ALSA: hda/cirrus: Add error handling into CS8409 I2C functions In-Reply-To: <20210313113410.90088-2-vitalyr@opensource.cirrus.com> References: <20210313113410.90088-1-vitalyr@opensource.cirrus.com> <20210313113410.90088-2-vitalyr@opensource.cirrus.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > @@ -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? > 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. thanks, Takashi