From patchwork Thu Feb 1 18:00:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195426 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp342611dyb; Thu, 1 Feb 2024 10:07:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFlMG/wWHADewaTKK+CYmAevgPPcHOHLIxyaldyAtTEFd2e3uiF0ryJtCqfaq20/Kzu3jZa X-Received: by 2002:ac8:5b8a:0:b0:42a:b61a:410f with SMTP id a10-20020ac85b8a000000b0042ab61a410fmr7245234qta.56.1706810854716; Thu, 01 Feb 2024 10:07:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810854; cv=pass; d=google.com; s=arc-20160816; b=PVl6QXRU5pY4Px/oih33Ydb9KTYftaysu8/VIAQv8b4UsCCcfUEpkJbpTGcrO4HG0i 9Dmf5Al7beJakGlQPJpkGErzTlVDaO7zdCwPxHctw5q3P2i8EZza4ECctnRB/62GtBw7 6YOp6Q358WLan1Rfg41bPtBvQOGZ/01SwZ4AFZBjUopU86xtvK3wZGqmGxT7LdWEeWgB 2Cy4QIyp5AB2+5gMHNi0cfv6pXjCo9rSloPcLpJYem7nS/HpZfMoX/t7VqchgbdY2cAM x1JS9WR47LPNTfsN1pOBq3t8XfC0CLcv1J6G9ugnQDgD+p8k6VcpGHlFaREZ/uutDc76 fiYg== 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=+G0+pgJSnU5fwVCPi6o87aIaEwxTHSWkqXIA7rb/G3g=; b=Bvw46n0cPyCiXe2p6VWLK47JcRKOPVcMTL+kds0srtDudmjbTc69wFqbaWSxUJjfeO JyO1TwW8qmfGpa1U4rsTwRvlBWmFvGFm0luAoupQ8ldc5Dt4D+BQcU1++H1RpziqeJ8X nMzb7fZWjFuyygeBh30OY5KKUOq292yQfKnaM4LnJ+xnUX4oHRBsh+iqjIt1BGAMXlV5 nDDsBDbtX8cEDSh+HO4ozrHcU+QyRkm1duD8NYvBFIN2Kc8dKvhjjtEyqxxAXctp3m4C 9CZypsTzaB+Ls0dZAZpZ+Y30l3lH15xNSh8wTmPYgOaGgK7/fd3UpXSwr0ZFDFi9/ks9 /P3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=UyO5EnnD; 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-48650-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48650-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCWGrDPjrbZG3UvH5/znuunhxJWCcTumCGhaxho4ZzekW96cfte5b1GMSJaJXQke1toYtpI0KQOqD0l+y9dbJP4Bpz1cBw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a18-20020a05620a103200b00783f21c1280si49961qkk.507.2024.02.01.10.07.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:07:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48650-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=UyO5EnnD; 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-48650-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48650-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F04511C28C7B for ; Thu, 1 Feb 2024 18:07:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19F5812D16C; Thu, 1 Feb 2024 18:01:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="UyO5EnnD" 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 C4D0712E1ED; Thu, 1 Feb 2024 18:01:40 +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=1706810502; cv=none; b=qnnyfaE/QcqQqG7rFaPfUdBTLE+fdrlqZlX/cANwK+nO0+0ktmUrerVm3jGlOjE8DVq4rKv1EPfeGFINpNkBvx9lbIWJb9n404G5QbQjj/VmKx6QWlsxmCAeM35LZ1+ppTw78jqVgQkAQIze4A9Pyfz94adHUkCAZaKGNcR5xBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810502; c=relaxed/simple; bh=piMJuCp6Oyf7VRRgvElf9jQlTaTY6OoJDvy6PpEE/uE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MKzF0EDq367etnYP5OoVEyHfVtPHDyZx0cEShMtK9f21QF3bsXMbOXxL2aHt9C4cB1dAM9Tu0yfV6K+Z64e4FRPZ9AxUhKMsD6fpzUOsWuYZz51it4t5n+Bm3O8WIuyWBMMWz90qFVSlvqoQpEesHzeEjSPIXR5QLf5iNSd+Jk8= 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=UyO5EnnD; 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 fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 411I1C0e127793; Thu, 1 Feb 2024 12:01:12 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810472; bh=psW+zR+255VuGRBEiZa3qV2ZSoJCA9HDeWGIZlh4BNU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=UyO5EnnDRngm9H5SGH1A+jEgO7wkevXIJJ227pxDcUetRFvBS9480xEhg15nfp+R+ nj4Su04MrkyrG0saepA77HVR2LW/DreMBTJ1KaHdr9Oo5AsU5avhRdjIixfbcnDmGI snG8ICoQK2Ebi8klQh3Udfc9/3St+CDi3QE8n4v0= Received: from DLEE111.ent.ti.com (dlee111.ent.ti.com [157.170.170.22]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I1Ctb047604 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:12 -0600 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE111.ent.ti.com (157.170.170.22) 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:12 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE115.ent.ti.com (157.170.170.26) 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:12 -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 411I12Gs117221; Thu, 1 Feb 2024 12:01:11 -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 14/18] power: reset: as3722-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Thu, 1 Feb 2024 12:00:58 -0600 Message-ID: <20240201180102.70395-15-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 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789720898649129009 X-GMAIL-MSGID: 1789720898649129009 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);