From patchwork Mon Feb 5 19:44:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197011 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1154450dyb; Mon, 5 Feb 2024 13:26:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+dUecF/9hTLJCq3dgA9fTSDronbTfYWcIg/T47aPVOjjfqdh4x6y2bQAtxhnjP7d16Irj1LVfYRYtAsYc4FAphEmifA== X-Google-Smtp-Source: AGHT+IGbWiT5Op8g7Pwi92ISdzBmFGAbxd3dnLsXjJ8x8ciug0sgEL6jD45zHnsJUc1wDNsJEoKm X-Received: by 2002:a17:906:319a:b0:a38:1afc:9699 with SMTP id 26-20020a170906319a00b00a381afc9699mr4556ejy.8.1707168418194; Mon, 05 Feb 2024 13:26:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168418; cv=pass; d=google.com; s=arc-20160816; b=z/yfo870/6rBwIdIrete+NHXb0sK1ahHtW7otSkKyBTIudXhdLdXOJeN8ZFTxRvwqV P3q7aQxsKRelWzisaHvSik+0NGYIdYnmF2i68sa2YVw4A0AXSUp5gD1UjhVqwRmLeKTW YYN5qajO9at7nsKlBNQqfI+skycqHelc97MpzzMBVoCiFA1NQ4nT7sUYTNJ0SbIgFb7J lIat0hWs4DM1KGgKYSvz5bIfeHnvnOviOSV5GpkgtohOObLy2WAp1bImE9VAjkAWjAGh 64EHY07KUhucIJWAhf+QnxU2zSYQ3DFzzUW5Wya3o3mCMf+mBUXP+IVyfgAMbC+kOo/L sHaQ== 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=psW+zR+255VuGRBEiZa3qV2ZSoJCA9HDeWGIZlh4BNU=; fh=et5sLwdLe7qx4enzZsUxbiW1j2JJSNJJOelFGqcJZvI=; b=KcA+/NBbGc0/cLqGeGWOltP2YGWJNKvtaSNv/WISYudaVZphjmjgAygdKq4QHAQt/8 UVLFlyzhd/WztGdDuEjVS6JXrxfa9Ra9fY2L2x87tsUGIlfIWsngFvoXpRhhvGhGT08o Wl5YkaGlpRh1dvUVo6OGDbgSx+gZyXzk6zB69RENI91jLE677DQpTXE4j0P42ooaLYVO cPp7J1WPo8O49VN9AB5Zo9MdqGJfLH3RLFG+5En5xkMzKrucuaIctBKElDPh+FetaI2X QNtPRduGmcfOiyCa6wmQxs3+wTX7rCoDf+DiepcMfw/ssbqYZ25qakIAIcDEcXvPkcEy A+gw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=SuZoOmzM; 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-53844-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53844-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXf9v7xex8PwuExHWj6Xvstxc6S0jg1RI7VduXFRRahDhQdD/Ws4r2+TxVZ2IRbnYRdGnkRnaojBiQMyzDgf/irrt5Pwg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b26-20020a170906039a00b00a374a28c88dsi250219eja.140.2024.02.05.13.26.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:26:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53844-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=SuZoOmzM; 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-53844-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53844-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 360E91F296A6 for ; Mon, 5 Feb 2024 21:26:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEB7A7316C; Mon, 5 Feb 2024 19:45:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="SuZoOmzM" 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 89E8163519; Mon, 5 Feb 2024 19:44:59 +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=1707162301; cv=none; b=qDDW2rUOyAShkrmy+vgyEhGEZVPmlrF/dslJuBfFH5sbVuGE76Ei6xIqs2LCQ0oq38rRIkkWytRBUltyoj52Z8Ue4T7O/L+nm5ZHvtFL/abDlS/vfwOc2gRUU3sysb2HG4D4nPtk8W79RP2sT673TWQiB89bRsG8Dr+tRpwWTPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162301; c=relaxed/simple; bh=piMJuCp6Oyf7VRRgvElf9jQlTaTY6OoJDvy6PpEE/uE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eL5T3VFQpEmGQNblKvCISPv8g1T05N+Zcsp7gOrcNZMObSGHX7Zku6R0rX8PAxxOAcPZglvwbaOLaz6K0HzJX6mnWoUvkH3LhLrM4rm+5/wvfC86fGGs9w0gGA5PvoxXXCOfkmR6cRqHZcsEKK9cHmYYcqidjamgxE9RSnV3tLY= 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=SuZoOmzM; 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 fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415Jinwq016365; Mon, 5 Feb 2024 13:44:49 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162289; bh=psW+zR+255VuGRBEiZa3qV2ZSoJCA9HDeWGIZlh4BNU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=SuZoOmzM5855zc/unDBamQAPnbFh0/l+IxHxo2mxv2GwQprAXhgzERtF0WhwdSlBt iO8s+waONp/E83sOwXJBp+QVS9zaaaHIhBYzhSghzJLoPn10V+141BhWYz1eZyaODq kbEdG9zh1qI+sPO/W9iMoTgsaO0P0zi0K3kZiohs= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415Jin4Q090697 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:49 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) 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:48 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE107.ent.ti.com (157.170.170.37) 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:48 -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 415JicQc028467; Mon, 5 Feb 2024 13:44:48 -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 15/19] power: reset: as3722-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Mon, 5 Feb 2024 13:44:33 -0600 Message-ID: <20240205194437.180802-16-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: 1790095831288480336 X-GMAIL-MSGID: 1790095831288480336 Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis --- drivers/power/reset/as3722-poweroff.c | 30 ++++++++++----------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/power/reset/as3722-poweroff.c b/drivers/power/reset/as3722-poweroff.c index ab3350ce2d621..bb26fa6fa67ca 100644 --- a/drivers/power/reset/as3722-poweroff.c +++ b/drivers/power/reset/as3722-poweroff.c @@ -11,6 +11,7 @@ #include #include #include +#include #include struct as3722_poweroff { @@ -18,22 +19,18 @@ struct as3722_poweroff { struct as3722 *as3722; }; -static struct as3722_poweroff *as3722_pm_poweroff; - -static void as3722_pm_power_off(void) +static int as3722_pm_power_off(struct sys_off_data *data) { + struct as3722_poweroff *as3722_pm_poweroff = data->cb_data; int ret; - if (!as3722_pm_poweroff) { - pr_err("AS3722 poweroff is not initialised\n"); - return; - } - ret = as3722_update_bits(as3722_pm_poweroff->as3722, AS3722_RESET_CONTROL_REG, AS3722_POWER_OFF, AS3722_POWER_OFF); if (ret < 0) dev_err(as3722_pm_poweroff->dev, "RESET_CONTROL_REG update failed, %d\n", ret); + + return NOTIFY_DONE; } static int as3722_poweroff_probe(struct platform_device *pdev) @@ -54,18 +51,14 @@ static int as3722_poweroff_probe(struct platform_device *pdev) as3722_poweroff->as3722 = dev_get_drvdata(pdev->dev.parent); as3722_poweroff->dev = &pdev->dev; - as3722_pm_poweroff = as3722_poweroff; - if (!pm_power_off) - pm_power_off = as3722_pm_power_off; - return 0; -} + return devm_register_sys_off_handler(as3722_poweroff->dev, + SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_DEFAULT, + as3722_pm_power_off, + as3722_poweroff); -static void as3722_poweroff_remove(struct platform_device *pdev) -{ - if (pm_power_off == as3722_pm_power_off) - pm_power_off = NULL; - as3722_pm_poweroff = NULL; + return 0; } static struct platform_driver as3722_poweroff_driver = { @@ -73,7 +66,6 @@ static struct platform_driver as3722_poweroff_driver = { .name = "as3722-power-off", }, .probe = as3722_poweroff_probe, - .remove_new = as3722_poweroff_remove, }; module_platform_driver(as3722_poweroff_driver);