Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3878328ybb; Mon, 6 Apr 2020 18:10:45 -0700 (PDT) X-Google-Smtp-Source: APiQypJ/7AVvn3aWl0/Gjzplmo9nz/nozN0UnxyGu2ziiFORUWpm8HNAt+9PamXFqX2MADm1ubKT X-Received: by 2002:a05:6830:158e:: with SMTP id i14mr20818507otr.103.1586221845050; Mon, 06 Apr 2020 18:10:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586221845; cv=none; d=google.com; s=arc-20160816; b=za6lN6Mjv0s3RdeNdroGmX/8Po2y0GM5XqIdXauOt66gxTb+nlD4dVATexpjsY70zh rYBmKZCYjSnQ9x4YTiknAn+Rni9REu1TOp8dS/+TZL60cLNFHnm+Y5hvoIPv6s6YD0KA vIY6VdGlh2YXwZCZhiuI+dj2CKTPcHAbNxPOBOmRl3AbFe9fdTKPOz/OQmUPQqInwvWy oJUWibgPBwNb0JV7KR+p8pp+aVdEJnimUFy7B7/cnO6RASgDvCmUquLovGygWN9NWLMf o1HtTJEH+BN9mVEcYmeAvIaZ9kfkujAin+FbqOheWsk7eCNfu7IrMNtLzZ1IroShyo3I iUIQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=457RnyMVsNvg8Pb1hIw/s7Bb+SCmATGSkt0Iz3XVsxs=; b=XTT8m9CC9ZPjSpz1R42YWA/stcrZOtHxHh5w5VI2VAoB4KHjzFPtYowjyp+Sn+NV5s A5b/nWwXhd05TUGov1X6dxaKiDpaMM2sevXuISMA1PYMQ7H9RL5bh5M4utGxVzippAkj 8nUFsCitHhir/tjK8NkITL2pb6P5k3fz6JPo08HesTUIkWANdl49/f/+DozjOANwcoWa VHsCHzDswKZmyMEhYtKp0xP2hm5r5f23ksizvWQWCirmJ/7aPXDkWTUVeK22Ru51RUsE Z/U0sXVjJioUeIpY6Awz5dJPKiPxzsEzjMxZtzybsv9rn8/L8YNvY2TBzAcewR2fwGJ8 w4gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=T7GECrWC; 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 g188si9867oia.203.2020.04.06.18.10.33; Mon, 06 Apr 2020 18:10:45 -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=T7GECrWC; 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 S1726312AbgDGBKH (ORCPT + 99 others); Mon, 6 Apr 2020 21:10:07 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:46052 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbgDGBKH (ORCPT ); Mon, 6 Apr 2020 21:10:07 -0400 Received: by mail-pg1-f195.google.com with SMTP id o26so897712pgc.12 for ; Mon, 06 Apr 2020 18:10:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=457RnyMVsNvg8Pb1hIw/s7Bb+SCmATGSkt0Iz3XVsxs=; b=T7GECrWCy8XAulyaDsK2tqRBlLFxksZ+je7TjvdZ1UOQupgdgcUiH6Xl2T7+y4gwFy hjIdDlbmSJVKuUW3BliZZ8Fy/CwPZnS8UBEx9MznEqAYkgE2aiJKa8YG5Ccqi+oTGVAM i4Do+Padob4TvBOeiYql+199n2j7VlCbW42Qw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=457RnyMVsNvg8Pb1hIw/s7Bb+SCmATGSkt0Iz3XVsxs=; b=HMCHk9YZ93VbILxbV11YzFfqDgTnYdTpqgXjEqGskvjanhdGouEjRNxCpqyCCz62iF uhsTnZf1SVkywqv4fTtoBvt10/kRyio9SgGgG86486TIMCZ/vWOqwsyKNr2d54axgzcT cxGAirDL/bqwrQFbpSsQpxcJhqL2J/hdjjuUyiabQUcfQPjoz6r4M8VhGnlHf4Ol6+AQ zo+lhjn2ruDSDBUChvHB80O5aRdsCYVDJMlmFqofbygYtFpqDHHYhEWMlZopsuXPYVHv vEzQbilyUu7/fZzAEfNtJ0dTGF3nte7KJ9XWJMsrFlctoaL10vFAe1REcTDJUZGr0mQv WpUw== X-Gm-Message-State: AGi0PubwL2v1eJSlxf30vqLrm9Ugkg3L97tV8twUxW7C6m1r7A54tO4g 323vGwzdYIGqkkbpR3iU0fD7kRFD8to= X-Received: by 2002:a63:c345:: with SMTP id e5mr1673380pgd.403.1586221805707; Mon, 06 Apr 2020 18:10:05 -0700 (PDT) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:476b:691:abc3:38db]) by smtp.gmail.com with ESMTPSA id s27sm12086500pgn.90.2020.04.06.18.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 18:10:05 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH 1/3] platform/chrome: typec: Use notifier for updates Date: Mon, 6 Apr 2020 18:09:38 -0700 Message-Id: <20200407010940.155490-2-pmalani@chromium.org> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200407010940.155490-1-pmalani@chromium.org> References: <20200407010940.155490-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 #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,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"); + goto unregister_ports; + } + return 0; unregister_ports: -- 2.26.0.292.g33ef6b2f38-goog