Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5646589ybl; Tue, 14 Jan 2020 12:30:40 -0800 (PST) X-Google-Smtp-Source: APXvYqyesi+sWhUTndZX9DrMcpsGN9H1w2NFNn8/QezDa1c+ac0pR2P40ho6ipwPlCvvWsSYEKT1 X-Received: by 2002:a9d:806:: with SMTP id 6mr136392oty.90.1579033840471; Tue, 14 Jan 2020 12:30:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579033840; cv=none; d=google.com; s=arc-20160816; b=ageogY2D2z2AMDPGnbtL0hVsZJ4L9O21ic4cXojlxlOkrq3XGT9x9+F72nu3+x/RQ8 oxcWJ27OwcIbPGh7aNZAcC8FBLsAwEPIzEeWaYuy8OE8dpFqJZlrgAhlcd3TohiAyE3e 8U9M3DrEYgPpir6JIF8kLlhslOZOLEIDyVUS6J91l+jAOKkP8J7o9HTpurA+xmCU4Pju EfomIQAirYoPr0DLdAilhCLXbcVahc/B1ICpzzHOHEulOIa7arSdL/mXOCDoTnZSv1ff UPuF4CQn+ST6/3Y4yQ11XHqYKIWCj1cYvgjWl9sgGTUm7OcAPU2PalDY6ApcJADK0HpM 18ug== 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=1lQWtsFqQ4hkDiboBrmE69qOP+9Ah0O7izoXNaG8zkA=; b=eQ/3rnio4CmTaDgDVwmZA0RWwZwxBNpD6JyDdEAS2rs6EiEecQ0yycRUHoJXQZRfdg wGnGYimIq+tc0WxpfQLZc6+dNJZ97Yng29DAuytV9vUK6YXB1x1VHktvy7jzxgBtX2gz e9eBW2KtlO7E9zl/4rYrK+F1ptn/2KE0bKoadkk22gpZR2oTlmM4lmGgfqb8xACWEB5r 7nN8NK8ODxYPjdtJysEB0ncMrSEEflH4pg/zLK1meMAV3Sx+NapHX01L09t8I1r5cf7q SH/ElN24LhmqvMIqsXrNZRsUJOBeuekZ95oXqTAknz1W1iZ6U6VL4J93qiGIk+cK32iq GB7g== 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 h14si8124748oie.98.2020.01.14.12.30.27; Tue, 14 Jan 2020 12:30:40 -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; 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 S1728754AbgANU3b (ORCPT + 99 others); Tue, 14 Jan 2020 15:29:31 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:35586 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbgANU3b (ORCPT ); Tue, 14 Jan 2020 15:29:31 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 9CD84292AAB Subject: Re: [PATCH v5 1/2] platform: chrome: Add cros-usbpd-notify driver To: Prashant Malani Cc: Guenter Roeck , Benson Leung , Lee Jones , Linux Kernel Mailing List , Jon Flatley , Gwendal Grignou References: <20200114031056.44502-1-pmalani@chromium.org> From: Enric Balletbo i Serra Message-ID: <4ddf93f1-fe0c-763c-25d6-144bdce5cd4c@collabora.com> Date: Tue, 14 Jan 2020 21:29:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/1/20 20:23, Prashant Malani wrote: > 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/ >> one problem is the above^ drivers/platform/chrome/cros_usbpd_notify.c:67:27: error: ‘cros_usbpd_acpi_device_ids’ undeclared here (not in a function); did you mean ‘cros_usbpd_notify_acpi_device_ids’? The others I didn't dig in. My build commands are the common. make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig # Enable the new cros_usbpd_notify driver make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j4 Cheers, Enric >> 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 */ >>>