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 = { From patchwork Thu Feb 1 18:00:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195432 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp348172dyb; Thu, 1 Feb 2024 10:13:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGO4CYDIXbtDQ7OQP0q/5YLUJ1nY83YF/TU79DnpjvVzImK/gdmmDdvq08lBPikHC5/q8rc X-Received: by 2002:a17:90a:6fc5:b0:296:1e3d:a98 with SMTP id e63-20020a17090a6fc500b002961e3d0a98mr1756667pjk.3.1706811236892; Thu, 01 Feb 2024 10:13:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706811236; cv=pass; d=google.com; s=arc-20160816; b=UJ0D93Hmcr/9oqgEZA+wdNrBp4bfhTzsQhZlLxAsStIfDZEt5bgfQ7PWImpa964iky M0W0hlsJOOBTzO6turYZoXYYk1t4UzcTxfaugv6UcEQObYsP7U1Zugp8Ys787uGcdUpi aW/Fcw91AxBhServaOiGVMTMygugKS4kzAsXJlkwr8IVtBLbYe2u4PBTV1LnmUaeBsO9 qpsqgSB5g06Vv/Jgl77BCLW0mX6c96vweBECT4aLRkG1bNRTDGN+zdRVT0yTXzdN9jnc NeiKgMvgeJ+nPjd7glTrLSJeS16sKTnyukPEmo0pCuLFLqaOC5ndv7wOfWVuBLZo4HY8 kvmA== 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=hXLCqKm4Glc9oibMGSw5m2cqpfN9ksrp0QRlvqdn0Os=; b=ckN0P78o97W2etITv/X1svCCQH1EIo4aWu6GDwvx54gsWjUuLOT/8PQY/cacY+hm4U Ozj51Ij5z18599/jK5gVYmqhr1QpgRcvo3w2OeUJJ+sGWtcY+kwwWSH2oHq8jddtVRMe niWzWNASd0qcQJsPXMgchy0jWKeUABH6e0dRPfHz8/NQ7p0hSdhEVVVGSw7XyRHjhSrY AnkVoB3MGku3OD2ZVJQiGgFRjWlYHfywOzU59t3OHSba2iEPBsDAJ1zs4+bjTf857vD7 KPb2kbReRI7jH0QjdiBN1KG61DfVvMnzItBLvabWzYimJQVlwJh0L1I3EjgaMz6CCRuu Vd4A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=WFAKBpzZ; 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-48641-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48641-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXLruVa0hl2A82LwoilFzJv8CDjg1I6oPGIdlOVuC2KLU8xd3s3/2lWk+CWqaA3242fkBC7R42//ZT3daPByLewbtbV1A== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id gt21-20020a17090af2d500b0029615f63409si1807252pjb.174.2024.02.01.10.13.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:13:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48641-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=WFAKBpzZ; 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-48641-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48641-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 191B328438B for ; Thu, 1 Feb 2024 18:05:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4F1112D149; Thu, 1 Feb 2024 18:01:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="WFAKBpzZ" 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 0420084FAE; Thu, 1 Feb 2024 18:01:33 +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=1706810495; cv=none; b=o56pK1kZAp/Clbjnz5vO/xjlDModr0GGXtGFILwjt9pjT5czHi7IuUEPHNvhL9EfyNQFDBPwv3gVxxcLvhjJVR7XjOopq77GtlbLokO2WetVgYRf+Rg9byqMapfvla6P4Iud74k8Y4s6SvTJ0YMhSGfqVIwNVVkwpNLqChfa06k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810495; c=relaxed/simple; bh=piwvd9XDrLI4E6nIns4idZqQIBccnh+XSsbLYNv6vd0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bjKZd21gpJaqbJUZcxgJOq7uyt21vlVJf+ZmbznTHiP1Xd2jCN9Y4/AFU1tFCRqZXf8CIhLuzKHcDZor2dCcbCDpxzL6uShRFH2hZXvXzzY40gpV1OIlRPd7fF+t33UJNdMjyF7FEBWs0IU6EkYjerl8kGB4OaeA8Gd8B8LQYdI= 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=WFAKBpzZ; 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 411I15eu051685; Thu, 1 Feb 2024 12:01:05 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810465; bh=2cm9ruqVmpJKRpRfi1ywbymPKB5JK0jfSdZffEo1IXY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=WFAKBpzZr8XH0UH/yTaauAenayP79B92nzcgKNGX5NHkoL2yMTLrJ0qHr72rYyQ4S vPO0s47dDljMp0FOjmXvrcQmQ9YtgfGhkEpf6upvRC7HV+gZNsPlAhNObawuyj41Uq 6pRtn5qtcCXM3IqQVviwd1O2CbSj0ioAVPtZawJY= 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 411I15UE029129 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:05 -0600 Received: from DLEE101.ent.ti.com (157.170.170.31) 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; Thu, 1 Feb 2024 12:01:04 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE101.ent.ti.com (157.170.170.31) 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 411I12Gg117221; Thu, 1 Feb 2024 12:01:04 -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 02/18] power: reset: atc260x-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Thu, 1 Feb 2024 12:00:46 -0600 Message-ID: <20240201180102.70395-3-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: 1789721299857670972 X-GMAIL-MSGID: 1789721299857670972 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 Thu Feb 1 18:00:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195422 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp341773dyb; Thu, 1 Feb 2024 10:06:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWS1lCtr2xQDxTl4NXLVsnCPZcXDAMlGjGozFHgG+q96DDQ74k7kSIuuw6HFuo0ANwPRjF X-Received: by 2002:a05:6808:114d:b0:3bd:99e1:5826 with SMTP id u13-20020a056808114d00b003bd99e15826mr7038808oiu.50.1706810798319; Thu, 01 Feb 2024 10:06:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810798; cv=pass; d=google.com; s=arc-20160816; b=dSt6467RgtHlFTdO9wpmRWBym4kgSSUm/nlt+bdqSpQLuaT15yufauaK5dWbp1NGfq enru7xi3ZS2AEEbEzScwFYou0SizhXktpShQ/cb2sf6o2SSWQcPLXmjqQkS+7eZKeeGq LsWOMBU7mTreo2O4C+674CRIBABNG/FXAPP/UI9c8l37vv/tuOAFIx1cwUMS4amuFufN MNYp9kwVAtbwNqHaSm+2In/tx04WMCL9+g74RMAalv40O42MxrJe5Oyv2R0IypegVqUT 8mxMS3Fn40Z3g4rhntg1nYFA2lWnud/okZFf/b/h63xjkgooNIBFGBS4o4+NAh6cO35H lX7A== 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=COOyqqru2hxz+S/Tw5V0x98XNKrZiamgLSe8wHDYh14=; fh=fx8x/rdoMXDSPGxg0GiuyfH9jOXeSddsl6W03UP+eDo=; b=FNlUDREGejh/De7EYcuHAbQ3A3q03l0fvVydnjzd0vjn+Jk2Vv/agPJ810ybGDxsh1 liM6FZTs50E+PjizOY1gE3e0mnFmnotSkanCAqA8cQx84+xdMN79hy71oYdHdazkoinM Fqst6Z7YIyxlK3nEgsvlw19pJuePb1tkSgvAe5/PrYZKHroLSHpQaDkPzajkn9tqp4tq hWk1kR3YbJKu04a5uhAVFCqYooQxXotm4Kl3Y2tRijzwlbPVJpu3A2Bj07Ia0thSWzLc 0BR2u5dx2/KJSWsnh3E+923XLn4f2FPgNMbPLPAAqSbPEcphOe9Q2ysYJKiMC/mA+C6D k8ow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ZUTao+ON; 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-48643-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48643-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXxHqM1ENFXZo8OQKWWt1QuXAC5ZMW8iz3ubXNJN8Q6ahIbE4Si4U60zDYCbRh+DNb3+GUsQZa8l+ylkpl+Ej/1uUoing== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g32-20020a05610215a000b0046b1ce3d501si1391831vsv.720.2024.02.01.10.06.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:06:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48643-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=ZUTao+ON; 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-48643-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48643-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 65D171C28746 for ; Thu, 1 Feb 2024 18:05:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A14E12D158; Thu, 1 Feb 2024 18:01:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ZUTao+ON" 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 7A758127B56; Thu, 1 Feb 2024 18:01:34 +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=1706810496; cv=none; b=J7UbgCs0clyrzdvL2u7mC3LVf/HOMJUnCWcfWxQw7+jtAjMPxKJ9apBwpZS/IK1PKjjSL8phV+P9D8AATZG/61sWcro17Ig6vJXz0pz5U01dxyqyix1Uw+pBkj0yeE6He4GIQ+j3Ar50krjbM4Gg4iwnCp3axxNdhYs0T2w/9Mw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810496; c=relaxed/simple; bh=JSE5uhznoPyN+QLY+7zV8P38mPel3szrDdKbhqYd4Dg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cBxxhHie+XpPtfx43Ll2eUXelZY+BpIGaj9hiiRW0+xbjiy/gwUpYLwOJ3Ne4l5+Q9SMRBjN9HKoE4QHKhiBi39pVhnBK6wW+htmV46enoYmknjbr/CfOYBr036Rz3GTrHxpKuBTEhThXPtjPnmWg09/olye4dYFH2MJRMysBKc= 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=ZUTao+ON; 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 411I15Ww127741; Thu, 1 Feb 2024 12:01:05 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810465; bh=COOyqqru2hxz+S/Tw5V0x98XNKrZiamgLSe8wHDYh14=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ZUTao+ON9CWb0zgC3QleK6FgjoBGaePcjIH1rqYG741ILwUOVJ5EPuu1x7fRDozW/ KhssLyZRFRkz13rNM4UuQXysuBo7g2w11hWdsMcXYClMGnNT0NipIfMZb9m6AteHwX AgYM+Q18l6fGcV0NnJi889mkmA7JSH1MPJe2wSok= Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I151w120338 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:05 -0600 Received: from DLEE114.ent.ti.com (157.170.170.25) 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; Thu, 1 Feb 2024 12:01:05 -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; Thu, 1 Feb 2024 12:01:05 -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 411I12Gh117221; Thu, 1 Feb 2024 12:01:04 -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 03/18] power: reset: xgene-reboot: Use devm_register_sys_off_handler(RESTART) Date: Thu, 1 Feb 2024 12:00:47 -0600 Message-ID: <20240201180102.70395-4-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: 1789720839733119077 X-GMAIL-MSGID: 1789720839733119077 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 c2e5a99940d37..5c923ab838a55 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 *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) { iounmap(ctx->csr); dev_err(dev, "cannot register restart handler (err=%d)\n", err); From patchwork Thu Feb 1 18:00:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195420 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp341268dyb; Thu, 1 Feb 2024 10:06:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIcLkGJ6p5hoTKvpx9ISjNmPg7WeeyoPzd3seEPyDiRCDOYhvCgKulex0XU3ljdcn1cR5k X-Received: by 2002:a17:906:e0c6:b0:a35:8c8b:942f with SMTP id gl6-20020a170906e0c600b00a358c8b942fmr2419856ejb.62.1706810761308; Thu, 01 Feb 2024 10:06:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810761; cv=pass; d=google.com; s=arc-20160816; b=loBSyMg9Pt8XNQYDBsdX1c/7kaM64qSF1OjDCUmFzwbIezaFrtlfMaazqSWkf4iIZq 9QolrLeiZ7imxf9h+FK9mPxIurWr+cUxhg/QaIbvnMCTo2ed7lph6QIA9qzwD/t1ioEr o4lDRHFgEIdd4WaRRq0SzS7mpxt/fI3P3GrmC23wfwEM8ilVObjR6PAvSPQIoU+jMinY fQywnN6Lhee3Lj2kkF2oTyse3Xd4WiVirf7pg67bMM+zW3VCN+7bELfMTbmIgGgwe/qM JhrIGl7wJ0jHCmRcsHTV95Pu0yvnz6+PLVQEb1tNMeWX9U/53mt6nV2S4Gk27RPUm3sC 1khw== 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=qnY0lUpvq8yuyaA1cV+p70YeNn3HCv2Nlio09QDNO9g=; b=p4a/0vniKqjdweGUZUyMeJiKeQNUyyMSGtL7VNitN84pgW5KvFsd4Nqw2Hbqbj+hiA mWWWjt532XnbenCwoSTNpK6way9i07/83tmV5142nVraq0nDGpqlh9WqqzN33t41CyAe 3sfqjNjo63EQ8us8FRiQEUVgqBMepiDTVgoI01FhKJjyKi7QZ05A3xZYQqW557D2T+u+ esp9n9co9vlTWcnjj7JOkCtKKXm8JpwhkGTb8JvmV93eBiP0VIZkbXdgC71x1lAfwVVW 6FWAyoxdkPtKAxtJCHZd2LzSqgFb+cjQNzXNCeoyvUXhqs0vGmF2XJ+IGc1mGs/4pCT5 T5LA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="XoHZm5N/"; 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-48645-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48645-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXO02JdNMXieMHMhbn5v8b2DsTG9LcfKaZE9yfmAJMS3AZdfCNEON1Q0ELDpPJ70z/Uk2T0myHwPwpZSxxTPwjDR9X2vQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x8-20020a1709064a8800b00a35822ff674si24556eju.923.2024.02.01.10.06.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:06:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48645-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="XoHZm5N/"; 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-48645-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48645-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 BE2301F23CC4 for ; Thu, 1 Feb 2024 18:06:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F0E912E1C5; Thu, 1 Feb 2024 18:01:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="XoHZm5N/" 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 F2C9112880D; Thu, 1 Feb 2024 18:01:34 +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=1706810496; cv=none; b=c+1mssqe+PX2Bzoa5P6hjwwaUrx33f0hT1AMdf+n73a2u5ky2p56ucgPCOrPpLsGm7cPTgMz9TKwMeqLYv6QKX714Q93r5ntMlG85xN/+A14yIqZ9xwgFJY56h/61zWN4Xa+JXyKVJKYeJkqq6XYS9RV9RycxDlFc0A+ZdQHhnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810496; 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=HosUPeUq5egMGxU8Ja2uOdxNPHJ1jO4OBh/HcidiihpXsImA8RcdxK+3D/6SVZ5R/UwjDDJZovSKKyEBLLtFwaTihaRQuZXRf4BJsRCn5AUV8TuncOFA4SzOVUGzVo6ugYVKI/w/IvRv2n5tvATYa2Axo2mgzjXE2Da9uaiE4Hk= 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=XoHZm5N/; 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 411I16gG051694; Thu, 1 Feb 2024 12:01:06 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810466; bh=WrDlA3MVIblMNMt/x1ENZcDUaj6UX9hq3LACckiD2VI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=XoHZm5N/ksa0p7K2CmREBkZyvQFkZMj1GRRjzXAkXLbury1bHz/F7KJqOZgtCiz9/ fr4LdPZv3HeBTuzcoz8j9hZdN3sFkMtZ82gJTC1t0hH+CeC9L15jhJ8UUSobDUceTb PoQyhtR6SMnUQOhGOp904Xpl4e7umsV3nNpcw34g= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I16D5047472 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:06 -0600 Received: from DLEE113.ent.ti.com (157.170.170.24) 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; Thu, 1 Feb 2024 12:01:06 -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; Thu, 1 Feb 2024 12:01:05 -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 411I12Gi117221; Thu, 1 Feb 2024 12:01:05 -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 04/18] power: reset: tps65086-restart: Use devm_register_sys_off_handler(RESTART) Date: Thu, 1 Feb 2024 12:00:48 -0600 Message-ID: <20240201180102.70395-5-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: 1789720801123967274 X-GMAIL-MSGID: 1789720801123967274 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 Thu Feb 1 18:00:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195435 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp365812dyb; Thu, 1 Feb 2024 10:37:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEu69w7ynPnz0IlDDAEbK6rYL5BjuiBhsiojqmcBdOvqagQWQrh615y9tU3vCw3YBUXMAHn X-Received: by 2002:a05:6358:b017:b0:176:a0ad:131b with SMTP id l23-20020a056358b01700b00176a0ad131bmr4998530rwn.16.1706812641615; Thu, 01 Feb 2024 10:37:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706812641; cv=pass; d=google.com; s=arc-20160816; b=j6VEX2nm9caNvHJwlPzjzwQOszYzih6xB0V+oBJvMxTRb3DyCQHgNA3QvCgmxXu2Lz tSBejO/6GhhWKKr1sVrGEXpHIMk/L97MXX6jqFmG4Y3n5IL7vMfQLo0GOj76AfuZujY8 M1UEEgLLOTncyeo05WqdMWpugxrbV6lo04XYi/ktqkmnCXhgOZj87CVrzrFPKozGy7TA v1umvMmkORR5wNxbZql5cPAK0jLUN1IA/3C+57uA8V6DacGACSPUTEQa5InRQh+dbn6r HCXJbUhsxAkH5SncxPGBVgstjz/tRlYNQPtdbCJF9I0yMPcfFVVnyM77b4CN220NC97y Ui6g== 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=pbgrWTrhRWP4UtlmGGgxuchXg694bR9RbzPx4DgGMvg=; b=pvKd3CBg4Yniru9zgEgZcha7FxM4gUG/0gvLG1qp5us18JLqhGkiX4lit17eyijXJD JhOoWm0Fs6RC/TrRt5JrFac+ELnAPrVvzRkJ3whTiApicP55Ls2JkrpyPCiXGlMB+ddF jgalTXJFCHqkav7mfMNzrOBeOrckoHus3XTno6yHpld4LT0QmKyQl3DCNiW0UU+JbZy5 J7F7gA/bJgvxhwrdenpvzTgZjsFo8RLc8m8L+MK2mFpRGoCsnoIHMyDyclvgSuXfTscZ qocCrg2qC6K5lo2UxvtLDKW6OP7xSXoJNzh3SVCnS9MusNzqaYEyCLmBjzqsHwkD23XN uNAw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=w1pNiTRg; 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-48646-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48646-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCVUYOtIIxi1z4quev6lECaUakDiresDRulp7hiAMAe16Xs8gcPFhC53kAs0OJ3WgOjIS9h3zXZVGDcRtjzv0z1u3tZOHQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 34-20020a631962000000b005d8e12c85d9si133510pgz.738.2024.02.01.10.37.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:37:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48646-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=w1pNiTRg; 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-48646-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48646-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C9E9FB26853 for ; Thu, 1 Feb 2024 18:06:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55F3612E1F8; Thu, 1 Feb 2024 18:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="w1pNiTRg" 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 B77EC8526D; Thu, 1 Feb 2024 18:01:36 +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=1706810498; cv=none; b=h+KoppKlwPtgNiyLzZG+jaagi+B8EfbdWbB5q/aLxTNiS31dsgoepU3nEpLji8AupM+bXv26QKp4K5jyKcjVi1doWc7Kg2lj3IGynxYGCGDyE310Hpc5R7biUf9NQPDDkhq4Olcs7zbhpIfW8wLpcOcJBRDdmPJwAyi9wX/KgkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810498; c=relaxed/simple; bh=cM1cFjnSzQs76i3u0egboaHOZ+8JvQ6u6lgJc80Opuw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IG6tCpP9EQGJTFvdstA/WlF1/SVbgQbhb7ignp90ZnO6nyqj9Y+Uxd8gzUKGLlwQ9KQtlQ9hO/oq4lqt8KO7+sohJm9Tj3ggYlayyUVjG+/prR47mchCLcsjGBqyUp95ph0S0cI/p2NY6Bbdijk+VdR2fDEaqX2kYAM0KML8u08= 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=w1pNiTRg; 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 411I16NW127754; Thu, 1 Feb 2024 12:01:06 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810466; bh=awh4L/FvuKTUk4LCovxuQcQcm/YmAlMhgCuKLpIU3pA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=w1pNiTRgiYLJ3cK7YvY8c2Pa4edi510sVdoaT8seLl/gN9yEbfAU6Nl/gX2KqZhQO jQpE3eI6pz/LFdKE9c6sgY5455FAfFmj3+bpt38atd6cneNOvWGhnDOl3+cEWWiOyv Xws7a6m7Jn2cXLLzac0mfvROnKD1dLeI5pESMkco= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I16oq120370 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:06 -0600 Received: from DFLE106.ent.ti.com (10.64.6.27) 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; Thu, 1 Feb 2024 12:01:06 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE106.ent.ti.com (10.64.6.27) 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:06 -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 411I12Gj117221; Thu, 1 Feb 2024 12:01:06 -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 05/18] power: reset: tps65086-restart: Remove unneeded device data struct Date: Thu, 1 Feb 2024 12:00:49 -0600 Message-ID: <20240201180102.70395-6-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: 1789722772295233001 X-GMAIL-MSGID: 1789722772295233001 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 Thu Feb 1 18:00:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195414 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp338836dyb; Thu, 1 Feb 2024 10:03:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/FovNf1a9onftGRe+aVMi834Mf+b3am1TwzZKchbv6P9F8I5zADBT17wVUhiAsJjp26UE X-Received: by 2002:a17:906:78f:b0:a36:877a:edde with SMTP id l15-20020a170906078f00b00a36877aeddemr4492020ejc.11.1706810599630; Thu, 01 Feb 2024 10:03:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810599; cv=pass; d=google.com; s=arc-20160816; b=aLNkYrGBAK4x3GQBR34IYF5SnCmlqXdUnjWw2MrXsITZcnrd3ewbWquCRCLj81iTsH gZDYg4/og6eSApKSy7qGBv7L/ZzJxceqpDpt25rtBS8q+DdAsIg3NerQn7PbTNqw4JvQ WBnQJkSItGGmN/BysA6YbKYi9HxRzeH7kvm/QjAI1FoRxQjpctsXsrXCKTWFyBcNTMnf /8dBdyiYgXou9id+v0pFQf67OFUfdWmnMQylGKJd3Br3Fzah0NZ0BX5tX6Nd7SCDVzLe lxrO6Nn+CyqmVAZQ4HrtbcHhu3q+5LJtFRtY/p2r/eb9Z2EwsGt/KVRsx6CB0C0mTz4X uLag== 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=b1ggeAlqOeW6cDM2I0g1Lrz7ya2O6mo0S8OfUg915BU=; fh=jnwBU/BwFKkgpm7cCeX3fMfYXtNU0b/Z9V+CmfzQnPY=; b=vFgbruQ8/LavGewhZWudnw2Vf7JaUk/XMz6sdo7xur950mG5scE1nhipnDhZigGCIH ygGj7M20RX96Aukw40fkJnoIxACP6CkA/NZCrhS3uvS5Mjey1PuLdUtiD4IioZxmtdwn +thflXIvYPQZfff/iJtKxb7Pf4RcD0E19+u63iZ9/3+mDn0XLZ00UJn+UyjRVEJQ0U8c AEA0m1iwEN3uHuDvJT+nqm9WUfHrj7ik99GX5T1x+lEbYvaH9mRqUli7Vi5w+v7JCqUj N4kTLP1f3vfMdpzkAIcYJbp3wXP+R0rzMwMNFJSv9tQzCRqk6d3YJ9nIPao/Omc8kRpO ua8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=BhjY8BID; 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-48637-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48637-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXO1+wYHjBNCxv/uP8dkpSl4cXmvWVjNLR0/ZjI/DZ72Tampz2Mwz9sEPKTJriwP27HzTYjrBH8ZmaoQccf3b1PlITHEA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gu20-20020a170906f29400b00a3162551e88si24263ejb.349.2024.02.01.10.03.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:03:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48637-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=BhjY8BID; 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-48637-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48637-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 36DD91F22AD3 for ; Thu, 1 Feb 2024 18:03:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3911B127B5E; Thu, 1 Feb 2024 18:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="BhjY8BID" 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 D3A8084FA8; Thu, 1 Feb 2024 18:01:26 +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=1706810488; cv=none; b=urEAeRyAz3hBhsYcdbjutL0vErzbzxOnl7TTD5b2hBvu2AYgzgpADRo4CEOFWuTLLKXaiIlO0cNIdkgsTmO4wG/fN7H4HUxQFmdW9eOWl8FiJytILRlbkpHgoxWgQ265gRVCRsw8gC7wCpsds3+Xx1oOjEs/HEDcdcJh0ITv8YU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810488; c=relaxed/simple; bh=bDDsP6FtSJ5wVZ0CYHdodnlun3i/+w7VsSjbcJGnQeI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q26H5LTxg+JrFHDkcXX6+q3U6aGj/66sdzsK0cEV4FPUdoJYj0HyriSG3rBNTDqm5SzoaWnUaiOFRdEraaV7QJ75xs0Y0uLSujd08tahqHBgBAm8L5KTyn6ZufQFOR78FCuPSi7La3+Lhptx+7H5tWr+5efbRt3ko4K22rszqtU= 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=BhjY8BID; 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 411I17wO049584; Thu, 1 Feb 2024 12:01:07 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810467; bh=b1ggeAlqOeW6cDM2I0g1Lrz7ya2O6mo0S8OfUg915BU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BhjY8BIDCh34TqTsuxsNCp59BD1rh4Iiu3NvrhnJGpkouoZ0xzRgSAoNY4vAPZdPZ gs+ymMss+pkmQL/x6MLDYhVTdPO2FLT5r0jJqXPVt4NO3l0ep76M+kHielPchllER4 fMTgVca4uiNbwX7Om2ggWGKxfTBw0mKtGGw4C28g= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I17n2029189 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:07 -0600 Received: from DFLE108.ent.ti.com (10.64.6.29) 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; Thu, 1 Feb 2024 12:01:07 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE108.ent.ti.com (10.64.6.29) 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:07 -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 411I12Gk117221; Thu, 1 Feb 2024 12:01:06 -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 06/18] power: reset: brcm-kona-reset: Use devm_register_sys_off_handler(RESTART) Date: Thu, 1 Feb 2024 12:00:50 -0600 Message-ID: <20240201180102.70395-7-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: 1789720631567275096 X-GMAIL-MSGID: 1789720631567275096 Use device life-cycle managed register function to simplify probe. Signed-off-by: Andrew Davis --- drivers/power/reset/brcm-kona-reset.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/power/reset/brcm-kona-reset.c b/drivers/power/reset/brcm-kona-reset.c index d05728b1db097..4bb956c8f24f8 100644 --- a/drivers/power/reset/brcm-kona-reset.c +++ b/drivers/power/reset/brcm-kona-reset.c @@ -13,11 +13,10 @@ #define RSTMGR_WR_PASSWORD_SHIFT 8 #define RSTMGR_WR_ACCESS_ENABLE 1 -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) { + void __iomem *kona_reset_base = data->cb_data; + /* * A soft reset is triggered by writing a 0 to bit 0 of the soft reset * register. To write to that register we must first write the password @@ -31,18 +30,17 @@ 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) { + void __iomem *kona_reset_base; + 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, + kona_reset_base); } static const struct of_device_id of_match[] = { From patchwork Thu Feb 1 18:00:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195417 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp339349dyb; Thu, 1 Feb 2024 10:03:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJuSE11m8zmEcvTYGB2fIQ+WDsvYN5YL0TXbKZedQBLmcJbkdp1acKqInCeDrE/Dj+2J/K X-Received: by 2002:a05:620a:898:b0:783:518b:9d57 with SMTP id b24-20020a05620a089800b00783518b9d57mr3287432qka.42.1706810635553; Thu, 01 Feb 2024 10:03:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810635; cv=pass; d=google.com; s=arc-20160816; b=SC90NuYCv6m4zYqg7RBxVkxYel0Mdzb9AcDWHnokPZZ/oHNgeuXDuXVmAtDlUX7anT u7UKbP/DdYyNHz91i/Gt3MFdlSQM6uNml4coGdfn/IBWsr1kODQfggTqDLzyaUFMEkOA Y0bBfnqv7F6r7k7fKAN4vL0U+hvNZRY7HfSP9cpPSln8VqAxTykaT8zTKAvBsYcpgtmr nZqUPLShqs07f4nZ2Uxz96ZWD/zMS1kGQv2O6JOV2jbTjh/UkckfSah79JUaEZh1FdSz G6z2GUcybVOmnCVTE9OJ/s0ohHSwaK/dJJqNFXxcse6HcuwMUtHMV+N/Lb+hp49UaQ3O q4aw== 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=1CmPboCtgMe1la3c/Wi99oG8zJRT0CFF/QJbszjEsHw=; b=tOsjmPYyfVXodQ6UGCkSHFZUsjWbPzfurFhyhu0FIsPr5V9jbaUHraAhgcFih34W5V Er5zF58PoKyfollWKknCCAOued/B50YngvbvMf3//V7gUlKAF92VOeA9YAwgvSDIz+fL SvxMlbqVwR24Q+SaS85E7WbN8EU81FMyFLkRI0XgNmvHkby0Qz0tLuTyi4NRI0miETuW JuNNzg+JPkAqyzt1qReSXSSodPB4isStopT+XTuuGd8oltUCbp+j4VNwQUcYcu2LZ93f sn5FFqFIbtxmeRVAHn/6DAoduH4IRBdNeItTT/mOrWp6dA0G89ojwb/ppYltU0709F+S mmvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=eQYWuq+o; 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-48635-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48635-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCUtKywJABiYajVNYn5p2BOxbIWJcaYyZwCTWX8ys0wy5FIo+MkMf5VsaxnQ9sp4Mdehm8kR0hr1LnplwFYRXk0BRzrLYg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id k11-20020a05620a07eb00b007839e747700si65474qkk.192.2024.02.01.10.03.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:03:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48635-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=eQYWuq+o; 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-48635-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48635-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 8AB291C28F3D for ; Thu, 1 Feb 2024 18:02:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 073AB8565C; Thu, 1 Feb 2024 18:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="eQYWuq+o" 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 A3DC584FA6; Thu, 1 Feb 2024 18:01:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810487; cv=none; b=fnzShCqSPw/ziZoGahEeXtqtmeUJTC7bJeVypXFJgptG2Sg2mtSjortEd8GHK66mOZ44VdGJmR8Dm+7AVeEnwyPDliGpYJwQmUjSyKxvWXemiNmrViE+3uEmBDQuMgSgjJlTtXhGH6HIA7nDhndND52N75NDpzc/vaLWwQn9ah8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810487; c=relaxed/simple; bh=QekKnIF+GkovKO7gb14ZkIhecaU+qacpUcgS7SjOB24=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=laxuBJJ139WkxPfGT3H5PVanCU1yAMfy01iigmvfqkFc1AqQ1cx3POAe/g1UlfZOWQuxocNUsTXSb1e71KNFZQg4LyP9MfIqBuvW8mWGQ1y+3x2D/1Rj7ZVIk76y4Zmiz1F6VYlnQ4KjZy4Yc7cZnGs55rUTpgqmuBf7GISLW/I= 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=eQYWuq+o; 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 411I18Cq049598; Thu, 1 Feb 2024 12:01:08 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810468; bh=2TI8f8x/5Y4Kr2Vxqhq6Wi5Pu8tSR0ICKXsQgkmtu64=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=eQYWuq+oUvJbHoGPrNtq5ir2oEU+L6SOYJqp9NBnd33fXSL4HVVqGRItaEb/8bljG eMA/EbEc+6q2xUmQllVAKB/7BvHQ0EGMpuQMXf2i/5DQoFh5Wfri4pJCxDQe1X6ht2 El6qPNeH9O1v32iCzBKRC12kD+U2W2OYLu1U9+eM= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I18tF047528 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:08 -0600 Received: from DLEE112.ent.ti.com (157.170.170.23) 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; Thu, 1 Feb 2024 12:01:07 -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; Thu, 1 Feb 2024 12:01:07 -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 411I12Gl117221; Thu, 1 Feb 2024 12:01:07 -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 07/18] power: reset: axxia-reset: Use devm_register_sys_off_handler(RESTART) Date: Thu, 1 Feb 2024 12:00:51 -0600 Message-ID: <20240201180102.70395-8-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: 1789720669054288104 X-GMAIL-MSGID: 1789720669054288104 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 Thu Feb 1 18:00: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: 195425 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp342462dyb; Thu, 1 Feb 2024 10:07:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxj3L5hvD50AnWM4+A6eoVz8njONKz9eiOcNa1cd6O4/5q2L/4QBTkKC6RF+KOrWhoYpxJ X-Received: by 2002:a05:6102:ad9:b0:46b:119c:17eb with SMTP id m25-20020a0561020ad900b0046b119c17ebmr4803132vsh.1.1706810842966; Thu, 01 Feb 2024 10:07:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810842; cv=pass; d=google.com; s=arc-20160816; b=ZX+euQiRkNcHZrvlj9mGla+eWQATGGIWnRukW/DqgtxwI5pDeYB1HsLXI0lRM0JbGQ b/snb2oiIE/Qz8GnSlPf9l7m+eMNUvUuy/NoBK7NAaMkrNpwVmt48wfrcgqJSpp1kPq+ /JY9B3qy9U/2nRvbRc0Mn8YsYEkRP4PQzqISWGIuTDzaRqpTLAS98Zep72v1ISfw/UoJ zCqapQkW5N5x0fkdvLP2KSG/IrWS4EbM5WaCvoML2Zr7SKBJL2tLFC+ZjcsC3MJklt+a LOjvMZm1hBhAnLIw6DH4PFat6WYfCh4MnbMnQsI3PbFcMYYm39fYyHnVdOHa0rQ4bUcO +67A== 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=HT+FnIs0I4ANTd+DcHN+9ZdpwOfg7H0WObK/m9iytX0=; b=lVQWnsDQ6SszG0UgfOhySHR+XWB3ZojMach3BIo8zBJLgEF5gKB7YVS9ZiA5cr7o/Z eEsHJimQkiSKwGG8Q8OaOLDWFnGYIM0tvpXMMtreSrZMxLfnYRNzedgNex+sX5BU8yAH oQNz1R6LPLgHoDV07V6KdPNwTPFSWEPF3I4hr6IsqWhmLhHMBHdi+8wSHaH+W9t1yQg8 fI/l+1PwHVEvTqQtchgq2ccdd7DmEGQpgRCUwT0rX3T/N1fa6cMC3ZlPY3Y1dg9OW9K4 I2PRuoXRZc8WDgZh/bhLTT1vs4XR3odL8ZhT5vtr6W+xW0dJqrgIVwHMEntRbF3fN4Ku ahXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=O4waO+1u; 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-48648-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48648-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXNUQxS2rQr0Rp8EvFLH0M18ikpfORw6sLViqmETt3KYEQCIbGP3oumrsL6au4YL5OKVSCV4V6WCQugQo2GzYotcTIspA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id dh5-20020a056102578500b00466f93264a5si502896vsb.424.2024.02.01.10.07.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:07:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48648-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=O4waO+1u; 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-48648-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48648-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 AA7011C24952 for ; Thu, 1 Feb 2024 18:06:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8920012EBDF; Thu, 1 Feb 2024 18:01:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="O4waO+1u" 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 21DAD12B159; Thu, 1 Feb 2024 18:01:38 +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=1706810499; cv=none; b=EXReYGvj5an1M/il5mIY02RhH4Lr/kvtqf8EPCGT9IUs8bAUUGH1gfsrGm8SaMUkypdwIHxS0oCNWx2Rtw8bx1DLMCAX3utiXb/ICF4N62HHKv7sDilsyOjiEwn/kvSV5vHI3AJ/wFFLS/FzTZcEghJ8HDbYp3tPVfwEjkdJsVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810499; c=relaxed/simple; bh=/wWLg9daNT6pfazjCLsyzkG8hTMGV8b457Vt9N+MIYA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h6qH1o2bfnJNbiNL/BPec9ej74j/Ufo4JGALMNfqhEPn6EiT/7bYxEJmAdV1xHCUlmlZH3Fal0tIQMbGygn8cyylRnMJ0VyZn2qI/GrYWI+9L22lkUj/0CihW0LAzpzylMFvru4Fvr1UC74leeCIunqUZLCLPQkbKL6VCI+mcF8= 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=O4waO+1u; 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 411I18QG127771; Thu, 1 Feb 2024 12:01:08 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810468; bh=cEd9h6ts7ZA9SmxTtqXrV1X3OAdroJfb+pEHlYKYQq0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=O4waO+1uqN59VsePrSEG4VCsJCg8ZXHl2rWEqwvUo0vLM6/7b6H4sn8iU8og4Q4EE WN/ucJbGJPby/S76a+f0aCGZBfsYcJtDB2+V5uhoj5NjvjxBJy1VJcYuDFBoKt8nl5 UbWCUym9TB69TmC4GeCftprH5gCfidGs3LpcMgrk= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I18S6047536 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:08 -0600 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE112.ent.ti.com (10.64.6.33) 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:08 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE112.ent.ti.com (10.64.6.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; Thu, 1 Feb 2024 12:01:08 -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 411I12Gm117221; Thu, 1 Feb 2024 12:01:07 -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 08/18] power: reset: rmobile-reset: Use devm_platform_ioremap_resource() helper Date: Thu, 1 Feb 2024 12:00:52 -0600 Message-ID: <20240201180102.70395-9-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: 1789720886440722748 X-GMAIL-MSGID: 1789720886440722748 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 Thu Feb 1 18:00:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195431 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp347558dyb; Thu, 1 Feb 2024 10:13:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGiKcms558WCFkWWPZ+5sFZo+PKa/jfFQwHJgP0Xk4odpXbmI3Q4pIbXNYRK5NfIBbua9Mk X-Received: by 2002:a05:6a20:12c6:b0:19e:4116:fd87 with SMTP id v6-20020a056a2012c600b0019e4116fd87mr4583626pzg.13.1706811192495; Thu, 01 Feb 2024 10:13:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706811192; cv=pass; d=google.com; s=arc-20160816; b=hSGPhXRu2vrmGu/uJJuUlIgFwYpsIOOfV2VTve+ngkmXBnKQkVNJpllu1xhBVlhcTt 2pIHza8ERHYHtkqqTc8+Bxn6DdcymBStKWCQ+DDSE2ygRecb7GNG8CgnuJ72z4g3AdcB VHUrlD0VUBn1eOxdWbCxW2IhyHhNrSRscgsiktuDiJJbcHZZi2gIdoPelrlcWr1RxJh3 vZNNZrwlYbBj+HW7n9W9GX4Uj7wjOvap1VGs+2Dofy7GJ6Td63V6bMVwhQEC3im6SXOC JdOj30TEhAehEKYDF/CEhNU3TXdn17OOVKTgoITK6pHxeEFO+D2c6msvi4F5V5V1h2l/ mjlg== 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=+6oayEskVPsQjbi/C7/hq7hBkB4TpvJeAVLuE/xrEZs=; fh=uw24EUy6M1/a2Uyw3PGwMeG3ABplhZ5vSxfDEWIxIu8=; b=t0q87k9f2cp7yPEykB8dx1M22zyas8j9yKz4s1GPYkgA30QkBoCmvtW9FiLj5qQwAP S0uEX+WuauGM5Hrvl7gsnepsMJws1JfpMnJ7hiYLzNouN3lTcEcdk85kfoDLS4yrS46T fHmTGAIgIGiCPFtV6pJUreEQ0VmT0SjOzm6Jj02mN5I5td8gbgNmJ3Y3lr13ULNvxdvE Y7K0nuMaBfvQ7BwWW41NWjamLWeevUyQzZLEvm5TuS2gQTdX+9lqzq//UkrsgJi0o5fT 7MmaHYGf3vMHpKblrCrCD2WGJLIG1JS7niN5Rz5+ZiT3mDlXnX+scNFC+v8N5d3GW5IS vm+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=TkMHSo1B; 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-48644-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48644-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCUEMdLFgkn1dG065G2bUCkCtb3Qj5G+Gf1kQ/DXPs2wvUtvkbFtSwxadi5rsoj/iJ6ohpnmmkPme39eXWF56mDts9PQqQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e18-20020a63f552000000b005cf1ddb15a1si117455pgk.93.2024.02.01.10.13.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:13:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48644-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=TkMHSo1B; 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-48644-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48644-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 276A7294788 for ; Thu, 1 Feb 2024 18:05:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED62312D17F; Thu, 1 Feb 2024 18:01:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="TkMHSo1B" 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 F2C7012880C; Thu, 1 Feb 2024 18:01:34 +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=1706810496; cv=none; b=jR+clYl4utEf15MzrClt+GT51w7VJDKaSfz61g+PH3RoFnR8F9wTPu1VDIdLing3FejzIyOEpocESR9wOfD1rWw/kzfPpzJfQszVxRdHf47q3hnjMsAx6/HpcQM0w+cd4+DCY9dI2Xl5G/5rVwQbroQdjJt3DBJ+WUI9lTsCATw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810496; c=relaxed/simple; bh=wOijXjJjHUtVV5dF2aD/1HsDkNeACwTKkwSZrl92nVA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GSyx2j54IwjhOaXUfRVG3YfwT9eKLJuAMA+ddSDUCDP1tT5T5SeACagRWGL+xSJaFU8HEGobgvGVdSDL6O9i5AdAe16+tXP53KZ3HYj82aY8Jr2SGHlnxWsh8f1NkTE6T50WUKOS8AEA5T4rVmia91gVDo2B1rYF+wsMz7QzKgY= 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=TkMHSo1B; 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 411I199X051703; Thu, 1 Feb 2024 12:01:09 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810469; bh=+6oayEskVPsQjbi/C7/hq7hBkB4TpvJeAVLuE/xrEZs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=TkMHSo1BMyKoOIbCWU3HX8M28fj0T0x3o3StVz6DcodkPqNOgrTa8GWGnzto05G1T it5cLq9uOej23dW0hC4TOpK3HF215DWpczQB7yt0qw4HW/KjMOwQpPQ6MXblpItdsC gAMSfCetLVILORJaDa6kR2UokQIXzowQPIEi5RVI= 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 411I19DL047540 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:09 -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; Thu, 1 Feb 2024 12:01:09 -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; Thu, 1 Feb 2024 12:01:09 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 411I12Gn117221; Thu, 1 Feb 2024 12:01:08 -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 09/18] power: reset: rmobile-reset: Use devm_register_sys_off_handler(RESTART) Date: Thu, 1 Feb 2024 12:00:53 -0600 Message-ID: <20240201180102.70395-10-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: 1789721252922522522 X-GMAIL-MSGID: 1789721252922522522 Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis --- drivers/power/reset/rmobile-reset.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/power/reset/rmobile-reset.c b/drivers/power/reset/rmobile-reset.c index 29c17ed2d4de9..41e98ff33a3c3 100644 --- a/drivers/power/reset/rmobile-reset.c +++ b/drivers/power/reset/rmobile-reset.c @@ -19,12 +19,9 @@ /* Reset Control Register 2 */ #define RESCNT2_PRES 0x80000000 /* Soft power-on reset */ -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); + void __iomem *sysc_base2 = data->cb_data; /* Let's assume we have acquired the HPB semaphore */ writel(RESCNT2_PRES, sysc_base2 + RESCNT2); @@ -32,20 +29,20 @@ static int rmobile_reset_handler(struct notifier_block *this, 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) { + void __iomem *sysc_base2; int error; 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); + error = devm_register_sys_off_handler(&pdev->dev, + SYS_OFF_MODE_RESTART, + SYS_OFF_PRIO_HIGH, + rmobile_reset_handler, + sysc_base2); if (error) { dev_err(&pdev->dev, "cannot register restart handler (err=%d)\n", error); @@ -55,11 +52,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 +60,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 Thu Feb 1 18:00:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195413 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp338686dyb; Thu, 1 Feb 2024 10:03:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSNyLYvtuQ8Axd+Px9S2X21OWQoufy0HZtNxwFkUFbs+ywQLIJJHqiS2qOVIwVjvgWSnGK X-Received: by 2002:a05:6402:d78:b0:55f:a38:a4f5 with SMTP id ec56-20020a0564020d7800b0055f0a38a4f5mr5192682edb.11.1706810590097; Thu, 01 Feb 2024 10:03:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810590; cv=pass; d=google.com; s=arc-20160816; b=tfeCYxR0GK/JeMg29iPgAfxLyJX/DWVBURCYD2kGtaKp6UkVMtGY0uVqzRXMmDgEFY CeEm/vMhmVCJp5WH8uUDb6woMMmn3y9B+C4AF++WeyWyYcaLyWW8PjKJknBeG1DBEkOF oYsknTxZBMIw+gyqHp5kxfszqhysqCPQjO3Bf9AOdv5SzJASANgbKw6ydfBtJ9VKQZrj V4Cm5LzMDCaRBLbVt3hvyXeVgD+F5tyctyC/QJg+QzOyzGJKm7/9pdP0u0FX19wk9j1j h+fxgK/HOK05BnmbwPLTAeRw499J2LJZi1HTxTSjPpYjjPeB2Ag9/Oh81/LiWqZw9Lau JHlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ngOnUmcKUfVk/SqAddQuFt8kMzihNR+9E3bjKI3tkA8=; fh=PbzkFqq9CYsXBCCMBbf7OkrMf4jlA6glgqf4UGHS/8w=; b=BedZU2O1xnEQryYfA/SYrK7e9EIYRK8015qaEMqO0uwqAhJrIsL+BSVL26mEweh3Qf N7kZ5rx+sNp+KH/dZFhkxzVivZmb51CPxJpsXTgS7GKp1ThYlCid4+htDu6Vp85476tP Fm3Uk6ZIyXt9hZITVr49O1A/S11PykzgcswLV1klOrtd9WzZpIbvUcDzJGtAekPBR2wg /QeeEooXMLVCGzsg5jOO8+5gu63iS5zJ51MI6Be7+ZZmFab0oRx61FUG/Nu12FR8+Rl1 Cl/TCvnMMw4MAilbEUqkHK+fOy5UILwwo0YyMxJZjpvWQFdMNxnFfDshS+NgycXiaeyl 2JpA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="wC8nhKc/"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-48636-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48636-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCVLKuh9cBxUZjShVWYdJbx1126aMN3JrBoF6SdX4ozdeQGSXAY7aqkh8dgD6kJLNpdhvJC1jwqOSQiY3R2qYx59AS8nNw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cy2-20020a0564021c8200b0055c2df7fa74si29102edb.529.2024.02.01.10.03.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:03:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48636-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="wC8nhKc/"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-48636-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48636-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CA0441F23F59 for ; Thu, 1 Feb 2024 18:03:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3617C127B46; Thu, 1 Feb 2024 18:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="wC8nhKc/" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3E0984FB1; Thu, 1 Feb 2024 18:01:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810487; cv=none; b=DPoi3V7rtzfjjhILlJO6zFol/y6XGy4gcDuxlrthJhgdOrADZp8kI6Pt5xsjx1G3ZdZIXTCqLWRwnHrt36rVjJSzD2oJZn67ijg1+kQIQdnN4iq6KVeyQVnmVv20o8EMpacJlNDM2EpJuiDMYGXK0XvNN1TRXrNeN2VHlHCsa6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810487; c=relaxed/simple; bh=ig53Er0IQr8J52R1XJK5g8TmLfD/5crHUpIF26cVFwU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LWdL0Cp/bQQMywt5vL2VfBkEgckdqPa2/gtXbCvFPcafzAOlcyZ2f5Xh0Z0CxRNkoTYyrPfth/sfx64DY49fJ9I9lf6KPN7irwS5ZAdA1IVQyrVsxm92Cj+J4FQq/dPBbAtKEQbg+hAe6Nn+Ko5OL6ct3S2gGB+umJmmBvkcIqU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=wC8nhKc/; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 411I19Yr049608; Thu, 1 Feb 2024 12:01:09 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810470; bh=ngOnUmcKUfVk/SqAddQuFt8kMzihNR+9E3bjKI3tkA8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=wC8nhKc/6Xj7NXCKH5q2UKfbxE5WvY3T9C9I4VEKY3P/I8fabPJdzpFtaEtyqWQtk AXbR8Q7WjCGp+oVKS/cpcuU5P3exGd+CpSMUScfzCUBg2v1Bl4Nj6dJ3Wi17nAor18 ZG8YIfrPCcSWImLKRGlX44Jae52pQALGR+2QeSuc= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I19j7047547 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:09 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 1 Feb 2024 12:01:09 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 1 Feb 2024 12:01:09 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 411I12Go117221; Thu, 1 Feb 2024 12:01:09 -0600 From: Andrew Davis To: Sebastian Reichel , Manivannan Sadhasivam , Cristian Ciocaltea , Florian Fainelli , Ray Jui , Scott Branden , Bjorn Andersson , Konrad Dybcio , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno CC: , , , , , , Andrew Davis Subject: [PATCH 10/18] power: reset: mt6323-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Thu, 1 Feb 2024 12:00:54 -0600 Message-ID: <20240201180102.70395-11-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240201180102.70395-1-afd@ti.com> References: <20240201180102.70395-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789720621245694575 X-GMAIL-MSGID: 1789720621245694575 Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis --- drivers/power/reset/mt6323-poweroff.c | 28 ++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/power/reset/mt6323-poweroff.c b/drivers/power/reset/mt6323-poweroff.c index 57a63c0ab7fb7..ca5d11b17ff03 100644 --- a/drivers/power/reset/mt6323-poweroff.c +++ b/drivers/power/reset/mt6323-poweroff.c @@ -14,6 +14,7 @@ #include #include #include +#include struct mt6323_pwrc { struct device *dev; @@ -21,11 +22,9 @@ struct mt6323_pwrc { u32 base; }; -static struct mt6323_pwrc *mt_pwrc; - -static void mt6323_do_pwroff(void) +static int mt6323_do_pwroff(struct sys_off_data *data) { - struct mt6323_pwrc *pwrc = mt_pwrc; + struct mt6323_pwrc *pwrc = data->cb_data; unsigned int val; int ret; @@ -44,6 +43,8 @@ static void mt6323_do_pwroff(void) mdelay(1000); WARN_ONCE(1, "Unable to power off system\n"); + + return NOTIFY_DONE; } static int mt6323_pwrc_probe(struct platform_device *pdev) @@ -51,6 +52,7 @@ static int mt6323_pwrc_probe(struct platform_device *pdev) struct mt6397_chip *mt6397_chip = dev_get_drvdata(pdev->dev.parent); struct mt6323_pwrc *pwrc; struct resource *res; + int ret; pwrc = devm_kzalloc(&pdev->dev, sizeof(*pwrc), GFP_KERNEL); if (!pwrc) @@ -63,19 +65,20 @@ static int mt6323_pwrc_probe(struct platform_device *pdev) pwrc->base = res->start; pwrc->regmap = mt6397_chip->regmap; pwrc->dev = &pdev->dev; - mt_pwrc = pwrc; - pm_power_off = &mt6323_do_pwroff; + ret = devm_register_sys_off_handler(pwrc->dev, + SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_DEFAULT, + mt6323_do_pwroff, + pwrc); + if (ret) { + dev_err(pwrc->dev, "failed to register power-off handler: %d\n", ret); + return ret; + } return 0; } -static void mt6323_pwrc_remove(struct platform_device *pdev) -{ - if (pm_power_off == &mt6323_do_pwroff) - pm_power_off = NULL; -} - static const struct of_device_id mt6323_pwrc_dt_match[] = { { .compatible = "mediatek,mt6323-pwrc" }, {}, @@ -84,7 +87,6 @@ MODULE_DEVICE_TABLE(of, mt6323_pwrc_dt_match); static struct platform_driver mt6323_pwrc_driver = { .probe = mt6323_pwrc_probe, - .remove_new = mt6323_pwrc_remove, .driver = { .name = "mt6323-pwrc", .of_match_table = mt6323_pwrc_dt_match, From patchwork Thu Feb 1 18:00:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195415 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp338953dyb; Thu, 1 Feb 2024 10:03:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMcT9rfQ0z5Fo8Y93FaBpH4Heto/wOokNrzy/2d0n/IxuLV1F40wCSrHdLySSoxuG1WaCp X-Received: by 2002:aa7:c988:0:b0:55f:327c:d18a with SMTP id c8-20020aa7c988000000b0055f327cd18amr3726338edt.36.1706810607981; Thu, 01 Feb 2024 10:03:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810607; cv=pass; d=google.com; s=arc-20160816; b=M539ULsUpiGCkeInM47clI1qDfq7XWHNWR1MQMQfeZ/mlmQs5ja9DLSDlk9WE60P9D 1aIf+ISFhfLGQDUTKIpAvhj3IGq6QQrOdjkSpL9PxPogQO1kn0WAJXzSY/VZKkjcxCkJ 7lgI7vcv7cQGAKBV2OAnr0cxn/GbRBgjNyPCY3FI+GBMgXLkPrYEIihynO+x9AGbpbfG xnqDU5A7kJRTObD1DJqoJIEaqiYbXyIXVDmxnNBw9Q5dKcrZDeWKAMtTSVQBExKlgD9O oFKZTqlHMhbfgiOcxF7cOr98bptrN3a64IcY0Y5lhjZ3F6H3xrfsEr/XJ+4NsvAtO42m OPMw== 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=bethv8rbEtWQ4Q2GLts2be7F/kQbtt7BOodJqLN+6KE=; b=KjM0p53/CBHlDFPympW7p2yYrwZWVhDmOQOUjJfZvcIhd4paC/ZPVdHcKuq7HLDzY0 oaOFanFv1+w5UgUJWfiNl1aJbGe9K7h3e6/jLYNUt8vL04rkM5R6FU9b9sxL5PZDtpK+ r+MMBsuiEonLVr2mku++6CT2cdPTbBENlnisLtoOuO+/S5uZvN+nZANsgwkfEmIejuja hxoW6RS+xT4u1TRVO3wCXhz5LYi44iy4Yv+Uk7RVpCrFFKXDU/pHt12qs/lsX2hShZRA vYdPrESlvxv7m+zgU8j+ayPQlj7nnjL6rkN/FqsB8enXyjKTI+vs7FB6S5HRmHVlpyzY NMMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=tyMEeCj1; 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-48638-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48638-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXCOiDXu5o3amA8aIqa5DCEjDsQ5FJ9Fg6yy0kOSg5oyj8TwxR4pTIQzUdT3IdaRO5QUBqh7AMwER34iLba3KB6IMq6Xw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p21-20020a056402075500b0055ec0610657si30035edy.517.2024.02.01.10.03.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:03:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48638-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=tyMEeCj1; 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-48638-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48638-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 7A9CB1F2155C for ; Thu, 1 Feb 2024 18:03:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5EFC7127B70; Thu, 1 Feb 2024 18:01:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="tyMEeCj1" 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 2202F84047; Thu, 1 Feb 2024 18:01:28 +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=1706810489; cv=none; b=J1SVuDmYl0OAV8gZs5cAR6nIm8hbctOHep1MaS/y7GyyApZDGT/6cg1kX1vishsAPd2Y80vOHeDB38h9lks8yt1QCCFXP2lZ14SlWRCmisgtDlGABLcG+f/M4gMrK5swCsK3TB5jz4A+zzcRCq3zyoeg1qRmDl6+zffvMeEBMU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810489; c=relaxed/simple; bh=BvK8IwqnEFboy699PAEmSTVNPQ3C5pW/mK6yHdKKsaA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=piitROrhq1hWX02Z9noM1+WJdz+BKzpND+pWpnnE37ah4TtdzDc03vCNVBr4Ht5BlZnqPzOcgVos6x4cdcUgfCyao3yOmNdiksfGro/O3Uo0W20izaFy2n7U8cMshLJc6McGeEjnW36Y6dtNr4CDQjLp5xpAAl69eAwJJQh0nEA= 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=tyMEeCj1; 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 411I1Boq049613; Thu, 1 Feb 2024 12:01:11 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810471; bh=+iboSw0kHr/XQ2F6mUqPjCZdFfbDSD+ql6zjttiLFSU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=tyMEeCj1fPmmpSRTUugtA3JXIw2BLd3voyMAK+H1o1ri8TRYBSGil6K6Pph/3LzDr 3B8RWfZGnEqLzaYhsUCFx3bbSEwjfowhTX7Ox25oF48u6IdQRLrobxcUM61Dr15ER4 3OwoQL4VnZGHXtznw3cPfhjvTlLE4AywOaqNCDjA= Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I1BuU004593 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:11 -0600 Received: from DLEE110.ent.ti.com (157.170.170.21) 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; Thu, 1 Feb 2024 12:01:10 -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; Thu, 1 Feb 2024 12:01:10 -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 411I12Gp117221; Thu, 1 Feb 2024 12:01:09 -0600 From: Andrew Davis To: Sebastian Reichel , Manivannan Sadhasivam , Cristian Ciocaltea , Florian Fainelli , Ray Jui , Scott Branden , Bjorn Andersson , Konrad Dybcio , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno CC: , , , , , , Andrew Davis Subject: [PATCH 11/18] power: reset: msm-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Thu, 1 Feb 2024 12:00:55 -0600 Message-ID: <20240201180102.70395-12-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: 1789720639707219434 X-GMAIL-MSGID: 1789720639707219434 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 Thu Feb 1 18:00:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp341683dyb; Thu, 1 Feb 2024 10:06:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIxqIR5a6lk/sXqF87F7CcIvktRT9xv4sEl68qddFbdEEmDFshj6hsB9kxDm7x+QzbL73u X-Received: by 2002:a05:6214:20c3:b0:680:b7fa:15c3 with SMTP id 3-20020a05621420c300b00680b7fa15c3mr7032027qve.50.1706810792798; Thu, 01 Feb 2024 10:06:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810792; cv=pass; d=google.com; s=arc-20160816; b=pR3D8RyIIcY9ZFJzLgQR11bcORembGCadWqa7q0f/44s89nRteAaoh/3Tf7Z8hMc3N J3unx1dO4f4JikpNN4LphVir7HsA6lWHEEnbZSv5MZF+4HkLhw29ilIjdpvJMogz/wAI iJHinluwGsG8hEt2ltPHuSU2B0MPa9EdpOpqhCep+8C0euSYgD9xW9tgOKeJrl/mz/dm IPiE7ZZ1XfzhEfrr/KBijiWTqEKP8LX5YmmUx0dLhPUaD9qOpPPeF1bKGmU6Q9HobQqY aBYQg+bZlJS9/D+vT0sZUR2EeuhzTbTKL3WNEM3yaK6bhbpsO8TFU/3hswUWHOXBDQuN SibA== 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=Sde+W2EausNp7VWAZVenI+h+E+wt7paRRBDr/aFtlRU=; b=avAUpLz9Yl0PmVL/vy8zR8XC1Myg+eru5swLI1OwNJqROtYL1FhrRSC758ZqEyfrQ6 QyYvgLSBwmpx+qI803GHdCQuorb5ICDRfMXFIgrSq39ztfAaukf3kxCGPKH8NlA3aBoc VFVqcn0sP57F33iRmm8F2o4Tvks6ZLOfM9cbI4TK0KZI9QEmC3B6Bp+Tsm8uZEoaaHnZ qzdMhg1e+7xpxdQVqQLj6XC/X/AwV5bTR9fYnqw2CWZi0bUX82n1RJVthqIKuQa5bc9h iem7Jhx/QmnmD9taLPJZ3H4+ea0gVVfiUXqd5dUeE8omuPM1vvHMkON+pcKUhLOhdWOk 8X8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=LAT0O6ph; 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-48642-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48642-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCVttRGgOlUPcNerRQmiTM4XHQa3eYe9ixgssJJc980w3W1XDX7VEWIQWpXjOHS0odH/hb8/9wITQEA2IqmGAzzJINcagQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x21-20020ae9f815000000b007833a6cf962si58399qkh.299.2024.02.01.10.06.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:06:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48642-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=LAT0O6ph; 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-48642-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48642-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 CA05F1C28151 for ; Thu, 1 Feb 2024 18:05:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E52DC12D14A; Thu, 1 Feb 2024 18:01:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="LAT0O6ph" 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 48A9F84FA4; Thu, 1 Feb 2024 18:01:33 +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=1706810495; cv=none; b=ByVvF3mYrFRPwEmyGV/qGN5YUOCTwchYelrMTLu8x1zBpKw0Rly1gKLiWnLzDMOxAlCeKxXw1UBkSQxW7vQNR0mWpXyJ8ZHRJl1UW9H/1Ty+S19O4iw0C006Hmi3EtqgKhQS1mPtAwSM2XvaAJTo1TPEI2Hx/Kssjdxt6T490bQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810495; c=relaxed/simple; bh=TcZggvWPAiMNrDjTaYr88pR3WYNyYJDkk6qpMPNTC3Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AF+NYesrpEPb8I5bK615YtX79syjqnRlEAoWCSwj/SRV7aY65f9KRY/RtcNcBe5sn7UC+ROKH2OoySV6u/Zv3JlygEYRiEBvr/DFPCSQc8o2qcWK4553avENiBlaiBq15UDmjNSKs9xJP78TMZlMfhxaj/2DciQEz8W0CFjkMS8= 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=LAT0O6ph; 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 411I1Bdm127784; Thu, 1 Feb 2024 12:01:11 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810471; bh=5a2BDxvry/mDEJhidMjtTRkucrmFZYMP54rfoZVMxFg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=LAT0O6phzzkUn0u9DiUYG23YLkVnG+TYgkm1qnbGo9sMFLwGt67eUqB8AlcsG1llS yVaoHeX+MzXx51esdmGSVer69TG9Dkc6nEIvp9WQDn8I9Ipua4LBephbsEfUNnpJKC f5WBxZGqByyxHtY6vjigb4NrNXXZt0YZwMX0cJG8= Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I1Bll120465 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:11 -0600 Received: from DLEE105.ent.ti.com (157.170.170.35) 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; Thu, 1 Feb 2024 12:01:11 -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; Thu, 1 Feb 2024 12:01:10 -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 411I12Gq117221; Thu, 1 Feb 2024 12:01:10 -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 12/18] power: reset: msm-poweroff: Use devm_register_sys_off_handler(RESTART) Date: Thu, 1 Feb 2024 12:00:56 -0600 Message-ID: <20240201180102.70395-13-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: 1789720834035478964 X-GMAIL-MSGID: 1789720834035478964 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 Thu Feb 1 18:00:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp342083dyb; Thu, 1 Feb 2024 10:07:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTp1QlA7HL6UrQbD7XDmnB1bmaFvlASb0G3HB2PXRvt0Zb0yKu7odZ1gvtd4g32z5Dc+x4 X-Received: by 2002:a17:906:4a52:b0:a31:2ef1:c137 with SMTP id a18-20020a1709064a5200b00a312ef1c137mr4431995ejv.46.1706810821250; Thu, 01 Feb 2024 10:07:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810821; cv=pass; d=google.com; s=arc-20160816; b=n5HME1lUs3Y3K5EVUyX17q8A3Ay6UCeMlBof5fS+TfshDpVtqifzRL3vHBn6XAZ2Up ekK0pQJ2usJkOFRtRjPPqqBLUNDksefKvmGRUcjpKXtmZxRALN8JrUrMwIS0ZjBGmr5l Bc8xx6ig+69hRRx3I2ow/qgm/PH3M4stlFBi+uve0iYQXNIla5ANHTQ/TEjcrIWXw8P5 JXlH5SPRnUDp74GzJiZ9JkWii4P6SGxafeIOe2qcoSZNwAiQP+AR01FZvrcSqtJO6CwE wHK8YgPa6Bz0hJwmbvU+bQqqqjhB5RlTRJXZ+mdGJYrAQFnNpe9L+MhDFr+ezJbalyY8 jPfg== 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=7H9e6kzbaoVy+ly1K4kpbsA7ei1l3wvg/WHnR8b5nNA=; b=X86HDFwTWxnN6dlUVe3zXNdCODhxI3f2BTKBklTzHmWSiH5EA5KUriESXezNJJAo51 59kcMx8GYOchxGuGyLFjWNivaqdsSFcf+9SAqBuup3ZNwLu07my2AIi81ZomCCHHsNLB BP+ENenI98ldxNvHKBehhHCXjqZQsN37g8Tu7Akt56gGGpN0ICM5XsIX+ztJ6pZnJB5o lwGCK7e3N6q9Vs0t+2+yHg+Co8CdU3Q0N6PuktXHjr+g5jnudW72QHyBG4OQ6ThXb3mE y5/YY0k+2qtDrUprLZuQIoDxYoSpOqyhmoGwpdHVvRIpiF9LRMxjkjz3efxBBLD4Kc/V uDYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=TEdRKWAS; 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-48649-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48649-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCVbuLRQDWhy2kBQw1Kaxrk+sWeNKF05K0DlgImE3uTWKegyl4K4sIwjUjU0VoFtaTdhkyqDCgbXavwyOGFKXTHGR3Kn9g== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id j21-20020a170906411500b00a368fc619efsi24285ejk.868.2024.02.01.10.07.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:07:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48649-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=TEdRKWAS; 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-48649-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48649-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 14A8C1F27180 for ; Thu, 1 Feb 2024 18:06:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F7F612EBF1; Thu, 1 Feb 2024 18:01:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="TEdRKWAS" 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 4E0B112B160; Thu, 1 Feb 2024 18:01:37 +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=1706810500; cv=none; b=HudZQ3zYJvZQT5cDwmoQ8KTX9ixI6MTh7zr9KiXasC00QHTO1reuhXv5vRwenMb7nD31V1pzmhynh4WCOTUVIA54i4Q7g81zZTReUnRKi3ux/0PvuK7phvp6Wk1CHZXx8adhFGrXCr04qZBUOjwkPavwpbgbhDIpKCrVXRkvW7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810500; c=relaxed/simple; bh=b1HCM6PNhU5iOFP0yy2ZAE2FiVY5BYt6sfsBzt/lauQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sPkSVWJQEBEbgyJ7fSMI06UIunYWK5II9aZ8jo2yl3GpxoV1HtKXJ56j+8MJCxKUURGm9pPW0elZ3tUR2l04tGaAxivJNKZQkH0NVj88XnDXGq270kkkFBWHz3nRpmkYR1KR5xMxOnUJbmtlXdPZJrwYvHirBLmdEJy/cnpm9Rc= 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=TEdRKWAS; 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 411I1BFn127788; Thu, 1 Feb 2024 12:01:11 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810471; bh=+yoH0oyAcvSMYuuy/HNbc6iZw+avNZNinJT/iIL/4IE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=TEdRKWAS68vhJJnd9EvHzfpDNDUtaYTLUff5lKyt45xraFCOzBhWFWWDs6v686NP2 JOCvYzpgpUi/mgq0ZWXBUyM+qKVCJ5kDjTsxt+FfOzRKdJfKEk7xPbGKA8ms77Ds+H VvV1Jgk+88Xd8XmBSqPY1fo4wyAmLT4a7eaGPGtM= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I1Bso120468 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:11 -0600 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE112.ent.ti.com (10.64.6.33) 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:11 -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; Thu, 1 Feb 2024 12:01:11 -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 411I12Gr117221; Thu, 1 Feb 2024 12:01:10 -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 13/18] power: reset: regulator-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Thu, 1 Feb 2024 12:00:57 -0600 Message-ID: <20240201180102.70395-14-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: 1789720863898224705 X-GMAIL-MSGID: 1789720863898224705 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 Thu Feb 1 18:00:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195426 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp342611dyb; Thu, 1 Feb 2024 10:07:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFlMG/wWHADewaTKK+CYmAevgPPcHOHLIxyaldyAtTEFd2e3uiF0ryJtCqfaq20/Kzu3jZa X-Received: by 2002:ac8:5b8a:0:b0:42a:b61a:410f with SMTP id a10-20020ac85b8a000000b0042ab61a410fmr7245234qta.56.1706810854716; Thu, 01 Feb 2024 10:07:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810854; cv=pass; d=google.com; s=arc-20160816; b=PVl6QXRU5pY4Px/oih33Ydb9KTYftaysu8/VIAQv8b4UsCCcfUEpkJbpTGcrO4HG0i 9Dmf5Al7beJakGlQPJpkGErzTlVDaO7zdCwPxHctw5q3P2i8EZza4ECctnRB/62GtBw7 6YOp6Q358WLan1Rfg41bPtBvQOGZ/01SwZ4AFZBjUopU86xtvK3wZGqmGxT7LdWEeWgB 2Cy4QIyp5AB2+5gMHNi0cfv6pXjCo9rSloPcLpJYem7nS/HpZfMoX/t7VqchgbdY2cAM x1JS9WR47LPNTfsN1pOBq3t8XfC0CLcv1J6G9ugnQDgD+p8k6VcpGHlFaREZ/uutDc76 fiYg== 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=+G0+pgJSnU5fwVCPi6o87aIaEwxTHSWkqXIA7rb/G3g=; b=Bvw46n0cPyCiXe2p6VWLK47JcRKOPVcMTL+kds0srtDudmjbTc69wFqbaWSxUJjfeO JyO1TwW8qmfGpa1U4rsTwRvlBWmFvGFm0luAoupQ8ldc5Dt4D+BQcU1++H1RpziqeJ8X nMzb7fZWjFuyygeBh30OY5KKUOq292yQfKnaM4LnJ+xnUX4oHRBsh+iqjIt1BGAMXlV5 nDDsBDbtX8cEDSh+HO4ozrHcU+QyRkm1duD8NYvBFIN2Kc8dKvhjjtEyqxxAXctp3m4C 9CZypsTzaB+Ls0dZAZpZ+Y30l3lH15xNSh8wTmPYgOaGgK7/fd3UpXSwr0ZFDFi9/ks9 /P3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=UyO5EnnD; 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-48650-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48650-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCWGrDPjrbZG3UvH5/znuunhxJWCcTumCGhaxho4ZzekW96cfte5b1GMSJaJXQke1toYtpI0KQOqD0l+y9dbJP4Bpz1cBw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a18-20020a05620a103200b00783f21c1280si49961qkk.507.2024.02.01.10.07.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:07:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48650-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=UyO5EnnD; 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-48650-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48650-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 F04511C28C7B for ; Thu, 1 Feb 2024 18:07:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19F5812D16C; Thu, 1 Feb 2024 18:01:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="UyO5EnnD" 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 C4D0712E1ED; Thu, 1 Feb 2024 18:01:40 +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=1706810502; cv=none; b=qnnyfaE/QcqQqG7rFaPfUdBTLE+fdrlqZlX/cANwK+nO0+0ktmUrerVm3jGlOjE8DVq4rKv1EPfeGFINpNkBvx9lbIWJb9n404G5QbQjj/VmKx6QWlsxmCAeM35LZ1+ppTw78jqVgQkAQIze4A9Pyfz94adHUkCAZaKGNcR5xBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810502; c=relaxed/simple; bh=piMJuCp6Oyf7VRRgvElf9jQlTaTY6OoJDvy6PpEE/uE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MKzF0EDq367etnYP5OoVEyHfVtPHDyZx0cEShMtK9f21QF3bsXMbOXxL2aHt9C4cB1dAM9Tu0yfV6K+Z64e4FRPZ9AxUhKMsD6fpzUOsWuYZz51it4t5n+Bm3O8WIuyWBMMWz90qFVSlvqoQpEesHzeEjSPIXR5QLf5iNSd+Jk8= 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=UyO5EnnD; 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 411I1C0e127793; Thu, 1 Feb 2024 12:01:12 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810472; bh=psW+zR+255VuGRBEiZa3qV2ZSoJCA9HDeWGIZlh4BNU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=UyO5EnnDRngm9H5SGH1A+jEgO7wkevXIJJ227pxDcUetRFvBS9480xEhg15nfp+R+ nj4Su04MrkyrG0saepA77HVR2LW/DreMBTJ1KaHdr9Oo5AsU5avhRdjIixfbcnDmGI snG8ICoQK2Ebi8klQh3Udfc9/3St+CDi3QE8n4v0= Received: from DLEE111.ent.ti.com (dlee111.ent.ti.com [157.170.170.22]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I1Ctb047604 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:12 -0600 Received: from DLEE115.ent.ti.com (157.170.170.26) 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; Thu, 1 Feb 2024 12:01:12 -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; Thu, 1 Feb 2024 12:01:12 -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 411I12Gs117221; Thu, 1 Feb 2024 12:01:11 -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 14/18] power: reset: as3722-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Thu, 1 Feb 2024 12:00:58 -0600 Message-ID: <20240201180102.70395-15-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: 1789720898649129009 X-GMAIL-MSGID: 1789720898649129009 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 Thu Feb 1 18:00:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195419 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp340227dyb; Thu, 1 Feb 2024 10:04:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9CbYCJiAP2X7sEoGcInBbn1SZQyccQnV9Kjv+ZAt735CUGmbclfHk9791PeCUTtqz0Dc/ X-Received: by 2002:a17:906:2291:b0:a36:7a72:de45 with SMTP id p17-20020a170906229100b00a367a72de45mr4373576eja.29.1706810689149; Thu, 01 Feb 2024 10:04:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810689; cv=pass; d=google.com; s=arc-20160816; b=BR2IluuDv5ddEZ6JF5pNA34BbzUyKcKbMIm+0S/0tTQLV3INBAbGRuvPBbIW5x6xtY lrc0iN4NJ4E5HB/62P574RKdHxfw/6vFCA8QFx2kOMkMISQkVHdvJdhTIXg5VorbchRt aUm3YdUeE05Kp/u74LEI1Tqf5rbxtdvqM4qQVSwDFYkyRssvc+RJfqryG9PxwhoHulCN 7tF3mZAE/nsoKhwU02/DMCibg9fTVJLGr7h2jzkaqKQRAYwYoVLU1TZdkLcVXfFqYAnj vaO8CItjkgQidHlc7cUlcFuxWtRjfJZVNH82/i/gVrJRtC8jvYIMf5nEM+Fvy9ZH3jS7 parQ== 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=ewewNsnIMwxnDoI3l4XPWbjODltwR884egun422byPg=; b=kxlwCXRbmoiU1DyziyRY654OwugdfqrVgB3ixxDe6qg+5bGiMNQik2UMi4YGPOwz3z s7E6D4GSpRmMRjwow6uMW+vRFrU5Vs56tA8Cdv1abuEhnQ01T/srrbGEyV9FJd4vuzvF ERqbjwJzs2zd6+tYNrBp/7+yu06xEof1Fxlyjm5wOOznWDjz4aa49wQoK/qIwtis/qEu 38yv/Qq4qVY991QG6e1Tx8wwtFB0HrBGyEEpD9HifkLnqqwJtrMur2IYElW/gKXW+CgS 201HRiv9378Ro8Y2fQWuAalIp6eVPUsaFMyrnie5CfXJ4bvAoYJqN/ALn2cpANqQr5Tw F56Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=rVR3s6B8; 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-48640-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48640-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCURkmZSV5CBCzX7G22IC3DhJz2OrPTWTn25l1iycGuKwNF8EmvtECHvHDPqclQMybizX9CBv+hVH8agDWoB8HuL1X+JgA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n2-20020a170906088200b00a36e051af9bsi27223eje.96.2024.02.01.10.04.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:04:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48640-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=rVR3s6B8; 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-48640-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48640-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 C0B541F2282D for ; Thu, 1 Feb 2024 18:04:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B60F12B141; Thu, 1 Feb 2024 18:01:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="rVR3s6B8" 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 0D332127B76; Thu, 1 Feb 2024 18:01:32 +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=1706810494; cv=none; b=uVU5kAT5lirYZpjnhBVM4WLzhS1x0jMfUcu1DbG/xk9ArQrpnLbNWsVo8vjzK3d2A8M5/6HuuT1ks2J228pdso6/7BS7DISX7P6wLCOZLaolQfQLPeRyJlUGRs2rL6CjvIFSKnWsqDRvyDAP5XPR9bqw+npiH2tZTXVIqkKKi5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810494; c=relaxed/simple; bh=HDoP9l78EFZDdW16hNeR9IATxUCA5uyr6j+jeh40ipg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PWEJW+NOHhqvz7+YC+ajAs77ks7HzIa4QTsOVOiJx4p99WJJmr/m9c8KWqFOzi6sNiVXDfuQAyrj0ZBH/uMUfVS9X+E2UYuk+Rt86+4l/haOz8BFIwb3modU2YyVusjct2xGSz7JoVeCnVs7eRojnIhzapKscQapADRsMiRuIZQ= 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=rVR3s6B8; 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 411I1Dio065886; Thu, 1 Feb 2024 12:01:13 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810473; bh=WzOWw71XNiTDn9UhRVmQ1YL+kbl79QddxFr5AngwFzk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=rVR3s6B8tKTCDfJU3grYmIf8QM7v+xDBZBRxj8SPo9VevKcyHwm+NLzJeATY6XLQ8 3+p0B9aiXn0MrAHFAniOIead1A55Vbb2pU/04hqbtOdg3WYiIDdOY9C6UOri1LpUS+ +Eq5RPK3ubkc5BRzcJ2BRS3j2OZ5oqbHnGlhdV+A= Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I1Dq6004634 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:13 -0600 Received: from DLEE110.ent.ti.com (157.170.170.21) 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; Thu, 1 Feb 2024 12:01:12 -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; Thu, 1 Feb 2024 12:01:12 -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 411I12Gt117221; Thu, 1 Feb 2024 12:01: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 15/18] power: reset: gemini-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Thu, 1 Feb 2024 12:00:59 -0600 Message-ID: <20240201180102.70395-16-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: 1789720725514316461 X-GMAIL-MSGID: 1789720725514316461 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 Thu Feb 1 18:01:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195430 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp347466dyb; Thu, 1 Feb 2024 10:13:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBd+dWYdj4lCff8Gd6+QbxPPxdipbVyVyq49qm2HLaIN4kZFmBozszrMQP82VS7NDKdQhe X-Received: by 2002:a17:90a:77cc:b0:296:2b4:df8c with SMTP id e12-20020a17090a77cc00b0029602b4df8cmr3862855pjs.18.1706811186180; Thu, 01 Feb 2024 10:13:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706811186; cv=pass; d=google.com; s=arc-20160816; b=kRklzopTucwNwYBAFtA4LDCU0Dh4w+ZbMdq8a2IuHgDRTPAxOXDAoAw4Lw8Quz6P+s 0HiyGRbHhgpk93CUu/G95roYsv5gB+qnJV1arQB3pB9RTR1H0WaZqauREFmR/k5CZAzJ 2f5JinSNQye1Kj+MB456+MPuLa0ZbsmJcD+Rc1aRmzQe8jIMUeS13fzHUgHzpZnhrF7m EGM/GJC/IjctpQr1a4N2VEJX+gUBQU+hCI0mTLGvGFb0QJs1RyikUVNC4mI9hl6Jpqi2 nDTRppj+JGAqR4PGtBqkaLDeSm8adeWiw+PEVqyF/UW9o/GKKnOG1oerQw+pX9HBNQ5m B1cg== 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=yQ/dg+0QKYK0K9/6HaWu2MQauSwCO5Vz027uF3WhZ5U=; b=Nranyxton19caRhJDB7S9WWpOrjKA0Zo815xznIj0J3OoN1ng5mXsY2FpcSWkwypFG ta5QwGx8tItx2/jnmphuf3JJ3AgeSEf9pGnINpviEX6VsKm/8pFtDQ9/BVaoAnlgd7tb qijbodHcxfRFBBTd0xePgPggFrXsxFx/MYLnkRzeAtH4h/UI3FYsmEvc0yoZOU1DBrq9 pVXPTD6wwNxXr+8okjogGkFpWqGigHmoJ9kXiOb4aErCm+rG4Hj2B9MdznKbcLsZM0Y1 BO2fQJTQGsU7zKpVAhwwsbvp2mbhHE2o8coWc6GKb12ubriVqhYUjKqbU9E16Y8znVfl aU0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="hm/vqbXr"; 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-48647-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48647-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCVllAzljWrs/jQvdBw7FsqT3NUwDJtn17349mAWGA5sR6+NqNcbJ+sDyl2BavpuR/sxme0AhjApi6rfn+yW8SYGsV1sqA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x12-20020a17090a9dcc00b002960ba41030si182769pjv.128.2024.02.01.10.13.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:13:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48647-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="hm/vqbXr"; 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-48647-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48647-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 ADDC0295AEE for ; Thu, 1 Feb 2024 18:06:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93DCA84FC3; Thu, 1 Feb 2024 18:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="hm/vqbXr" 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 F3AB485281; Thu, 1 Feb 2024 18:01:36 +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=1706810498; cv=none; b=F8fkZWklH+tiPgS4NVjtyEoIglHoj+7VwEB3YX2aQ66JFsmfPluiJr7oxTzEmA36K1jPmO1Jen4MdPsinMKLOW2jWQ/5nL3gFiv3xUP2XGqxONKfhpoKu7ZuRddYVnP8yRALu+hbvbAVQFMCAnOyP4Y3YFyHT8xSdJbtlDN+uXQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810498; 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=t3IpnsTssZZI6eyXcFX9EX2eLuHeYZ6GWMvRHez632ydkHIv7d12EQg/8zPMBZb6/HlvwtOpEKsGRT0bnXf89bqEv9mJVDnH5+nVb6o4o1yJSfruYGie7IlV7uDUsKFHDa06qsHNPw5HNduDVIsGYVVmYmJ+u3nalt0fVbcuR9c= 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=hm/vqbXr; 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 411I1DCY127798; Thu, 1 Feb 2024 12:01:13 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810473; bh=2C083AYY3Dbpmc6BgF2r63gVH+xSPvAPWXFMl2z3vuQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=hm/vqbXrgkdvEpEseIm/bM006N8riAizOx5/j5+hdGUZD2Nwf8XevghZVYgJcCZYX moNtW0wPVgM0bo/dIgq99Lg+ZyUwU4PnhEgq8uFb8ItIAU3nD91AialkzNiRSAX7Q6 QRo6p/JDDnQOeM0s9Psit199C7qg0fU7vbq7GRS8= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I1D6k029277 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:13 -0600 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE112.ent.ti.com (10.64.6.33) 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:13 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE112.ent.ti.com (10.64.6.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; Thu, 1 Feb 2024 12:01:13 -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 411I12Gu117221; Thu, 1 Feb 2024 12:01: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 16/18] power: reset: restart-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Thu, 1 Feb 2024 12:01:00 -0600 Message-ID: <20240201180102.70395-17-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: 1789721246117447177 X-GMAIL-MSGID: 1789721246117447177 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 Thu Feb 1 18:01:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195418 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp340103dyb; Thu, 1 Feb 2024 10:04:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHoRC2VGGUe6GymHBKUgerBm0cncOXZ2aJR823xbCFYI2UEEWSw6HipnLeD0nUh3Pn5A3iT X-Received: by 2002:a05:622a:1111:b0:42b:f6c1:dc1b with SMTP id e17-20020a05622a111100b0042bf6c1dc1bmr2560703qty.31.1706810682927; Thu, 01 Feb 2024 10:04:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810682; cv=pass; d=google.com; s=arc-20160816; b=zcEX5zd1qaFoVxBCvV1HaZw4AusqkurMaz8xWoNphAl6heuj19ZDjNrPZMrn+3Okm4 Ps6ukspGt76zpbl8fGrX26UA/yqKuKB0csVRNBzs0Lt4/SM04AIj9JyN9ZVDHFMlYSV5 oR1z6coF6CgT2kjrUz76/aUQl/58DR7SMzzb3gx/4pjkCuNGAUIK7FmGOxmaUGdbtaPZ WjYsi32iPj0M3m57yJOZu/ph9ttbQuC6A94Q4DxZi9lTmO0vrWAuFqOWxwaySk0CEHLq bWu9k2Ayui7MExdzZeUXvFIx3ESj5fUK92W3GWhOsaqMu+/z2kFPcSqLsDP3CMbsX4dY wlcA== 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=3InAWL9eE2MFm/9NMXYDbrcE4pg5t/9WcNQuTzHLiRE=; b=rHKp/0JM4OrZvenQsDj2WqavjX4EHsnm6m19SOQwpUkM9QAB8H38HDp/YjXO3E9DUA BdSFuNLBCwSy2bxQPSrGSJV28Dh/rIr5VgEgq5TGcubmkt80VzkaLOzjM3FWuYprYv9Y D/KCUHG4dDddkeVYL4n9EoFvTlIpIRnoBY4qtC5FvVl5NmNwgp7oAw7ugjcSguwGaMO1 JCxsrBq+vyO6GnehYp/N8ltPzoqa1omTOjHanpikHvVBDBKLpDeYMPSczQtkAaKTfnyo kc2X6IJpTN7oew1GQfeNLqU09EenOnDk+KXgqS4iPhYJRxT0dQG6229m2UShQhRNSggM FoCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=alGgElcI; 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-48639-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48639-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCULPCRqTASX0Rvvn/xe9EYCDlo2U1pMyjNHgy2FOPQJiANF1GGF7sYvEkL3BLByJxzVrt1tG9CIdggNabzNnJv7KV08nQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t15-20020a05622a01cf00b0042a9d4326e6si10481416qtw.357.2024.02.01.10.04.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:04:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48639-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=alGgElcI; 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-48639-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48639-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 496F01C290AA for ; Thu, 1 Feb 2024 18:04:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F6D812883B; Thu, 1 Feb 2024 18:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="alGgElcI" 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 C0510127B60; Thu, 1 Feb 2024 18:01:31 +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=1706810493; cv=none; b=W2c44K41sy2yfwvHeAW3n1MbRc1j6pSe1QLmOPMyoM0qhDyX7ChGqHiWiJMWBtoRz7tWJZrepTIYBWXxuoGr9s9j9cohKhOuvI4Nvo0gLHfOAt/Jxz73Z6XmZjvlLoRgnTJBuWyeIWxAOCve7XTrxwUwMz83+MLOIHz1DzhJq34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810493; 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=RzmaMZNDD74xEra4MuI9AOZDNozSKzIWfnV4qsXJqMlzRN3fNidp5nNkcSXkTzwftzUlItPprw6WA4KGxETYy2J5ekekywX4Hrj+w3yPAVn25eSFEyCdX3+ou4g128JPHnKdiMxcPLhPUN70mbiYOUgZhW/vEhA1l+x+WYHiSvk= 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=alGgElcI; 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 411I1EiX049636; Thu, 1 Feb 2024 12:01:14 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810474; bh=rjOs3HQelK8dD7ON+CKELNocYhGYtTpRb3RjtcpZp+M=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=alGgElcIFoxueD1e1sbl7KER0iExHsEMJHWdamR5M0QH+QPfnKGNyvhDBrQOFecGG q4tGqqYwHJuILBQ2p7m+Nb9aQ6idMYzD3XqDbK5fLuP7sESOqM50+c4uM4ZhuVTuqL XlckU/hX0u7tdX0M2Hm96ueyrhr8Qd7PoM5Djv08= Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I1Eko004643 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:14 -0600 Received: from DLEE105.ent.ti.com (157.170.170.35) 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; Thu, 1 Feb 2024 12:01:14 -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; Thu, 1 Feb 2024 12:01:13 -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 411I12Gv117221; Thu, 1 Feb 2024 12:01:13 -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 17/18] power: reset: syscon-poweroff: Move device data into a struct Date: Thu, 1 Feb 2024 12:01:01 -0600 Message-ID: <20240201180102.70395-18-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: 1789720718811659698 X-GMAIL-MSGID: 1789720718811659698 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 --- 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 Thu Feb 1 18:01:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 195424 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp342423dyb; Thu, 1 Feb 2024 10:07:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5pzua8iHyDRBYvWxl1x6awa4NczLeAjxNPfd8HEbDxMxRhEJYVF2u0GoTXuprzJ/+oqHp X-Received: by 2002:aa7:da47:0:b0:55f:c83b:15a6 with SMTP id w7-20020aa7da47000000b0055fc83b15a6mr1503785eds.26.1706810841799; Thu, 01 Feb 2024 10:07:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810841; cv=pass; d=google.com; s=arc-20160816; b=OIgw8cekZ7HnF/y3s0Mpa8AH5GFvqUHUl7j08H4o6NV/EkRQzT1E8Yj24N1/kMzWfD 9GpGN1j9+5D8cpQ2+ZYLpGoGUxqxmr2k2NKlTflk04107K2tmQVn+l3Dr2rR3ekJsaKK nkB81YRW0VmxmlQGsnIKs1K9MUJilyKcg2W/jpALo9jdYZA0GQvDdos5MkHzYTjzmKro JyYuKuh6Ie3Guyi5VMeRnOcyoSN41ala3i7qJjMKszTV7S2/qkq5T5WHIY/x6lXAqWxZ d+7ntkyFDGFjtIrH006gKvcNOFVnv40xNyK16SbKx2EunQaJt7q5s6zLIhs2onnFo52u klJA== 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=LpOQwtiCnX6zpzk/+UyN5TGZarg5A7tH7qd15mIeD48=; b=f4u6P0nK6clRW0s8o3T+5ak6jumTmFSb+lUzGuk5kZR3dH+/EevrAoiH2Hj+ZWoXt8 fZ9ZVRwSWFk+tJa6m0kJlneD9sokVtYqNWDY/lfYChLzvcFIuNZDo055N/8UEE1gVhww I1KB82DcfFbLRS3los1f3ZPTXCg03XLMSn2CdlCOqrqTanm2pSL9JnuFYM/2vbsBtHMK klu3EvZ+xi8oPl89BRyUcNKaqY93vMzt/3xxpqptfbD7zgWs0AjSEl+bMob66Asqd3qo t9OleMsmDgE8ewagvIdRgeKRwTrMd6h4fvvxSDd9X1WBcYvWgRk+3rAtW8Kf1biRPYjd LTSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=rm1XIA5e; 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-48651-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48651-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCWcJ3ZBKOgRUfiHd6HjHU3/LQq+eo+DLpRl2wFVKqCOXXYXfGTUtkKL45Ehvqn0X7hyWG08IO0TKJ/H2MSq9CarakF7eg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f13-20020a05640214cd00b0055fda78fdb7si32041edx.543.2024.02.01.10.07.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:07:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48651-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=rm1XIA5e; 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-48651-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48651-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 657A01F23E7C for ; Thu, 1 Feb 2024 18:07:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D51412FB19; Thu, 1 Feb 2024 18:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="rm1XIA5e" 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 C77A112B159; Thu, 1 Feb 2024 18:01:44 +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=1706810506; cv=none; b=SULwPvAo6ZC8A8cqrHKhYGBtg+xYIv7hkVS20UJZPoNpDW3vVta1FsSmHIBimuTuuC79+ScjxBePVSMhLeNn0qWwjNQezqpJZ0O9VifItLAgEMP+5eoIwSL3WI24xTad1RxlMyERaM/o/9YYd6h+d9LlQoRHetSDOqdhrzJGHGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810506; c=relaxed/simple; bh=XmOFZVJS2nbpGNUIJRoCh2m3rWFsAgRF8B1pZ3UaoOo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=d97bJCTXFG+IlJQrCIlUDP/StuyibuGTxC80bzGgGPecbCx3rl3OXhXWwoOGXWA1nx2xc6ye5JCfNmYrx+qsuNKxkwqELRwQoyGzuPbLuYOn1+K/efyg52sfhUbGier6kdi8AMapubAfCnOYhY/AF0lYTO0TPB4A7JPTPkB60I4= 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=rm1XIA5e; 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 411I1ELM051733; Thu, 1 Feb 2024 12:01:14 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706810474; bh=NIThW8dvWRvWMprZfYkUcAv9QvAIjazC0Wh9+WTdW/k=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=rm1XIA5e4Rd+MaKMZD53SqGG1cTPvCemTrgkowPC2TgVVIYHMHHtJS0ad9yi9KOeb +tfC+54rcrgXtKzhqOZN0rv/Uf5rfNYE5TuSras9Ff6Qljz95lgsORpI4ZRRY61NYW 4ov56vN26Wgga0dm5uhiXV/+HhxaKBnHfDrHFGHQ= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 411I1Ec2004657 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Feb 2024 12:01:14 -0600 Received: from DFLE107.ent.ti.com (10.64.6.28) 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; Thu, 1 Feb 2024 12:01:14 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE107.ent.ti.com (10.64.6.28) 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:14 -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 411I12Gw117221; Thu, 1 Feb 2024 12:01:13 -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 18/18] power: reset: syscon-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Thu, 1 Feb 2024 12:01:02 -0600 Message-ID: <20240201180102.70395-19-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: 1789720885062615954 X-GMAIL-MSGID: 1789720885062615954 Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis --- 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,