From patchwork Mon Feb 12 16:28:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 199904 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp30418dyb; Mon, 12 Feb 2024 08:34:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVEO1O56N8M+JMuHezCwaLiZJQCLKUzOx/aiPk6PwK37DxRPTKgK67ZtG87C/tQNflnAHnW2PuPQd7FSTdsEDtDgITroA== X-Google-Smtp-Source: AGHT+IHewDCS68rBaYKxwGv6Xhrb9wOljt+Dky+1AqAv1uom2b18Ey5ldhpVoqZenBLn9w0T/hxw X-Received: by 2002:a17:907:76cc:b0:a3b:ae82:a721 with SMTP id kf12-20020a17090776cc00b00a3bae82a721mr4559179ejc.77.1707755657289; Mon, 12 Feb 2024 08:34:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707755657; cv=pass; d=google.com; s=arc-20160816; b=a5mS+ckXVQoog0YMlRzvLyX32tTWw+Jb1+WEF+Fb9FplqQjZ1WP+rz9l7cP2xnK6Xx v49rinc/JPyxgyTDU96ZV/ecG85btZ5rw7EdoJLB4pXjilKtVo9xGw5FzdKx3Y1axJkT 0YbpRh4YytizwzRHWDNnKPexf8VJ+ItYkgIGhYU7z/ir1JI63svN/+eLEzjU+onU1DSZ bu/LAjDVyi3n9jhH+gscfJI8agbhhvVaKpzjHBrsIFQNCZJcANeRvmeDaQXzIKvg5Tgw VPVpWlQaURlprCLhJd+paJcEXfPVMwUwq1J2gE6/FHT34+he7RZ9CJbqTT3nwlXbIpPY aUbQ== 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=YBjzo9gJtOpJSbCsQ7o/XWGSUmnayPmrnaQ4cwqNkNA=; b=O6yubhL+jBDwp31Jkp5Zj2jjjg/PAdCBGtRWxS7bXu5RDbJsdV1MQlBDBqmzyKnvPa sTCYU3BwGcZf3XSPnuSymM89I327ehxLTeDvYX19v+uhvrHsR/6sRhhzqVpTNiqj9cxu i+e7GmbdVVJb8OOBs/TwA/pDR3xtz++MTFfAhoznfZv09y8TH88i7zu1fG2/fhifqDsl OcTyN+/HxePNHILWmxegdlwqsfiFJqT39ffNYSB1hem2muGXw0kVQHULe+ZanJuCIpkj NCVXPun+BREKUbC50RnQwFD+CdDYNe8Uh0kFuHuKdy56uiwI+se8+y8zXlPOXNPnh+BZ 3n8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=FhZJa8zX; 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-61972-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61972-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=2; AJvYcCWOF9yp6dkqPF1IyFwWuaXLtMcOzzOtBOYH3+fbem+lsMsyDLGdjV/DNQmR1NwcdSs91wwGZxlYOGufPUyJrddODTbVzQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a24-20020a170906275800b00a3be99f21f3si314637ejd.767.2024.02.12.08.34.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 08:34:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61972-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=FhZJa8zX; 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-61972-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61972-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E15841F22987 for ; Mon, 12 Feb 2024 16:34:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A1E54D9EC; Mon, 12 Feb 2024 16:28:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="FhZJa8zX" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 7A11845979; Mon, 12 Feb 2024 16:28:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707755336; cv=none; b=mercUKsx73G95rIYFT3OU4eMjFIEs4x49cKA+azXjEmM64zqX6iR/nCxpRm8RJ+KlSxCKjs0K3x+LaA5mVKilnRp0XvVjUmPhdVge1WWouLMD3xaCfKfapUdHxSO2E/y7outFRtdsNmlDdvLDG5NMA/+PkS/JM4JUkKBYa95EXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707755336; 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=K4vaekfB2vWZ7JOL54KNNmJTqT5GkGmzm/d5vTA3ZNA44Hm6tEZWzOFsddOBl3bAOft5T5PKbxD7N13hXNgbawR3B1gd3HIrlJe9yqtQTSytsMmcpGiC0z9XlQT4xl/m9HeLtOyVzKZHQMxpTdG3MXdHQU8TPt5AGW1Drv0ygFE= 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=FhZJa8zX; arc=none smtp.client-ip=198.47.23.248 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 lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41CGSiaq045228; Mon, 12 Feb 2024 10:28:44 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707755324; bh=2C083AYY3Dbpmc6BgF2r63gVH+xSPvAPWXFMl2z3vuQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=FhZJa8zXqUlGfri6+7NSdSKghrmp/oFQo4NCFcevA2xq9hK7sk56QPLMhJ+UVuRTf 55iI0W69dhALrbMVBskOar7brWAML7N4FHQRw+rhehtt6nfM0DBXF4SKuVXWfnP4Xc j5SJRp75LxIcJvvYxEPu76DV7TPUnRWaJqCh3nZs= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41CGSihZ024951 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 12 Feb 2024 10:28:44 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 12 Feb 2024 10:28:43 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE106.ent.ti.com (157.170.170.36) 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, 12 Feb 2024 10:28:43 -0600 Received: from lelvsmtp5.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41CGSWRD090688; Mon, 12 Feb 2024 10:28:43 -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 v4 17/19] power: reset: restart-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Mon, 12 Feb 2024 10:28:29 -0600 Message-ID: <20240212162831.67838-18-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212162831.67838-1-afd@ti.com> References: <20240212162831.67838-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: 1790711596026597397 X-GMAIL-MSGID: 1790711596026597397 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,