Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2045544ybb; Thu, 9 Apr 2020 14:04:10 -0700 (PDT) X-Google-Smtp-Source: APiQypJTFlTyehSgyJeprJ7vxLLMIUZIKKmLZgLkNrOVRFr1ilFCrhFcXL4pMrbIu5Ocll101ru7 X-Received: by 2002:a37:d0c:: with SMTP id 12mr799798qkn.361.1586466250094; Thu, 09 Apr 2020 14:04:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586466250; cv=none; d=google.com; s=arc-20160816; b=HiPoxyHFuLLUjqaUPL4cc+KkQvgzlwX8y4Em3R6s+UGrxH0WJ4aNBIMhlFMoui6vlN txMUZKCg8mtHgFksoEfzG0HZjxXC4yrW8CSUayXFS6Z8N88fRRottMJzw22Xpv9Q4Tq6 5HCu25LNBlMiU1T1y31IDZuHEYskW2O/QXGKiqq6Y9ZIsMRmkNQ2Zv3tjm95OcYfMwW5 7FVQrMmdYpJrO9j2afEYk9SNCARV8x4xjWaiSZSUiR8SVZxUmTXH5syRinrRVhKXN2wo s9XPRBl+Pgj8XvC+OhA4jvwjfex84Wii/W50CtEHP5DlrshMAOgpIBDWd4zNl3wm+MqQ ElUg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=EfnF0VzYF1b6znZTK45gzx2m/o3WszXJkAtsCJyLzrc=; b=Kgox7V/kbuqFLfdC/8kAn3MmQkRoGqTfd1oMKVUpLXzoQO4aM+n5X3mKHiMev2Ell1 SF30BuzSEuQ0RKm2eKmTwufaYfqM6+FYHhSY0SyRknPdGEXDn0S9bbsJYm0sEZwIDHCt 8i7CUU/8TkS3mvC5goQYc+f0s/SHqp3dd5Xg4joxK6fhj2p1RsmMRNdiV+KTFKkxiYZ3 FbHdifHxHDYBFXmcZwbXbBji4vvnwCfT2CATyfZYi0OjlV7AF5jSDPA2NCFBonSWYvZG Sm5XLS53k+rEmHhY7hV6Z0G8KbjPJO+/wrhJymU8WLHZbfmP8c3kbRkGNTOtVcVuRpT2 P8mQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13si86932qkj.162.2020.04.09.14.03.54; Thu, 09 Apr 2020 14:04:10 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727441AbgDIVBr (ORCPT + 99 others); Thu, 9 Apr 2020 17:01:47 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:41980 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbgDIVBr (ORCPT ); Thu, 9 Apr 2020 17:01:47 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 079EF290E5E Subject: Re: [PATCH 1/3] platform/chrome: typec: Use notifier for updates To: Prashant Malani , linux-kernel@vger.kernel.org Cc: heikki.krogerus@linux.intel.com, Benson Leung , Guenter Roeck References: <20200407010940.155490-1-pmalani@chromium.org> <20200407010940.155490-2-pmalani@chromium.org> From: Enric Balletbo i Serra Message-ID: <12997222-5df5-1e16-3eb1-1e26252315f8@collabora.com> Date: Thu, 9 Apr 2020 23:01:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200407010940.155490-2-pmalani@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > #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 > + } > + > + 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. > + goto unregister_ports; > + } > + > return 0; > > unregister_ports: >