From nobody Thu Nov 14 16:46:50 2024 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 F3AB485281; Thu, 1 Feb 2024 18:01:36 +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=1706810498; cv=none; b=F8fkZWklH+tiPgS4NVjtyEoIglHoj+7VwEB3YX2aQ66JFsmfPluiJr7oxTzEmA36K1jPmO1Jen4MdPsinMKLOW2jWQ/5nL3gFiv3xUP2XGqxONKfhpoKu7ZuRddYVnP8yRALu+hbvbAVQFMCAnOyP4Y3YFyHT8xSdJbtlDN+uXQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810498; 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=t3IpnsTssZZI6eyXcFX9EX2eLuHeYZ6GWMvRHez632ydkHIv7d12EQg/8zPMBZb6/HlvwtOpEKsGRT0bnXf89bqEv9mJVDnH5+nVb6o4o1yJSfruYGie7IlV7uDUsKFHDa06qsHNPw5HNduDVIsGYVVmYmJ+u3nalt0fVbcuR9c= 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=hm/vqbXr; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="hm/vqbXr" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 411I1DCY127798; Thu, 1 Feb 2024 12:01:13 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810473; bh=2C083AYY3Dbpmc6BgF2r63gVH+xSPvAPWXFMl2z3vuQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=hm/vqbXrgkdvEpEseIm/bM006N8riAizOx5/j5+hdGUZD2Nwf8XevghZVYgJcCZYX moNtW0wPVgM0bo/dIgq99Lg+ZyUwU4PnhEgq8uFb8ItIAU3nD91AialkzNiRSAX7Q6 QRo6p/JDDnQOeM0s9Psit199C7qg0fU7vbq7GRS8= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I1D6k029277 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:13 -0600 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 1 Feb 2024 12:01:13 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE112.ent.ti.com (10.64.6.33) 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; Thu, 1 Feb 2024 12:01:13 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 411I12Gu117221; Thu, 1 Feb 2024 12:01:12 -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 16/18] power: reset: restart-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Thu, 1 Feb 2024 12:01:00 -0600 Message-ID: <20240201180102.70395-17-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240201180102.70395-1-afd@ti.com> References: <20240201180102.70395-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Content-Type: text/plain; charset="utf-8" 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/r= estart-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 =20 -static void restart_poweroff_do_poweroff(void) +static int restart_poweroff_do_poweroff(struct sys_off_data *data) { reboot_mode =3D REBOOT_HARD; machine_restart(NULL); + return NOTIFY_DONE; } =20 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 !=3D NULL) { - dev_err(&pdev->dev, - "pm_power_off function already registered"); - return -EBUSY; - } - - pm_power_off =3D &restart_poweroff_do_poweroff; - return 0; -} - -static void restart_poweroff_remove(struct platform_device *pdev) -{ - if (pm_power_off =3D=3D &restart_poweroff_do_poweroff) - pm_power_off =3D 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); } =20 static const struct of_device_id of_restart_poweroff_match[] =3D { @@ -47,7 +39,6 @@ MODULE_DEVICE_TABLE(of, of_restart_poweroff_match); =20 static struct platform_driver restart_poweroff_driver =3D { .probe =3D restart_poweroff_probe, - .remove_new =3D restart_poweroff_remove, .driver =3D { .name =3D "poweroff-restart", .of_match_table =3D of_restart_poweroff_match, --=20 2.39.2