From patchwork Mon Feb 5 19:44:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197013 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1154942dyb; Mon, 5 Feb 2024 13:28:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV0LUPn7W+h0dVbc9K7exR7UocuJJlYshpwL2uZSnyZIc9mo5mUdrKcbVNG5cIqcWSvuFqPGPv+SnJv1Z7Mh+p4UcrLvw== X-Google-Smtp-Source: AGHT+IFJrR0JqW7D9gJw2cQV7KIGqpT8akX+R4/rU/fPlx6/xZebTRG97F9X7fvemgt4QxrnKoY5 X-Received: by 2002:a17:906:1bb2:b0:a37:9603:a1e4 with SMTP id r18-20020a1709061bb200b00a379603a1e4mr386913ejg.48.1707168502618; Mon, 05 Feb 2024 13:28:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168502; cv=pass; d=google.com; s=arc-20160816; b=pvcMfAcFCJaqWbtLzzlHSmYqJyxkYHeKknmjnFvCOpyKz740zF/R5SJ6+Jj9i2de9B DrlkNGGpogB9btc3ncKJIURj+6eF+E97nky5gw0BaRe8CQkiKetaXuGw0D82kl49roNS OKUH0NgSqJkPrnS1bQeGRy68lZaceiGhCSCybm3MP21XecR6mqhEW/tXh9R2okWqiGCW 2LASZStyt/XH9j6KfUoW40zzZhbDe4u5Zxp7H1nT4976pw8AdtNpWjFG3wjNl6FGvXum 7A40BRWKRjzTC2lb3kDhntwwcBO/ajPayRrt95mGHyn1oS801UPtR6wqX85UgYXM4Cwq xXeg== 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=eDTJGp1LNK+YD1bJfvgjkV/rIr2yWhv+8KTb7j41Dpg=; fh=FUgeRLa9NDVtUi7+hUBKdiMVcKDD2MI3GbvF0xiDepo=; b=LqMMLYncHoIxPB2/MTrfmViIdiN2qfTQALhmeS2ze14oRNGlspKUV79rWbOsaDxI2k VD10qAtW2p/d79FOk+uyl7bgNRS2Q3Y+qkFeyaoQyRlGSFMkMB7ZleUbIH0wpQKq9xJ1 bSCYHubOwI0SkEGyo/NF6g9Fc7zvFEIT+ZzoUy9mhQfczWb6lGrsYv/gCQVlTGmQ3Rai SffkUU1GUOhdgDJ1ALCKvwEEe5nfzQE2wmooSAx71AtywX4Ul+HUNwO3Uu9YskSQgdf4 ap24LVZ+02urDz1xQFwmYgHQPLe5B/QLPbED60LZfHMPXuf56rNqbuTAZBOw/S0si4Jz o//g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=KGtXTaIK; 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-53848-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53848-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCV17wSL3MYBqtrifE9i2ltfQWg5dof6d105tQ8y+6Epk7/9XsZpzhGZtWh3Xnrk4eHQg/EtWlu06Wr93z7mXUuY2QamkA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id yr5-20020a170907334500b00a3735f02e4asi257755ejb.671.2024.02.05.13.28.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:28:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53848-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=KGtXTaIK; 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-53848-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53848-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 29F0D1F2598C for ; Mon, 5 Feb 2024 21:28:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 710147AE60; Mon, 5 Feb 2024 19:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="KGtXTaIK" 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 8FC3173188; Mon, 5 Feb 2024 19:45:06 +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=1707162308; cv=none; b=pBQYZuThpTlTpSk3zc18gu6gRFYSq/eZ2bAuPtYLiJMCY3hvjxMDQ53YX74IlELDp7Br+LZ7RDpl2RH2vEph6O7D6k0m3NWwpKADinFBrlc4mg83khxapR6WyWH6Mrtene4hqgos2ko6EP0LXtwCYjyPS8jzYFDuZL/xYosGFtM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162308; c=relaxed/simple; bh=hjODPAvfHHQsYQrgcPIWkoWLz7Tm/5vLqy/n+aT9TWU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nT+57Zg8sOPYocbka7FeU81/OUBvUihepKBOZ1Uxuw3EJz5m6S+M3Vnhxwm8DbLtaUI4tXePTeOSf+TJGnD9wG1hjis6Ze3nqj8LXRMmcu6AjLPsBR9hWxhaoo/4/nH9Hezu3KmrKpvPCA6T5UuFHSVIrr4IGlOAYpU/a24nyus= 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=KGtXTaIK; 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 415Jie0V101173; Mon, 5 Feb 2024 13:44:40 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162280; bh=eDTJGp1LNK+YD1bJfvgjkV/rIr2yWhv+8KTb7j41Dpg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=KGtXTaIKNpTRCgWBMxGewdtW9tr/I49a7Z6K481Uik1P0I1jmVPDkLL4LC4RmiwSL kbqjMOuV6A/o7E1vPAxfCQOecHNyXihZEC/UzRmE2nGNU1EY8C2LP6+VjYVJsqcqJZ 2Z5+sJAJ00dSOv36Teztbx8N5m0qnvRUl1yyo76E= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415JielY090555 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:40 -0600 Received: from DLEE113.ent.ti.com (157.170.170.24) 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; Mon, 5 Feb 2024 13:44:39 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) 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 via Frontend Transport; Mon, 5 Feb 2024 13:44:39 -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 415JicQO028467; Mon, 5 Feb 2024 13:44:39 -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 01/19] power: reset: atc260x-poweroff: Use devm_register_sys_off_handler(RESTART) Date: Mon, 5 Feb 2024 13:44:19 -0600 Message-ID: <20240205194437.180802-2-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: 1790095919527060050 X-GMAIL-MSGID: 1790095919527060050 Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis --- drivers/power/reset/atc260x-poweroff.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/power/reset/atc260x-poweroff.c b/drivers/power/reset/atc260x-poweroff.c index b4aa50e9685e1..ce2748d3282c3 100644 --- a/drivers/power/reset/atc260x-poweroff.c +++ b/drivers/power/reset/atc260x-poweroff.c @@ -16,7 +16,6 @@ struct atc260x_pwrc { struct device *dev; struct regmap *regmap; - struct notifier_block restart_nb; int (*do_poweroff)(const struct atc260x_pwrc *pwrc, bool restart); }; @@ -172,11 +171,9 @@ static void atc260x_pwrc_pm_handler(void) WARN_ONCE(1, "Unable to power off system\n"); } -static int atc260x_pwrc_restart_handler(struct notifier_block *nb, - unsigned long mode, void *cmd) +static int atc260x_pwrc_restart_handler(struct sys_off_data *data) { - struct atc260x_pwrc *pwrc = container_of(nb, struct atc260x_pwrc, - restart_nb); + struct atc260x_pwrc *pwrc = data->cb_data; pwrc->do_poweroff(pwrc, true); return NOTIFY_DONE; @@ -194,8 +191,6 @@ static int atc260x_pwrc_probe(struct platform_device *pdev) priv->dev = &pdev->dev; priv->regmap = atc260x->regmap; - priv->restart_nb.notifier_call = atc260x_pwrc_restart_handler; - priv->restart_nb.priority = 192; switch (atc260x->ic_type) { case ATC2603C: @@ -225,7 +220,11 @@ static int atc260x_pwrc_probe(struct platform_device *pdev) dev_warn(priv->dev, "Poweroff callback already assigned\n"); } - ret = register_restart_handler(&priv->restart_nb); + ret = devm_register_sys_off_handler(priv->dev, + SYS_OFF_MODE_RESTART, + SYS_OFF_PRIO_HIGH, + atc260x_pwrc_restart_handler, + priv); if (ret) dev_err(priv->dev, "failed to register restart handler: %d\n", ret); @@ -241,8 +240,6 @@ static void atc260x_pwrc_remove(struct platform_device *pdev) pm_power_off = NULL; atc260x_pwrc_data = NULL; } - - unregister_restart_handler(&priv->restart_nb); } static struct platform_driver atc260x_pwrc_driver = { From patchwork Mon Feb 5 19:44:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197008 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1153873dyb; Mon, 5 Feb 2024 13:25:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGikwqq6w9ztUjpb0CKI2Ij3mIy7Rj/F17zJqwTI2u+eDNsdGrhB5CHXBZ+E014fDnscglt X-Received: by 2002:ac2:5632:0:b0:511:1b35:51e8 with SMTP id b18-20020ac25632000000b005111b3551e8mr304397lff.53.1707168340550; Mon, 05 Feb 2024 13:25:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168340; cv=pass; d=google.com; s=arc-20160816; b=YrK308HA2G8BgYIvxGzQDqCyeT2Yh28mQUdTeJDzfftOODNqslK4sN4DTsLlxmV+hg YiSPJ99aN3NvMg+t8zzjWiFXGM/WzYu7TFaWS1RJ/3jlsh5gddxsGsM/SM8cIvXCN9Nu DxcvVN3CbFxs87jBftAVpzPuU+YI1HKydrjED/QmoEklwpB4aZNi744r7nNIZNlLtVPl 9aLzOHdc3A68rjzj5R/KSL3y6yJNLPTTydyRy9XDsap1c2k+w7yltZlPiJncTyFXJR6w VxuphEo9wx4m3tOdhmtIJPro3pz63wNP9MOAApMZqPMjEqwRS1TBWdOprsw/5mXuDfU9 yI1Q== 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=2cm9ruqVmpJKRpRfi1ywbymPKB5JK0jfSdZffEo1IXY=; fh=b8XK7woOxFnDQqtMn/hMSJxjnBnSAMBsCSfvu8XBnoU=; b=BoId+myDr+DBl2OT1ajuC6Di6NaSzUnJuwgd7/j/URt+HMdWLnlbmEmRd/+YUqNY+i 6b9yMPyw4pS92vMydCunAEkLc8PkQuUKP3DGvyPr02h8lWnrqlWkXpZxfVFRWo7Ic8r5 JGutJqmB2BwSQjp7TcQj91Qe6Bo8q3g52/Noh+KaN2TmmvUaOYSrM2dmi2SVqMvXfCwC nLqUM6hq9rcFnMDTnjHbqAq/m2MyHUjuIwTlR5zvX9WS3ywqq5SUFmKmhkfqBfGGv6kq UpN6jDCNnfEtsxslpOX5eVAJHUlRGJddVt39jVMKXDGcdSw9R0KWfvpPuXpcwwYOybYk QSqQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=VkWHnhCm; 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-53841-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53841-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXezXlyhBrluaVJ30f9xNV9uq6GRyUSSxPPAk5POI2XP5bwWygZs5GaeJz1mrQy/CHeHnLDu+C2He/02j+qleKMI+Ozyw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x19-20020a1709065ad300b00a37d9f6dc2esi236301ejs.394.2024.02.05.13.25.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:25:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53841-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=VkWHnhCm; 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-53841-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53841-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 EF8941F24726 for ; Mon, 5 Feb 2024 21:25:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 430CA634FB; Mon, 5 Feb 2024 19:45:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="VkWHnhCm" Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 586D6634F2; Mon, 5 Feb 2024 19:44:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162300; cv=none; b=Gxj46l5nEY1RDkekJbOZjUjucjToaxUS9Jj108294Hq/bGtYa6jFnpX/Ak3GbKBwfIqyNTKOZp/xnDwjogyYPpMS7sE0bRZfju0c8eIAEM1XJq7kquj8N6PBNDDnh/MCxJqpL4SyzZfkPLJc8aJuXpUC3wcvHNNeQgH/ABT75bk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162300; c=relaxed/simple; bh=piwvd9XDrLI4E6nIns4idZqQIBccnh+XSsbLYNv6vd0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=anhj2Y7URGEjlvNQPUQPPFSFlTsoGiE5g3D0h070pzke3BTQRzLuKP4BwryRw1ddgmeoGkUMIn+MZzsy9WRUfM//rOnYmDrFec/7v79m3AaGJVm9FwjV6yuQfM2kEhUFYW/TEp9CYJ7C8VEk0J2KiBoMWsdWyF+DG8XlONlCJfk= 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=VkWHnhCm; arc=none smtp.client-ip=198.47.19.142 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 fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415JieFL019183; Mon, 5 Feb 2024 13:44:40 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162280; bh=2cm9ruqVmpJKRpRfi1ywbymPKB5JK0jfSdZffEo1IXY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=VkWHnhCmALjsai9OTAcgxL9qPQyY4V0U43LmfGnbK8vjDQmvxYgecOqENSfajorvl 5e2t2t1wFsl+y5nH6pEvyotGqfSTDVMt1axqkvSFJM9FIP90EQBfce9KwT0Za49tfD Hc6YhmOLoixTlBFlmm+jqoUal46sEELyyzJH44wo= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415Jiej3073113 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:40 -0600 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE115.ent.ti.com (10.64.6.36) 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:40 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE102.ent.ti.com (10.64.6.23) 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:40 -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 415JicQP028467; Mon, 5 Feb 2024 13:44:39 -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 02/19] power: reset: atc260x-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Mon, 5 Feb 2024 13:44:20 -0600 Message-ID: <20240205194437.180802-3-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: 1790095750029733450 X-GMAIL-MSGID: 1790095750029733450 Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis --- drivers/power/reset/atc260x-poweroff.c | 38 ++++++++++---------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/power/reset/atc260x-poweroff.c b/drivers/power/reset/atc260x-poweroff.c index ce2748d3282c3..e3e4621ccb1dd 100644 --- a/drivers/power/reset/atc260x-poweroff.c +++ b/drivers/power/reset/atc260x-poweroff.c @@ -19,9 +19,6 @@ struct atc260x_pwrc { int (*do_poweroff)(const struct atc260x_pwrc *pwrc, bool restart); }; -/* Global variable needed only for pm_power_off */ -static struct atc260x_pwrc *atc260x_pwrc_data; - static int atc2603c_do_poweroff(const struct atc260x_pwrc *pwrc, bool restart) { int ret, deep_sleep = 0; @@ -164,11 +161,15 @@ static int atc2609a_init(const struct atc260x_pwrc *pwrc) return ret; } -static void atc260x_pwrc_pm_handler(void) +static int atc260x_pwrc_pm_handler(struct sys_off_data *data) { - atc260x_pwrc_data->do_poweroff(atc260x_pwrc_data, false); + struct atc260x_pwrc *pwrc = data->cb_data; + + pwrc->do_poweroff(pwrc, false); WARN_ONCE(1, "Unable to power off system\n"); + + return NOTIFY_DONE; } static int atc260x_pwrc_restart_handler(struct sys_off_data *data) @@ -211,14 +212,14 @@ static int atc260x_pwrc_probe(struct platform_device *pdev) if (ret) return ret; - platform_set_drvdata(pdev, priv); - - if (!pm_power_off) { - atc260x_pwrc_data = priv; - pm_power_off = atc260x_pwrc_pm_handler; - } else { - dev_warn(priv->dev, "Poweroff callback already assigned\n"); - } + ret = devm_register_sys_off_handler(priv->dev, + SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_DEFAULT, + atc260x_pwrc_pm_handler, + priv); + if (ret) + dev_err(priv->dev, "failed to register power-off handler: %d\n", + ret); ret = devm_register_sys_off_handler(priv->dev, SYS_OFF_MODE_RESTART, @@ -232,19 +233,8 @@ static int atc260x_pwrc_probe(struct platform_device *pdev) return ret; } -static void atc260x_pwrc_remove(struct platform_device *pdev) -{ - struct atc260x_pwrc *priv = platform_get_drvdata(pdev); - - if (atc260x_pwrc_data == priv) { - pm_power_off = NULL; - atc260x_pwrc_data = NULL; - } -} - static struct platform_driver atc260x_pwrc_driver = { .probe = atc260x_pwrc_probe, - .remove_new = atc260x_pwrc_remove, .driver = { .name = "atc260x-pwrc", }, From patchwork Mon Feb 5 19:44:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197024 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1157159dyb; Mon, 5 Feb 2024 13:33:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmeihLvExRX1km+Scs0bJWeCU/TqBQ4eVM8fqwLsKMbxDsEXQYOasbUrPNhGwliQ5YtTsM X-Received: by 2002:a17:90a:688d:b0:290:f5db:c4ad with SMTP id a13-20020a17090a688d00b00290f5dbc4admr701773pjd.46.1707168786405; Mon, 05 Feb 2024 13:33:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168786; cv=pass; d=google.com; s=arc-20160816; b=F3GDXVS1UECx4uXWOCIGH7kQ4fG4rsEJo2bJUskAmw5EGNB6leJx1DtbXj0FKiWPOe u8JfPN6swzdvNJCQIaqZ6ChLk31KKMfobdGz/nLKmsaQAAeAIQFd1V5s/WJwi37HFqK9 gL0/V6U+Q01ptevg92SklR82PFSGDE55Fe/AkV2gLgX74bnKPH9WqsbJdb6P/nthKjhZ 7cT30JR9FoOiQiorcM2DKjzVBqCDwXJgBnHA/YR0SXqak0Lu+5I/safh1O+FU8UworWa qKrTU+lh2UuDs4AhjE9lXsORngu+5RnvgQywBA8c0mWyYIY1VEj/c15Wbg0GuMVJrA4x vRhA== 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=DM5F+CDTYAkATD9JuxoEYM5J5TLXMlR0cMppKdmlkcg=; fh=LFp+SfsuKhmrmWY4jZPnTrC2wZIuEq/mi34VgBID808=; b=jEqRUMe4QxU5y+uZ+dCw3zrPYglVo/f9GZKzmgpwZVmN7l1AAPFgpBfqZkHE6xrUkN AaZZjKmfKopObsITPBuonhBYAXy30O3PlW51f2OVQ7igp8eyY1yH+19MnIRatgyXp5Fu hFjRJA+A5xJ7NslOr+FWyVLC8hJSEv7ZzRrctXQ1sFyfBD/c5bEbcB8ZZgioiBA8zPJF etY0u6m8SdsinLfgXHqO9GSA54rRoMeS8zT59NxH9E4bahxvFPdGXAi6954FqLQrRo7o WYsz/Wyc5XYcnx4WiXuRFSuZybS9g39F63DCc8hUXVF/HJMR1mDTZY5U/CTaDHO124Jl koiw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=nNOg3AKT; 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-53845-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53845-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCUMs0aW7Gg5pH+BFCPgFmQQ6pObfJA//QxtP9H310u2TWZW4DOpFbrH9uQJ85vaBvVWbvXkxO9bwfO2YMTlhraHa+1H4Q== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j13-20020a17090ae60d00b0028c86e12f01si4999952pjy.41.2024.02.05.13.33.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:33:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53845-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=nNOg3AKT; 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-53845-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53845-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7319328D9D9 for ; Mon, 5 Feb 2024 21:26:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1807473176; Mon, 5 Feb 2024 19:45:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="nNOg3AKT" 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 975C467C7A; Mon, 5 Feb 2024 19:45:01 +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=1707162303; cv=none; b=DNxJwj+YCGK9LfDklL4FxXsVyzhQUkRSrYXUezQSfvVtr5xomD2MS7oWf0FI+wAjWyi+jNuad5JernwN4Cmquj2DtTb0XJeCjJBFKCUOPB4yqXbhE1V9DvH4ATvUO2cfsDbvDCJ0DGC0/yi5F2cTsCc2gZTx0tT7UEW/mls3F2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162303; c=relaxed/simple; bh=ilhrdoWUjxQAw/qNLh+VKGDKCDBwtm1fe8dEPR5edio=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=asiuNODk0XO5QpOnycopyzLHlA2ZkqeeCc+XuKEcqtM/4HYniAE1lAWB4RZ4roXQRYg5JKLrs8lOj7gld1lzDc90giNp486u5bReoz1kspHMGFIUSkDULJyAb8d6+sMBi8fFcGoM10pdoNFwElHKctubQzvBHECaL9htm4MKI5c= 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=nNOg3AKT; 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 lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415Jifbd010933; Mon, 5 Feb 2024 13:44:41 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162281; bh=DM5F+CDTYAkATD9JuxoEYM5J5TLXMlR0cMppKdmlkcg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=nNOg3AKTGbEdbI5tdXnyfF9whOL/RRDOnTnD/qwzXM9FlJ5O9b3bY/eavQBwwQEXm TZdYMGu3A4sTcZ3GapMSfSW5bKTMjXjmrqPWrQbUe8DetR16CO/XE4Jc+eBrskw+E9 3JcqNMjCrdXtDqC5fWUV/m1g3jb5lnPxxlOJyoRI= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415JifXm003438 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:41 -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:40 -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:41 -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 415JicQQ028467; Mon, 5 Feb 2024 13:44:40 -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 03/19] power: reset: xgene-reboot: Use devm_platform_ioremap_resource() helper Date: Mon, 5 Feb 2024 13:44:21 -0600 Message-ID: <20240205194437.180802-4-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: 1790096216973819356 X-GMAIL-MSGID: 1790096216973819356 Use device life-cycle managed ioremap function to simplify probe and exit paths. While here add __iomem to the returned pointer to fix a sparse warning. Signed-off-by: Andrew Davis --- drivers/power/reset/xgene-reboot.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/power/reset/xgene-reboot.c b/drivers/power/reset/xgene-reboot.c index c2e5a99940d37..6b545a83d8889 100644 --- a/drivers/power/reset/xgene-reboot.c +++ b/drivers/power/reset/xgene-reboot.c @@ -22,7 +22,7 @@ struct xgene_reboot_context { struct device *dev; - void *csr; + void __iomem *csr; u32 mask; struct notifier_block restart_handler; }; @@ -54,7 +54,7 @@ static int xgene_reboot_probe(struct platform_device *pdev) if (!ctx) return -ENOMEM; - ctx->csr = of_iomap(dev->of_node, 0); + ctx->csr = devm_platform_ioremap_resource(pdev, 0); if (!ctx->csr) { dev_err(dev, "can not map resource\n"); return -ENODEV; @@ -67,10 +67,8 @@ static int xgene_reboot_probe(struct platform_device *pdev) ctx->restart_handler.notifier_call = xgene_restart_handler; ctx->restart_handler.priority = 128; err = register_restart_handler(&ctx->restart_handler); - if (err) { - iounmap(ctx->csr); + if (err) dev_err(dev, "cannot register restart handler (err=%d)\n", err); - } return err; } From patchwork Mon Feb 5 19:44:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197006 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1153690dyb; Mon, 5 Feb 2024 13:25:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1EQ6lF8B1IWcVSYFsEKCcOHanVDMi2w2JEGDPDrleQDywDW4kQBnZLbI4c1EvOGDYvM5u X-Received: by 2002:aa7:cf99:0:b0:55f:fd10:5e73 with SMTP id z25-20020aa7cf99000000b0055ffd105e73mr311865edx.20.1707168316930; Mon, 05 Feb 2024 13:25:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168316; cv=pass; d=google.com; s=arc-20160816; b=QfT9qk2l/zD5yiQduCiZM2y4fbqkRp5NzPLA5HWx0risQE31mJDCZDPZfdT2T/Eofs tL0C9d+dX7PjBZdhOvof8cNJd4BFEmkz6yi7dbttbAGQ6GQIQGbFa94PAM+m1yNcIu2P FYuvmABA05+ZyAfMutmNyz3H5Ho6N0bAAlU+5yT4fmvxzDsjLP3sTnkVPMHOjdBJ48pO KtNl1USP/wpXh6K9SVxKBqUHU50mTcizILyn357mMSFjLXv1rFm0xUMbHzdHrESbrk1z bNZK4mJJB5S3QZUTR3JDY6qGpi8t+x4cESQedmbhfQUwq+cc7o50DSxkZ15WLwL42Zxe /QnQ== 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=9UwPUx+fSL3rKTkctxFppsbeFk236+6n4WL7g1DOd5Q=; fh=3VflCStC3bkcMYFvg5AJYsZAXe2/RMEI4VsmZvV+dVg=; b=kVHkfxAJ/zP4nQR2W7h7gdBXyx27rLGY1UWDKtKzqErnT4PM2iEvtcE2ukJUlkAXS2 6UjGnF4wsKjcLaSoRulSvg84eCfjKepg7YgAqDrVoKfO2yDMUGyNd40ww36J0wxEwlOW uu7pRIHj55MNXJtD5cev5xnr5nJednF2qZLykqdu6KOStFF0zVL8UuDO4SXJBVgRH/Ir Xnp8wkS6ussLEleKEbzyMwoyXSnx/OvUMp7NkSGUX+NwkUrkz7+bCDewnwxRLMomn+wh R2CiuhVTLQ3lW2xcOvtxSRFI3cp4yRAC6PIOxWvWQXr3+Jihm1dJfeUk4ghip+Evcp0x JF+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Cmuafe8v; 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-53838-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53838-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCVLrKbFM3ngqY95n+tJ4a2gYkDmlQYOvsnDIaEOQFAVNGsrYv9n5DvdL+EDNsReJ82qzCZ4OacwqdrgsyvME/+CCTVgWg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g2-20020a50d5c2000000b0056037469195si293969edj.393.2024.02.05.13.25.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:25:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53838-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Cmuafe8v; 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-53838-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53838-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 89D3D1F29F38 for ; Mon, 5 Feb 2024 21:25:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02F3969D30; Mon, 5 Feb 2024 19:45:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Cmuafe8v" 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 70E13634FE; Mon, 5 Feb 2024 19:44:57 +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=1707162299; cv=none; b=H0LGs6JNAbLg6O9v0sLxAmmEZ0STTXWQIufSOcHueq9nckEQjvZPjjVKxU0Uj1MGoQJ7UY3w2K7JOfwt1iRH4rko7Y7sISMH/nfxCea9845CZUfLfF1DPaBYy50JQU6EQiCSQYCs0ruhJAuht9Yc5ScPbgLb6UmFdx3/oZxNKOg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162299; c=relaxed/simple; bh=F6j/rd2uqE1cUyZDghMq6eHqquIs5sdJYRKTy0Bo8is=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sPHJ/HEmTETdpZa2PP/vqGCXdrUTcRk9OlHAQPvaCi93sFW6/iNuQn+m9t0ZZ0K4YDeVVhM4O9nLjI4Bvy4M0yJAr3j6RVuShoVULui8OtH358Upigzecy9bsa/CJWT0k9Ib0xINQwDo/tHxPhZMagrxNKvGzF+LX/xlytv3LEo= 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=Cmuafe8v; 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 fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415JigDQ016347; Mon, 5 Feb 2024 13:44:42 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162282; bh=9UwPUx+fSL3rKTkctxFppsbeFk236+6n4WL7g1DOd5Q=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Cmuafe8v4HrVCHgJ53LMs2HBitQNyBfXSdqCm98nQrEBjVtIyeFphsaMxFB99dr3H hhtBOJvVjD9cO7IPQw4rF9PC+tS21MJS7eab2X4yolSNXCWpVYEs21Y6Mvlz1mosVz ir3Ash+EGGyN2vRAUhgUhGuxqMEpB7m6p03QNWWg= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415JigvJ071002 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:42 -0600 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE109.ent.ti.com (10.64.6.30) 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:41 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE111.ent.ti.com (10.64.6.32) 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:41 -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 415JicQR028467; Mon, 5 Feb 2024 13:44:41 -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 04/19] power: reset: xgene-reboot: Use devm_register_sys_off_handler(RESTART) Date: Mon, 5 Feb 2024 13:44:22 -0600 Message-ID: <20240205194437.180802-5-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: 1790095724974973906 X-GMAIL-MSGID: 1790095724974973906 Use device life-cycle managed register function to simplify probe. Signed-off-by: Andrew Davis --- drivers/power/reset/xgene-reboot.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/power/reset/xgene-reboot.c b/drivers/power/reset/xgene-reboot.c index 6b545a83d8889..867162dfe7eae 100644 --- a/drivers/power/reset/xgene-reboot.c +++ b/drivers/power/reset/xgene-reboot.c @@ -24,15 +24,11 @@ struct xgene_reboot_context { struct device *dev; void __iomem *csr; u32 mask; - struct notifier_block restart_handler; }; -static int xgene_restart_handler(struct notifier_block *this, - unsigned long mode, void *cmd) +static int xgene_restart_handler(struct sys_off_data *data) { - struct xgene_reboot_context *ctx = - container_of(this, struct xgene_reboot_context, - restart_handler); + struct xgene_reboot_context *ctx = data->cb_data; /* Issue the reboot */ writel(ctx->mask, ctx->csr); @@ -64,9 +60,8 @@ static int xgene_reboot_probe(struct platform_device *pdev) ctx->mask = 0xFFFFFFFF; ctx->dev = dev; - ctx->restart_handler.notifier_call = xgene_restart_handler; - ctx->restart_handler.priority = 128; - err = register_restart_handler(&ctx->restart_handler); + err = devm_register_sys_off_handler(dev, SYS_OFF_MODE_RESTART, 128, + xgene_restart_handler, ctx); if (err) dev_err(dev, "cannot register restart handler (err=%d)\n", err); From patchwork Mon Feb 5 19:44:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197017 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1155181dyb; Mon, 5 Feb 2024 13:29:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9cvtFqINI672ogoZ/ukvJSJLhJkshuLa2GZWpz3RgRsD1GH1w/G1A/yOAjZsuKPcljnGr X-Received: by 2002:a05:620a:4510:b0:785:5a8e:6f00 with SMTP id t16-20020a05620a451000b007855a8e6f00mr845556qkp.31.1707168540921; Mon, 05 Feb 2024 13:29:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168540; cv=pass; d=google.com; s=arc-20160816; b=BGrni41+iN/nbeWE2k+o+XTiB6Z1MTtq2xnkj7NwFlJD/q6WucPOdr8bJwKwfimamU 9IetQyE2mmxGSm1XbG26Ki/HVhh/DpLdZNrWjbPaYNNY2RqaOgpEik1rFSJ6BqZu0Y5V 8/Ov+SFj/frfMBXjFh0ppAijeDaSGiJ070aRBf/PmKI2lSBH4w9BkSx+rOtc3yCLJBBW mVbl0cMEUGOAb4Pn0qDFqmU2PJJlwBozdIBd9M08ErAYg28rebjBW0NJjmNGCIqf+S97 MunNtGySciddF/ImKQnMjbdx3fhvsaL9r/Z8Fh8Z2937Tp9QpRrhPK6/X0hIn/aEofnz XJTA== 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=WrDlA3MVIblMNMt/x1ENZcDUaj6UX9hq3LACckiD2VI=; fh=H0ie49dfb82/T5ysRcmqBqY22E2fg9qo18ipA4QKjqU=; b=Vqsmhu7bdMeErhjJUqgb8vjYBcarDmCgGPAkPjOx9EsLT3locACHIBu+psxsfB3TZf 2jwW8rhekwd8vLwkR/1eHYUHk0zZ9V3/oznEZV4jnZDd20GxB89qEAqz3zGvZ7Nq/S5S ACP940MJnb0M0WVkGRM/ZeQI4W1+fVCXaVb3dXjrxAnNcs3u5qqxIuEmaxPdmvWoBaSV PxviiTILPTI4saPsNDOjgbHtkhpEBUtFiTHUkbsO+FwPWmXTbd5xky2ky8YJ98tblNYU sQavstfVk3WkjRPgnzaFbI0Ny9caKN+u8SwxvwcT0nf0oRCggkjFPMbmODCMl7ClXEzD qQEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=I6Ct7cod; 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-53851-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53851-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXJl1ce76t4AifCWD6kZe/Q1S//pPSrJKL1md6mMXIRwQmpnEI6dlDLok5xvqbf1XfiO+LzBHNH15TmWjn7dja1IyHFqA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 2-20020a05620a04c200b00783ff74583bsi757074qks.123.2024.02.05.13.29.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:29:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53851-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=I6Ct7cod; 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-53851-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53851-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 AE57C1C26DB6 for ; Mon, 5 Feb 2024 21:29:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEFF87E110; Mon, 5 Feb 2024 19:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="I6Ct7cod" 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 AA369745C2; Mon, 5 Feb 2024 19:45:07 +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=1707162309; cv=none; b=sha2i4ZZCpfEsl2oMzQpohVB3AcU0L+2Epq/1I7T1u+qVAYbijFGkzQ70C/dbMGlRxtZZvxM5KsIzARe1ubNRzOgXDQ9a2IAKq/76zhApkUyGHfoITIz12LOZMhmGtcrOFiDaoqTPE7o+Z/NyaYWogDYfQKPYSJPjp27fnWvd5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162309; c=relaxed/simple; bh=Lm8ufyWOJHp/dqvPwPh3Hgph+gKZYEOGeH+5IYuik28=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VFityvmI8Thyc8l6F4niCp7OV7NOtKmb34kZrVEhWIrxHCv8ORgTJLMN1Y5tkz+0dy8L7/b5Q4JAlmA91aOnj1ISp6K4l9QF/0Psv26xtoRj80wgaBYDucTcMHl3DBEv+7bRdw9e443MSNuGb5K3DSVZDFWm07XS1JBDIaoS1Tk= 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=I6Ct7cod; 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 fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415JigZ2101183; Mon, 5 Feb 2024 13:44:42 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162282; bh=WrDlA3MVIblMNMt/x1ENZcDUaj6UX9hq3LACckiD2VI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=I6Ct7cod9fsUB8kCs1mwpqH0/pAWuGaLzBldpsbL8vu/DN8d9j7tGIlqUitfv+yrG O/G0XDX0vGXV6uM9AtNp7SNhzgUcP9Q64jQla20bYBHih+WuQswX1NdG4tXuEBaKD2 77oVBxhncT0d17q4/mSNnODnLw18Ebc1urZFLSAI= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415JigNI071017 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:42 -0600 Received: from DFLE113.ent.ti.com (10.64.6.34) 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; Mon, 5 Feb 2024 13:44:42 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE113.ent.ti.com (10.64.6.34) 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:42 -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 415JicQS028467; Mon, 5 Feb 2024 13:44:41 -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 05/19] power: reset: tps65086-restart: Use devm_register_sys_off_handler(RESTART) Date: Mon, 5 Feb 2024 13:44:23 -0600 Message-ID: <20240205194437.180802-6-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: 1790095959780417781 X-GMAIL-MSGID: 1790095959780417781 Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis --- drivers/power/reset/tps65086-restart.c | 35 ++++++-------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/drivers/power/reset/tps65086-restart.c b/drivers/power/reset/tps65086-restart.c index ee8e9f4b837ea..82d7a761a0385 100644 --- a/drivers/power/reset/tps65086-restart.c +++ b/drivers/power/reset/tps65086-restart.c @@ -10,15 +10,12 @@ #include struct tps65086_restart { - struct notifier_block handler; struct device *dev; }; -static int tps65086_restart_notify(struct notifier_block *this, - unsigned long mode, void *cmd) +static int tps65086_restart_notify(struct sys_off_data *data) { - struct tps65086_restart *tps65086_restart = - container_of(this, struct tps65086_restart, handler); + struct tps65086_restart *tps65086_restart = data->cb_data; struct tps65086 *tps65086 = dev_get_drvdata(tps65086_restart->dev->parent); int ret; @@ -46,13 +43,13 @@ static int tps65086_restart_probe(struct platform_device *pdev) if (!tps65086_restart) return -ENOMEM; - platform_set_drvdata(pdev, tps65086_restart); - - tps65086_restart->handler.notifier_call = tps65086_restart_notify; - tps65086_restart->handler.priority = 192; tps65086_restart->dev = &pdev->dev; - ret = register_restart_handler(&tps65086_restart->handler); + ret = devm_register_sys_off_handler(&pdev->dev, + SYS_OFF_MODE_RESTART, + SYS_OFF_PRIO_HIGH, + tps65086_restart_notify, + tps65086_restart); if (ret) { dev_err(&pdev->dev, "%s: cannot register restart handler: %d\n", __func__, ret); @@ -62,23 +59,6 @@ static int tps65086_restart_probe(struct platform_device *pdev) return 0; } -static void tps65086_restart_remove(struct platform_device *pdev) -{ - struct tps65086_restart *tps65086_restart = platform_get_drvdata(pdev); - int ret; - - ret = unregister_restart_handler(&tps65086_restart->handler); - if (ret) { - /* - * tps65086_restart_probe() registered the restart handler. So - * unregistering should work fine. Checking the error code - * shouldn't be needed, still doing it for completeness. - */ - dev_err(&pdev->dev, "%s: cannot unregister restart handler: %d\n", - __func__, ret); - } -} - static const struct platform_device_id tps65086_restart_id_table[] = { { "tps65086-reset", }, { /* sentinel */ } @@ -90,7 +70,6 @@ static struct platform_driver tps65086_restart_driver = { .name = "tps65086-restart", }, .probe = tps65086_restart_probe, - .remove_new = tps65086_restart_remove, .id_table = tps65086_restart_id_table, }; module_platform_driver(tps65086_restart_driver); From patchwork Mon Feb 5 19:44:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197014 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1155104dyb; Mon, 5 Feb 2024 13:28:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGH6sdU/Bd2exCP8KucbZYx98UbRF6/qigGwHzsM2q8A/lKgRxwklLXir4jqBUzgiMFhpQK X-Received: by 2002:a05:6214:21af:b0:68c:37e0:5aa5 with SMTP id t15-20020a05621421af00b0068c37e05aa5mr765197qvc.43.1707168529558; Mon, 05 Feb 2024 13:28:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168529; cv=pass; d=google.com; s=arc-20160816; b=pz1pBd73rO3HnRvvO/iM+ALrlt7v0t8lDsVALJCMFG4yPm1v5kxNG9PWGXmwqLB43H wRQja4EWmTr7UJCsviRFOVLg+nI/rAF/CftEimKGSFeZFx6EkUNeRzclTR0qVFydxjoM OjGI9Dg1k4XnaVoONyuQGG3qufaiLwwP0HWtPRVcxfjYCjStQhnzyM/tZkDvrl3ZJkne Jz7Zl+iqKLkDV4LpVyWPiTpWTexXdng1zTdSE5uLf9GPnaPblt4gsZ2tod8jAh9ImLFP JZzo40++5CzN13ueEDae5MY+bbKrrUsR3fHg/zL7PRIoZdv2mlCqEZpRmGDj/PYu4jC5 GY3g== 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=awh4L/FvuKTUk4LCovxuQcQcm/YmAlMhgCuKLpIU3pA=; fh=08Df321PM5fZ1TwnL9bechsNMIAHgreisWznFjhvTOs=; b=eSizSsRTHKt2K0AP+JO40BI+5ka3BKq2Ti0XZ39QNDXx37gKtmzPuEoIMI/Rw+OMfi J1bDjckJBL8O6h688cQTnRjCHqkgDKSdIaBEDKE/TJJLZLcmucdTqu2pE690K6BXLdJC VMNoS+u/HaRzkFvo7qsj53fGLLZp+PGu7rUJSrK25JLCc7i8vPQkeYksJkk/ugqXcay9 jyvR8H5FAQwWBrVCS7Ppw9pNlZpovy30xeMeWGYSCGCazFnuOlTmn4N1exVhCVY7u2XL I4zjsFmW3ZosC6A/pAPTZsSpfrJDU5ETE0KVaYfwKNRth32b9bteN9TDksJD+h2Vsp9Z sjpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=SUJ3YcvT; 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-53850-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53850-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCV689UW3NEf6ki2f3DMhgBn+AhZj68qTk4+XHBUhzhGqHQ3yws87RZDhKmBnVezjKKBQ0gLg0embuGSYNM98aGsPSwUUg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g5-20020a05620a278500b0078535d34010si833662qkp.698.2024.02.05.13.28.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:28:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53850-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=SUJ3YcvT; 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-53850-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53850-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 5AFD31C26DDC for ; Mon, 5 Feb 2024 21:28:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56D607CF39; Mon, 5 Feb 2024 19:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="SUJ3YcvT" 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 8FC6C73189; Mon, 5 Feb 2024 19:45:06 +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=1707162309; cv=none; b=qnjkhtqUMt9w6L0bMqn44nsyW1nh0rubEgBhHAgR+Pa8xfTkWiozLLJuTCsgfrSjllhIYso1of83MaB7NgNfeCZzGU2iYrRDSrQ63MwDVwqJxdYMP/XiwobYArPzAPkZqP9Z46G0AtejebxpD/9lvD4AzNHAHiOGd7dSwja2cTI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162309; c=relaxed/simple; bh=cM1cFjnSzQs76i3u0egboaHOZ+8JvQ6u6lgJc80Opuw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=enxxC+LA8+krPN2Cv5zy6ngOAeuBDH+bUz7aoz9Jb9qOV38a+eoLgo0y7VqUCW0mebnO5Ent89y3t7PpkKUtCPU9BhnFSoMsq8zhPR/0dK3bup98UGAPwtQKC12rHgDL6QAqi9cQ6IQ3ix0nKo5iJ8QSgB8bfF28Sb09FhKkfdY= 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=SUJ3YcvT; 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 fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415Jihna101188; Mon, 5 Feb 2024 13:44:43 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162283; bh=awh4L/FvuKTUk4LCovxuQcQcm/YmAlMhgCuKLpIU3pA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=SUJ3YcvTszMWD1WwIh++hFLIxAH735PX7tg5KxFB7VOI+3a17kIUDuSe4PEEQZDuS 5QIVkmmSQcLgZzLloTbWW216lEPldOegGRwbs8noeAUq9DfrGCvk2wHbkddnzKlUA9 BODoYHr1wM3kOR1NThM0RZDx9PkTJD7p6dHu4vvw= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415JihKo071021 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:43 -0600 Received: from DLEE102.ent.ti.com (157.170.170.32) 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; Mon, 5 Feb 2024 13:44:42 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE102.ent.ti.com (157.170.170.32) 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:43 -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 415JicQT028467; Mon, 5 Feb 2024 13:44:42 -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 06/19] power: reset: tps65086-restart: Remove unneeded device data struct Date: Mon, 5 Feb 2024 13:44:24 -0600 Message-ID: <20240205194437.180802-7-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: 1790095948281602190 X-GMAIL-MSGID: 1790095948281602190 We only need one member of the struct tps65086_restart, pass that tps65086_restart_notify() directly. Remove that struct and its allocation. Signed-off-by: Andrew Davis --- drivers/power/reset/tps65086-restart.c | 35 ++++++-------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/drivers/power/reset/tps65086-restart.c b/drivers/power/reset/tps65086-restart.c index 82d7a761a0385..6976dbcac74fa 100644 --- a/drivers/power/reset/tps65086-restart.c +++ b/drivers/power/reset/tps65086-restart.c @@ -9,19 +9,14 @@ #include #include -struct tps65086_restart { - struct device *dev; -}; - static int tps65086_restart_notify(struct sys_off_data *data) { - struct tps65086_restart *tps65086_restart = data->cb_data; - struct tps65086 *tps65086 = dev_get_drvdata(tps65086_restart->dev->parent); + struct tps65086 *tps65086 = data->cb_data; int ret; ret = regmap_write(tps65086->regmap, TPS65086_FORCESHUTDN, 1); if (ret) { - dev_err(tps65086_restart->dev, "%s: error writing to tps65086 pmic: %d\n", + dev_err(tps65086->dev, "%s: error writing to tps65086 pmic: %d\n", __func__, ret); return NOTIFY_DONE; } @@ -36,27 +31,13 @@ static int tps65086_restart_notify(struct sys_off_data *data) static int tps65086_restart_probe(struct platform_device *pdev) { - struct tps65086_restart *tps65086_restart; - int ret; - - tps65086_restart = devm_kzalloc(&pdev->dev, sizeof(*tps65086_restart), GFP_KERNEL); - if (!tps65086_restart) - return -ENOMEM; - - tps65086_restart->dev = &pdev->dev; - - ret = devm_register_sys_off_handler(&pdev->dev, - SYS_OFF_MODE_RESTART, - SYS_OFF_PRIO_HIGH, - tps65086_restart_notify, - tps65086_restart); - if (ret) { - dev_err(&pdev->dev, "%s: cannot register restart handler: %d\n", - __func__, ret); - return -ENODEV; - } + struct tps65086 *tps65086 = dev_get_drvdata(pdev->dev.parent); - return 0; + return devm_register_sys_off_handler(&pdev->dev, + SYS_OFF_MODE_RESTART, + SYS_OFF_PRIO_HIGH, + tps65086_restart_notify, + tps65086); } static const struct platform_device_id tps65086_restart_id_table[] = { From patchwork Mon Feb 5 19:44:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197016 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1155153dyb; Mon, 5 Feb 2024 13:28:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFr+hgw3vFzcNKaMNHmCIr6Ak8N1jykePCz+lHPSNG0CgHnkbRizUznghVkieahk4gJCVjm X-Received: by 2002:a17:906:6711:b0:a35:d634:ed71 with SMTP id a17-20020a170906671100b00a35d634ed71mr135885ejp.23.1707168537617; Mon, 05 Feb 2024 13:28:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168537; cv=pass; d=google.com; s=arc-20160816; b=KnKhros8yKUqd8VKnxyMMglYteDc9KeKW9/IOzeckCCDFfwMoOG+S0MH1SVtQMItxj 3YfwpPpJQooRjE+rfUx3rczud74idOIYAkJiWYkxWhiBbistbpawkP0FGqbqp4m9IHPr 3VQpKAiKfo1POr2uT7POos04sZpbGdd8hbGxuto/ASPdClBlNkj2kTDexHn+Qup6C6m8 CuEZZBkhVuWZvd60M61VG1PG4puiA/dam5y77qZoSsv3KxptjbVFbVp1fOZy6nDOfu18 Rg1sZbr5tkdCYeUBxVLGHYZBbu6X3FiBF0w62hTDtBz1cvPii4KodEH57GeK9Q+z8Vsn 0HKQ== 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=iOS81LCWivcsA7Ov+uMTe+f7Pr/kqVip8XQZGb4u/UM=; fh=lAKyJIKL98jMQ6gurlzxN/2HSwDVNGSmLpwdS7fp0ow=; b=b9/XjV+DwfgSD0SDUMGwh3eaAd6CHqQ4zDi3nwCRN55zr+tYaIWZehnPRB56cqPQ1e r8cRzGtM6HtHE3EYOpReiVb8lfyt1PqIJqGlI/fCdZbVHDCU6Zxs/1x4Ea1xOz7MVKka XrvG3l1zo7Dz00GAXEjW17xkjMS6n4idS7EFiJxZdFMBcKpSXIfhG2rEdf9Z9YnsXIZF /wEByegnLcDzB10CyNU/oFhzXuI0mFt6FQYfpVIp6xYVWMeuNfvkHnPngyzyRe1a9Oaq QMyJoer7Chhwu6tZtJ2apa8Jhj9bsXAK8p0HDNo7ChR94AHH26Rqi33Zl4U6CEpxxk1c WwjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=sTliSK7m; 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-53853-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53853-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCUZnzAIQkqelowkji6B9nYV4hJxmkRbv780oipQr51dIVnkrdWv3A+Kinz84gLKyc0+nghWkscQ3g4T+noOaD94F7U3sg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kq25-20020a170906abd900b00a371fda7cffsi88094ejb.275.2024.02.05.13.28.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:28:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53853-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=sTliSK7m; 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-53853-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53853-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 3192C1F298CC for ; Mon, 5 Feb 2024 21:28:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 947FB7D40F; Mon, 5 Feb 2024 19:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="sTliSK7m" 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 C6209745C9; Mon, 5 Feb 2024 19:45:07 +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=1707162309; cv=none; b=pUOCo+IxV2DxRQJZT6iLhRIy0LunZzCybhF6cPw/N+mWb/3Rlny5WztcLD4gkauS8BM3M5lr3Z3QWmCbb6RNvea7+q3kd38fmarvsPaLgtT4qrR9KAwBsIyWJZcIqMOHbY9SQ5qKiQaq/wgLHA3ocna/Wp88M3cT4XzTZz9ipA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162309; c=relaxed/simple; bh=iZTSGfwsAJGOr5392OKEepblMvBqT/YAcpCjzijmjmg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=vEmH6zNdXOBBIngGC54xIBrHGQ8c+MQ74J4NmvjPdbaF11a5g0iQMIOjb3d2/5maizlCWASpB3sIGg46WbpkvcmuYcTlWr7xmmberyC+OqzUN1yu6URDBijkJ+N+GUR4Axluu8FCHfoIseg2241lOgJ0czhbfMg+vZ4GjD7mUko= 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=sTliSK7m; 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 fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415Jihlm010943; Mon, 5 Feb 2024 13:44:43 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162283; bh=iOS81LCWivcsA7Ov+uMTe+f7Pr/kqVip8XQZGb4u/UM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=sTliSK7mrwvqgEzQR9fDWcHHW1JpaRAuFnBoxmmM2B49apTADPxOEVOqs6Lwq++px 5IMSiUr+9NP7vKk6jR1MrZaqIhq0/wrecr07Nv2EotEwPGb1qFsaflKw+QuNQYad9d 3L+/n8yDsSeIYUYDXXDPhv8x8L+yNjmqnE4KCYv0= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415JiheV071026 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:43 -0600 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE114.ent.ti.com (157.170.170.25) 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:43 -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; Mon, 5 Feb 2024 13:44:43 -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 415JicQU028467; Mon, 5 Feb 2024 13:44: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 v2 07/19] power: reset: brcm-kona-reset: Use devm_register_sys_off_handler(RESTART) Date: Mon, 5 Feb 2024 13:44:25 -0600 Message-ID: <20240205194437.180802-8-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: 1790095956728259232 X-GMAIL-MSGID: 1790095956728259232 Use device life-cycle managed register function to simplify probe. Signed-off-by: Andrew Davis --- drivers/power/reset/brcm-kona-reset.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/power/reset/brcm-kona-reset.c b/drivers/power/reset/brcm-kona-reset.c index d05728b1db097..ee3f1bb976530 100644 --- a/drivers/power/reset/brcm-kona-reset.c +++ b/drivers/power/reset/brcm-kona-reset.c @@ -15,8 +15,7 @@ static void __iomem *kona_reset_base; -static int kona_reset_handler(struct notifier_block *this, - unsigned long mode, void *cmd) +static int kona_reset_handler(struct sys_off_data *data) { /* * A soft reset is triggered by writing a 0 to bit 0 of the soft reset @@ -31,18 +30,14 @@ static int kona_reset_handler(struct notifier_block *this, return NOTIFY_DONE; } -static struct notifier_block kona_reset_nb = { - .notifier_call = kona_reset_handler, - .priority = 128, -}; - static int kona_reset_probe(struct platform_device *pdev) { kona_reset_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(kona_reset_base)) return PTR_ERR(kona_reset_base); - return register_restart_handler(&kona_reset_nb); + return devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART, + 128, kona_reset_handler, NULL); } static const struct of_device_id of_match[] = { From patchwork Mon Feb 5 19:44:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1154632dyb; Mon, 5 Feb 2024 13:27:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzjTFudOsAeXpKowoFspZ4D48/mFrtHkY3elkM+pBVjweRp6v6A9JTi1oiqH0tbaBDmHIz X-Received: by 2002:a17:907:8f0b:b0:a37:246c:30f1 with SMTP id wg11-20020a1709078f0b00b00a37246c30f1mr400075ejc.15.1707168448119; Mon, 05 Feb 2024 13:27:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168448; cv=pass; d=google.com; s=arc-20160816; b=QRcNxijDsf7sXeVg12QzhgL+MaZwiEWBbvx3GpJgq9KoeqnS8/a1oFuAD3VZp1glOH /gaQAM8aqCzTmJtD6k/TSRarl9nqfO+4ZzjkDNXBfZSF26K5ITMg2zi2cMwLh9h6Oy66 MRlS9XzXyeRYWE7xdUvP9S7aPE3M+xmfPfk5ayF8cSX+WYYBuVqRb5oi4VI/SyB/0MM3 JwIPOKn5ngOwSI4aTbuMWkcC9sgFl2GK6B6HslV3aDCpbemWVKyb73pSMLtvIqPrXqqX TtafelWCZLP6bsQJuqRwizkUqqvkD6UXJpYW9SF5oy30ORecUabP7NdX5YftRti4v2XG zauA== 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=2TI8f8x/5Y4Kr2Vxqhq6Wi5Pu8tSR0ICKXsQgkmtu64=; fh=mkYLER2o+XXfplfSFwiqKhQ3uWaA89Qib+TPabXMuZU=; b=P21ygaobgCHpNbabCGN7uEFeCTZWkOxBMa/af66XxEiETpxAU+37KM+N1bGTtXnGh0 j0A4Qy4xz70G6NzvtuSEHklB2lvaPH39sUyfTtp17Rc0EI4pvnqv/3UjPMybI+4Sw9vX gkaJh9Ewt9bKeoRH7kjayNapXwbeuPmHQ/zE/w/y0IBHUYSPr7D1uptd1YvTwPSBmyah ju8WNQHUsle8XN4yLki+hJ95J2tWqUmFeRnDOtTAFX0VYfscvxcrAUke71fWH6+6Rf8c /Z5w3+pQgDXXgYDGsvCVM3ryco64YzJzEuR+i531KNIG/5e4Y78j8B0MOCoLBFUaQoIw L5vQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=fVK6Jrdp; 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-53847-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53847-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCUo9tcmu9S5Lr3t6TaGpqCEWcixqd0H4UcimLN2FmF6zWE7HhfYAy5IrDQxEjQOOjC1j5+OIhoj61CvuVq8fkAvdpQ6sQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gh3-20020a170906e08300b00a379065e8besi238587ejb.338.2024.02.05.13.27.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:27:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53847-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=fVK6Jrdp; 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-53847-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53847-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 E6CE71F27E40 for ; Mon, 5 Feb 2024 21:27:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9703574E37; Mon, 5 Feb 2024 19:45:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="fVK6Jrdp" 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 BCFEB6A359; Mon, 5 Feb 2024 19:45:04 +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=1707162306; cv=none; b=LUp1l/7YhiC4h0SmVW7qz8+ajMHQtpYDQFDkDFXC9urmKBlAsiorgvP+IzoNe+jq8oRPBj9qtpgVnqqDzK07oUnRuMZxCOVY519+oGTZd+uKdqFvy3Xlzn+vgdZhNXR+6ke3uN2dGV3aq/PQFhedDIyLyY9PSnl4rq13gvuNV+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162306; c=relaxed/simple; bh=QekKnIF+GkovKO7gb14ZkIhecaU+qacpUcgS7SjOB24=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dTLUqypC4Yd8Oje/qYuP3LWyajqg4dlRozDBH0M+zq7wS45YA2qZs8ObLTWNYkQF62LMzjCXnotKvDOADjlGNj/xQxHonGemqn/tk3G6o4SI5VVmt+BteA6WkcktifCouGSjHnB8On3C1KCuSCVb9Lf0ovvwXF3B710gc/8oou8= 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=fVK6Jrdp; 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 415Jiiou010948; Mon, 5 Feb 2024 13:44:44 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162284; bh=2TI8f8x/5Y4Kr2Vxqhq6Wi5Pu8tSR0ICKXsQgkmtu64=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=fVK6JrdpM2cJwetj/TG79ucMkxYwOcYhcSwbRobFnWuCJmLSCg3tfNl3Lvvas86H+ oMQCCdRDquJRW45mGtVxR66h8DW38oJ6JGE0UbeuranOEKBDAG7um9DpGPvRSMC5mB TBmFHyOYh7GYSL6XtqQ8Ro+SRfBR/l5k3PLC8Quo= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415Jii1p090637 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:44 -0600 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE114.ent.ti.com (157.170.170.25) 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:44 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE110.ent.ti.com (157.170.170.21) 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:44 -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 415JicQV028467; Mon, 5 Feb 2024 13:44: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 v2 08/19] power: reset: axxia-reset: Use devm_register_sys_off_handler(RESTART) Date: Mon, 5 Feb 2024 13:44:26 -0600 Message-ID: <20240205194437.180802-9-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: 1790095862639177942 X-GMAIL-MSGID: 1790095862639177942 Use device life-cycle managed register function to simplify probe. Signed-off-by: Andrew Davis --- drivers/power/reset/axxia-reset.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/power/reset/axxia-reset.c b/drivers/power/reset/axxia-reset.c index 24946766760c3..797bf6773860e 100644 --- a/drivers/power/reset/axxia-reset.c +++ b/drivers/power/reset/axxia-reset.c @@ -26,11 +26,10 @@ #define SC_EFUSE_INT_STATUS 0x180c #define EFUSE_READ_DONE (1<<31) -static struct regmap *syscon; - -static int axxia_restart_handler(struct notifier_block *this, - unsigned long mode, void *cmd) +static int axxia_restart_handler(struct sys_off_data *data) { + struct regmap *syscon = data->cb_data; + /* Access Key (0xab) */ regmap_write(syscon, SC_CRIT_WRITE_KEY, 0xab); /* Select internal boot from 0xffff0000 */ @@ -44,14 +43,10 @@ static int axxia_restart_handler(struct notifier_block *this, return NOTIFY_DONE; } -static struct notifier_block axxia_restart_nb = { - .notifier_call = axxia_restart_handler, - .priority = 128, -}; - static int axxia_reset_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct regmap *syscon; int err; syscon = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon"); @@ -60,7 +55,8 @@ static int axxia_reset_probe(struct platform_device *pdev) return PTR_ERR(syscon); } - err = register_restart_handler(&axxia_restart_nb); + err = devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART, + 128, axxia_restart_handler, syscon); if (err) dev_err(dev, "cannot register restart handler (err=%d)\n", err); From patchwork Mon Feb 5 19:44:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197022 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1156832dyb; Mon, 5 Feb 2024 13:32:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtbuTCEw1Bz/cKBy8oWuSNKWqdESMbwAb8PNqlTdW51Sw1/qmZkR5Nhy5PWiLXyx6z9JXp X-Received: by 2002:a17:902:f745:b0:1d8:b6c8:d9e0 with SMTP id g5-20020a170902f74500b001d8b6c8d9e0mr811367plw.68.1707168740449; Mon, 05 Feb 2024 13:32:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168740; cv=pass; d=google.com; s=arc-20160816; b=yMF6d46SppWIjVh0R4qcWsL6YM2QPe4BNtEqt2+vBcUF7xY03gB2X9XK0wSlTAf5Xg lxa3RKdWg6+/5J7EyRAPmNoBEe+vq9n6QpWWxS8e6d2eZyOsy29Tm8+JbCwPwsmo/vE9 zfqrOPXLpYaqX32YMYr3cut6ApCaLz/dFhQ9csDZ638ZJOvv2kx7mfoHQ2qS+IPfVr9f S6faYeKFdWblYZIjriTf6iRTbiEb2jMKBeWZBcFDqIzgOfeAxhyJD2iwbSxq0yA8uJd4 +H3WEhlWP2O6UTWGVlQrYtE/Bq7QJnEFKvWdF5eok4VLweXIkxGlHxEgsYdzMwC+chue rVrg== 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=cEd9h6ts7ZA9SmxTtqXrV1X3OAdroJfb+pEHlYKYQq0=; fh=JgKgnWbGgrfLPN3fO3VB7CGVP++aNP+a2c/b3APfJoA=; b=E/0PZnjOGGQ4TALCgIAT1AIPKdKIRp4Wc/t19xKZFUjtDcBQkzv8YexwIT9LN0iY8m 2oq5FM177b9ZmkJu3pjbxstFzMR+iqyMTBmj+rVOdXqLeXNqH45RSw2G2gy9E3uula+P +mizj2vOdofH7NeXTW7uexXelPSAPelcS+Ezt7MwoHepm0blDh66bvdashhD6bq2tMWs j/5XK9LmypbFgH88A3FNbFvyYamz4PS6gM8/5nmqYbJTrR5E2dNqKDXqb/7h07SVADLe NLCP/p6s1Gs8G1kFek2A54vA4llapoy8JX/anfLtDj37HdvaEDAiC1in2yW1nq/vAVqy SYxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=LmHrQ9Hb; 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-53840-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53840-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCW86NkdHZDibWYijWR+cHBiopvRuS3utpp1lwQxf4aWsq76rSVnNP0Ni/jsBHD1Wx429joYYygQ//2cTWls4lvPgsZ/ew== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o5-20020a170902d4c500b001d8fb17a204si447096plg.351.2024.02.05.13.32.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:32:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53840-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=LmHrQ9Hb; 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-53840-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53840-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9C79F28AF94 for ; Mon, 5 Feb 2024 21:25:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40FE76A346; Mon, 5 Feb 2024 19:45:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="LmHrQ9Hb" Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 C2B26634FB; Mon, 5 Feb 2024 19:44:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162299; cv=none; b=Kbwtnf2cNjSH/UUBro471eG1/05kE0quzaqAMIcCWl82XP1+qRZPaKkZ6Fqe/FOkRyIXywRSIEXeBSAE0lrftJPmt7Ere5/NruMCaCJGXhM3umOXJ6huxgRZ6tOnpBDvJeBZfTq4rGlN3cDwuC+fUcuxC9G6H6OKMXBKb79hdJw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162299; c=relaxed/simple; bh=/wWLg9daNT6pfazjCLsyzkG8hTMGV8b457Vt9N+MIYA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OuPnnqoDuLTt70hukxf7H6fhjGN8m9/qEuuDiP1nqbqKKljj6jJI72pDA+0hBDuUMXLjbha4V70y4k3lJBo6M4tCrOOB5n2uiWesN90OUP4U125YlQRNaZkMKvNN8iuTWl0TGDfjm7eSxOG7ENxbm23tSgahUn+EG+oNaGKUkjY= 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=LmHrQ9Hb; arc=none smtp.client-ip=198.47.19.142 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 fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415Jiju7019199; Mon, 5 Feb 2024 13:44:45 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162285; bh=cEd9h6ts7ZA9SmxTtqXrV1X3OAdroJfb+pEHlYKYQq0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=LmHrQ9Hbfo6vIKGpC3hnSMYqZ53YA2d6q12KS6nZqLMJP2NDixzpI94UYu6hzXDQE juw2fgOpR7JkW0tQK3aDSI2ngWPg03ChC17t9551MO9skM4usWf85VBS8/bvwakb31 WG2YqU41hCcaDgOQJ5/18ifjB1Hwc9th/2ICrUIo= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415JijQ7073162 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:45 -0600 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE108.ent.ti.com (157.170.170.38) 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:44 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE114.ent.ti.com (157.170.170.25) 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:44 -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 415JicQW028467; Mon, 5 Feb 2024 13:44:44 -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 09/19] power: reset: rmobile-reset: Use devm_platform_ioremap_resource() helper Date: Mon, 5 Feb 2024 13:44:27 -0600 Message-ID: <20240205194437.180802-10-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: 1790096169277477868 X-GMAIL-MSGID: 1790096169277477868 Use device life-cycle managed ioremap function to simplify probe and exit paths. Signed-off-by: Andrew Davis --- drivers/power/reset/rmobile-reset.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/power/reset/rmobile-reset.c b/drivers/power/reset/rmobile-reset.c index 5df9b41c68c79..29c17ed2d4de9 100644 --- a/drivers/power/reset/rmobile-reset.c +++ b/drivers/power/reset/rmobile-reset.c @@ -41,28 +41,23 @@ static int rmobile_reset_probe(struct platform_device *pdev) { int error; - sysc_base2 = of_iomap(pdev->dev.of_node, 1); - if (!sysc_base2) - return -ENODEV; + sysc_base2 = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(sysc_base2)) + return PTR_ERR(sysc_base2); error = register_restart_handler(&rmobile_reset_nb); if (error) { dev_err(&pdev->dev, "cannot register restart handler (err=%d)\n", error); - goto fail_unmap; + return error; } return 0; - -fail_unmap: - iounmap(sysc_base2); - return error; } static void rmobile_reset_remove(struct platform_device *pdev) { unregister_restart_handler(&rmobile_reset_nb); - iounmap(sysc_base2); } static const struct of_device_id rmobile_reset_of_match[] = { From patchwork Mon Feb 5 19:44:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197007 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1153727dyb; Mon, 5 Feb 2024 13:25:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJgWcyFL3JzkFA0Etg7S80uYpZsQ43q6vyTPSmc6sJUk32s/Wox1GAq83MUKZSw6CwpArz X-Received: by 2002:a17:906:2b4d:b0:a35:7a4d:8c44 with SMTP id b13-20020a1709062b4d00b00a357a4d8c44mr427297ejg.66.1707168321094; Mon, 05 Feb 2024 13:25:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168321; cv=pass; d=google.com; s=arc-20160816; b=xFK3Hn4MY531XvNhMYfxHQhiPO/dexeXfc8bEeOEAirtClHRYSiaCN8Al/3qYF7Snv B+K6lU1iFdEE18td0U8Dy3Mibt1CXl6N5jvEOblFDcutSBLNp0pe92rDRzJGS1YY+05C 7NgYzEL5J9aBFzD3REpMlrwrmtRqPtL4lYwMU0kEpzEZ7B9ZQgHtq6GhV7abfzmHRTCk Nxfq984Yc6a4uQM4VmR4IYb5wCT/03HdNvvnOTeF612EUPvQxRvGniNQkO1ElWZ+6NVi S17dIfHc4oWqbd0v36gtK1Bk5/SeubpeC4e3uvqMC3Ol3ZnDC70hvZpMb1rasFf+EsuO VLfw== 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=xaEkc9P0QHDNnu0iRVj8KaMT84h1o2uYT86tsdK5kok=; fh=+PQ1SKdcNogua3exE8LaiE9m7Abl3iw5u4NkR3fmips=; b=juXlSMhv9ISA1nP7RIM81HmVbueO8YJjUCXAU3aSHaUgQYA2O4Zg8SwS2gS6s/kYPV l00l47YkCaTfuZ4ItcBChBPsxY4aY5Fx8ztePp/EsdPUSbbpCMf4kC3pcTwWVHGjuK5v SXMWLIEJOMJ/9TD+sqTTXprqvRq4uGzrG0rz7blCUL5MzJw7O/imDIL5rsxS4NOaJcZV iH5082Sy1trc/N3G0rujYssZEzU68PCn34UBjHGlAsnV01kSGSmSTGdK6/lg9Nd7Y6Oh bFbRHj9rAPfyP2zV32HjwLpupVTrni4632qKZ8Di+XjNRHmkWO1GPgbJUAq0kzCipY8a /EmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=R3yRjmdB; 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-53839-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53839-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCVdIVKRwu/Esiq0aDl1e0xL2ult9VAUQbTJLm6sCq6LUa1pX33WGgP8BfL1UJIruEYSCx6PkQf3nJIbh//G+GTASBjvHg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u11-20020a170906068b00b00a36cb0ec095si236187ejb.499.2024.02.05.13.25.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:25:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53839-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=R3yRjmdB; 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-53839-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53839-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 824191F292DC for ; Mon, 5 Feb 2024 21:25:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CE206A320; Mon, 5 Feb 2024 19:45:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="R3yRjmdB" 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 70DF2634FD; Mon, 5 Feb 2024 19:44:57 +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=1707162299; cv=none; b=sd4P5aROgEqyb9xTTZt4dpa47/5mPG0XUYw/2r+IChj9c/i+d8xew4PqOyN7A0bpFebZRH1UEDFhPIML9TEz0o626vJdNvFLJy0Nf9DbB46ByYpQB7OsHxIbYv+Kb9IJxCJXoE2PI0+e9NMq+y/sMTM+DJd76IlXWuaHJTlAnoA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162299; c=relaxed/simple; bh=BDfN2nf0FtNoFJUROgfPRBi9IPv21+42h664up+VGOs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NX4HdwcYAigwXLeidm9fDClMKVjNP83J9NuA8xFKxlaC9l6R4bASDJHIzk3JPFk8VlSQyjyCm8INpx1Pl9pwRN+rR67QpxFK52+2eTnlUH1j1XkXOGnDfP2MBz4Kg+bLIY5aaJFJiV/4uQfZdX5DixDauaDnTyX2UNdnJNER0xk= 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=R3yRjmdB; 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 lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415JijoD016354; Mon, 5 Feb 2024 13:44:45 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162285; bh=xaEkc9P0QHDNnu0iRVj8KaMT84h1o2uYT86tsdK5kok=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=R3yRjmdBHuYHapf0HnrgDpEAzbHbM55+XT9JFPsuhyTrYvK1160tynFOJH5lOM/+1 PVlGQbGm7CUNXDrxeGoZiUz+06zibPLpSdYze0/HzKzQ2xEvZipwJAzyyqHkDGuTUM 6gs7bdZ+xTBZGch868y37IEILV1D2trKYjeYa6uM= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415JijhR003481 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:45 -0600 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE110.ent.ti.com (10.64.6.31) 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:45 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE101.ent.ti.com (10.64.6.22) 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:45 -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 415JicQX028467; Mon, 5 Feb 2024 13:44:44 -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 10/19] power: reset: rmobile-reset: Use devm_register_sys_off_handler(RESTART) Date: Mon, 5 Feb 2024 13:44:28 -0600 Message-ID: <20240205194437.180802-11-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: 1790095729626791030 X-GMAIL-MSGID: 1790095729626791030 Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis --- drivers/power/reset/rmobile-reset.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/power/reset/rmobile-reset.c b/drivers/power/reset/rmobile-reset.c index 29c17ed2d4de9..80265608c18e0 100644 --- a/drivers/power/reset/rmobile-reset.c +++ b/drivers/power/reset/rmobile-reset.c @@ -21,22 +21,14 @@ static void __iomem *sysc_base2; -static int rmobile_reset_handler(struct notifier_block *this, - unsigned long mode, void *cmd) +static int rmobile_reset_handler(struct sys_off_data *data) { - pr_debug("%s %lu\n", __func__, mode); - /* Let's assume we have acquired the HPB semaphore */ writel(RESCNT2_PRES, sysc_base2 + RESCNT2); return NOTIFY_DONE; } -static struct notifier_block rmobile_reset_nb = { - .notifier_call = rmobile_reset_handler, - .priority = 192, -}; - static int rmobile_reset_probe(struct platform_device *pdev) { int error; @@ -45,7 +37,11 @@ static int rmobile_reset_probe(struct platform_device *pdev) if (IS_ERR(sysc_base2)) return PTR_ERR(sysc_base2); - error = register_restart_handler(&rmobile_reset_nb); + error = devm_register_sys_off_handler(&pdev->dev, + SYS_OFF_MODE_RESTART, + SYS_OFF_PRIO_HIGH, + rmobile_reset_handler, + NULL); if (error) { dev_err(&pdev->dev, "cannot register restart handler (err=%d)\n", error); @@ -55,11 +51,6 @@ static int rmobile_reset_probe(struct platform_device *pdev) return 0; } -static void rmobile_reset_remove(struct platform_device *pdev) -{ - unregister_restart_handler(&rmobile_reset_nb); -} - static const struct of_device_id rmobile_reset_of_match[] = { { .compatible = "renesas,sysc-rmobile", }, { /* sentinel */ } @@ -68,7 +59,6 @@ MODULE_DEVICE_TABLE(of, rmobile_reset_of_match); static struct platform_driver rmobile_reset_driver = { .probe = rmobile_reset_probe, - .remove_new = rmobile_reset_remove, .driver = { .name = "rmobile_reset", .of_match_table = rmobile_reset_of_match, From patchwork Mon Feb 5 19:44: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: 197009 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1153926dyb; Mon, 5 Feb 2024 13:25:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGkyAt5WyikO+dFMlrvQ1btr0Dt/4nZYhhda9xGbaKpn1H8DF+TlY5fEb6iiZ9MkI/rOhFp X-Received: by 2002:a05:6214:5298:b0:685:396c:7c51 with SMTP id kj24-20020a056214529800b00685396c7c51mr704236qvb.21.1707168348785; Mon, 05 Feb 2024 13:25:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168348; cv=pass; d=google.com; s=arc-20160816; b=U12EDN3+EsTku7uASJVKLQX6oZx77PTQnK9ZP8J0TX6pHfwcY9m4Tou2EdemZJJ73W nQg7vfEn9Fa/Fkg6EwVXhQAW0fOUInKyR+/oinvfBO+XoAuL4GFSXodVcgI4TuqHI8lf +iX0wygzB2YhdqzV3L3e8WiCcOdpE2VSmq8NS0b9myRR9eF65GtyLt8zZYoS5OvxFoRX PvRqe5QpC0VgiccF1NpqNDDwxQEnFSHSwWvuN0ImicFvXwaNk2NsJlZbERRK0Kz+9doZ nLhzzLXYOAynBiGSHp7FnKJTo2km+bR3hkNP0qYHaomYIQalfyesjav8f9PMgk3U02co JHzw== 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=W6ID4atK1cUOva4b8hsE6r6Z8dMmbY7HtlymKlvZfr4=; b=Im31lbLGYz6RBUUX3xux/dw54DXaFBWpaNbUuBkJsgZk7FI+DACw9K7q+lJN7N56ZN jm0yEG5gfGQSumP+iEfwxTaRdMyorXZ1u3P5BBpPZq+ubKJE2zlWztkitvZJ1/Np7+JH 7yCpYjC8zHnpHVqxdGvyhe+U9l0T4uuWi5WbUsA40cqpYZOiVni5CFPWfpG/SXAgI8U/ afeGeD6JHZRDPsU8466rAT7tR6NwEyIZ6hk9ZAl4qLHJcUSTcj86W/ELrd+SOAGfUs/0 kBFQM0eM51gf4Cgtw5Ghsy+R1+WBGkau8XJIvbLrLIVMZl6VpHgkVaFQUgvrwqxeIn2O vChA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=X27fViWT; 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-53842-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53842-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCVeE63MrmG6ddEJAMDf9qHYJPBnlPv2wjKzEItCHJoGR0wFL/EUPb47odQcqPROP8JvcHnDVdbC+ii4SmdOfhsORKdHhA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s1-20020a0562140ca100b0068c897d71cfsi1030485qvs.41.2024.02.05.13.25.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:25:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53842-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=X27fViWT; 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-53842-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53842-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 D768F1C24E7F for ; Mon, 5 Feb 2024 21:25:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6271C664C7; Mon, 5 Feb 2024 19:45:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="X27fViWT" 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 7551963509; Mon, 5 Feb 2024 19:44:58 +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=1707162300; cv=none; b=Fs8Ygh337t0wbAmbO0GTHEuApksXKksqaRQkCFadi8qMgAtqzKr5PXNt6k4IiMpUE2jSxmSRZe7wnsyG8hXbz9UJ7038cGlKIhmcPWiTWRD+rfridhBlJ72ULUG6VuiOaabgIKknZh0/wXvDRekDn3m/cIiMb252wnrmMMU6dGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162300; c=relaxed/simple; bh=ig53Er0IQr8J52R1XJK5g8TmLfD/5crHUpIF26cVFwU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PkJjZjIYQrJs1EgUubbp+3RYRGaqANRRG2/fZ3jTTvgFsW6gqoAqNNW6X8JbfXuIHjpjHRLt0t2sq6Q/EkD0k30LUvJ6BExIfeQcGU8pqXTXH9p3nXkEAI1JnzpkBFxQ9a23XlUTk+OntNvD9SCdwCmWIClWCx23jGty4vpAgUU= 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=X27fViWT; 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 415Jik8o016359; Mon, 5 Feb 2024 13:44:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162286; bh=ngOnUmcKUfVk/SqAddQuFt8kMzihNR+9E3bjKI3tkA8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=X27fViWTupMnmxzyJy/auFJDnRqASH9CxNqLFuGZJk/+yYFjhGgHB1glVDBgk5B/S mQIDuDBNodhOiXQWmQI8BkPx6H+KqwHWlF2zHA6szR2w1W8kfZq1jpm1yHfIjJUGqf aEWS53lYyCCq05bLUW2msoG9vRorTDJgTANochWw= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415Jik4o073183 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:46 -0600 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE112.ent.ti.com (157.170.170.23) 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:46 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE100.ent.ti.com (157.170.170.30) 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:46 -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 415JicQY028467; Mon, 5 Feb 2024 13:44:45 -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 11/19] power: reset: mt6323-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Mon, 5 Feb 2024 13:44:29 -0600 Message-ID: <20240205194437.180802-12-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: 1790095758795991072 X-GMAIL-MSGID: 1790095758795991072 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, From patchwork Mon Feb 5 19:44:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197010 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1154135dyb; Mon, 5 Feb 2024 13:26:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXlveIzRHH3MWfK2+vKXNr9ArWUUGS2yldfCXPMPNQAVMLu3h9Kg2aYqF7WnkOhLOyrci9 X-Received: by 2002:ae9:e103:0:b0:783:9a16:307f with SMTP id g3-20020ae9e103000000b007839a16307fmr290513qkm.18.1707168377613; Mon, 05 Feb 2024 13:26:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168377; cv=pass; d=google.com; s=arc-20160816; b=vz7RO0slxRwltG7bFBfo0Uuow3VX3PYkS0d1X098PmtZqx8uicYA5+4ZcpW3ZiTYfM kGFUKnCJZZ3bVqYor9nn+9af4ThC3c+RKZEQqp6j4xBiJZgYjjzDfGLY4xwP8uSVva5V 6jgB8gATDAOaiZZS2a6hxC87ucgy5M7a/bH7hNBf55GEph0nqoEJztFGLNTXPwQbKmPu x+JzgNJUy/LnH4yoYO5Yrf6JvkjVydxgcTqkD4pMgZpG3oCnPWBN5lwW4N8dGdut9aPo z8BQhlwVQcIpS1Jg+fZ5yP6E6i0h5jtPaPfP7kQkB250PfXJNVNnpCDZknm5XbNaJFnY dDWg== 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=+iboSw0kHr/XQ2F6mUqPjCZdFfbDSD+ql6zjttiLFSU=; fh=iU/tA638c7PSROwOTNh3/pOweL8u5s322HRJQX90oLU=; b=IPEH5OO2WZUCGaGTRIHKcuvnpr2ogQc0kapFk2lzQwv88I3XmnV/7CwAw0ecYSSBkJ 1bY3wqbyr0y/SLiObvSWUlOdTUwm6RUwhZnBp+CbxcikW7lQcakeqGJDP9MF9Jmadrbo UFkjYqVkhRqkABjD9dlkdGs2ysTXzjrG9C/tKkDo/qh/BSFu7pkTIUI/My8vS6SFXXO2 vQjvvpGA/CgzTIwk6+ra1Q7tLZBwwJL/3aOjZv+S83s9omnyj4Az1sLHQwuDjzTklzEQ iavH7eVm6j7Nv61q1Ey9/hcvLTqe+IW/HZ5yCqorg49tM/GSti8Vl0m/ehMj51DbyI+E oDHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=pxWjPzPl; 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-53843-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53843-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCUnPYjslt5dNfe6tluuWG6k8mhhmr3f9ULoeeLkAGHrzWNf7+wDXfWGv/s2gJDHTs3l+EXNeXqqCw6to6oLyTzMmEIZ+Q== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v5-20020a05620a090500b00783e29d715bsi738596qkv.769.2024.02.05.13.26.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:26:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53843-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=pxWjPzPl; 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-53843-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53843-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 683A51C236C1 for ; Mon, 5 Feb 2024 21:26:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68F676EB7D; 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="pxWjPzPl" Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 02E7463120; Mon, 5 Feb 2024 19:44:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162300; cv=none; b=kGBgBHa/mWrCNU1gDWdentemLW1wwr3dpuTPsyHbp6hKtrNHsUeUgH0W0tT0JGhc7q0qKHpq9BmlpYTOTuoLhAcYSbveIvKn0UEaSL5Bz/RYtxJAWFKkBEC1qduIZyuQHH9YdatveBEo1yN+zTrYAHTU3EZ3qQ8r3VaMVyc4pFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162300; c=relaxed/simple; bh=BvK8IwqnEFboy699PAEmSTVNPQ3C5pW/mK6yHdKKsaA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JIjcw0Y/FJ2Ddkv6N48OUJtUR0VTGTusf5H/Xa+MHSdVtLdUJeQT2etVrWU9OhnFy0ALLQYx4qucvotosJkfkOZ1rKihX9gmzF7txcF6dt8BcSc2meuOikvikIFIchcryTeETGPwaC35vcaWDOArnKnkvBnSlje9DeFsMhxZvpc= 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=pxWjPzPl; arc=none smtp.client-ip=198.47.19.142 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 fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415JilQq019205; Mon, 5 Feb 2024 13:44:47 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162287; bh=+iboSw0kHr/XQ2F6mUqPjCZdFfbDSD+ql6zjttiLFSU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=pxWjPzPlQJYhH1Zc4qnwsLtnX/Y5OfFu9DpbD9A0sa5WfVySkdz8nt+W+Q9IaRp/W pcUr+Gw+WRmmWS9H3ERHsYSIsevbSsmXWXA4PkUwwM6Xer7ppREWG1Jwo7NUlhm5DM 1Ss6DaJg8qAyAb1DtMKQTyMSrmkDC4muqJtULvp0= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415Jil1l073190 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:47 -0600 Received: from DFLE109.ent.ti.com (10.64.6.30) 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; Mon, 5 Feb 2024 13:44:46 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE109.ent.ti.com (10.64.6.30) 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:46 -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 415JicQZ028467; Mon, 5 Feb 2024 13:44:46 -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 12/19] power: reset: msm-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Mon, 5 Feb 2024 13:44:30 -0600 Message-ID: <20240205194437.180802-13-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: 1790095788969168976 X-GMAIL-MSGID: 1790095788969168976 Use this helper to register sys_off handler. Drivers should move away from setting pm_power_off directly as it only allows for one handler. The new way allows for trying multiple if the first one doesn't work. Signed-off-by: Andrew Davis --- drivers/power/reset/msm-poweroff.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/power/reset/msm-poweroff.c b/drivers/power/reset/msm-poweroff.c index d96d248a6e25b..bcf04491e7022 100644 --- a/drivers/power/reset/msm-poweroff.c +++ b/drivers/power/reset/msm-poweroff.c @@ -28,9 +28,11 @@ static struct notifier_block restart_nb = { .priority = 128, }; -static void do_msm_poweroff(void) +static int do_msm_poweroff(struct sys_off_data *data) { deassert_pshold(&restart_nb, 0, NULL); + + return NOTIFY_DONE; } static int msm_restart_probe(struct platform_device *pdev) @@ -41,7 +43,9 @@ static int msm_restart_probe(struct platform_device *pdev) register_restart_handler(&restart_nb); - pm_power_off = do_msm_poweroff; + devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_DEFAULT, do_msm_poweroff, + msm_ps_hold); return 0; } From patchwork Mon Feb 5 19:44:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197018 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1155337dyb; Mon, 5 Feb 2024 13:29:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhIXeZ2bEst9U2cJOMKRJxD4DBI2vjfQeEI2QE6ue1CsELH9XX4PwYCo8CU4tzUE/Sv2ys X-Received: by 2002:a05:620a:810:b0:785:87fc:179d with SMTP id s16-20020a05620a081000b0078587fc179dmr614017qks.57.1707168565099; Mon, 05 Feb 2024 13:29:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168565; cv=pass; d=google.com; s=arc-20160816; b=Qc6ybXFtgFdo+sJbwSUYyxK4QzaiP3/IxGbsXYqrCHmHHnAQWwJqYG3s+sh0EaVsmL OaLsk6sppPoNyZ+0crweNRLXd84WRtcvRrK8q3q3NnYcpvqPvdmJFCKu9mv9P2wHJHHk 8WF5VDy+mLk3b2z+iQCU1LBAN7eXv9Pd9vCnSIG/6ZkTadkL5XG/lcoBr1fyJ64VIPer 5fca59izybYOr5PGvgsZ979dlw+ePuE9crwAB8FH0kkAVWHRv05beanTHmAvJ40q30fK crBMDtzBH2r9WvfpV/9+sEEJv87S/p6sTjipN2mIUiCmuUpe0c4bYXbg0GwSpaFedfy4 uAjQ== 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=5a2BDxvry/mDEJhidMjtTRkucrmFZYMP54rfoZVMxFg=; fh=DQnZBytHmUofcnDYzAjbToii7/HC/Jzs0bOPH+CC2/8=; b=uhYBNg1LewsArvGsTK8Pq5Pfvzy5/PGz0Qv4eZvr+cJvajWNpI1dYYOQYvneUNuYEY 7yT0UHjATFMcBp5s5UHPixjnBdok8yQ7yfIV3lpe01ru7ITxDWtQtxCCU6M+1frIZhc/ hcZK6onCkuCFOEwLTswFbgesHJ+aC8HHYqfUAK913xRhvRNKfrreRVBQIgQkYWZj2hRW HanqZCNzTBrZrQ9A6FmPBNRS0VzkSMoMjr3BgyYjVQqIk1ZhfdMESLRqDlYlvhU70S2s 8N9r0DStLBs5RdKqsKTsEJGVtvy0G20cl3cEgdOOWb47N6Wx8K3i3yjn9pO47oRzj7xj O+3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Qw5q5B3k; 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-53856-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53856-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCUJDFMEOsQ/1Iw9zpdNcOwSRRj+WBHA+dQ7LCxP64Fz+fjne7yalVffQk50esHnYbd+XSC3q97PfGvRt+91RR7SZH3ZWw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g5-20020a05620a278500b0078535d34010si833662qkp.698.2024.02.05.13.29.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:29:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53856-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=Qw5q5B3k; 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-53856-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53856-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 D9B5A1C26E4A for ; Mon, 5 Feb 2024 21:29:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40C537E59C; Mon, 5 Feb 2024 19:45:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Qw5q5B3k" 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 99036745DB; Mon, 5 Feb 2024 19:45:08 +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=1707162311; cv=none; b=gC8Au7Lujk8wWMFjp+tbTln0zyU9V2MmIZIXu2uo9zAHFuBGfvIBGOdQgyHmCUV9QZG1fiyJ6lsu6ncuFk4RVnzBFygObIdfcNzcUHOQ0K9RBqy1wI93B/MfHxJJcyrCDbBY5MUFYIcHKvsJBa8ZCmmNQEFJt07inPLIr4hPg08= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162311; c=relaxed/simple; bh=TcZggvWPAiMNrDjTaYr88pR3WYNyYJDkk6qpMPNTC3Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iqqY/Meyxxzmc64S719MeOYrEHpFrqJWLlNVJkKiN68+fxp1IUuPzvZrY8Rs7DLWn5Gr88GHbbR8B+igOjEXQsk/cUuhgoSj2cEU1NyqBD3IJdv2HY6fYIMyAQ5i3XCBtsSgnSf8OelL0FsbKBwmLuI7OY1331QKxfyfQJVVy3s= 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=Qw5q5B3k; 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 lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415JilnK101200; Mon, 5 Feb 2024 13:44:47 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162287; bh=5a2BDxvry/mDEJhidMjtTRkucrmFZYMP54rfoZVMxFg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Qw5q5B3keTde63yHWlZpQ7EVk4tQF9AphT2TKbB0uVKzxcP46i9J1hxwiPkvnhfU6 yx3v/eLF1zvt5mKdeJM+rw+fQHl9Lon2LkZyUxz6YoDK+bNLBBZrYfXipnLDENW0Ig 9naCSq3dVPMP2uMY58c+MhSsfrUKANATzLTuHB0w= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415JilEK073197 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:47 -0600 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE115.ent.ti.com (10.64.6.36) 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:47 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE102.ent.ti.com (10.64.6.23) 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:47 -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 415JicQa028467; Mon, 5 Feb 2024 13:44:46 -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 13/19] power: reset: msm-poweroff: Use devm_register_sys_off_handler(RESTART) Date: Mon, 5 Feb 2024 13:44:31 -0600 Message-ID: <20240205194437.180802-14-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: 1790095985330493857 X-GMAIL-MSGID: 1790095985330493857 Use device life-cycle managed register function to simplify probe. Signed-off-by: Andrew Davis --- drivers/power/reset/msm-poweroff.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/power/reset/msm-poweroff.c b/drivers/power/reset/msm-poweroff.c index bcf04491e7022..c5831c46f69e2 100644 --- a/drivers/power/reset/msm-poweroff.c +++ b/drivers/power/reset/msm-poweroff.c @@ -13,35 +13,24 @@ #include #include -static void __iomem *msm_ps_hold; -static int deassert_pshold(struct notifier_block *nb, unsigned long action, - void *data) +static int do_msm_poweroff(struct sys_off_data *data) { + void __iomem *msm_ps_hold = data->cb_data; + writel(0, msm_ps_hold); mdelay(10000); return NOTIFY_DONE; } -static struct notifier_block restart_nb = { - .notifier_call = deassert_pshold, - .priority = 128, -}; - -static int do_msm_poweroff(struct sys_off_data *data) -{ - deassert_pshold(&restart_nb, 0, NULL); - - return NOTIFY_DONE; -} - static int msm_restart_probe(struct platform_device *pdev) { - msm_ps_hold = devm_platform_ioremap_resource(pdev, 0); + void __iomem *msm_ps_hold = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(msm_ps_hold)) return PTR_ERR(msm_ps_hold); - register_restart_handler(&restart_nb); + devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART, + 128, do_msm_poweroff, msm_ps_hold); devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_POWER_OFF, SYS_OFF_PRIO_DEFAULT, do_msm_poweroff, From patchwork Mon Feb 5 19:44:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1157235dyb; Mon, 5 Feb 2024 13:33:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHs5q2EAC1RvpTvHHmVoCpHse+Ag9CSpfBJAYYCg3vS4N76lFSZXE32EJREJDTJP6da2jwB X-Received: by 2002:a05:6358:93a8:b0:175:e1fd:11f8 with SMTP id h40-20020a05635893a800b00175e1fd11f8mr1060025rwb.29.1707168797599; Mon, 05 Feb 2024 13:33:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168797; cv=pass; d=google.com; s=arc-20160816; b=HLWoBFyAXAS1xB9uhgrl0yTrfvQuSNDEOcRtSJ9fZpmTegdKJRGoRYwu/AoWyurZl/ lkl6Nto2/CsTsnWd3ISX2VYgqm4/wvobRukaiBZGBPSOdbYsvXmQn50CkK9H6INdGPjA J3AKcEliaw6ZCPbtBBCLjk6CBLLgr4eb4LwmroPToEkPVl86rY2t2lL+hg5+udMNCE1I xBSFPQXcdCcptmw6NdOs+yMHm3aN/vfL8hWA/8glZATR8rSdPhk5rAvnxrryU2q90UeK Wkjcvse1wlPo5kFP7X8/e3AtEcWnEHke9+4qCuFIDMW/uDzREMtKsWVXOqkp2M5zkLJ8 5Vag== 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=+yoH0oyAcvSMYuuy/HNbc6iZw+avNZNinJT/iIL/4IE=; fh=7Wxp+3RUoILMb+OMwOoXd6SSvzW4dV0tdT2bZv008c4=; b=0g6MMkSedP1RFUzBJOtQckFo4cZPTiL10WpTbaNZMokHCcnAzdisXpUHJ9kVPY1Lfr 5oepk8aCg+QSC2FurpPd1FCLy2e7YRprVAABQia6/olIJy5Ayj4VyXWCOOzRZCz1u2QR 4U0VlTboBmYSCdYPPgzl2xaSOopdbAhRnRB1NpMjQAtuEQPS5IdiQIv62IPPeHIyRW6+ uGLBPtSwV408IpHGMKBVrucsXblqqElNxFp6msjE7tot0oXFVzsXpdhBd7rfG4lSz7We aOhZSF1OEBcgvtKggImKpT/Z4gozYtL03qDDjRfjUpGrqO/2rMCIvY5XNwREi7U0HHPW aP5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="F9iI/LUd"; 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-53846-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53846-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCUP30i4CgXhJH3g8ERHlIwqZc4oiXXsPqoJOsvrUQZnrQ+kTVnRRIqYPsoJj3Vj96CyN35d83AdxAlDyilfVwhWOfQYGg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 1-20020a631441000000b005d8b8c6f94csi462536pgu.565.2024.02.05.13.33.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:33:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53846-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="F9iI/LUd"; 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-53846-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53846-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 045D428DCCD for ; Mon, 5 Feb 2024 21:26:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6A17745C5; Mon, 5 Feb 2024 19:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="F9iI/LUd" 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 818A167C73; Mon, 5 Feb 2024 19:45:01 +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=1707162304; cv=none; b=UAvKAMGSnNLrPhW1k5IjUFpLVfKa+koWOrDqjMDLKwaNbndDr09nWZ1KaY9yHTuxBbi0sNTuqoOyXmKk3By8o+MBtQVoCV+Gjw01Rz/kNV5iqJvg9O9uu/M4zbyz8EAD1TAbNWDvgWe8BZGy8C3/bbtRrLNQR28A3hnr4WvAUFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162304; c=relaxed/simple; bh=b1HCM6PNhU5iOFP0yy2ZAE2FiVY5BYt6sfsBzt/lauQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D7xjpDQz0MIu1Xc1uZtqymacYCAiEELYl+W8Na0DvoQqX2MM1Q83Z+tEqIW82V6Ng9RWNWtI/y4+nB2EixZxfO+O2WIXjtbXSeIm+DBThhye2xwxPhn0M2xU51nnRboqZuTmMIx0cdhZ5JVi1Kq9DwxgziTPnH3P+OD/KRCdCc4= 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=F9iI/LUd; 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 lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415Jim2e010991; Mon, 5 Feb 2024 13:44:48 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162288; bh=+yoH0oyAcvSMYuuy/HNbc6iZw+avNZNinJT/iIL/4IE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=F9iI/LUd62aO4jAa5xw0Msug8EiYAOLBWp7QTaKA02TbzRmqYHEkJpjkya+uSv0q3 5uKlMIABgZXPUh60SVK4wZCVVdekaBR3EAqm6kisPeH5DyLEUqUf7ptfYi36jVRx3R A/2jNOmItuKLr9HIwyCUfv5V7YWNoa+5hQNTc/UU= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415Jimbi073209 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:48 -0600 Received: from DLEE112.ent.ti.com (157.170.170.23) 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 DLEE112.ent.ti.com (157.170.170.23) 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 415JicQb028467; Mon, 5 Feb 2024 13:44:47 -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 14/19] power: reset: regulator-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Mon, 5 Feb 2024 13:44:32 -0600 Message-ID: <20240205194437.180802-15-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: 1790096229081031217 X-GMAIL-MSGID: 1790096229081031217 Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis --- drivers/power/reset/regulator-poweroff.c | 36 +++++++++--------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/drivers/power/reset/regulator-poweroff.c b/drivers/power/reset/regulator-poweroff.c index 15160809c423a..fed4978e38580 100644 --- a/drivers/power/reset/regulator-poweroff.c +++ b/drivers/power/reset/regulator-poweroff.c @@ -13,18 +13,15 @@ #include #include #include +#include #include #define TIMEOUT_MS 3000 -/* - * Hold configuration here, cannot be more than one instance of the driver - * since pm_power_off itself is global. - */ -static struct regulator *cpu_regulator; - -static void regulator_poweroff_do_poweroff(void) +static int regulator_poweroff_do_poweroff(struct sys_off_data *data) { + struct regulator *cpu_regulator = data->cb_data; + if (cpu_regulator && regulator_is_enabled(cpu_regulator)) regulator_force_disable(cpu_regulator); @@ -32,30 +29,24 @@ static void regulator_poweroff_do_poweroff(void) mdelay(TIMEOUT_MS); WARN_ON(1); + + return NOTIFY_DONE; } static int regulator_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, - "%s: pm_power_off function already registered\n", - __func__); - return -EBUSY; - } + struct regulator *cpu_regulator; cpu_regulator = devm_regulator_get(&pdev->dev, "cpu"); if (IS_ERR(cpu_regulator)) return PTR_ERR(cpu_regulator); - pm_power_off = ®ulator_poweroff_do_poweroff; - return 0; -} - -static void regulator_poweroff_remove(struct platform_device *pdev) -{ - if (pm_power_off == ®ulator_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, + regulator_poweroff_do_poweroff, + cpu_regulator); } static const struct of_device_id of_regulator_poweroff_match[] = { @@ -66,7 +57,6 @@ MODULE_DEVICE_TABLE(of, of_regulator_poweroff_match); static struct platform_driver regulator_poweroff_driver = { .probe = regulator_poweroff_probe, - .remove_new = regulator_poweroff_remove, .driver = { .name = "poweroff-regulator", .of_match_table = of_regulator_poweroff_match, 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); From patchwork Mon Feb 5 19:44:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197030 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1158345dyb; Mon, 5 Feb 2024 13:35:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IH7HFZMfTraVP1hQyZJ2pRLjOcyLpmfQbrBQrWI+U3JHCs+R/T+XOqIZZauiCFWC3sXA1X2 X-Received: by 2002:a17:90b:23cd:b0:295:fe86:ad25 with SMTP id md13-20020a17090b23cd00b00295fe86ad25mr711579pjb.36.1707168857913; Mon, 05 Feb 2024 13:34:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168857; cv=pass; d=google.com; s=arc-20160816; b=OS1YTvlhNlsQVg3YW4/hNIE3gycg9tvKyKP8RUwnrpMVjNFeziUmyMwjpOOBT1LWxX 7u7U3u8ztcQe+ztbGZ/nPAa1oL6WjKqH43ZbgzHjnw9znWZ1edyEdzOJal9bue4d3dTm KJThzVhlLUp43u2Y9KF5eIXlKtzPu2Gw2dilGRWfcDAhCA+27Pgp/nO2Q+hWS+g1vVDq P9TuA89hMMiieUUjXwOCM2i8nmI9jFwKTQm5Dbq3KIT/GKjQNCMpSmBMa7xvXUyq4esG 53Uf21vtPUAOGbPn7EizvxAMPUOlr6AHU2dqNGgXPi8XqAQGsxIp/Wm9PDUIgewwapkI ++gQ== 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=WzOWw71XNiTDn9UhRVmQ1YL+kbl79QddxFr5AngwFzk=; fh=UR0Pcyje/vN7WGVNZtTLtjqFuNHrpNpvjjAY49bWen0=; b=abm9XAwyknRhuSVz2j4sgSqWfGFB+C0M4m9P6ba2v7i2DtHPmJxDhqT8aUhpJ9KbuG E/vmjVGTKaFsbL9gIdcs1RUkMJiDXWDQIPGv1bXEttAkV3Jeg68lSrABnRyPvC1zZJ67 Y4hlkxnfCJGKePVIBiA2Z0ktXHB2hbUs/zY1ftbIH0efU2KZUUb2CoZ7OAbfRVeQJV2l SC4w2oJNfLFCdoql2jGxAfhevEbqZjVKwE04W9elVlx35DVb2EIhhO3m6FvCEEKkKmyc vW+3gMORKXS748OhOM2FazLP6sdX9JrRxPCnwgXJ2r+T0cx7A0PBegOZro79e6pvn6sP cARw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=y4LH4b6u; 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-53849-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53849-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCV65U0+W1VxgmD1FSAICMSLKpbwvmVSXUDCHgBDBaB5zZ0ybJPb+2QbWs0cwIXwimWAykn/nX0hkLmHckLHoagj8LwX2g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s63-20020a17090a69c500b0029647a8c1ecsi5177395pjj.143.2024.02.05.13.34.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:34:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53849-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=y4LH4b6u; 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-53849-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53849-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5427528F1BF for ; Mon, 5 Feb 2024 21:28:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A6667C089; Mon, 5 Feb 2024 19:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="y4LH4b6u" 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 CBFE467C7A; Mon, 5 Feb 2024 19:45:06 +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=1707162308; cv=none; b=DNoj2bvLhNjahc+J+NMxs4/UfwxUydXys5eSRSFOUBVyozEKJ56XFgc6VriTaomqEeULPmjN1nfAlc0IJvrnyLiufaaElduFz5PX6sdgM4oGGe1seQt01cygyOWFVnPievppovw0VQc8voL4sF1sqh0TUwM6SViuxN7ZIrk4UoQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162308; c=relaxed/simple; bh=HDoP9l78EFZDdW16hNeR9IATxUCA5uyr6j+jeh40ipg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C/95H5snnlrewyBrVXpce/bscwr1BPwlDGKxdBxtn7C/5DJ4j147ivWlZIZFB2ZoaQWeFn+YEoTA6I+gWxsJmK/q+2oHv0y51soVtDmiuEqao+pD6zsr3foc2x+R3Ps+ZrLMNvAGAkK1lgRg/e7AgXsycjE1IvDzgZ/K6i2HOvs= 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=y4LH4b6u; 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 415Jinrd016369; 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=WzOWw71XNiTDn9UhRVmQ1YL+kbl79QddxFr5AngwFzk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=y4LH4b6ulzamJwhySTEphCv6EwMNeefDtvs7/wzFB6NaU4Gdt0Bk9TUO+GSzvRwO7 twYh7leGt6uelYy7EethThSJuViNEc/ojFMl2KFWpJ9bCXO9SeKMGcsiqvkg65hHDZ 5/Xnzc0VdrZE5ff69Io4pqpnRvnRUlkuVMsi7Joo= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415JinAb073217 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:49 -0600 Received: from DLEE105.ent.ti.com (157.170.170.35) 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:49 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE105.ent.ti.com (157.170.170.35) 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:49 -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 415JicQd028467; 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 16/19] power: reset: gemini-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Mon, 5 Feb 2024 13:44:34 -0600 Message-ID: <20240205194437.180802-17-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: 1790096292268040494 X-GMAIL-MSGID: 1790096292268040494 Use device life-cycle managed register function to simplify probe. Signed-off-by: Andrew Davis --- drivers/power/reset/gemini-poweroff.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/power/reset/gemini-poweroff.c b/drivers/power/reset/gemini-poweroff.c index d309b610142ce..06d6992dec892 100644 --- a/drivers/power/reset/gemini-poweroff.c +++ b/drivers/power/reset/gemini-poweroff.c @@ -70,12 +70,9 @@ static irqreturn_t gemini_powerbutton_interrupt(int irq, void *data) return IRQ_HANDLED; } -/* This callback needs this static local as it has void as argument */ -static struct gemini_powercon *gpw_poweroff; - -static void gemini_poweroff(void) +static int gemini_poweroff(struct sys_off_data *data) { - struct gemini_powercon *gpw = gpw_poweroff; + struct gemini_powercon *gpw = data->cb_data; u32 val; dev_crit(gpw->dev, "Gemini power off\n"); @@ -86,6 +83,8 @@ static void gemini_poweroff(void) val &= ~GEMINI_CTRL_ENABLE; val |= GEMINI_CTRL_SHUTDOWN; writel(val, gpw->base + GEMINI_PWC_CTRLREG); + + return NOTIFY_DONE; } static int gemini_poweroff_probe(struct platform_device *pdev) @@ -148,8 +147,11 @@ static int gemini_poweroff_probe(struct platform_device *pdev) if (ret) return ret; - pm_power_off = gemini_poweroff; - gpw_poweroff = gpw; + ret = devm_register_sys_off_handler(dev, SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_DEFAULT, + gemini_poweroff, gpw); + if (ret) + return ret; dev_info(dev, "Gemini poweroff driver registered\n"); From patchwork Mon Feb 5 19:44:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197029 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1158324dyb; Mon, 5 Feb 2024 13:35:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IETy7vljXJxpOFY5PASZsWnSY2z3H7G8oTHXBdaL2QEeMLPvmzj+dbmoW0pOgNE0bUtI/J+ X-Received: by 2002:a17:90a:7404:b0:28f:ee83:13cd with SMTP id a4-20020a17090a740400b0028fee8313cdmr9651836pjg.0.1707168950911; Mon, 05 Feb 2024 13:35:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168950; cv=pass; d=google.com; s=arc-20160816; b=Jp2Yl6QFOxj0pSZzVDrhFVvtYqeAecjSd8uVodbVRIJXBsO8ShkJF6DC/NVhri3+1W MRfzeaN/Q0GXpnVvnOASDm1RU6DVmJNuCzKSO8f2CQm0Laat0hqvDgDef6NTpI2aBREG JpDa7spjULawm5pnxfUrj1hAfDXfRrnZj1EQ4F4cCZnlqkPkA6jywl48mETmCHHTTpKD 5Bn/zM5eoh7/N+SLbC0MuYxYajnUavD3+cRT2N1ogC8+k8OJqzYiDUdgrbF110jD1L0K 4nWsJCYH3LfMHedZMhKg7Fnyr2hCFAZ5mSLt4yvjLWPtOXE77Q4VTYGpLcW4/tG8AgzH 5Flw== 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=mhaPA8Gk9hQadp9HCtCbQB3YsyTin8hWW0xui1HDfc8=; b=OARp3RyGAJvjc6TsaNJsqcerpZa+hwuorFT7lFfR7Jw21GcM1J3/bWnORWpUqKzLlc ZaWA/5j0Qfm2hv32bOu2xMrA5ZgaJXif2LTRq//y8iJvNv3zLCgyW+2zP92c4BrKl81T 4EQULThiUTT3qevG4lptJHtWy6kQGiHeTYJidx7kOgBZxLaZid+SqrhG11UBXZmLQTUU pashBbfCkXPh7fReApDRtwP5MQ6SrFpLvuFG7AMIQBrQcEAmBrhIsU+Iu9LeFEAkEsJ7 3tgLgIoWWC15U2c2IDUUL5x5aZWyVSBWUAI3IK7x3rrkPYeJtfHoCH1RcSIRZGRZhf4z Dfzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GdF5tHW4; 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-53852-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53852-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXoIX/W891tQEtXSy6FK9a2egHMyJc9M8hTaWxw1pXE3jO0DIyv/wHqGxL+KzX86FKPw9CFamETBARWiArYfvkQ0T0I0g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id fa8-20020a17090af0c800b00296167b289asi522406pjb.135.2024.02.05.13.35.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:35:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53852-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GdF5tHW4; 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-53852-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53852-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4331C285E76 for ; Mon, 5 Feb 2024 21:28:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D65F77F1E; Mon, 5 Feb 2024 19:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="GdF5tHW4" 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 AA31174299; Mon, 5 Feb 2024 19:45:07 +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=1707162309; cv=none; b=ZuxNgiVD9JBOkyXSm8C6PwTvyg+v90j5XywkjjpHlZNJpiP5RuM4H/u0Q3jnSxUL4S8T01oWoMGf0g+ZqO8ZJmhs8S3CjoNbeB0KbD27rSry5TcaQoe4qV+5Ski/1HsuxGrTAm/3H/7OOnu7pa8ESEWtkgJFpzWy/aQ/rqKe+3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162309; 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=KgC5D1AX9+H/B9p4PaidGb3+vrzQ1yDjX3yfBrGPK9Lm61eFokS8n/AQVppkRHkLeI/AAcG+CezswVFznoygVG4PZJFDzvCvnR0EL40b1cZuXe7ot5WP9ndSEPGSNDDY6SMpYcva0A4F3M0hpszj7OEXTXexe+r9if3Sdz/e3m8= 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=GdF5tHW4; 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 lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415Jio4c101210; Mon, 5 Feb 2024 13:44:50 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162290; bh=2C083AYY3Dbpmc6BgF2r63gVH+xSPvAPWXFMl2z3vuQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=GdF5tHW4vzndgKxEyXIeI8eLEW54cQWpCTP52/uyE3c97R3xx9IYCNHWFvivSJ+N0 MH37hDvqVgS7bwgbvdOrxoNtlus6KLo4v76Fy1eIO2HeCoQ1YOh6L7oLcxAA449kl4 0td0wfa8r3oakbSl9C1XYXrpobQbKABB21LhqjR0= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415Jioca003534 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:50 -0600 Received: from DLEE102.ent.ti.com (157.170.170.32) 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:50 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE102.ent.ti.com (157.170.170.32) 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:50 -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 415JicQe028467; Mon, 5 Feb 2024 13:44:49 -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 17/19] power: reset: restart-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Mon, 5 Feb 2024 13:44:35 -0600 Message-ID: <20240205194437.180802-18-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: 1790096390117230215 X-GMAIL-MSGID: 1790096390117230215 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, From patchwork Mon Feb 5 19:44:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1158405dyb; Mon, 5 Feb 2024 13:36:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXa/2efTx59OX4LgWqYX8l330oOPLpxveTair5uOS02zMPEbdw2QJPYkP6Zl9F5WRgs7r+ X-Received: by 2002:a05:6a21:9985:b0:19c:8ed9:7b94 with SMTP id ve5-20020a056a21998500b0019c8ed97b94mr399970pzb.51.1707168967198; Mon, 05 Feb 2024 13:36:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168967; cv=pass; d=google.com; s=arc-20160816; b=ObUDGxpVaH5p+WELgQotHy/BDQjh9znBlJFTGPu3VlY2cxma7kk4y6VC4psOnF1CqS 4/xWUaRqKLrGEOI/V9AFEcGBUMU3jGv+3o9YVJwlAPokS3E/66tldh5yDvSfPuz/jLMZ ACQIxJ8ahymti7Qj1iiCq2qIWb09OPoGtmp8f3YYO29ty+9ke8I+PGudj5DePTiPJB0/ 3r4laPY1LSIu8ff5QRSYxT8jODHoMwJucrhtKLGnHJezgikUg/pw8XFiJ+RVp/JJhXz2 DwcMY7n/qO0BTVelD/pHFobE0oKORkTJjNTPgpqVD+3fwRjGYXLYu35FF2MJZPGn5oUO rDxg== 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=rjOs3HQelK8dD7ON+CKELNocYhGYtTpRb3RjtcpZp+M=; fh=4yF5NOFrzPqDv/JTN3Epd9NCAlPhQQzSRxgOxXQeZ3o=; b=bvQTLtdsm0Xi2eYZklPmgCohi4oUQno3Tw5DXRxGXfXkAOggS6ijtb3AbHMvrayag7 YTERbxGw4W+mUY1rONPmdhQF7qxclOrAVMK9cPcdIbe5Il6TLOTyZ29rXG25vGepYYyk jsg2kLnj9mh8wXCRNqZqckTjtdTB0SHlGQbE/E923+WNJZl2HtTqRAjESjlHiOk00PMn RuaKxH7PAJM4ff/3d+U0c51xc7yAqxLWf5xjFhhQXDUu/zElFCXqfo+ink0xCnwva8Lv JGpku/JiItCLwYSB1vN3c019Nzh45Hr8ctC+yEOWnksEgZuFx4R+S4i9ApfxQx90c5Bl I8Qw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=IvTDUc1A; 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-53855-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53855-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXR+OP7AD378CVNcFH1M8l0ipBeJ6yu6IguHHJqGM5WG02k7UWJRvMHMtsDTH44MisGEW7V9BNbHnpyJy+Y3EvGYbsRJQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w13-20020aa7858d000000b006ddc389179esi398492pfn.70.2024.02.05.13.36.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:36:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53855-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=IvTDUc1A; 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-53855-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53855-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D272D288937 for ; Mon, 5 Feb 2024 21:29:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DACED7E58F; Mon, 5 Feb 2024 19:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="IvTDUc1A" 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 E2A89745FA; Mon, 5 Feb 2024 19:45:08 +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=1707162310; cv=none; b=D41G+XhDuawZSDVOHWQ03OOKaiA/oVnUMVYkMcqqAOCkRUTcBYeEVYJQQYmoLqlW9XwrfuUh/QhCgj/TzCNecotpdntTp0Of4TMrElNHUJZtRvxxz9Lfz7oE5mbv04nIchtXePqVpcV7gfGt5sqZtQg0lfQp5x5KfWbTy5FHQ2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162310; c=relaxed/simple; bh=4I1vc+9qiFHbkF+qYQtdPfpYZxXqQl61oW4rBcSj/cM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bCCoKgp5oLYx2+c2UNZWkxLlO7hFHRoFF+P9CUGdC9oWGLHoQIah+MNc6dZcMNY2v1Sq7B9soyBl9l87Cla0FWRiNguothoWpZVE+/5pEZwD/gCePC18lBWcXhngT3j3O0OnNZpb4gcuywjwLBPDLElWW4AHf5CzY+rZGFOUHDE= 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=IvTDUc1A; 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 415Jip8j016374; Mon, 5 Feb 2024 13:44:51 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162291; bh=rjOs3HQelK8dD7ON+CKELNocYhGYtTpRb3RjtcpZp+M=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=IvTDUc1AcaZKT3LzhAh3725W3cPc+vgKIt6Ifl23KPLJZBfkVCuePHss9pFGG2aEP Mel/MjKplcGrtmDsN+u+TjEMF4dXq5OsRWYTqUOsvfT3ejwSx/k6izAxxfmZrr52cG 08uO0v4issu64ydcSdipSD5o/DKjtN5rwZULp6FA= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415JipiG090728 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:51 -0600 Received: from DLEE108.ent.ti.com (157.170.170.38) 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; Mon, 5 Feb 2024 13:44:50 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE108.ent.ti.com (157.170.170.38) 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:50 -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 415JicQf028467; Mon, 5 Feb 2024 13:44:50 -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 18/19] power: reset: syscon-poweroff: Move device data into a struct Date: Mon, 5 Feb 2024 13:44:36 -0600 Message-ID: <20240205194437.180802-19-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: 1790096406946115813 X-GMAIL-MSGID: 1790096406946115813 Currently all these device data elements are top level global variables. Move these into a struct. This will be used in the next patch when the global variable usage is removed. Doing this in two steps makes the patches easier to read. Signed-off-by: Andrew Davis Reviewed-by: AngeloGioacchino Del Regno --- drivers/power/reset/syscon-poweroff.c | 36 +++++++++++++++------------ 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/power/reset/syscon-poweroff.c b/drivers/power/reset/syscon-poweroff.c index 1b2ce7734260c..4899a019256e8 100644 --- a/drivers/power/reset/syscon-poweroff.c +++ b/drivers/power/reset/syscon-poweroff.c @@ -15,15 +15,19 @@ #include #include -static struct regmap *map; -static u32 offset; -static u32 value; -static u32 mask; +struct syscon_poweroff_data { + struct regmap *map; + u32 offset; + u32 value; + u32 mask; +}; + +static struct syscon_poweroff_data *data; static void syscon_poweroff(void) { /* Issue the poweroff */ - regmap_update_bits(map, offset, mask, value); + regmap_update_bits(data->map, data->offset, data->mask, data->value); mdelay(1000); @@ -35,22 +39,22 @@ static int syscon_poweroff_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; int mask_err, value_err; - map = syscon_regmap_lookup_by_phandle(dev->of_node, "regmap"); - if (IS_ERR(map)) { - map = syscon_node_to_regmap(dev->parent->of_node); - if (IS_ERR(map)) { + data->map = syscon_regmap_lookup_by_phandle(dev->of_node, "regmap"); + if (IS_ERR(data->map)) { + data->map = syscon_node_to_regmap(dev->parent->of_node); + if (IS_ERR(data->map)) { dev_err(dev, "unable to get syscon"); - return PTR_ERR(map); + return PTR_ERR(data->map); } } - if (of_property_read_u32(dev->of_node, "offset", &offset)) { + if (of_property_read_u32(dev->of_node, "offset", &data->offset)) { dev_err(dev, "unable to read 'offset'"); return -EINVAL; } - value_err = of_property_read_u32(dev->of_node, "value", &value); - mask_err = of_property_read_u32(dev->of_node, "mask", &mask); + value_err = of_property_read_u32(dev->of_node, "value", &data->value); + mask_err = of_property_read_u32(dev->of_node, "mask", &data->mask); if (value_err && mask_err) { dev_err(dev, "unable to read 'value' and 'mask'"); return -EINVAL; @@ -58,11 +62,11 @@ static int syscon_poweroff_probe(struct platform_device *pdev) if (value_err) { /* support old binding */ - value = mask; - mask = 0xFFFFFFFF; + data->value = data->mask; + data->mask = 0xFFFFFFFF; } else if (mask_err) { /* support value without mask*/ - mask = 0xFFFFFFFF; + data->mask = 0xFFFFFFFF; } if (pm_power_off) { From patchwork Mon Feb 5 19:44:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 197032 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1158395dyb; Mon, 5 Feb 2024 13:36:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IESin/KGSl9MjxRnAkCX4Oujy5agGiR+lh3v82oNG5FSMHZSyg1r05mCP4X8N/d1zr8N8KA X-Received: by 2002:a05:6a20:1453:b0:19c:9a4a:6606 with SMTP id a19-20020a056a20145300b0019c9a4a6606mr1027069pzi.13.1707168964325; Mon, 05 Feb 2024 13:36:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707168964; cv=pass; d=google.com; s=arc-20160816; b=ES1hBCLU2Tp40Um6xYTQmhZ7hWmgF1ICDZS+HoOUcH067YjLnermXOkZXNwmW31o5J ZzLUZS+8jXZHy6otpcwRZ2AHcPmqEB0EI0W3nwXffePEzpGRYKY3ECzfJ3x/ui8fd45P aL3zaqpJd7+7vfSkQPABUKV5Uk4mJIaeDK4EOTUnF2EaYfAbLkJdHcdMt2qA/Vs5niL+ gbUi1UqEVM/sq515zympmWPx2yrnCmuVhHcTaXyHTvFPjL+M8PP0Sr7sMM9NaQA8ruqH n0IdeBJ6BdyDOf4XgyT3BI+GhMV3HekOsl1IrhBUE/OEncoTksep59YCq2uIs2tm+H7n CcWw== 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=NIThW8dvWRvWMprZfYkUcAv9QvAIjazC0Wh9+WTdW/k=; fh=g+lq/nKlUVERF+NoyDb6ir/m3LiBMq2LTbMo8t+3qws=; b=z0ea8dk4iv6aUXPOVRiEtinIm7sFtbHhHUD7j33kGKj/r+UpzOJ2tEJUMUcuPPHYxH s1bMR4eOreP4VrF5Ruj9eNevokWafhE0ab/UEv8z+7uf2U2vTNPjbrwf8uoRnib178+X 6x9nI1nP2ewD43+YUWHcoCem2Juki/pjG6npw9r1+PuKYtogjp4A2WcVARfO5/B3i+oB 1No9fUOzF/iW0E9GY24GXLPN15JLZQJj/kKgNWFpLhlAIsn/E24F6IxfQGgAAC618Vci thixpX1q1tVACXzVagrbuAJOnM/1M83qSC8c9gZ845r5pBMCOn3RhovoJghOp/XOexRD db+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="U/TDTDZe"; 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-53854-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53854-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCWp1fNog9A/CMJ6ML5POzQmKbcnlAcd8UpW27c/njcBTgnsrmJeeYRgOem91jMWVlKRsk2xGPwQPu4amcq0VIRkYUYJMg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j34-20020a63fc22000000b005cdffe116d0si448656pgi.532.2024.02.05.13.36.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:36:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53854-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="U/TDTDZe"; 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-53854-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53854-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A29F02885D7 for ; Mon, 5 Feb 2024 21:29:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B9267E58A; Mon, 5 Feb 2024 19:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="U/TDTDZe" 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 99437745E0; Mon, 5 Feb 2024 19:45:08 +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=1707162310; cv=none; b=pDM5swpaM6/p/8n5jV7MUyI5tmkxYXEjPYgGIywYzq4vyOvsdbe5Ab8iB8raS+4EaOKMswiNiH+AXtaqhOUsyhITvLRByH8jHlSaaPOVBut+jp8jTC6nZLTvE+h6qOth0o3IvoZebCBRLG3IVnbu+k8KWR9O23ZGYKjaP/AjkY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162310; c=relaxed/simple; bh=XmOFZVJS2nbpGNUIJRoCh2m3rWFsAgRF8B1pZ3UaoOo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sy2QDPcpE4SHAKty750eEafSStxSqA1Qt63dTXFeXV1SfrQ/c3Ams4ZfsmU6hL3TTcPPtzbR/4+rp98eV3t31/XX34EXckcLITYRAcreh0PJP6t9FiR0M88P7sPHcQFvVuSQ7KlS+EIsmV1LVBLWHHCUu6Ozp4expNNpGoHSQaI= 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=U/TDTDZe; 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 fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 415JipUM101215; Mon, 5 Feb 2024 13:44:51 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707162291; bh=NIThW8dvWRvWMprZfYkUcAv9QvAIjazC0Wh9+WTdW/k=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=U/TDTDZe48TOZlXKa2/P5bsRemvEkpBf2zyycXeCvsfYIdO+o9EUhYrflRA9TzKi7 ojOnTHFu3wGQ41vLoQCyPhBK4d1tw0pk93aOPmp5SttYKOV3URTAH2ZrJBH0Y0K7SC gSqacdWWQu2J0Q+d1zPa59WE9cTXWcxMLozZqblg= Received: from DLEE111.ent.ti.com (dlee111.ent.ti.com [157.170.170.22]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 415JipKS071105 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 5 Feb 2024 13:44:51 -0600 Received: from DLEE103.ent.ti.com (157.170.170.33) 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; Mon, 5 Feb 2024 13:44:51 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE103.ent.ti.com (157.170.170.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; Mon, 5 Feb 2024 13:44:51 -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 415JicQg028467; Mon, 5 Feb 2024 13:44:50 -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 19/19] power: reset: syscon-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Mon, 5 Feb 2024 13:44:37 -0600 Message-ID: <20240205194437.180802-20-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: 1790096404052419934 X-GMAIL-MSGID: 1790096404052419934 Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis Reviewed-by: AngeloGioacchino Del Regno --- drivers/power/reset/syscon-poweroff.c | 34 ++++++++++++--------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/drivers/power/reset/syscon-poweroff.c b/drivers/power/reset/syscon-poweroff.c index 4899a019256e8..203936f4c544f 100644 --- a/drivers/power/reset/syscon-poweroff.c +++ b/drivers/power/reset/syscon-poweroff.c @@ -13,6 +13,7 @@ #include #include #include +#include #include struct syscon_poweroff_data { @@ -22,23 +23,30 @@ struct syscon_poweroff_data { u32 mask; }; -static struct syscon_poweroff_data *data; - -static void syscon_poweroff(void) +static int syscon_poweroff(struct sys_off_data *off_data) { + struct syscon_poweroff_data *data = off_data->cb_data; + /* Issue the poweroff */ regmap_update_bits(data->map, data->offset, data->mask, data->value); mdelay(1000); pr_emerg("Unable to poweroff system\n"); + + return NOTIFY_DONE; } static int syscon_poweroff_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct syscon_poweroff_data *data; int mask_err, value_err; + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + data->map = syscon_regmap_lookup_by_phandle(dev->of_node, "regmap"); if (IS_ERR(data->map)) { data->map = syscon_node_to_regmap(dev->parent->of_node); @@ -69,21 +77,10 @@ static int syscon_poweroff_probe(struct platform_device *pdev) data->mask = 0xFFFFFFFF; } - if (pm_power_off) { - dev_err(dev, "pm_power_off already claimed for %ps", - pm_power_off); - return -EBUSY; - } - - pm_power_off = syscon_poweroff; - - return 0; -} - -static void syscon_poweroff_remove(struct platform_device *pdev) -{ - if (pm_power_off == syscon_poweroff) - pm_power_off = NULL; + return devm_register_sys_off_handler(&pdev->dev, + SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_DEFAULT, + syscon_poweroff, data); } static const struct of_device_id syscon_poweroff_of_match[] = { @@ -93,7 +90,6 @@ static const struct of_device_id syscon_poweroff_of_match[] = { static struct platform_driver syscon_poweroff_driver = { .probe = syscon_poweroff_probe, - .remove_new = syscon_poweroff_remove, .driver = { .name = "syscon-poweroff", .of_match_table = syscon_poweroff_of_match,