Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp496187yba; Wed, 3 Apr 2019 12:56:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhPx3iEk1vvwLVDAPGCKw5RSMmN/gu3gjpX0rgIZkpib6lulqM4dahwLhzWYCiQayyu0fU X-Received: by 2002:a17:902:1003:: with SMTP id b3mr1875406pla.306.1554321384577; Wed, 03 Apr 2019 12:56:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554321384; cv=none; d=google.com; s=arc-20160816; b=ns0hb4+SebvQYezKwWI5EueP+nckNR7Qcqd2xpDdLPennMyiVBiA8oy2fl6TUwVE/I ND69tDrpm5xQwfDHROhEYYN/2B1Q3FN0xZoNIT5T4vIxpwtEhjLWhQc4wWHK4CPf5I6Y OPJFY04IkmcTEaTiBpOs3g5vN/fQhgZ0pTOt1WTbnUKqORaWcXVXnzS3riHrU1tLWxU5 HgzY0xPoqJw16ce6QxOvfkQbhkWSvYkCkr9k1J5S2SWA2Tdfds4xf2gNaXLKwr0tkZwj ciwsTJjuDW9vPM1Vsggxabh6LrnwVguJQep4QP2Jwt1rkuUYKNYhlPWXLWP7Ka4f5qLG x0+Q== 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=5JDg9BE8i0v0GIx9r1uZtuJoaGtNDxpmI6KlMDrFxrA=; b=o9fAXhD4b/HK6pB4d1ppSPchmEPfitKanLK3SfcAQqr+9guLqCq5tgzU9MuPa/WwXO P4axf49BrfcqXvmitaSK7OktNsUCRebHNWko1BLbBBiaTgI/q+eZBG786eThVJajskt0 x/tDh0608xcxDteqRasRdpUTMcmdM2s8lWx7EKnaKgHkj6LAf3AfRGQCy11s4gBQl83p +IcU485yDXH83R2ei9Hz6j42XTEnVQicjoESYCH9HjeXi/aJHpgSIKBPpk1q9pfbWhAq njGHyZLkYZ/je1ksla9mQmpzz9AmeQf1RpVt4uXjdS4cyq6m4rv3d997t1nR9u+XrzhS Ie7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mi34POsi; 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 j9si1277579plk.125.2019.04.03.12.56.08; Wed, 03 Apr 2019 12:56:24 -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=mi34POsi; 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 S1726580AbfDCTzH (ORCPT + 99 others); Wed, 3 Apr 2019 15:55:07 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:46250 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbfDCTzH (ORCPT ); Wed, 3 Apr 2019 15:55:07 -0400 Received: by mail-io1-f68.google.com with SMTP id b9so15132264iot.13 for ; Wed, 03 Apr 2019 12:55:06 -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=5JDg9BE8i0v0GIx9r1uZtuJoaGtNDxpmI6KlMDrFxrA=; b=mi34POsivnv8cmQd1Rl9sRFDAyRzQh/WDG5gkdX+RuSRoz8vquTIWYrlUy5xuJ9G/e 510FKE51QrGKsOumdroKw5UniuFaxRiN93CnwUmdPLSyOvixtxquHQw80V8h9i8Uie60 AJCzfFEMCp7mGX7bh+sVgvQjJXi/RRAvx89R8zV4kt2UYsiA8WXHleeHzoLCmpGE8Azl zL15EDFF5iYRwa8+637C6ZPbc8zBPGdue2FM4pXAcHlC+/2mTXVYEh4XSlEKuLo5Ytj1 d/aJGgz+GThyKjW/Q4dUTfjaMPQuxoDt/TrgZoq5orToLSjEqCZcTQYy62gcN5HnRmqS vBKg== 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=5JDg9BE8i0v0GIx9r1uZtuJoaGtNDxpmI6KlMDrFxrA=; b=F56ldq+9Qui15a/fWxTzd8odI3eBge4S20uq/3C5jgjVmg7Z7EbOrk4C2WGEiLvqeF RLEDOWdQuEQFuwqwhoE4XmYIOu47C83mrkfgztSheqejkRrTX12cEgPIegAe/q3Qu2qo gWIbASWmXOL+SRHULhNZD84Cng2ADOZhqPBOAoD1w5uJ2KzlwQCc7qHaBbxwrWV/hTFD z6gTpvBnW5Vdv+5ENJCSxPnDLYBhrpVEMsvuqGk2j3rKicmh/CqMiPEcg/ASuxfvaMht BpVIuCBbD3Af+lrNzUucKODsE90LQJzKYprS4GTt7dVAwAgINYBbhNyZIJR0KbEs7ZOs QoGg== X-Gm-Message-State: APjAAAWtGaJbmjRtuWFBQFs6M81YxQ1xAgWd6F/jwkbFjV1NdXInwXiZ bjAgq+3zYR8QxndnKndPqZIfXFdcsRrN70U9RJVttA== X-Received: by 2002:a6b:8d87:: with SMTP id p129mr1568313iod.10.1554321306080; Wed, 03 Apr 2019 12:55:06 -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:54:55 -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" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Because I did not know about it till right now. Thanks for the suggestion. Will upload a v2 as soon as I get a chance. On Wed, Apr 3, 2019 at 12:53 PM Guenter Roeck wrote: > > On Wed, Apr 3, 2019 at 12:40 PM Enrico Granata wrot= e: > > > > I can certainly add a "did_print_error" flag or some such, but in pract= ice, if the transfer function is NULL, the initial handshake will fail, and= this will in turn cause EC registration to fail, and no further communicat= ion 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/platf= orm/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 =3D ec_dev->cmd_xfer; > >> > > >> > + if (xfer_fxn =3D=3D NULL) { > >> > + /* This error can happen if a communication error ha= ppened and > >> > + * the EC is trying to use protocol v2, on an underl= ying > >> > + * 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 comman= d\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 > >> >