Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6532498rwl; Mon, 9 Jan 2023 09:28:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXs9zBx0wmW+DUMYZooDkIAQ10BnjcO/1XUgVsnPC0z4dGEid1TvHcXSNjIrYe+tcjCTfRD5 X-Received: by 2002:a17:906:c092:b0:7ff:7876:9c5b with SMTP id f18-20020a170906c09200b007ff78769c5bmr53058055ejz.70.1673285338443; Mon, 09 Jan 2023 09:28:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673285338; cv=none; d=google.com; s=arc-20160816; b=ICiu/NE5d5E33YtTs/Fn8iIeypj065kGr1CIgT/90BE9mvQcNTaa2f/Jo94BwK/pw0 7BDkW9Vr/PJ3k3WknIw5+EnrbgKZOyxtvXGfdJ2YRzE0bCtJDqssqyETM3TDiy+O8tSF OPNy+n9gJ2HNJEzj/BIyll6iSJl9qij5vvi+Xri3Uy1wFgAvEj1ekN7VDPgfJqB136TA rEB7YcKz5TR1xaCgXnU0nykR03nNHXCn+xTpu7TKKxv2t6DA2vXLSpPMmaOkw/adxrbb pOSXcPH30mCT4dcmXutvDaU6aYdMWriSs1UWS3OADxtmfqvd2vunLqq19V6uvYIbhzcW 2U4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=bjLHmqoQwogtloleviQRNznqj8dnVnunWmSEfYcRiJc=; b=vgdQwDxR4bQzhLXdEUCHZhyVJgDEOAVlD8ogV+3/HJtZtMcopVUY6BfjMPSPbauQAg DRddqDznraMX2lVYA/VX01EmGYjqft/Uq5v4AjAdxEThg6PMDEZeFeDnsx5jMI8+0pL+ rTb/FrFL6YVAGup6MXKOnzrZzrK+W5pB8v6SBD51P5umQ6qxmbdc27fdTw1moPWOrgBD UF6ZjKsI1Aif6ACOGPfMWOEw52bUbRemXHfRLWUuNZFLQEBeCJXEPucKRFrTbkVx7EqM UPSPYE5H5bLq3T4aKyLZnewE0IHyixhkkpfbGqMvUF4BOdjmk1UFUQddyG7cL6pNtYIJ Ibuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FMY1mzh0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w19-20020a170906b19300b0084d3497942esi5349213ejy.331.2023.01.09.09.28.45; Mon, 09 Jan 2023 09:28:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FMY1mzh0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236276AbjAIRNY (ORCPT + 53 others); Mon, 9 Jan 2023 12:13:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234756AbjAIRM7 (ORCPT ); Mon, 9 Jan 2023 12:12:59 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B97958829 for ; Mon, 9 Jan 2023 09:11:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 37054B80E76 for ; Mon, 9 Jan 2023 17:11:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DCE3C433D2; Mon, 9 Jan 2023 17:11:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673284316; bh=sOKBXH00f4x9Idnwc6yY00btcdQhBdQ61HUjUHD4HCg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FMY1mzh0TPROyPBXs/bwOIm6VLSKyEi5kAMHsyHNQW4XK+6mSaW85K6w6bCgGMYSV Ss9Mfg4diy8lB3uh3V7W4TDlReOXayfe017efcSs3Gr5C0ccGTl+CNtGq2B+9adNyJ CBK/Dw1Qzqc3J/vGai1tWFR7vVck8RfGbuoimczcnt5I8zvi0jpDk+GsoWwnbfe9/a 6K44hwxOIAL3PV7zjxhP17wy8o+Q4tQlAqq2nT/x1Lp0s7lXKXuogqT6c9RkAYj48h VEB2C/YAzelA2xnYGYCaidK01LS3BjkQumwae1bR4T64cDlpHxMHw9XhY/rZBOAnyA zHv4J56k7sZJg== Date: Mon, 9 Jan 2023 17:11:52 +0000 From: Lee Jones To: Samuel Holland Cc: Chen-Yu Tsai , linux-kernel@vger.kernel.org Subject: Re: [PATCH] mfd: axp20x: Switch to the sys-off handler API Message-ID: References: <20221228162752.14204-1-samuel@sholland.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221228162752.14204-1-samuel@sholland.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 28 Dec 2022, Samuel Holland wrote: > This removes a layer of indirection through pm_power_off() and allows > the PMIC handler to be used as a fallback when firmware power off fails. > This happens on boards like the Clockwork DevTerm R-01 where OpenSBI > does not know how to use the PMIC to power off the board. > > Move the check for AXP288 to avoid registering a dummy handler. > > Signed-off-by: Samuel Holland > --- > Note: this patch depends on updating the PSCI driver first[1] to keep > the existing callback priority. > > [1]: https://lore.kernel.org/lkml/20221105214841.7828-1-samuel@sholland.org/ > > drivers/mfd/axp20x.c | 26 +++++++++++--------------- > 1 file changed, 11 insertions(+), 15 deletions(-) > > diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c > index 47fd700f284f..58f82f1f4b43 100644 > --- a/drivers/mfd/axp20x.c > +++ b/drivers/mfd/axp20x.c > @@ -23,7 +23,7 @@ > #include > #include > #include > -#include > +#include > #include > #include > > @@ -825,17 +825,17 @@ static const struct mfd_cell axp813_cells[] = { > }, > }; > > -static struct axp20x_dev *axp20x_pm_power_off; > -static void axp20x_power_off(void) > +static int axp20x_power_off(struct sys_off_data *data) > { > - if (axp20x_pm_power_off->variant == AXP288_ID) > - return; > + struct axp20x_dev *axp20x = data->cb_data; > > - regmap_write(axp20x_pm_power_off->regmap, AXP20X_OFF_CTRL, > + regmap_write(axp20x->regmap, AXP20X_OFF_CTRL, > AXP20X_OFF); Nit: Can you pop this on the line above now, thanks. In fact, forget it, I'll do it. > /* Give capacitors etc. time to drain to avoid kernel panic msg. */ > mdelay(500); > + > + return NOTIFY_DONE; > } > > int axp20x_match_device(struct axp20x_dev *axp20x) > @@ -1002,10 +1002,11 @@ int axp20x_device_probe(struct axp20x_dev *axp20x) > return ret; > } > > - if (!pm_power_off) { > - axp20x_pm_power_off = axp20x; > - pm_power_off = axp20x_power_off; > - } > + if (axp20x->variant != AXP288_ID) > + devm_register_sys_off_handler(axp20x->dev, > + SYS_OFF_MODE_POWER_OFF, > + SYS_OFF_PRIO_DEFAULT, > + axp20x_power_off, axp20x); > > dev_info(axp20x->dev, "AXP20X driver loaded\n"); > > @@ -1015,11 +1016,6 @@ EXPORT_SYMBOL(axp20x_device_probe); > > void axp20x_device_remove(struct axp20x_dev *axp20x) > { > - if (axp20x == axp20x_pm_power_off) { > - axp20x_pm_power_off = NULL; > - pm_power_off = NULL; > - } > - > mfd_remove_devices(axp20x->dev); > regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc); > } Applied, thanks -- Lee Jones [李琼斯]