Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5586028ybl; Tue, 14 Jan 2020 11:25:17 -0800 (PST) X-Google-Smtp-Source: APXvYqxdzSymK2Hl01T0AF6aVx4sycnfymkNx5sYOxkl63en1AZFm6EwmUoDuKHRR3OwGdHQxFEV X-Received: by 2002:a9d:7305:: with SMTP id e5mr17588648otk.64.1579029917314; Tue, 14 Jan 2020 11:25:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579029917; cv=none; d=google.com; s=arc-20160816; b=pc/hkyA/5W/kE7MpilIdpe8kGkvlNx3fIu2ChIQDRA+7kDJ/s9yskLostKMuYLwEdP 019c8dHGqH815/20jBmUYLLEHuudiPoxt0sTVykeZSDRHNBUwMuOxRtvvoyMbqvid53R 1EcH6yqMGcDggfuHpohxY7auuZdlmKYqHSPx4SS63LI0vwhVwUGMmpTn5FtBLkcRTASX 5jlqm8yIeMpevW/HFZllmJFP0Y3fp+IOFcQ+k+0tPxmsEOSd/YuVe2E3d4imDUtS3nAK BkP3LW1E42wdzR7lPvaHTU8k+gtMhRKbglMMbqgRuxLoHQmwb7XCR8kbkr/mSF4cG0C/ kI9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DRjRPlux6wSyjnZ/ZJLi4YacFFAZNG6NTQbrGZ6UsVI=; b=Btn7KoZsUahwKrblQ9iNR5NZi1JJ+A2QI7RTyImg2Gc/6EXpFOf66gR9ACCTY4k0fb /a+f5il4E5ICjtkt+EiZe2dlnmRuZh9biBzda1S537ktdDsBhXL0wCtgWYJ9Y2hZhXz0 55rMWDah0lwTU4Tquzrvn/tSoCWkL0/1mV0JjHnlc4NgVSk1gLQk9uEoCOi+axHt0JmV gdwqZAOM7CZq/JpEsYSrm/bXjxe+KFACnBR/QpXKszAsZXc3Tku3YxFtPy7etqbk8hh+ gJGgraqVNUUHPH6dtKrdQ0jE8Ii7RMi7sJZxkiM8ituJnE71S6RW8da81gozRz63T4IA Nv4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="X+or/FqQ"; 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 j71si7803259oib.213.2020.01.14.11.25.05; Tue, 14 Jan 2020 11:25:17 -0800 (PST) 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="X+or/FqQ"; 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 S1728721AbgANTYF (ORCPT + 99 others); Tue, 14 Jan 2020 14:24:05 -0500 Received: from mail-qv1-f68.google.com ([209.85.219.68]:40239 "EHLO mail-qv1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbgANTYF (ORCPT ); Tue, 14 Jan 2020 14:24:05 -0500 Received: by mail-qv1-f68.google.com with SMTP id dp13so6208345qvb.7 for ; Tue, 14 Jan 2020 11:24:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DRjRPlux6wSyjnZ/ZJLi4YacFFAZNG6NTQbrGZ6UsVI=; b=X+or/FqQvJcJefSyOeYni8dpHySKwCWrwsSVsIhbsd2LEAQqTsJigEzCCxPiiUY+8B LPN/q5FC3o36GkAT/PIsyB4ODEabpJ8xupqyU3ogulJQ6cALyxu/PAqI4m7wOtXN9Gbi jQijUtZ9/mrDcvmbd0KAt0nuXaWmmPRH9R9iI= 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; bh=DRjRPlux6wSyjnZ/ZJLi4YacFFAZNG6NTQbrGZ6UsVI=; b=pJMrzA0wa77SCKUSjx0mVeHgBBke9XkKfsaHgZMHzNbR3JcRJ2vWzmOoKsD/auNm8n lBi4HTnI7OFSAKBkAZoSQ8jtNYNNcjHsWwlOnc8DuaUktxtPX6cafWeUQDCtTfbeNiAj MOj8HC3I5K0Do4/IXMBFWXPLsdY0onCuav9Cyav2/gyM0RMyEHwDBE1EwWO/YeWb2VDA e8jVWUUhGMpe5IEJUXkZayvQyqqXPB1Kn9HkanB/Ywv0jP5mVjOu8pU2mRSWg/DHxbn7 HhYV2vtGghsYHU24cc/mel84h0Z4XnTuF9/r3IBGyJVSmkiPo3o3yS9Neii7O8I473SV 8IhA== X-Gm-Message-State: APjAAAUwFaXphcJmiUlWg5YVbZkkUyi3Fn4VgszSlm42APJzEpOsbWbX N9nbopkQpkpTo/e7OqwV60cuuzp5bHMwY8l9DFoq/g== X-Received: by 2002:a0c:e790:: with SMTP id x16mr22050544qvn.18.1579029843997; Tue, 14 Jan 2020 11:24:03 -0800 (PST) MIME-Version: 1.0 References: <20200114031056.44502-1-pmalani@chromium.org> In-Reply-To: From: Prashant Malani Date: Tue, 14 Jan 2020 11:23:53 -0800 Message-ID: Subject: Re: [PATCH v5 1/2] platform: chrome: Add cros-usbpd-notify driver To: Enric Balletbo i Serra Cc: Guenter Roeck , Benson Leung , Lee Jones , Linux Kernel Mailing List , Jon Flatley , Gwendal Grignou Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 14, 2020 at 9:07 AM Enric Balletbo i Serra wrote: > > Hi Prashant, > > On 14/1/20 4:10, Prashant Malani wrote: > > From: Jon Flatley > > +}; > > +MODULE_DEVICE_TABLE(acpi, cros_usbpd_acpi_device_ids); > Ops, there is a build error here, please make sure to build the driver before > sending. Hmm. That's odd, I did check using arm64 defconfig. My apologies. Could you kindly share your build commands so that I can use this going forward? > > s/cros_usbpd_acpi_device_ids/cros_usbpd_notify_acpi_device_ids/ > > Apart from this I'm getting build errors with my defconfig which has CONFIG_ACPI > and CONFIG_OF enabled. > > Another problem that I have with this driver is that actually there is no user > for it. I'd really prefer have this included on a series that also introduces > the user of this notifier. If you are only testing the ACPI case you can focus > first on this use case and we add later the OF case (maybe is an easy way to > proceed). I'm testing with an arm64 device too locally. I will try to incorporate the new change which updates cros_usbpd-charger to use the notifier mechanism. I think we can try for the OF case simultaneously (it is probably just the build errors I need to check for) Thanks again! > > Thanks, > Enric > > > + > > +static struct acpi_driver cros_usbpd_notify_acpi_driver = { > > + .name = DRV_NAME, > > + .class = DRV_NAME, > > + .ids = cros_usbpd_notify_acpi_device_ids, > > + .ops = { > > + .add = cros_usbpd_notify_add_acpi, > > + .notify = cros_usbpd_notify_acpi, > > + }, > > +}; > > +module_acpi_driver(cros_usbpd_notify_acpi_driver); > > + > > +#endif /* CONFIG_ACPI */ > > + > > +#ifdef CONFIG_OF > > + > > +static int cros_usbpd_notify_plat(struct notifier_block *nb, > > + unsigned long queued_during_suspend, void *data) > > +{ > > + struct cros_ec_device *ec_dev = (struct cros_ec_device *)data; > > + u32 host_event = cros_ec_get_host_event(ec_dev); > > + > > + if (!host_event) > > + return NOTIFY_BAD; > > + > > + if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU)) { > > + blocking_notifier_call_chain(&cros_usbpd_notifier_list, > > + host_event, NULL); > > + return NOTIFY_OK; > > + } > > + return NOTIFY_DONE; > > +} > > + > > +static int cros_usbpd_notify_probe_plat(struct platform_device *pdev) > > +{ > > + struct device *dev = &pdev->dev; > > + struct cros_ec_dev *ecdev = dev_get_drvdata(dev->parent); > > + struct notifier_block *nb; > > + int ret; > > + > > + nb = devm_kzalloc(dev, sizeof(*nb), GFP_KERNEL); > > + if (!nb) > > + return -ENOMEM; > > + > > + nb->notifier_call = cros_usbpd_notify_plat; > > + dev_set_drvdata(dev, nb); > > + > > + ret = blocking_notifier_chain_register(&ecdev->ec_dev->event_notifier, > > + nb); > > + if (ret < 0) { > > + dev_err(dev, "Failed to register notifier\n"); > > + return ret; > > + } > > + > > + return 0; > > +} > > + > > +static int cros_usbpd_notify_remove_plat(struct platform_device *pdev) > > +{ > > + struct device *dev = &pdev->dev; > > + struct cros_ec_dev *ecdev = dev_get_drvdata(dev->parent); > > + struct notifier_block *nb = > > + (struct notifier_block *)dev_get_drvdata(dev); > > + > > + blocking_notifier_chain_unregister(&ecdev->ec_dev->event_notifier, > > + nb); > > + > > + return 0; > > +} > > + > > +static struct platform_driver cros_usbpd_notify_plat_driver = { > > + .driver = { > > + .name = DRV_NAME, > > + }, > > + .probe = cros_usbpd_notify_probe_plat, > > + .remove = cros_usbpd_notify_remove_plat, > > +}; > > +module_platform_driver(cros_usbpd_notify_plat_driver); > > + > > +#endif /* CONFIG_OF */ > > + > > +MODULE_LICENSE("GPL"); > > +MODULE_DESCRIPTION("ChromeOS power delivery notifier device"); > > +MODULE_AUTHOR("Jon Flatley "); > > +MODULE_ALIAS("platform:" DRV_NAME); > > diff --git a/include/linux/platform_data/cros_usbpd_notify.h b/include/linux/platform_data/cros_usbpd_notify.h > > new file mode 100644 > > index 0000000000000..4f2791722b6d3 > > --- /dev/null > > +++ b/include/linux/platform_data/cros_usbpd_notify.h > > @@ -0,0 +1,17 @@ > > +// SPDX-License-Identifier: GPL-2.0-only > > +/* > > + * ChromeOS EC Power Delivery Notifier Driver > > + * > > + * Copyright 2020 Google LLC > > + */ > > + > > +#ifndef __LINUX_PLATFORM_DATA_CROS_USBPD_NOTIFY_H > > +#define __LINUX_PLATFORM_DATA_CROS_USBPD_NOTIFY_H > > + > > +#include > > + > > +int cros_usbpd_register_notify(struct notifier_block *nb); > > + > > +void cros_usbpd_unregister_notify(struct notifier_block *nb); > > + > > +#endif /* __LINUX_PLATFORM_DATA_CROS_USBPD_NOTIFY_H */ > >