From patchwork Thu Feb 1 18:00:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195416 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp339250dyb; Thu, 1 Feb 2024 10:03:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhfNGOxKTxAfaFFYLENwvS45z98YlVuWVKCzEuO/wD0zDf003SfXI0NCSTNUGR9rIMo9zW X-Received: by 2002:a05:6214:27ca:b0:68c:61af:49e9 with SMTP id ge10-20020a05621427ca00b0068c61af49e9mr5386765qvb.61.1706810629072; Thu, 01 Feb 2024 10:03:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810629; cv=pass; d=google.com; s=arc-20160816; b=WS6+5sWGgHdvvWJW0PAskBxaEu9/D8jkgMNstCrk6j8v7qPfigUs+pjif1Wcdtm3Dy Mmk0R7/ba70S7Q1Mkjz8S1Mu1mABqP/SMTCFCN+PMpSwZvqunwRZpTMOzQ8yJwUUXfDl YIteL2wxdnNznwN6rQoUDdEIbzssbatIjvRWHX6Er+vBR5Bj3bjuEUZVngaaRPUZDQmo c3J5CqM8paKJFrTGPT7p84aAj+a6TjIa0ai5IlhHABxDAZv+1GWoTMGmySv7Qm3E+lYQ X8eACmmiydhKJdn9ifIqEnNyz0GRj4G4dNTjcmFmm3PxNRrYZ3nZg4gSFWAu7aq2oEoG H+XA== 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=HaGmPhkKWIMBFQqJdVVdExpl/aieaMF7IAoY/bo7IHQ=; b=cbbU65xxwqCYWTI6d38uf+N+4maJWfJJxrQCBX/e8D7RPutyYMu8aCix0lujJdZhwk Da1bb2nr8PWPAerWvogh4h8UYqGfbd0BECM6v0D1itxi7aGmkGxca0FEiJQ8BaoatjYF 194+eCMO9HluTdytzu6LJc3j9HZFd/YRFUNY6Hm/OoApeIdPnnu6kxI3+t7NP7Skv0OY DEgQXER/sRiEqZd7jmrsM3fckSBpR+TIatly5tl4K4MOolk20pkEcv2xniGysV8x+fRl ADQdcjcYoy1IdyPw5qYo/aVGGji6IdfObpGe6jE6152AormXVcEVDfx4A2W1ZCKgaWgc fpVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=NM+7Fo4c; 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-48633-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48633-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCW2E+FUP7H/rXHvSU9hVloBhbXOxRmRsAJJ50MGkHDNgILo4qO4rPVkgegKUb7X+AGaVk4xAjxiFZC9RtZ4wYPmgZb8Rg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 5-20020a056214202500b0068c3ca90f97si1588359qvf.564.2024.02.01.10.03.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:03:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48633-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=NM+7Fo4c; 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-48633-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48633-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 53CE61C285FD for ; Thu, 1 Feb 2024 18:02:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A542B85645; Thu, 1 Feb 2024 18:01:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="NM+7Fo4c" 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 3026184FB8; Thu, 1 Feb 2024 18:01:24 +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=1706810486; cv=none; b=ly0fCIW8gywUc1nT91sFFPjzAgtgiKqAT6AuvXZIuvybMQ73eIWpsy4p7BLgdG2Yv/+lA/gjyKns6zyQxf7b9vwBOvbZaD7S4l6wB0U838IQE4hFmX9irDicQN+xwhJ9ww29B62bvZ68ZiUHs2dZFFXHW1nWyFPHqd9VCZ9XQhQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810486; 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=PfKMF6PH76PFVbvSqWbPkkKj+X8g6uVOZNAhYU6K9F4aMlkX1Zma7vd5W08dsXwRfUnrx0ug1ecUNq8w6Vbbe67I5edxqMOwvOmZKq/iR0NisZniPweLynAgvh8ZCslkKzdH/js+9u+Y+Ps2UigwxL3GoJKNp6Y95yCoiqvgNOU= 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=NM+7Fo4c; 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 411I14nX049525; Thu, 1 Feb 2024 12:01:04 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810464; bh=eDTJGp1LNK+YD1bJfvgjkV/rIr2yWhv+8KTb7j41Dpg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=NM+7Fo4c7ceajZ+cEpoLOlC2yRfbGmX4fXpqrOKldutGs2RZfVYxgID1cm6MTbd3s evZHXEYzZL+7rWVOu0CjH+S9Kmu8TUWTDXGZYfz/eM2H/Z7pl3zgycJYUFY+DN9pyA N7FLw3cwJ7ENiIECBLNflp9C0t18B2XAaokdFhpo= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I14Ev004464 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:04 -0600 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 1 Feb 2024 12:01:04 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) 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 via Frontend Transport; Thu, 1 Feb 2024 12:01:04 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 411I12Gf117221; Thu, 1 Feb 2024 12:01:03 -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 01/18] power: reset: atc260x-poweroff: Use devm_register_sys_off_handler(RESTART) Date: Thu, 1 Feb 2024 12:00:45 -0600 Message-ID: <20240201180102.70395-2-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240201180102.70395-1-afd@ti.com> References: <20240201180102.70395-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789720661753485317 X-GMAIL-MSGID: 1789720661753485317 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 = {