Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp125882pja; Thu, 9 Apr 2020 15:54:15 -0700 (PDT) X-Google-Smtp-Source: APiQypJcZulKgesI8v16msC0TOc+mrJQfL6fyMrv3Dlgw4/9s674zbyRfP+YkizSxvHZA26MzNBe X-Received: by 2002:a37:6514:: with SMTP id z20mr1300669qkb.197.1586472855131; Thu, 09 Apr 2020 15:54:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586472855; cv=none; d=google.com; s=arc-20160816; b=mpIvPrHpWZGr7rKQntejFp75NTAVxxtoRt7bdsKUecmZSwsaDtVTWbsnUXnrwe6Rjt TGkAF0ZUSv3FdbF7BcnO4M16Vn5nH1zubOM7r5oKBcYYbPXa4q9ZdeMN7oZrDVr2Crqo VN7mLkx1ieCYEQd25W/8NFKCeZjZaEUgmhpJhwUr1ZqJNdVkqNmE7wSQkDQURZmk/0dL Bv+ivqecsHycTlLDQWiQRCwCfYt+a9U8y67O8M7MdZey8CJWlJhs5TMr6lFW+LksiXl1 WYQ/VHTY4dsesBZGGhSGqh4JMH8swr8IUTnI321AjCJTahXKOdikbXbRYbm3BsHjOxfc hadQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=VafVIttK4BQaNnVH9DUs0wyPcW9Q+K+8pZ94hsjXorY=; b=FmQBdyWzAMcRY6v5zRs0T6BpHf4wGIZenWNLMflyE3OkiGIwLecuREZk87kcGL+n0N xABPBe13ZQiQyEKBfJ7pNn6rAnyHFd82hs+EC/VqxISofVxXpEanCXkm5OCmpdu4xH61 CAqIEhqiRK/0pIHUB0NWIE82G/vZ65asq3KIHOgDXlz/bC0irZwdR9L+rbS3BmLuHixw eV0z4h3T7rSZsVdwP/DoZMTLgal3cIn2lupnAu29J1UGd6Rr7b9o2HSwdMAVpkazvx/9 Bd0r+JjpxuywCcmNXEI2LhiAPYBhkB64rTQeKVgsq8El3idrQeYQlUNClwGzhUQGIj78 uSeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ks+HwLLD; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r3si11234qve.188.2020.04.09.15.53.59; Thu, 09 Apr 2020 15:54:15 -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=@chromium.org header.s=google header.b=ks+HwLLD; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726918AbgDIWjQ (ORCPT + 99 others); Thu, 9 Apr 2020 18:39:16 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41106 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726689AbgDIWjQ (ORCPT ); Thu, 9 Apr 2020 18:39:16 -0400 Received: by mail-pf1-f196.google.com with SMTP id b8so201986pfp.8 for ; Thu, 09 Apr 2020 15:39:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VafVIttK4BQaNnVH9DUs0wyPcW9Q+K+8pZ94hsjXorY=; b=ks+HwLLDksBEOvVvqN/JGC0kYT1YA3ZyODv7fd5LcRQkkuCxeD/U4NzuevuVxgJHc0 N5Bpx7PYe2ea8hQXAZJUBCWzfmRs7/8n4XbU7v/nxBhZXmVzM/zBEsQKYM0j/LSOxFXb /58Uv7YkttG9qPg91DkELUonTxslLhWtlIM58= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VafVIttK4BQaNnVH9DUs0wyPcW9Q+K+8pZ94hsjXorY=; b=LfxyIpF528FnxnPDIRN1B0UF3gcEEBFh/te18sIG/o0HIsXUeZG4lrNBFlfipYoV65 m1qMdqxPUciIzN3enRl7jNiQiuQMp9FEeHnMPJHNxuk3Oe7NHynFRlGIRj1jNEsoZ5iv pgZyx/lCBOF1Br46HV1nI+sSjtXe999DszFopgWyOt+/K4h3ft9VgGjylkJrt7B/xRmZ ncKXZ/aoia/vkGflzPOt6Byj6xnT8DjYXchPfcoKCbpX6g+qlzVKoRW4ogA/se3305Pb onimIfofHuf1+IyWMCJTewWRyCIgrYzMwf+eDlgM0gemY32qSg2i4y8I0gerYB1jEM66 Ok8g== X-Gm-Message-State: AGi0PuZoVcq0siaeZZr23QrtIO3Kiy60HfKQurxbRa2Kn/jlv+jtmeyQ BfPPdu2YCqcNERvG36ysqfuP4ZGSLxo= X-Received: by 2002:a63:ff59:: with SMTP id s25mr1608578pgk.159.1586471955396; Thu, 09 Apr 2020 15:39:15 -0700 (PDT) Received: from google.com ([2620:15c:202:201:476b:691:abc3:38db]) by smtp.gmail.com with ESMTPSA id o15sm171016pjp.41.2020.04.09.15.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2020 15:39:14 -0700 (PDT) Date: Thu, 9 Apr 2020 15:39:13 -0700 From: Prashant Malani To: Enric Balletbo i Serra Cc: linux-kernel@vger.kernel.org, heikki.krogerus@linux.intel.com, Benson Leung , Guenter Roeck Subject: Re: [PATCH 1/3] platform/chrome: typec: Use notifier for updates Message-ID: <20200409223913.GA15090@google.com> References: <20200407010940.155490-1-pmalani@chromium.org> <20200407010940.155490-2-pmalani@chromium.org> <12997222-5df5-1e16-3eb1-1e26252315f8@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <12997222-5df5-1e16-3eb1-1e26252315f8@collabora.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Enric, Thanks for the reviews, as always. Kindly see inline: On Thu, Apr 09, 2020 at 11:01:42PM +0200, Enric Balletbo i Serra wrote: > Hi Prashant, > > Thank you for the patch. > > On 7/4/20 3:09, Prashant Malani wrote: > > Register a listener for the cros-usbpd-notifier, and update port state > > when a notification comes in. > > > > Signed-off-by: Prashant Malani > > --- > > drivers/platform/chrome/cros_ec_typec.c | 25 +++++++++++++++++++++++++ > > 1 file changed, 25 insertions(+) > > > > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c > > index 874269c070739..cf7c2652a1d6d 100644 > > --- a/drivers/platform/chrome/cros_ec_typec.c > > +++ b/drivers/platform/chrome/cros_ec_typec.c > > @@ -11,6 +11,7 @@ > > #include > > #include > > #include > > +#include > > I think you need to add a kconfig dependency/selection in order to don't have > build problems. Thanks, will make the change. > > > #include > > #include > > > > @@ -26,6 +27,7 @@ struct cros_typec_data { > > struct typec_port *ports[EC_USB_PD_MAX_PORTS]; > > /* Initial capabilities for each port. */ > > struct typec_capability *caps[EC_USB_PD_MAX_PORTS]; > > + struct notifier_block nb; > > }; > > > > static int cros_typec_parse_port_props(struct typec_capability *cap, > > @@ -272,6 +274,22 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec) > > return 0; > > } > > > > +static int cros_ec_typec_event(struct notifier_block *nb, > > + unsigned long host_event, void *_notify) > > +{ > > + struct cros_typec_data *typec = container_of(nb, struct cros_typec_data, > > + nb); > > + int ret, i; > > + > > + for (i = 0; i < typec->num_ports; i++) { > > + ret = cros_typec_port_update(typec, i); > > + if (ret < 0) > > + dev_warn(typec->dev, "Update failed for port:%d\n", i); > > nit: space between : and %d > Done. > > + } > > + > > + return NOTIFY_OK; > > +} > > + > > #ifdef CONFIG_ACPI > > static const struct acpi_device_id cros_typec_acpi_id[] = { > > { "GOOG0014", 0 }, > > @@ -332,6 +350,13 @@ static int cros_typec_probe(struct platform_device *pdev) > > goto unregister_ports; > > } > > > > + typec->nb.notifier_call = cros_ec_typec_event; > > + ret = cros_usbpd_register_notify(&typec->nb); > > + if (ret < 0) { > > + dev_err(dev, "Failed to register notifier\n"); > > Currently cros_usbpd_register_notfity calls blocking_notifier_chain_register > that always return zero. Is fine to check the error but the print is unneded. If > probe fails will report the error. > Done. > > + goto unregister_ports; > > + } > > + > > return 0; > > > > unregister_ports: > > Best regards, -Prashant