From patchwork Thu Feb 1 18:00:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195413 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp338686dyb; Thu, 1 Feb 2024 10:03:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSNyLYvtuQ8Axd+Px9S2X21OWQoufy0HZtNxwFkUFbs+ywQLIJJHqiS2qOVIwVjvgWSnGK X-Received: by 2002:a05:6402:d78:b0:55f:a38:a4f5 with SMTP id ec56-20020a0564020d7800b0055f0a38a4f5mr5192682edb.11.1706810590097; Thu, 01 Feb 2024 10:03:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810590; cv=pass; d=google.com; s=arc-20160816; b=tfeCYxR0GK/JeMg29iPgAfxLyJX/DWVBURCYD2kGtaKp6UkVMtGY0uVqzRXMmDgEFY CeEm/vMhmVCJp5WH8uUDb6woMMmn3y9B+C4AF++WeyWyYcaLyWW8PjKJknBeG1DBEkOF oYsknTxZBMIw+gyqHp5kxfszqhysqCPQjO3Bf9AOdv5SzJASANgbKw6ydfBtJ9VKQZrj V4Cm5LzMDCaRBLbVt3hvyXeVgD+F5tyctyC/QJg+QzOyzGJKm7/9pdP0u0FX19wk9j1j h+fxgK/HOK05BnmbwPLTAeRw499J2LJZi1HTxTSjPpYjjPeB2Ag9/Oh81/LiWqZw9Lau JHlA== 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=ngOnUmcKUfVk/SqAddQuFt8kMzihNR+9E3bjKI3tkA8=; fh=PbzkFqq9CYsXBCCMBbf7OkrMf4jlA6glgqf4UGHS/8w=; b=BedZU2O1xnEQryYfA/SYrK7e9EIYRK8015qaEMqO0uwqAhJrIsL+BSVL26mEweh3Qf N7kZ5rx+sNp+KH/dZFhkxzVivZmb51CPxJpsXTgS7GKp1ThYlCid4+htDu6Vp85476tP Fm3Uk6ZIyXt9hZITVr49O1A/S11PykzgcswLV1klOrtd9WzZpIbvUcDzJGtAekPBR2wg /QeeEooXMLVCGzsg5jOO8+5gu63iS5zJ51MI6Be7+ZZmFab0oRx61FUG/Nu12FR8+Rl1 Cl/TCvnMMw4MAilbEUqkHK+fOy5UILwwo0YyMxJZjpvWQFdMNxnFfDshS+NgycXiaeyl 2JpA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="wC8nhKc/"; 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-48636-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48636-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCVLKuh9cBxUZjShVWYdJbx1126aMN3JrBoF6SdX4ozdeQGSXAY7aqkh8dgD6kJLNpdhvJC1jwqOSQiY3R2qYx59AS8nNw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cy2-20020a0564021c8200b0055c2df7fa74si29102edb.529.2024.02.01.10.03.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:03:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48636-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="wC8nhKc/"; 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-48636-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48636-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 CA0441F23F59 for ; Thu, 1 Feb 2024 18:03:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3617C127B46; Thu, 1 Feb 2024 18:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="wC8nhKc/" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 A3E0984FB1; Thu, 1 Feb 2024 18:01:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810487; cv=none; b=DPoi3V7rtzfjjhILlJO6zFol/y6XGy4gcDuxlrthJhgdOrADZp8kI6Pt5xsjx1G3ZdZIXTCqLWRwnHrt36rVjJSzD2oJZn67ijg1+kQIQdnN4iq6KVeyQVnmVv20o8EMpacJlNDM2EpJuiDMYGXK0XvNN1TRXrNeN2VHlHCsa6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810487; c=relaxed/simple; bh=ig53Er0IQr8J52R1XJK5g8TmLfD/5crHUpIF26cVFwU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LWdL0Cp/bQQMywt5vL2VfBkEgckdqPa2/gtXbCvFPcafzAOlcyZ2f5Xh0Z0CxRNkoTYyrPfth/sfx64DY49fJ9I9lf6KPN7irwS5ZAdA1IVQyrVsxm92Cj+J4FQq/dPBbAtKEQbg+hAe6Nn+Ko5OL6ct3S2gGB+umJmmBvkcIqU= 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=wC8nhKc/; arc=none smtp.client-ip=198.47.19.141 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 fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 411I19Yr049608; Thu, 1 Feb 2024 12:01:09 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810470; bh=ngOnUmcKUfVk/SqAddQuFt8kMzihNR+9E3bjKI3tkA8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=wC8nhKc/6Xj7NXCKH5q2UKfbxE5WvY3T9C9I4VEKY3P/I8fabPJdzpFtaEtyqWQtk AXbR8Q7WjCGp+oVKS/cpcuU5P3exGd+CpSMUScfzCUBg2v1Bl4Nj6dJ3Wi17nAor18 ZG8YIfrPCcSWImLKRGlX44Jae52pQALGR+2QeSuc= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I19j7047547 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:09 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE114.ent.ti.com (10.64.6.35) 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:09 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE105.ent.ti.com (10.64.6.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:09 -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 411I12Go117221; Thu, 1 Feb 2024 12:01:09 -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 10/18] power: reset: mt6323-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Thu, 1 Feb 2024 12:00:54 -0600 Message-ID: <20240201180102.70395-11-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: 1789720621245694575 X-GMAIL-MSGID: 1789720621245694575 Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis --- drivers/power/reset/mt6323-poweroff.c | 28 ++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/power/reset/mt6323-poweroff.c b/drivers/power/reset/mt6323-poweroff.c index 57a63c0ab7fb7..ca5d11b17ff03 100644 --- a/drivers/power/reset/mt6323-poweroff.c +++ b/drivers/power/reset/mt6323-poweroff.c @@ -14,6 +14,7 @@ #include #include #include +#include struct mt6323_pwrc { struct device *dev; @@ -21,11 +22,9 @@ struct mt6323_pwrc { u32 base; }; -static struct mt6323_pwrc *mt_pwrc; - -static void mt6323_do_pwroff(void) +static int mt6323_do_pwroff(struct sys_off_data *data) { - struct mt6323_pwrc *pwrc = mt_pwrc; + struct mt6323_pwrc *pwrc = data->cb_data; unsigned int val; int ret; @@ -44,6 +43,8 @@ static void mt6323_do_pwroff(void) mdelay(1000); WARN_ONCE(1, "Unable to power off system\n"); + + return NOTIFY_DONE; } static int mt6323_pwrc_probe(struct platform_device *pdev) @@ -51,6 +52,7 @@ static int mt6323_pwrc_probe(struct platform_device *pdev) struct mt6397_chip *mt6397_chip = dev_get_drvdata(pdev->dev.parent); struct mt6323_pwrc *pwrc; struct resource *res; + int ret; pwrc = devm_kzalloc(&pdev->dev, sizeof(*pwrc), GFP_KERNEL); if (!pwrc) @@ -63,19 +65,20 @@ static int mt6323_pwrc_probe(struct platform_device *pdev) pwrc->base = res->start; pwrc->regmap = mt6397_chip->regmap; pwrc->dev = &pdev->dev; - mt_pwrc = pwrc; - pm_power_off = &mt6323_do_pwroff; + ret = devm_register_sys_off_handler(pwrc->dev, + SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_DEFAULT, + mt6323_do_pwroff, + pwrc); + if (ret) { + dev_err(pwrc->dev, "failed to register power-off handler: %d\n", ret); + return ret; + } return 0; } -static void mt6323_pwrc_remove(struct platform_device *pdev) -{ - if (pm_power_off == &mt6323_do_pwroff) - pm_power_off = NULL; -} - static const struct of_device_id mt6323_pwrc_dt_match[] = { { .compatible = "mediatek,mt6323-pwrc" }, {}, @@ -84,7 +87,6 @@ MODULE_DEVICE_TABLE(of, mt6323_pwrc_dt_match); static struct platform_driver mt6323_pwrc_driver = { .probe = mt6323_pwrc_probe, - .remove_new = mt6323_pwrc_remove, .driver = { .name = "mt6323-pwrc", .of_match_table = mt6323_pwrc_dt_match,