From patchwork Mon Feb 5 19:44:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197029 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1158324dyb; Mon, 5 Feb 2024 13:35:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IETy7vljXJxpOFY5PASZsWnSY2z3H7G8oTHXBdaL2QEeMLPvmzj+dbmoW0pOgNE0bUtI/J+ X-Received: by 2002:a17:90a:7404:b0:28f:ee83:13cd with SMTP id a4-20020a17090a740400b0028fee8313cdmr9651836pjg.0.1707168950911; Mon, 05 Feb 2024 13:35:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168950; cv=pass; d=google.com; s=arc-20160816; b=Jp2Yl6QFOxj0pSZzVDrhFVvtYqeAecjSd8uVodbVRIJXBsO8ShkJF6DC/NVhri3+1W MRfzeaN/Q0GXpnVvnOASDm1RU6DVmJNuCzKSO8f2CQm0Laat0hqvDgDef6NTpI2aBREG JpDa7spjULawm5pnxfUrj1hAfDXfRrnZj1EQ4F4cCZnlqkPkA6jywl48mETmCHHTTpKD 5Bn/zM5eoh7/N+SLbC0MuYxYajnUavD3+cRT2N1ogC8+k8OJqzYiDUdgrbF110jD1L0K 4nWsJCYH3LfMHedZMhKg7Fnyr2hCFAZ5mSLt4yvjLWPtOXE77Q4VTYGpLcW4/tG8AgzH 5Flw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2C083AYY3Dbpmc6BgF2r63gVH+xSPvAPWXFMl2z3vuQ=; fh=mhaPA8Gk9hQadp9HCtCbQB3YsyTin8hWW0xui1HDfc8=; b=OARp3RyGAJvjc6TsaNJsqcerpZa+hwuorFT7lFfR7Jw21GcM1J3/bWnORWpUqKzLlc ZaWA/5j0Qfm2hv32bOu2xMrA5ZgaJXif2LTRq//y8iJvNv3zLCgyW+2zP92c4BrKl81T 4EQULThiUTT3qevG4lptJHtWy6kQGiHeTYJidx7kOgBZxLaZid+SqrhG11UBXZmLQTUU pashBbfCkXPh7fReApDRtwP5MQ6SrFpLvuFG7AMIQBrQcEAmBrhIsU+Iu9LeFEAkEsJ7 3tgLgIoWWC15U2c2IDUUL5x5aZWyVSBWUAI3IK7x3rrkPYeJtfHoCH1RcSIRZGRZhf4z Dfzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GdF5tHW4; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-53852-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53852-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXoIX/W891tQEtXSy6FK9a2egHMyJc9M8hTaWxw1pXE3jO0DIyv/wHqGxL+KzX86FKPw9CFamETBARWiArYfvkQ0T0I0g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id fa8-20020a17090af0c800b00296167b289asi522406pjb.135.2024.02.05.13.35.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:35:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53852-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GdF5tHW4; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-53852-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53852-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4331C285E76 for ; Mon, 5 Feb 2024 21:28:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D65F77F1E; Mon, 5 Feb 2024 19:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="GdF5tHW4" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA31174299; Mon, 5 Feb 2024 19:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162309; cv=none; b=ZuxNgiVD9JBOkyXSm8C6PwTvyg+v90j5XywkjjpHlZNJpiP5RuM4H/u0Q3jnSxUL4S8T01oWoMGf0g+ZqO8ZJmhs8S3CjoNbeB0KbD27rSry5TcaQoe4qV+5Ski/1HsuxGrTAm/3H/7OOnu7pa8ESEWtkgJFpzWy/aQ/rqKe+3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162309; c=relaxed/simple; bh=uYeg52mDdc1d+Ytv8BgQ3wN198N/i0H+W5WTdHa6VeA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KgC5D1AX9+H/B9p4PaidGb3+vrzQ1yDjX3yfBrGPK9Lm61eFokS8n/AQVppkRHkLeI/AAcG+CezswVFznoygVG4PZJFDzvCvnR0EL40b1cZuXe7ot5WP9ndSEPGSNDDY6SMpYcva0A4F3M0hpszj7OEXTXexe+r9if3Sdz/e3m8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=GdF5tHW4; arc=none smtp.client-ip=198.47.23.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415Jio4c101210; Mon, 5 Feb 2024 13:44:50 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162290; bh=2C083AYY3Dbpmc6BgF2r63gVH+xSPvAPWXFMl2z3vuQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=GdF5tHW4vzndgKxEyXIeI8eLEW54cQWpCTP52/uyE3c97R3xx9IYCNHWFvivSJ+N0 MH37hDvqVgS7bwgbvdOrxoNtlus6KLo4v76Fy1eIO2HeCoQ1YOh6L7oLcxAA449kl4 0td0wfa8r3oakbSl9C1XYXrpobQbKABB21LhqjR0= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415Jioca003534 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:50 -0600 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 5 Feb 2024 13:44:50 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 5 Feb 2024 13:44:50 -0600 Received: from lelvsmtp5.itg.ti.com ([10.249.42.149]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 415JicQe028467; Mon, 5 Feb 2024 13:44:49 -0600 From: Andrew Davis To: Sebastian Reichel , Manivannan Sadhasivam , Cristian Ciocaltea , Florian Fainelli , Ray Jui , Scott Branden , Bjorn Andersson , Konrad Dybcio , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno CC: , , , , , , Andrew Davis Subject: [PATCH v2 17/19] power: reset: restart-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Mon, 5 Feb 2024 13:44:35 -0600 Message-ID: <20240205194437.180802-18-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240205194437.180802-1-afd@ti.com> References: <20240205194437.180802-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790096390117230215 X-GMAIL-MSGID: 1790096390117230215 Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis --- drivers/power/reset/restart-poweroff.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/power/reset/restart-poweroff.c b/drivers/power/reset/restart-poweroff.c index f4d6004793d3a..fcd588f9ae9d3 100644 --- a/drivers/power/reset/restart-poweroff.c +++ b/drivers/power/reset/restart-poweroff.c @@ -14,29 +14,21 @@ #include #include -static void restart_poweroff_do_poweroff(void) +static int restart_poweroff_do_poweroff(struct sys_off_data *data) { reboot_mode = REBOOT_HARD; machine_restart(NULL); + return NOTIFY_DONE; } static int restart_poweroff_probe(struct platform_device *pdev) { - /* If a pm_power_off function has already been added, leave it alone */ - if (pm_power_off != NULL) { - dev_err(&pdev->dev, - "pm_power_off function already registered"); - return -EBUSY; - } - - pm_power_off = &restart_poweroff_do_poweroff; - return 0; -} - -static void restart_poweroff_remove(struct platform_device *pdev) -{ - if (pm_power_off == &restart_poweroff_do_poweroff) - pm_power_off = NULL; + /* Set this handler to low priority to not override an existing handler */ + return devm_register_sys_off_handler(&pdev->dev, + SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_LOW, + restart_poweroff_do_poweroff, + NULL); } static const struct of_device_id of_restart_poweroff_match[] = { @@ -47,7 +39,6 @@ MODULE_DEVICE_TABLE(of, of_restart_poweroff_match); static struct platform_driver restart_poweroff_driver = { .probe = restart_poweroff_probe, - .remove_new = restart_poweroff_remove, .driver = { .name = "poweroff-restart", .of_match_table = of_restart_poweroff_match,