From patchwork Thu Feb 8 17:03:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 198494 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp313413dyd; Thu, 8 Feb 2024 09:06:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKiqppuA2nDbRI/1cR8fU1pWHSeWBQDsQLQIseuNmtyiy/nndUxf/QFvkdlt74XQjZwe9s X-Received: by 2002:a17:907:171d:b0:a3b:af01:a21a with SMTP id le29-20020a170907171d00b00a3baf01a21amr1629796ejc.33.1707412012748; Thu, 08 Feb 2024 09:06:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707412012; cv=pass; d=google.com; s=arc-20160816; b=gBWCrH0Ed8WYNuFZ2ktuceAKutJDZtBccKWqTa19Wim272IH0O3SEneI7tlR8vDiTO qRNNHpN78ptbPdtHN+vydlP6B9aMCi7ryVmxdrIEK9pdjUxZdjLt1qbC2sdYKX7qvkXy IYMncwqsiapmFM7XKO9dJo8ne+n2npgb10L4m6AJnEYg0ITqgxT8vBonTw50RywsyY7B wAz2jrDWNwHcicfTy0GQNLeeUI0f/F4NjdNzQEamylZUJ7iaTGJ0s890U8cGSzKueX8G RQnmdKsogZ8xqxb3mnJ7XroJRKy3YahYddOm2VmFf5hc9U1BNzljcnDTsF7ESt/Yt2If 9qlg== 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=VUZz1FlQaBFSPhBZ1P2WMWUVoxSABn639N6uJaJeTBw=; b=XmId0HDGDV/lXS3otjrqoNu8XBVYPdBagERPu5GwZEyWVh9QxAsJbao2Z1zZmdRyja jDFjfnddr4sDcGidlgCOOrVi2ZQJcCuKy0+c7bMHTOHRBL8f7yCe9UwYmd1QozeucgXX 3mUnQVi02dnk5EETuqRjKxXvyiYoiQRsP0rKjW6mg5t77r18XotqklhcL5NSEdPao14z 5onLBnKzf6J9pzg2U0xcfxvQKRc8lQ/79qWr7U895s4PwCnag6LeIAgTyzObjGc1KTsx PRhoY4l0uSz/9tqQFSVd4GhMwV0V8bDIZib+vekmmxkKJbG1NMCd8eSK9GqmhHSFO8r0 TOJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=lbhqaTPw; 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-58404-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58404-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=2; AJvYcCV7xolVvHfRJJUWIZRJSADtcUXHDh3jEPAfEv31KlmwVy3+9DrCgZxkiZHAsTt5G2wCMr6L4flCfRbHaMAVG9mKFNoOcA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gw23-20020a170906f15700b00a387c04438bsi232164ejb.638.2024.02.08.09.06.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 09:06:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58404-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=lbhqaTPw; 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-58404-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58404-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 5E6951F26E49 for ; Thu, 8 Feb 2024 17:06:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF41B1292DF; Thu, 8 Feb 2024 17:04:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="lbhqaTPw" 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 8F473823B8; Thu, 8 Feb 2024 17:04:35 +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=1707411877; cv=none; b=D1ixgyrhn7gbkK0PlCibCeGIw7bRB95c3nyRIYt3CLGUmW089qrWSY33EVuthCWrM9Ce9KIJZB5hLV31XQlm6bN7txd0R2znJ8TxlIsX07tBsmezm8csbi9/7XONfkKgRqgsonVo/nVwWd81lA+TrN1re9uENHk4fhFsAUzFpSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707411877; 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=blU82St/Agg04fJeULLbIkRRQyC4Tk3oWJQ6IXsTNn9ld06Z3o9vj+37ARuOAdzmSVsn8LbYcYtemT/hr/1JyCmWmyYvQv488SjSFuhfc4CBWfSO6LBWbjBTC2SyKKVYinZMDqFJJhdBFv1Q8HL7DvNBCT7b8EBqYfbNpvTJxV4= 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=lbhqaTPw; 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 418H4Djh095449; Thu, 8 Feb 2024 11:04:13 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707411853; bh=eDTJGp1LNK+YD1bJfvgjkV/rIr2yWhv+8KTb7j41Dpg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=lbhqaTPwsoLTE3aBwr6aGobKpww8K2ZKsF0V+rYlIE3j29OWfek4jmdOhBlpM/nva Eabzw4raVKlMzsdMRsyokiMc99v97M2Q3rrfsP3ZQvFcAU6HD8J0aO06j43NFYLRKQ x7+/JO6oyGyZ5e5sTJxNUF9Eo5Bpzff4cwYfksz8= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 418H4D9F042378 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 8 Feb 2024 11:04:13 -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; Thu, 8 Feb 2024 11:04:13 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) 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; Thu, 8 Feb 2024 11:04:12 -0600 Received: from lelvsmtp5.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 418H4B63091006; Thu, 8 Feb 2024 11:04:12 -0600 From: Andrew Davis To: Sebastian Reichel , Manivannan Sadhasivam , Cristian Ciocaltea , Florian Fainelli , Ray Jui , Scott Branden , Bjorn Andersson , Konrad Dybcio , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno CC: , , , , , , Andrew Davis Subject: [PATCH v3 01/19] power: reset: atc260x-poweroff: Use devm_register_sys_off_handler(RESTART) Date: Thu, 8 Feb 2024 11:03:52 -0600 Message-ID: <20240208170410.67975-2-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240208170410.67975-1-afd@ti.com> References: <20240208170410.67975-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: 1790351258735491471 X-GMAIL-MSGID: 1790351258735491471 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 = {