Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3734838ybc; Thu, 14 Nov 2019 13:58:55 -0800 (PST) X-Google-Smtp-Source: APXvYqyE0x+J2FS8wNypiOgGEX3YT+6py3wNG0XV/0rEhSJ7UPKEsezLdDWfEMGLNJWXwvA2xYhR X-Received: by 2002:a5d:5262:: with SMTP id l2mr10880188wrc.315.1573768735725; Thu, 14 Nov 2019 13:58:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573768735; cv=none; d=google.com; s=arc-20160816; b=jYmiSiwUpP6p3CdXNVwDNeqva6P8bKSnSi85euZKDQvnoGXQDse1kxixnmrvdIWE+R ALToJsBOUI3RvyJ7bgoJ9nhRjW3Fc+Pi3F0i/9TsFDO44ucuhPNFv1htKTw84n1lWNLO dsADI98rsJkd1k9GkiEhVlXtyxXuIq2EbSsa5hc/la/WxIsSY3wsjViKgpl66/v4OeYH Xlr1bC9yPismYx6lBnZ4NLpZo9iiAKvDd3rgTTQKqcCE58TMS8j8ntKydBJltK4Cg5Ad 22R+TYR8MFcJf2QpkaeBYoyHWsbM4pcnbiphjWxKUhgsDn1SIsDCulqCqnFwvX7LTm+I zppw== 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=9TQxPEhJ1QpedI2fdAYdmTWIf385KUzKuDuP9UXKDbw=; b=HGQkBVoSlkdDh1oxrVGKds+SXu+qsagN2Pfp8D4cGwVRsoPmqPPBqbZaj0JqrNUdBQ 5Ip+A5gdLSckeLEn9tn3OBRjEFIgdH4w5FnnMVPd6VdZEqzQcCBZIJ3lSgnlOPx6uJZA pD7nEd/p5lvPzfAeakanw5BeydVcP0NUSA3ubUJFrU+xg2HDqRrcaZkXWIhyuwxxCfMd IOBLgBVNPWRVflAVjA7zShWbdHeWNeTKl6ZVF8UEocQoUgBpvQxDyVkDbhzfN4oMxKAu 0fYtm/ijxwJtb+mQPChLBbdXxBhZE+ODFPGfIBTZI5Ae5YsXjCKcL/km4wIvRcEMJTyu tpfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tFR9JxRu; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b26si2422791edc.25.2019.11.14.13.58.30; Thu, 14 Nov 2019 13:58:55 -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=@gmail.com header.s=20161025 header.b=tFR9JxRu; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726952AbfKNVyb (ORCPT + 99 others); Thu, 14 Nov 2019 16:54:31 -0500 Received: from mail-qv1-f67.google.com ([209.85.219.67]:35131 "EHLO mail-qv1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726613AbfKNVyb (ORCPT ); Thu, 14 Nov 2019 16:54:31 -0500 Received: by mail-qv1-f67.google.com with SMTP id y18so3024048qve.2 for ; Thu, 14 Nov 2019 13:54:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9TQxPEhJ1QpedI2fdAYdmTWIf385KUzKuDuP9UXKDbw=; b=tFR9JxRuB2005f/p1gQKTsGFJfT0C6h+RJFiPWI6h6v2v7oa4P48Xv+rkwZ+WJqqLi f8Apio/Gt2QaaEysuTW7Vi5TNOjSw2s1uhNfV3JU+RzGHsOwY2FlBnMx1Mjk+c7MNz0V 43lxWmZOLxaiQr0OQCMKceh8Nv3cdITAtI7XeO/cgAn5nFJfizHr5Sw6RgXH0jkkxmtB cEsB7DOX86xt0J9FKG8jfqZTNaIv0ZxY8JlSpHnqM3srfFmWGxyfaZSZKtGsVwJHqOyZ eBgXalrQpj8puWtFFe2zPVUOAe7UWq0CaHOdo/uKI2txZwoVIVcrRudw4LfIgfnxi/jV mcGA== 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=9TQxPEhJ1QpedI2fdAYdmTWIf385KUzKuDuP9UXKDbw=; b=ZFHeHLaoEbYX1HRGKJmyrEgeIW/udkJmoA/cxj9S3zu0403b2wfL0KWBaJqSUTqdu5 OJyXr5JyeYc/JMRrGITNuppm3VAlAa6XdHZ3eFT9XnEm70D3IxqrhB/17hiNpbb1DnkN ebanOOcY5FwreILkcKKX3e6v8Tw76olVOCIli3wAj6qpHSX/GXNh1B9IwsuEJMxhBAY+ POjlkPUdwSxlREQyjeN+qrf761P0jgeBcFD85Jm179VBD3BCdF0pYfO8ZwXGqgIq/0zF qqnnz/LcugpOeejF9tOoimqCUF2jLFhkdO/2MTcqlUgNjiTcDvZdjgkchMbTP3tbMhY0 +muw== X-Gm-Message-State: APjAAAXLf2qBTzqdlL8YgCFPeskUQ3xHoJ03+rO4ZlDgeQxX+tu+sWNC Tj4SyzSBnSnB0US9WDQcDXilODsy3ejnMiMo6rggyw== X-Received: by 2002:ad4:4e6b:: with SMTP id ec11mr10497224qvb.121.1573768469560; Thu, 14 Nov 2019 13:54:29 -0800 (PST) MIME-Version: 1.0 References: <20191113031044.136232-1-jflat@chromium.org> <20191113031044.136232-3-jflat@chromium.org> In-Reply-To: <20191113031044.136232-3-jflat@chromium.org> From: Enric Balletbo Serra Date: Thu, 14 Nov 2019 22:53:51 +0100 Message-ID: Subject: Re: [PATCH 2/3] power: supply: cros-ec-usbpd-charger: Fix host events To: Jon Flatley Cc: linux-kernel , Benson Leung , Guenter Roeck , Sebastian Reichel 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 Hi Jon, Some comments below. Missatge de Jon Flatley del dia dc., 13 de nov. 2019 a les 4:19: > > There's a bug on ACPI platforms where host events from the ECPD ACPI > device never make their way to the cros-ec-usbpd-charger driver. This > makes it so the only time the charger driver updates its state is when > user space accesses its sysfs attributes. > > Now that these events have been unified into a single notifier chain on > both ACPI and non-ACPI platforms the charger driver can just be updated > to use this new notifer. > > Signed-off-by: Jon Flatley > --- > drivers/power/supply/Kconfig | 2 +- > drivers/power/supply/cros_usbpd-charger.c | 45 ++++++++--------------- > 2 files changed, 17 insertions(+), 30 deletions(-) > > diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig > index c84a7b1caeb6..7664849d7680 100644 > --- a/drivers/power/supply/Kconfig > +++ b/drivers/power/supply/Kconfig > @@ -659,7 +659,7 @@ config CHARGER_RT9455 > > config CHARGER_CROS_USBPD > tristate "ChromeOS EC based USBPD charger" > - depends on CROS_EC > + depends on CROS_EC_USBPD_NOTIFY > default n > help > Say Y here to enable ChromeOS EC based USBPD charger > diff --git a/drivers/power/supply/cros_usbpd-charger.c b/drivers/power/supply/cros_usbpd-charger.c > index 6cc7c3910e09..58cf51b51179 100644 > --- a/drivers/power/supply/cros_usbpd-charger.c > +++ b/drivers/power/supply/cros_usbpd-charger.c > @@ -8,6 +8,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -524,32 +525,22 @@ static int cros_usbpd_charger_property_is_writeable(struct power_supply *psy, > } > > static int cros_usbpd_charger_ec_event(struct notifier_block *nb, > - unsigned long queued_during_suspend, > + unsigned long host_event, > void *_notify) > { > - struct cros_ec_device *ec_device; > struct charger_data *charger; > - u32 host_event; > > charger = container_of(nb, struct charger_data, notifier); > - ec_device = charger->ec_device; > > - host_event = cros_ec_get_host_event(ec_device); > - if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU)) { > - cros_usbpd_charger_power_changed(charger->ports[0]->psy); > - return NOTIFY_OK; > - } else { > - return NOTIFY_DONE; > - } > + cros_usbpd_charger_power_changed(charger->ports[0]->psy); > + return NOTIFY_OK; > } > > static void cros_usbpd_charger_unregister_notifier(void *data) > { > struct charger_data *charger = data; > - struct cros_ec_device *ec_device = charger->ec_device; > > - blocking_notifier_chain_unregister(&ec_device->event_notifier, > - &charger->notifier); > + cros_ec_usbpd_unregister_notify(&charger->notifier); > } > Can we get rid of this function and call directly cros_ec_usbpd_unregister_notify where the function is used? > static int cros_usbpd_charger_probe(struct platform_device *pd) > @@ -683,21 +674,17 @@ static int cros_usbpd_charger_probe(struct platform_device *pd) > goto fail; > } > > - if (ec_device->mkbp_event_supported) { > - /* Get PD events from the EC */ > - charger->notifier.notifier_call = cros_usbpd_charger_ec_event; > - ret = blocking_notifier_chain_register( > - &ec_device->event_notifier, > - &charger->notifier); > - if (ret < 0) { > - dev_warn(dev, "failed to register notifier\n"); > - } else { > - ret = devm_add_action_or_reset(dev, > - cros_usbpd_charger_unregister_notifier, > - charger); > - if (ret < 0) > - goto fail; > - } > + /* Get PD events from the EC */ > + charger->notifier.notifier_call = cros_usbpd_charger_ec_event; > + ret = cros_ec_usbpd_register_notify(&charger->notifier); > + if (ret < 0) { > + dev_warn(dev, "failed to register notifier\n"); Hmm, now I am wondering if should we only warn and continue or fail. Makes sense have this without the notifier? > + } else { > + ret = devm_add_action_or_reset(dev, > + cros_usbpd_charger_unregister_notifier, > + charger); > + if (ret < 0) > + goto fail; > } > > return 0; > -- > 2.24.0.432.g9d3f5f5b63-goog > Thanks, Enric