Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2124341ybt; Fri, 3 Jul 2020 01:11:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUz3mW5IZWot6H9S9jqlZ86+ONqHM3o3nSXNm+7n6ALmsK2m1/DWE4E0iZwwC4BB7ZM1wg X-Received: by 2002:a05:6402:3113:: with SMTP id dc19mr38129072edb.20.1593763906702; Fri, 03 Jul 2020 01:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593763906; cv=none; d=google.com; s=arc-20160816; b=JVUOOjKgbcxarJeU5fnIPZ9HQr6MHG3YIosEzfk9asLSpPSrVBPfC/GHgtsRen6exm P3b96bGl6TSgXmCtZOMMSTC4UfsBFMItG77xKmwD3YF0m7/5hZ9zj2IjV93TCOXUkf2U kWVV2QqNzTGWN380Wm6B7CWMNpE3+xt5AG35btTbQ5wYh4fMDCl/iPiISHJMIIenFE9N ESZ4CNK50QGTn/IQl438S5+D9ZeQVqD2J52ShwH+YfvE+8adaa8i1BMC4AA5PHT5N9xT trm3P2pPG5heqPi1xvNEdbB/3gduBtREEc5h54rmiYy40E3HsFaMWFnQO0ZnUj8GBQYX wF0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=RhXU/shYl4I18iyGPVD6lf1/ryMOjlMTWXMnIVHwxHA=; b=mdEeT2k6V0tcUg+AsJzvi+ZvBQJOCM3yvW3j9jx6/oi6+QGW4JfcTwT8nDqxdDTKpb dcEDRliosvhEANSkw559Vt6pYrC2+NfGwLrwqmUU5L5Ho8eneCFAi50AfTZJ5PjDMsar 3cu+rM1hd9sojc85Vn2SYWYBnBFlqpUMvzdQ1R4z001SMQJDO4jtmkWw1D8KzAGCufFV 3mWMjSYAJY501gzEL444ajCr5lKI1qMMyR24rZO7Db3F6qyUtXy2EYv/JgaEHe71x34v IcW+/Hp3zgEE1aNiFM7rObJAIovWjK4ZJ4qElHS+sI65iECmNhgalea7RBJzxHFcZZqY 0nZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WHa7wIC9; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du6si9779876ejc.189.2020.07.03.01.11.23; Fri, 03 Jul 2020 01:11:46 -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=@chromium.org header.s=google header.b=WHa7wIC9; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726408AbgGCIKw (ORCPT + 99 others); Fri, 3 Jul 2020 04:10:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbgGCIKv (ORCPT ); Fri, 3 Jul 2020 04:10:51 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84183C08C5C1 for ; Fri, 3 Jul 2020 01:10:51 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id q15so31141805wmj.2 for ; Fri, 03 Jul 2020 01:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=RhXU/shYl4I18iyGPVD6lf1/ryMOjlMTWXMnIVHwxHA=; b=WHa7wIC9Cp235EQtCgtS/QrzR/3IT8+1JlGUE/lrcD+CFI5wqQG00Vn7R1Ex3A4Nty jmne9LDywJ5PqLiqzZfWFdPsu9YYHVs8sjrlNxe7wFStnRgN1Zw302Qb5iMp349s4/Dn yOfE2e4+hRLMzix1+FPOe66atzr05M9mW9OAI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=RhXU/shYl4I18iyGPVD6lf1/ryMOjlMTWXMnIVHwxHA=; b=osyTEavAiADyAdf4IVeVzWXlUZ7El0qpZH19dXnyamjGTqnKTEHv6LcL7QOiHBEqpc QdT2/oJjfCFDU92JigF+tMbupKdBnAidWfvoHLyd+fpQCF6jnwryUxIRIZThMWn4bb/Y Ivps8oRplo3MTN/orBvC5klzaLBXf3qwe2Yuza+LHpsKfdIZfF+Q5Mc71q1uq0OfDTdn kEl81JxUtppQY9M5Lbx4C7011jL5e4hjLoFTlqvok1jA1e1ezoEATe4x1wD/MI7jT8FC pCUsjbEGcQwKf9nVSZauhqlwvmfH1QQqocTwpwrY0XPGx0mbjXO+oftN+95Dnq3/Uj0O 4FxA== X-Gm-Message-State: AOAM532P0oSFUq63XNh1+dYQ9GagsnzoO6oG8OrVs0RRfeFgDFaSMk88 wQ/3i9Afce65hyglIER9dXUmSMIBnEqazLFazxVyqLmtKoY= X-Received: by 2002:a1c:e088:: with SMTP id x130mr34133709wmg.14.1593763850259; Fri, 03 Jul 2020 01:10:50 -0700 (PDT) MIME-Version: 1.0 References: <20200703071913.2358882-1-yuhsuan@chromium.org> In-Reply-To: From: Yu-Hsuan Hsu Date: Fri, 3 Jul 2020 16:10:39 +0800 Message-ID: Subject: Re: [PATCH v2] ASoC: cros_ec_codec: Log results when EC commands fail To: Tzung-Bi Shih Cc: Linux Kernel Mailing List , Cheng-Yi Chiang , Enric Balletbo i Serra , Guenter Roeck , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Benson Leung , ALSA development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tzung-Bi Shih =E6=96=BC 2020=E5=B9=B47=E6=9C=883=E6=97= =A5 =E9=80=B1=E4=BA=94 =E4=B8=8B=E5=8D=883:32=E5=AF=AB=E9=81=93=EF=BC=9A > > On Fri, Jul 3, 2020 at 3:19 PM Yu-Hsuan Hsu wrote: > > Log results of failed EC commands to identify a problem more easily. > > > > Replace cros_ec_cmd_xfer_status with cros_ec_cmd_xfer because the resul= t > > has already been checked in this function. The wrapper is not needed. > > Alternatively, you can still use cros_ec_cmd_xfer_status( ). I guess > it is okay to have 2 logs for an error. > > > diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_e= c_codec.c > > index 8d45c628e988e..a4ab62f59efa6 100644 > > --- a/sound/soc/codecs/cros_ec_codec.c > > +++ b/sound/soc/codecs/cros_ec_codec.c > > @@ -90,10 +90,17 @@ static int send_ec_host_command(struct cros_ec_devi= ce *ec_dev, uint32_t cmd, > > if (outsize) > > memcpy(msg->data, out, outsize); > > > > - ret =3D cros_ec_cmd_xfer_status(ec_dev, msg); > > + ret =3D cros_ec_cmd_xfer(ec_dev, msg); > > if (ret < 0) > I am thinking of if it is a better solution to print msg->result here. The problem is the msg->result is not always meaningful. In cros_ec_cmd_xfer_status, we know that the msg->result is meaningful only when ret =3D=3D 0. Therefore, we can not print the msg->result directly here. In addition, adding a conditional operator here to check whether ret is -EPROTO is not a good way, either. We should consider the situation that cros_ec_cmd_xfer may return -EPROTO directly. > > > goto error; > > > > + if (msg->result !=3D EC_RES_SUCCESS) { > > + dev_err(ec_dev->dev, "Command %d failed: %d\n", cmd, > > + msg->result); > > + ret =3D -EPROTO; > > + goto error; > > + } > So that you don't need this block.