From patchwork Mon Feb 12 16:28:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 199896 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp29265dyb; Mon, 12 Feb 2024 08:32:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxw6lOWRXBoarOQx6bcpqN5J6oIx5G603uB5u8HdSM97/KBRUeAQnVO5SKmUPxpzc9BBzI X-Received: by 2002:ac8:5f14:0:b0:42c:110a:7619 with SMTP id x20-20020ac85f14000000b0042c110a7619mr8432166qta.47.1707755535801; Mon, 12 Feb 2024 08:32:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707755535; cv=pass; d=google.com; s=arc-20160816; b=S0VCSnNTUThFF3uBb4WVPIy5b+2Eq/xcyvrr0AA8yGZfx5jNO412aIqCb5gibOdPJA TCKyi47JjfyCAMFLqv/IJVI3Y9rxQjthIH3cHXeB81z9z1FZKElsFCtP61dC4nojdaqy 1G2et2ycUsboxwb2UW9v+4+V9V01MDolXIUXlIBwxWokezrB5z3kB9AUZCT7mvz41eKu wXtD1Ae9RSmXs/Ke3Omii7sNxmDu6Xh2i+JwJ018tI2wydczh0PRZJ8LD5QHPhRLfUho cYH3X2WXA0gurYaeHaOzkrkkahQxMWkX05enTfFQuXdVRcGPkJ9qt4a+paJKzqR6w/G7 Sdxg== 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=m2vPULuK01zPVHozNrOgrbcJg9cnrsAk9354Of16cxc=; b=AO2MbZ9ku+cdenzOKky56YkrG6xe36Z+mdZNEGPEG9Zrxrgj8bTSl49e4U1FP/RMf/ Busrv4gI8zyv0EKsX+aSqW8szGDWb3KVLVW4r/D1XUhdiH1wnu8ztIYjFe22MSus25OL RpjVHcgo/kUEuq8DoGXGU7zXoOYqQQD84mGBaUH/KxAwlL8mMi0I+qHdujWxb8i8Fe4w Lx0E7xwjL7EpCsZk31/H+3U2PZXO2+Y9S1wQiAMLIdlTFDGyqASYtzJIpd1U1dB1+jLG 6ZXK49obT9RXMWEnYhP1thZK7qKWhtf734yuH7b7SpaPNU0tgj/Bb+wd3h6V8SyoTGIL nnpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=NigIJQCP; 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-61964-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61964-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=2; AJvYcCX0zydiB7TpaXuSdWDdhlixqK4b0CFnl7UFN7x2rca5E6p4DI4C86LNxE1NntnQ02PPcE22woUvf9voPpRkTDMIXyFjdA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u13-20020ac858cd000000b0042c7da1ebb5si808697qta.675.2024.02.12.08.32.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 08:32:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61964-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=NigIJQCP; 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-61964-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61964-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 883711C217D2 for ; Mon, 12 Feb 2024 16:32:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94F6D46B9A; Mon, 12 Feb 2024 16:28:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="NigIJQCP" 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 0F5913E474; Mon, 12 Feb 2024 16:28:49 +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=1707755331; cv=none; b=JzipcdtRnvINHCh6167uOlow1Y2EGrLsCbnf7AT2WRovbLT1CuYv7CTca84QB9resmlGwsLsRMlYwJU7JHnQcue1QHHwwoQaVdZGIVIzURRwinKas5iRzSFPxPD2YoYr7/q5cGhHQmYswcTWupQN9S/favp1kr9msMYuRMe/ZqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707755331; 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=cK6y4q6yulMjuykqmxyuxlrBxeZFFJXrIsBZJEJm9MLAOhRVinETKvq4aOzAh7gA55q6P+7zf2gC90jAQdjYcxETDvnpaBRtZTpNLuDg3ToGqY9nOyUYcVF7DBnI8hq/kRdCMSN0lhkujcXx8O7xP2VDPN48LL+O/Pf3atTW+oE= 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=NigIJQCP; 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 lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41CGSY9n080174; Mon, 12 Feb 2024 10:28:34 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707755314; bh=eDTJGp1LNK+YD1bJfvgjkV/rIr2yWhv+8KTb7j41Dpg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=NigIJQCP0PJXxoPX/D0CJJBkyc6Ign+K2fxu+Pg/Ua3l6FrsplqKGW0fkvCdS6lpb SVxYwRWS20ulLDCENqizre0LaHd6uHZac5kBCCxQ4JraEiqt84K/sSkFmrnDUmZRJ5 sms8Nb0TTyQjvNjg4iGHJuEayQVM/x8BTYEXvONw= 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 41CGSYar008653 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 12 Feb 2024 10:28:34 -0600 Received: from DLEE100.ent.ti.com (157.170.170.30) 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, 12 Feb 2024 10:28:33 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) 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, 12 Feb 2024 10:28:33 -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 41CGSWQv090688; Mon, 12 Feb 2024 10:28:33 -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 v4 01/19] power: reset: atc260x-poweroff: Use devm_register_sys_off_handler(RESTART) Date: Mon, 12 Feb 2024 10:28:13 -0600 Message-ID: <20240212162831.67838-2-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212162831.67838-1-afd@ti.com> References: <20240212162831.67838-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: 1790711468265355198 X-GMAIL-MSGID: 1790711468265355198 Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis Reviewed-by: Cristian Ciocaltea --- 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 = {