Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8500567ybl; Thu, 16 Jan 2020 18:11:34 -0800 (PST) X-Google-Smtp-Source: APXvYqzgjznfHZqyTVW4i53zZJfqkggRljvtO7gCs6qpSmjtN4HQXl+ArMQsRUXiGhIAKao4sYfd X-Received: by 2002:a9d:708f:: with SMTP id l15mr4753212otj.229.1579227093919; Thu, 16 Jan 2020 18:11:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579227093; cv=none; d=google.com; s=arc-20160816; b=kjSopyKiXQ1A4IrIwWbqR3kTPygZ/gnarpI1LY/RilwG+xhV25KALeIVr6PsjmAMGE XH9Cd5GtcNlAN9U8kRmDjiYEctb+gj3Bo93yeTb3F7OdIit9Ipx/erzkZPokX0Vj2Oyy XApTTKTwMitoAAjLucD6leY4G7tx6tncGcLv78G9IDb53GsdQ80GT9V8TBuvm1qmDcse rj2GFureGd+W1rAdZxqg3i4ciLcSWnDV2Ya031Ef3lgkuUEYkHZYQRTa862DeEJjAaEb JoIUQIgHvXBBlNVYx1LC2DwbM59zMPV+RHqga46U1K2dF69RdsfHhk0hw7oOsaouP1zO KGcQ== 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=NUb8ilLBAhUZ6/jWBRcP+4R7/8UlPkVpgXywFwbpI6U=; b=FlIL0S3hxhyO0OEVyLFvYHHIBpd9BVjp3x8wKx4HG57uEV040DlAyCDYGok3xZEQsf eW0wP90Sjzadap0fYCc3L652oTPqZiXXNlxmT/DRNLiRnrBry8D6nu+9v68W893PF8iT U/TL/4+ayMGlKZ8ozBdCaTPS7cO6pFNllKAmut4+BtEY3DixGAnvVfmllh1sBW1CINVm 2XmvoogPl+lHmMT96i8Di3kM2fvFakSsC+GtV83poED87sCsbz/RAAzR222YZVwXmKC5 mHPd/lNE2gkQEuRSHg5IbSOhtTiNRcpQZruijXLkQiySGt2+npM85bX32nvR1g6Ff0w5 fuAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="TYC/GqZ5"; 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 i6si14008266otp.5.2020.01.16.18.11.21; Thu, 16 Jan 2020 18:11:33 -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="TYC/GqZ5"; 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 S2389803AbgAPWJQ (ORCPT + 99 others); Thu, 16 Jan 2020 17:09:16 -0500 Received: from mail-qv1-f66.google.com ([209.85.219.66]:41430 "EHLO mail-qv1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388875AbgAPWJP (ORCPT ); Thu, 16 Jan 2020 17:09:15 -0500 Received: by mail-qv1-f66.google.com with SMTP id x1so9858701qvr.8 for ; Thu, 16 Jan 2020 14:09:15 -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=NUb8ilLBAhUZ6/jWBRcP+4R7/8UlPkVpgXywFwbpI6U=; b=TYC/GqZ5SQrKgEdAAYYA9Wut1vr7vwQzUWfzcrfJ2CSuF+xvvIw7qNNmJQ4xTwesfM e3VyuCwNqv57wZoT7JPmfyoeilP1kSDk3rvXlnK0W8N0gJsZCmu6A76umz/I9HhPoQiM LkhvhsaENVh/dt2wy9RTxLdRxZ2xvim6+8lVA= 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=NUb8ilLBAhUZ6/jWBRcP+4R7/8UlPkVpgXywFwbpI6U=; b=swvs9ycWkffE4vkIFK3+Yy9Wv/DX0g1bbJMq4N3teblCaKhoVCyvqoVEZLfaKIHrFk iApfmsqh13AqP49MCYabeJwzcSSJa8MseDeG8f5ARgVZYYOOr8xlLk7rHE2XF9paDs70 spDWRh6uBgkzfDfK62ymMHt91zvyPncCBr6bAcRJjVsE+pp+IM/iD0uCL6iStzCElTcs UlfiGdLLm5as6R9gVQ94LrGFViKqPdRXiGjLgJ3D4TkswWJ5SsGmOZXLHKSqQef4ZJVt TaV2zXYNrZHqaNZL+6GAbKNf7OW2g9VTDqysJ5Yjscqh1kH28sc9XtH2FOrzqxwg4o7A P1gw== X-Gm-Message-State: APjAAAVHoq7AfGJYCMsiQ9IM46tKWWAbmwOsksv5V7ONn6bySp5o79Al 1tzQKcMqTvSJNmyLEAD1NaW4kJQZtyt+gkq2vYFviw== X-Received: by 2002:a0c:e790:: with SMTP id x16mr1240023qvn.18.1579212554458; Thu, 16 Jan 2020 14:09:14 -0800 (PST) MIME-Version: 1.0 References: <20200114232219.93171-1-pmalani@chromium.org> <20200114232219.93171-3-pmalani@chromium.org> <20200116194556.GB208460@google.com> In-Reply-To: <20200116194556.GB208460@google.com> From: Prashant Malani Date: Thu, 16 Jan 2020 14:09:04 -0800 Message-ID: Subject: Re: [PATCH v6 3/3] power: supply: cros-ec-usbpd-charger: Fix host events To: Benson Leung Cc: Enric Balletbo i Serra , Guenter Roeck , Benson Leung , Lee Jones , sre@kernel.org, Linux Kernel Mailing List , linux-pm@vger.kernel.org, Jon Flatley 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 Thu, Jan 16, 2020 at 11:46 AM Benson Leung wrote: > > On Tue, Jan 14, 2020 at 03:22:22PM -0800, Prashant Malani wrote: > > From: Jon Flatley > > > > 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, update the charger driver to use this > > new notifier. > > > > Signed-off-by: Jon Flatley > > Signed-off-by: Prashant Malani > > Only a minor nit. Otherwise, > Reviewed-by: Benson Leung > > > > --- > > > > Changes in v6(pmalani@chromium.org): > > - Patch first introduced into the series in v6. > > > > drivers/power/supply/Kconfig | 2 +- > > drivers/power/supply/cros_usbpd-charger.c | 50 ++++++++--------------- > > 2 files changed, 19 insertions(+), 33 deletions(-) > > > > diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig > > index 27164a1d3c7c4..ba74ddd793c3d 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_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 6cc7c3910e098..7f7e051262170 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 > > Really minor nit. Alphabetize this #include. This insertion should > be one line below. Done. Thanks. > > > #include > > #include > > #include > > @@ -524,32 +525,21 @@ 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; > > + struct charger_data *charger = container_of(nb, struct charger_data, > > + notifier); > > > > - 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_usbpd_unregister_notify(&charger->notifier); > > } > > > > static int cros_usbpd_charger_probe(struct platform_device *pd) > > @@ -683,21 +673,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_usbpd_register_notify(&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; > > } > > > > return 0; > > -- > > 2.25.0.341.g760bfbb309-goog > > > > -- > Benson Leung > Staff Software Engineer > Chrome OS Kernel > Google Inc. > bleung@google.com > Chromium OS Project > bleung@chromium.org