Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4798977rwl; Wed, 28 Dec 2022 09:00:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXthruGzEKG6asZpeAAeDmrE9w0lha9H+goZBu22r4K21K+/PVAUIquu5II3vIazvYlbIu0/ X-Received: by 2002:a17:90a:f309:b0:225:c112:c871 with SMTP id ca9-20020a17090af30900b00225c112c871mr22528539pjb.12.1672246814108; Wed, 28 Dec 2022 09:00:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672246814; cv=none; d=google.com; s=arc-20160816; b=Ha5YQTMldAz1MqUF+CLlJ0PZctSPsvHId51toYUzGcmdWWVI1lYg7/jpjOdysS++bt KWzgLnZjN3jMPe+zoPPCEm7i/KggVDqWB/O8XQoLzTJ+uCoJlxBDFCy8/6PUkc1ZpkRE PlQbJ5brHy5Maql2BPRqwR16GM7MSCwB4QP43U3UAS1sppOBvYgBn4SiOuDJFAuJ1fce RpEtMrV0mnr7d1SF6477NcEG3WpOv3AwYSk1gjwA2jz6Wvv9+62+GF0Tm6+lDceFDhDR CXzb+/D6R7HWw2jqd1M0EARRBgUNN8BUpmjXcQbFO3BCT4lHXA0+dF4sYBFWkc+/w9vR aS2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:feedback-id:dkim-signature :dkim-signature; bh=k1jw7prIecCK9PqphsN3qWRlGngXIbmWqvs3m/zFc78=; b=HBiq8lQQgwsca5K1Wc+IQ0T5NlVpkFpAUMUN465bBpy01SNZAvJYgJuc2st4Uso+Y8 gDU29MNW6ZMo3C81zbOmF3GOvnPp/ETtf4jPKCWm+LZEDqIEa3Q9k3ucAUtkdLUdfOkh O0duWu1H7rGu4kv5bhI8oh7ZttVwlq6f1iYZhucNyTtajwbZUrnU8lhEE69VgLiEuJgc S7yY4+SQaC7T2PgiJK5JI2YoRH5t/4ZuTZe7oZ04reBEp1GCK1PAGIyM9+s4U8h0nIk0 SGO1PLDcnx1QA3AGSaZCqDGeYonG6GMMRw0h99FzcqxsTHHwyYJ3iaAwHKvptTy5qCNx Vm6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=JzE+szhB; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=GTrwt7em; 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=sholland.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rm8-20020a17090b3ec800b00212d06b4743si21876607pjb.34.2022.12.28.09.00.04; Wed, 28 Dec 2022 09:00:14 -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=@sholland.org header.s=fm3 header.b=JzE+szhB; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=GTrwt7em; 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=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234723AbiL1QcF (ORCPT + 63 others); Wed, 28 Dec 2022 11:32:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234726AbiL1Qbj (ORCPT ); Wed, 28 Dec 2022 11:31:39 -0500 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13DE11C113 for ; Wed, 28 Dec 2022 08:27:55 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 253D632002FB; Wed, 28 Dec 2022 11:27:55 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 28 Dec 2022 11:27:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to; s=fm3; t=1672244874; x=1672331274; bh=k1jw7prIecCK9PqphsN3qWRlG ngXIbmWqvs3m/zFc78=; b=JzE+szhB/q3OHjuOXgjukbGQve4Ad50vdmnw19NuC eunjp0gTYik63zu2/Z/Ms5QlTfmJ5pLKhLfwGl1Rjr4L5wBEGD0SHnTHKKtEp79D PHxwppXMyY4ZQU0jIEYBOkf9Pu+R1eMs5aH5bJBAsEv6uLSk9sA2/rrS3et1EJM8 +B1vkg1XcT86TxYMUTZNJobzBtQ+aGv59uD5S9ONRthf8vHPUVq9nzCU/ilvvbw9 T0HwLQO3yPZwcu0m0FBbuQBLcLbhyjXTvRHywqFN6nebEy6L58tUaCY3ljIoqoNP 5mxKoNxeZdgWVHqkgbORTi3O7iGAs6PSDgL0ccvOtdo4Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1672244874; x=1672331274; bh=k1jw7prIecCK9PqphsN3qWRlGngXIbmWqvs 3m/zFc78=; b=GTrwt7emst8sYUEVNRfZdZOAzN3a6NLnqkGZ8szSn0nB7FVRzaA 8sOZUtHz03dVgUcb8oSAMVAHzuanjicl54VwWwhedHrfolbHDz5Fjx4pk6RIuFru ts1j9GhdJUs9Idw6QYpnx7RO5qfQdCSwWjKVzXCI6hRoug9gnqU+XSKDOFxdPQFO S3vuV6CfLBDhZEh7eb/k81vVsuW8KMF5ZEQO9cMUMY12OSlMgxOIb0bZ9F/mTvrn dTDswTpOid75th2nRVrdWmIx16cstxyKd9V2KyL1qXxcBOdint06hiCJcq8w87qY tD0DgaYgXSjVuzOLXBLGYkczfBJY1KMia5A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedriedvgdeltdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgggfestdekredtre dttdenucfhrhhomhepufgrmhhuvghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhho lhhlrghnugdrohhrgheqnecuggftrfgrthhtvghrnhepkeehffethedtteffgfefteetje dvfeelueevudffgfeutdejvdehledvvdffhfevnecuffhomhgrihhnpehkvghrnhgvlhdr ohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Dec 2022 11:27:53 -0500 (EST) From: Samuel Holland To: Chen-Yu Tsai , Lee Jones Cc: Samuel Holland , linux-kernel@vger.kernel.org Subject: [PATCH] mfd: axp20x: Switch to the sys-off handler API Date: Wed, 28 Dec 2022 10:27:52 -0600 Message-Id: <20221228162752.14204-1-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, 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 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); /* 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); } -- 2.37.4