From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E2F9C433E9 for ; Mon, 15 Mar 2021 07:45:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 407EF64E6B for ; Mon, 15 Mar 2021 07:45:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230151AbhCOHpI (ORCPT ); Mon, 15 Mar 2021 03:45:08 -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