Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp495187yba; Wed, 3 Apr 2019 12:54:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2WkTnidI34m8u/deWmyf5iyH2CI3ZquCWjpts1rxA/8nFLmvyFUnypR/zhJ7VITMw5dTo X-Received: by 2002:a63:4750:: with SMTP id w16mr1564438pgk.256.1554321298215; Wed, 03 Apr 2019 12:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554321298; cv=none; d=google.com; s=arc-20160816; b=vlIhunI52SDIDAZiytAvmDIGll0HbdtoTYeHV3SktEfJ20BlwoyxlrqkSqqaL2s/42 1P1Aoo2+hETGLnR6T2dhWpxdhsfs6eLiL9uh1SLl+nlW6nVz8qqHrugORYjWKv3igQSy qpuftRNsaVi+hoGa0Zy3XIcNQMNzejKk2oLccZQSVyv2jnpz1nPBrWbZFH/gbtFOV/Mz 9cgbEU41r7vYLBazXX7B82cQ5IuWdcs6aNrjs39IslzZWhGDeQZKlBKyAUpBZjpa/DH1 lsrV0suAZUvq1d/ncbp0HwNwVY3oTpQsZZ+CUteG1ty4OH1d9hBbq49a1dL8NDw2Jziy ZdAg== 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=Pc15GEkJMlnZyPlA04ohBA8jL5M0SXCgs6HZOVzQF5o=; b=AcL6LbdRPzMPpxyVtkoiv+4nC1Ntmnx7MVWBQUxvfbEn4YH1cduxgXHYMg3bNDPGvh nInYf4NbD14m94N/GAUWCs3hxBrpe8HvjBDe1Hc2xBu4HS0sd/AqQqT2PGm6rA5OQ7E2 QH9HxU1E/eYnKMRTXGy+e7U0V2y9U8s2be10Ui9XB+g9UmzDMTE810fomR2LE33sg48z JB3qnOhRPvR5+Xz0Ra2JBjZd3hkunSTXL2+j62q9Hx1osRtXdi9Lf1FvXWVBbAuifGJQ 8ghmM4qMPujJ3SI/1eRctuEPsYLS7Xl8z55O66UFmBsaPlig73L3H4Z3pJm5LLiC53Dd mOcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hCkWrRfy; 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 f15si14840354pgm.132.2019.04.03.12.54.40; Wed, 03 Apr 2019 12:54:58 -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=hCkWrRfy; 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 S1726199AbfDCTxx (ORCPT + 99 others); Wed, 3 Apr 2019 15:53:53 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:37336 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbfDCTxx (ORCPT ); Wed, 3 Apr 2019 15:53:53 -0400 Received: by mail-yb1-f196.google.com with SMTP id o1so72280ybo.4 for ; Wed, 03 Apr 2019 12:53:52 -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:content-transfer-encoding; bh=Pc15GEkJMlnZyPlA04ohBA8jL5M0SXCgs6HZOVzQF5o=; b=hCkWrRfyyjXoVKdtDOXyrPYQrb2j+9pIOIEejGbjO83nV11ZdULTC91ogu5bDOHqyl agZVOAqAWQoG60CbdqoZVCj/0zKyFxfqXXA37ljXW0mpldFZ69pPpXTybDzFXyvKr4el +zyma+maHnCYN1kNqKxDiGoK6XqPzRkPo9z/mHfZyj/CcRkRTdQhNCFe9mvZcnmjMXL5 UVkVOSK84DCs11V7SzMil3GsBoG2HUCis6H9VfJ9N395B66/GAgkRqDENG1foAtRqEXQ CIDQPvyXPpe5yi+Mq1NRV2J8GO97XY/VnTDLksZ4XoM2DTsCutZnIBJoejmGLIMFyDlk BHTg== 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=Pc15GEkJMlnZyPlA04ohBA8jL5M0SXCgs6HZOVzQF5o=; b=BKm3gXDosOV5pQLJonn9jz/9CuqehwJ6pyUOHgw38muFu5SBVt/AYp9vjsoL0taocD GeN2ODRqWfLlYgX6dj3IzpuUGImkhkboEJ5O/tHF9ZRFSfth9WeE9vFNLffiwnDAGCnP ZwERNAj93Y4msMlUANOziTlfCZl+5PKUHlertPal6qvIMz7I+m1w5jtzu6pFERsSTJdu TNmfDVa8FXwjpeB3v5ptxjJC+upznaj7DDwGHruIMayFhTX0WG0j4ugsoYyj535sGKJV uLEfA2rIA8aN8a3ZxkSRuQ3vkqnoixDRm5GFwZCKZIXVRQDdzx5Q953Sd3Fv60zgj4TD 50VA== X-Gm-Message-State: APjAAAXchCoOmlqH+OYXrYvx6ZgUv0scbewUpxdCqzDoRFjsVqdX8FSX +PAY4GIPCWuXV5HI00LoRr9TOQXT5ZU0Z3gr2d5Mug== X-Received: by 2002:a25:65d4:: with SMTP id z203mr1836151ybb.370.1554321231914; Wed, 03 Apr 2019 12:53:51 -0700 (PDT) MIME-Version: 1.0 References: <20190403183048.56750-1-egranata@chromium.org> In-Reply-To: From: Guenter Roeck Date: Wed, 3 Apr 2019 12:53:40 -0700 Message-ID: Subject: Re: [PATCH] mfd: cros_ec: check for NULL transfer function To: Enrico Granata 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" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 3, 2019 at 12:40 PM Enrico Granata wrote: > > I can certainly add a "did_print_error" flag or some such, but in practic= e, if the transfer function is NULL, the initial handshake will fail, and t= his will in turn cause EC registration to fail, and no further communicatio= n should occur, so no further log entries will be printed. > Sorry, I am a bit lost. Why would dev_err_once() not work ? Guenter > 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/platfor= m/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_d= ev, >> > else >> > xfer_fxn =3D ec_dev->cmd_xfer; >> > >> > + if (xfer_fxn =3D=3D NULL) { >> > + /* This error can happen if a communication error happ= ened and >> > + * the EC is trying to use protocol v2, on an underlyi= ng >> > + * 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 =3D (*xfer_fxn)(ec_dev, msg); >> > if (msg->result =3D=3D EC_RES_IN_PROGRESS) { >> > int i; >> > -- >> > 2.21.0.392.gf8f6787159e-goog >> >