Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp485682yba; Wed, 3 Apr 2019 12:41:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgErghaAX8qG/N/YwjDN9tFDdL7PiOoEOw0jhnVJvwFVaw419WM+jYQJ6XL7nkSdPITrgH X-Received: by 2002:a63:2ad4:: with SMTP id q203mr1507320pgq.43.1554320501218; Wed, 03 Apr 2019 12:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554320501; cv=none; d=google.com; s=arc-20160816; b=TtAVwQx2dWzidYjulZyCoDFUDKLtdXrxU4cJyTE66BU6OdcSFFtYIV+zdCB0+7ArRH KYVNBMSVjcXBLh4BNZfelDbvbAy8yTCCmbUH/flJyOUwKod/8q/4bVaOEWldeQyqmFv6 eA0OsuUKhepNxyi7MPvyJZ5mkbkHQhehkXxdvlqihZHB7FOXdA4ukB3pZbHgQtWGBlwh D3hmNI9y5O1AT+OkPBnr0Sg0I+5MhgRPzCeIUtVGc+nRmd+Yo2ApzXkb2bos35EjzY4B B0bNr+YKflmRPOEzzmOT5r2ELn5JawFdMsHz6W62zJVE/HcdFCBFdPxqoHu3qCaTez8W fQzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=w6htbD7bpeSSbPwrNrd992xBMhL5gvuzlwbreQ35tk4=; b=aOBN8CcuDo2adXp9Ne3hWtJMdriA1S+KMgpQMbvfpAsg2Kr0yMgkfHLYxFNpuk90RO hcnHdbHeI12pczlwov1YA5bvtLfLDq34W05Ri7O+Yp9i89ZM2YdrvsWqUddpCQ5KXQX7 WDIUBBcSuy9FNNxk0H2CF24FdSxPtQRvCvFyrpnu+FEc7QlXx9UshFrS1pGqwpltf0l7 PoE4CM45s/6lPli8R9c4C9hBlDpFaJ6ijaf5xqfSwEFdSg2F/PJLnKKchwTGAvTKRYd/ dFOvpQo6LOwUQCuU4oz3hgukYJGcBmeuYyq6QfTDw1BMi2kqI09WieH7fsV6HZqh29kK 5wWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FUQ1YtFp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h11si15734714plk.270.2019.04.03.12.41.24; Wed, 03 Apr 2019 12:41:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FUQ1YtFp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726218AbfDCTkt (ORCPT + 99 others); Wed, 3 Apr 2019 15:40:49 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:44107 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726144AbfDCTkt (ORCPT ); Wed, 3 Apr 2019 15:40:49 -0400 Received: by mail-io1-f66.google.com with SMTP id u12so15097376iop.11 for ; Wed, 03 Apr 2019 12:40:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w6htbD7bpeSSbPwrNrd992xBMhL5gvuzlwbreQ35tk4=; b=FUQ1YtFpa1VkYxxv9c0Fj/KiOe525ATJ38i+fKTtgcwPqRq8IQn4bZMTywiWlchnGE 92T9sudVzcNSbD2bQGR8Azuogj9vu+S8feDeSulpjbazTg0dLauYxrZQBAFRLAV/WBWx jF4bzbnWx2FkIRuVv36EmSggOYcFmETO/+PhmHY/YuGlGzqHm09C5vprVhgw7uQCgPqm 9kEf+KlqRSbpNSJlD+BclxkptlT+dpyc5Wo9VufuVcEeFe9iUVyeXsmAjhYa3rm42SuR dMWiDtwAE8y6B+uTHsZoqJmI5R35lcL14SCyTbzCoZuNrKKNd5SuY98o093nYAG/hShr y5vw== 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=w6htbD7bpeSSbPwrNrd992xBMhL5gvuzlwbreQ35tk4=; b=MC8Zn51yrsLxWQCMLcSOB5N0m7FvEGj/jSimyVy4b1Hk+aPj1hie861l1w8TujRawf lfDVYFMeQsuo/WbG1wAlaJc68AAnjqJjbHACNHCCMnO/h6zpZMv8R9+ajCXIEItmSi69 0HiF2LjGAyWjYzZW5062pwPpt3xD7wA2FDa0Qmg4VwcRHZB5HVrsLy8fI9Y7i41bC3Vg 0bfM+3RzgauAjspYps5ap+ytwJBfLpyEuThvXkv3pNVW7LSsQ5iszaigyU3DCLJj8YQZ i0wDG9YGZXWHGerLATukvJM06tq4Ot+t1cdrFfWsln5KzN/Ndy9MVVdDJzLHawJ8mAsG xWuw== X-Gm-Message-State: APjAAAXIYDT62z0iNfbHe1jGu+ioY9gU6fWteqipBCCSb4UAqODDgUdJ omP/YB9MqYvzHRKRSk7gRoAajM0TKzTGcFmq+/xx2g== X-Received: by 2002:a5d:8543:: with SMTP id b3mr1386678ios.234.1554320448154; Wed, 03 Apr 2019 12:40:48 -0700 (PDT) MIME-Version: 1.0 References: <20190403183048.56750-1-egranata@chromium.org> In-Reply-To: From: Enrico Granata Date: Wed, 3 Apr 2019 12:40:37 -0700 Message-ID: Subject: Re: [PATCH] mfd: cros_ec: check for NULL transfer function To: Guenter Roeck Cc: Enrico Granata , Benson Leung , Guenter Roeck , Gwendal Grignou , Alexandru M Stan , Enric Balletbo i Serra , linux-kernel 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 I can certainly add a "did_print_error" flag or some such, but in practice, if the transfer function is NULL, the initial handshake will fail, and this will in turn cause EC registration to fail, and no further communication should occur, so no further log entries will be printed. Thanks Enrico Granata | egranata@google.com | ChromeOS | MTV1600 On Wed, Apr 3, 2019 at 11:51 AM Guenter Roeck wrote: > > On Wed, Apr 3, 2019 at 11:31 AM wrote: > > > > From: Enrico Granata > > > > As new transfer mechanisms are added to the EC codebase, they may > > not support v2 of the EC protocol. > > > > If the v3 initial handshake transfer fails, the kernel will try > > and call cmd_xfer as a fallback. If v2 is not supported, cmd_xfer > > will be NULL, and the code will end up causing a kernel panic. > > > > Add a check for NULL before calling the transfer function, along > > with a helpful comment explaining how one might end up in this > > situation. > > > > Signed-off-by: Enrico Granata > > --- > > drivers/platform/chrome/cros_ec_proto.c | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c > > index 97a068dff192d..953076ab401aa 100644 > > --- a/drivers/platform/chrome/cros_ec_proto.c > > +++ b/drivers/platform/chrome/cros_ec_proto.c > > @@ -56,6 +56,16 @@ static int send_command(struct cros_ec_device *ec_dev, > > else > > xfer_fxn = ec_dev->cmd_xfer; > > > > + if (xfer_fxn == NULL) { > > + /* This error can happen if a communication error happened and > > + * the EC is trying to use protocol v2, on an underlying > > + * communication mechanism that does not support v2. > > + */ > > I am not personally a friend of networking-style multi-line comments. > > > + dev_err(ec_dev->dev, > > + "missing EC transfer API, cannot send command\n"); > > That message will be displayed each time a message is sent, ie in > practice for each message. Is there any value in that, other than > clogging the log ? > > Guenter > > > + return -EIO; > > + } > > + > > ret = (*xfer_fxn)(ec_dev, msg); > > if (msg->result == EC_RES_IN_PROGRESS) { > > int i; > > -- > > 2.21.0.392.gf8f6787159e-goog > >