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=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 E7FA3C433E1 for ; Wed, 29 Jul 2020 23:29:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C45422074B for ; Wed, 29 Jul 2020 23:29:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="QD2LhtSL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728028AbgG2X3e (ORCPT ); Wed, 29 Jul 2020 19:29:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726718AbgG2X3e (ORCPT ); Wed, 29 Jul 2020 19:29:34 -0400 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B689C061794 for ; Wed, 29 Jul 2020 16:29:34 -0700 (PDT) Received: by mail-qv1-xf44.google.com with SMTP id t6so6787687qvw.1 for ; Wed, 29 Jul 2020 16:29:34 -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; bh=Ag+H1hGpAomnJAeq4yPJoXLabOM0ywnHRdghtWviE98=; b=QD2LhtSLWQP2TNjnoS6mqe5UA59jgN6HCy0aixdV7r2I3Q8LEf8OrJM9/XFxaYNCcw uY2t0zTQv3j7VlE0kUPrSVjp+11jncgubttjbEX4ea9KW03tLTBubx4v3oNnKVf+itvm 9hRts8LGnfKWgqhOtqyOgmuWhSeaQP2Z278L0= 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; bh=Ag+H1hGpAomnJAeq4yPJoXLabOM0ywnHRdghtWviE98=; b=csWzZCvIjsSArkf439wmg7+2zrtt5ymcodemqLsHJkqYccutsK1wRge/9AH8290q9o LqTb3siBZ+Bk83rQzjPykeHTQwW+/NOb1JmZOtuEIiGa0oFH7WtGmAJMX0X923TfYhMk 9G37wNrnEIkg1p9H/Qcf9lK9oLQwyDGknFMnx8o2EOPCGyhpCPv44gS88wVUEUJTat+/ yRCsYQUJMxqyAWPhUTamhs7ymESsm80KxsRgVbfmcYlE6jTfSsPRzCC4DGV32y9KD6g9 /hFoDVbKQqHaiT/XjxEKC3ZVDnutY6zlKlw2UJ6zw3ZD4q7u63urs25w3skXEN2HqvOZ HXPQ== X-Gm-Message-State: AOAM532wOq+qa1BVHygyny6s4ekR4kDJPc7IJOdaNR3YUVEzN1GWVb9p J6MH5pWbgKZniSZQb82U8GIb4PxRAM8= X-Google-Smtp-Source: ABdhPJxKrvzEMkOYwhft91xehzBr9T8QMIfj9gVtbTFPF/D+LKC94rHHNrn8oQfUvct3Ev2fjWkPKg== X-Received: by 2002:a0c:b665:: with SMTP id q37mr317388qvf.75.1596065371619; Wed, 29 Jul 2020 16:29:31 -0700 (PDT) Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com. [209.85.222.169]) by smtp.gmail.com with ESMTPSA id z126sm1741802qkc.58.2020.07.29.16.29.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jul 2020 16:29:30 -0700 (PDT) Received: by mail-qk1-f169.google.com with SMTP id x69so24049685qkb.1 for ; Wed, 29 Jul 2020 16:29:29 -0700 (PDT) X-Received: by 2002:a05:620a:5f7:: with SMTP id z23mr20316631qkg.206.1596065368695; Wed, 29 Jul 2020 16:29:28 -0700 (PDT) MIME-Version: 1.0 References: <20200726220101.29059-1-linux@roeck-us.net> <20200726220101.29059-7-linux@roeck-us.net> <20200729222150.GA970863@google.com> In-Reply-To: From: Brian Norris Date: Wed, 29 Jul 2020 16:29:16 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 6/6] platform/chrome: cros_ec_proto: Convert EC error codes to Linux error codes To: Guenter Roeck Cc: Enric Balletbo i Serra , Jonathan Cameron , Benson Leung , Dmitry Torokhov , Thierry Reding , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Gwendal Grignou , linux-iio@vger.kernel.org, Linux Kernel , linux-input@vger.kernel.org, linux-pwm , Yu-Hsuan Hsu , Prashant Malani Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 29, 2020 at 4:22 PM Guenter Roeck wrote: > On 7/29/20 3:21 PM, Brian Norris wrote: > > On Sun, Jul 26, 2020 at 03:01:01PM -0700, Guenter Roeck wrote: > >> --- a/drivers/platform/chrome/cros_ec_proto.c > >> +++ b/drivers/platform/chrome/cros_ec_proto.c > > ^^ Maybe we want to double check 'ret != 0'? Or maybe > > > > ret = cros_ec_error_map[result]; > > if (!ret) { > > 'ret' won't ever be 0 here. Above: > && cros_ec_error_map[result] > > and below: > > else > ret = -EPROTO; Ah, I'm reading too quickly. You're correct, sorry. > > ret = -EPROTO; > > dev_err(..., "Unexpected EC result code %d\n", result); > > } > > > > ? Could even be WARN_ON(), since this would be an actionable programming > > error, not exactly an external factor. Or maybe I'm being paranoid, and > > future programmers are perfect. > > > I think, if anything, we might consider adding the message below (result >= > ARRAY_SIZE(cros_ec_error_map) is just as bad). Not sure myself. I am > open to adding it if people think it would be useful/desirable. No, my primary motivation was that I thought the logic left room for error if there were holes. I was mistaken on that point. Secondarily, it was also potentially useful to point out when we fell into those holes. I'm not sure logging the warning is that important. Generally, we only care about a handful of result codes, and as long as the rest don't end up as "success", I think we're in OK shape. Sorry for the noise. Here's my tag (which given my misreading so far, should probably have a heavy discount on its value): Reviewed-by: Brian Norris