Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp404848ybz; Wed, 15 Apr 2020 10:58:42 -0700 (PDT) X-Google-Smtp-Source: APiQypLF1TEMO2VfFwxeO+0t91OWgkGfG0wsjh7jPlPO3K5IbAczjw+MxX3GCN09USGiJgDwCrGd X-Received: by 2002:a17:907:214d:: with SMTP id rk13mr6252480ejb.220.1586973522571; Wed, 15 Apr 2020 10:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586973522; cv=none; d=google.com; s=arc-20160816; b=uqUF19j67lRZRCzhnO5fhl38K6G8dahcrnLLL0DVuMmbH5+KSDSgdC+Ogl/EpX9onQ 1r12NRRr3dPJKWKWq3pnz9QMyq6gmMmFnYj550zeReu/f18W1bARi/kTMVSHwCf7U57V c+s0Qm90AMzfZriThuVcyiXb8Gp8dXgNxcVOzgdKTHjrGQdcRuQMfEREWlTf87mBX2bK 9Mo03heb2WWYZzOH54uu3nHuimE3dzhzchzwAOSoHohj29uTRX2vVK1arAo8/svKhHBJ yoCgIL7Ce0ZuxdwfxQvcD3aVW826WDRK2qM/4U+H+vRpe/m7hmsSOMKq/PAYwzN8OQnU /S1A== 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 :ironport-sdr:ironport-sdr; bh=1BDcACcgzAILSPybHqFZJ7tdD6U8AmXPszfLye3brjs=; b=eiYLHb5Y5dc1mslkR/f0po1Yf+7WsILm9G9s7L6KNe2cvQTblkwnukJj4tAy1pgoAl ajc9QNqXnSZ+sHk3Jzsd84ik1DwJkMDOm+Bv3QuG7PAKzdbI91mUYzDPQLDJaJJOWFjN I0e2bvZyMHu4rSlfhR3uNJ9XSV3ItbyStyyzyh5Ut3BT+gEd02wm726ptVnDi7FqoJ2Y wq7ttaSgI8fyW7n2wrLt1v8YSCVjtsYTo1HJF7MTgGXO3ga93Gf/JBnP28BaAcCLxOW1 1HMproYP/OruzyMy7PNMTJwAS7oSDRlH6WBaWSM13hXeiJxBbnFN4eUXfGcs29P1MP2b uxXg== 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 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce3si12703702edb.286.2020.04.15.10.58.18; Wed, 15 Apr 2020 10:58:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406882AbgDNHuA (ORCPT + 99 others); Tue, 14 Apr 2020 03:50:00 -0400 Received: from mga14.intel.com ([192.55.52.115]:17948 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406749AbgDNHt6 (ORCPT ); Tue, 14 Apr 2020 03:49:58 -0400 IronPort-SDR: tXDxMzFXh/jO1Ke0h8FGVxbwN/9jMN9L79ct7gVDKmYfiWu8k/yuk+5jGSpNhbnFgOOzXO0fBn dqVboFMFGLbg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2020 00:49:58 -0700 IronPort-SDR: hS3mSn/A5l5NAVio87rjivuq44fsUFgmrpSbM2Dj7MJEO3BSNfbi1ioWOmlI6Hsmf+P5ANekPn q6UkQakli8Vg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,381,1580803200"; d="scan'208";a="363304781" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 14 Apr 2020 00:49:56 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 14 Apr 2020 10:49:35 +0300 Date: Tue, 14 Apr 2020 10:49:35 +0300 From: Heikki Krogerus To: Prashant Malani Cc: linux-kernel@vger.kernel.org, Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: Re: [PATCH v3 1/3] platform/chrome: typec: Use notifier for updates Message-ID: <20200414074935.GA2828150@kuha.fi.intel.com> References: <20200410002316.202107-1-pmalani@chromium.org> <20200410002316.202107-2-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200410002316.202107-2-pmalani@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 09, 2020 at 05:23:15PM -0700, 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 Reviewed-by: Heikki Krogerus > --- > > Changes in v3: > - Fixed ordering issue in Kconfig dependency. > > Changes in v2: > - Added Kconfig dependency to CROS_USBPD_NOTIFY. > - Fixed spacing error. > - Removed superfluous devm_warn() call. > > drivers/platform/chrome/Kconfig | 1 + > drivers/platform/chrome/cros_ec_typec.c | 23 +++++++++++++++++++++++ > 2 files changed, 24 insertions(+) > > diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig > index 03ea5129ed0c3..a484ab2c91ff0 100644 > --- a/drivers/platform/chrome/Kconfig > +++ b/drivers/platform/chrome/Kconfig > @@ -217,6 +217,7 @@ config CROS_EC_SYSFS > config CROS_EC_TYPEC > tristate "ChromeOS EC Type-C Connector Control" > depends on MFD_CROS_EC_DEV && TYPEC > + depends on CROS_USBPD_NOTIFY > default MFD_CROS_EC_DEV > help > If you say Y here, you get support for accessing Type C connector > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c > index 874269c070739..d444dd7422a2a 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 > #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); > + } > + > + return NOTIFY_OK; > +} > + > #ifdef CONFIG_ACPI > static const struct acpi_device_id cros_typec_acpi_id[] = { > { "GOOG0014", 0 }, > @@ -332,6 +350,11 @@ 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) > + goto unregister_ports; > + > return 0; > > unregister_ports: > -- > 2.26.0.110.g2183baf09c-goog thanks, -- heikki