Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2555938rdb; Mon, 12 Feb 2024 08:29:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSUzXlB8d9TAHxQQ5qdpKM9KNDAa04Nhq9vT+BePqvOF3Jwk7VTv8zIdKySFYyE5LZFvi3 X-Received: by 2002:a17:907:1189:b0:a3c:3af6:722f with SMTP id uz9-20020a170907118900b00a3c3af6722fmr4597181ejb.21.1707755390700; Mon, 12 Feb 2024 08:29:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707755390; cv=pass; d=google.com; s=arc-20160816; b=QUBpV0yRyLtY7enjHf0AeWekMau4WN80gSdV/ykUsxAYq8kiWEpNzgdbiBqSUhmZPc l9/aBnq1R7t3ZN5m3E5D1b0MiY10YW1HMEz1yFdyUw1HTqwNGnuRun/RHd4Fc96u/xEQ Z5fHwpRiGIX0ZOc+wtkUUWXLv3vHsAhWDTczKP4tS6qwtf/PlSB3XuPY1eWLZF1HiOPU R52BoeflxN+3fg5Q5/41E7e8+YoOwaWgUzZps1IgzOw3aYI3EdiWWa4s1Dy6nmb0BcUS t9e/2ESigPOkMveZvnE/8EoMLMecuVIJkBjiTP1125InHLI/V7t3R3PKLaxV4M7R2Zji 7H5Q== 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=gCvlG8uLd2KvFzgaDWbp2zyTarFgWzAbhSvBr1vlWrE=; b=uRaEYJFQwsMnTer/pIgi2o3ylaNdofNrQ220Cgf5fkEjPZtbBx8sv2kAO4urxRf/UZ 4Zu8ihSy+iLZJr5QdYGFnJE7wbgQsiQa2P7oR+A+PSxzH3mompIs4ADUxm6Sr23v5OJN /YQfgZaUMMIFNUVPXp3LfoitAxkjeINt07vBr2qQbu6M9W0j7StdVcioHdZFw69VHi/r 0jUoMkKFxXSyvZBD5/wQrpnz7FG4MnYD6F6hqlYk39sFdR0bxEOEnZZho7PIRMDL0Kie lyJQar3AtDMG6j4ENrFlSiyZAtvCZ6qN6vzPEVYKmoNgjWf9I9WjaI4cLF+QEPX4AZB3 6eMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=i4FPyRbs; 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-61960-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61960-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=2; AJvYcCXt6Ny0b/MfHm5o+6chxODYvfs7kKHIxPyQxZj/4vo/6ONt3R8AIsEafaTCMgft4j5gIbxh8oGoDyPzvSeGWQR8RzaH13bNS5LCa12xNQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id jt7-20020a170906dfc700b00a3672af1261si317175ejc.743.2024.02.12.08.29.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 08:29:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61960-linux.lists.archive=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=i4FPyRbs; 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-61960-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61960-linux.lists.archive=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 72C9B1F21DEB for ; Mon, 12 Feb 2024 16:29:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A03F33EA78; Mon, 12 Feb 2024 16:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="i4FPyRbs" 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 AE8103D39F; Mon, 12 Feb 2024 16:28:47 +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=1707755329; cv=none; b=o0sH0AIri3kjlbb6Q3K+LRvOPCD4A88xgui1PABC902dOubOUxWNrDUShLAexZVn0yB1bEG9ijrAbHsDs0AXmllh9a15oOqDmI3W9ZF1JSYlDrIked/k5UtviUq+K4zGbKiBzFspEH/OojPXHCz8AnQM0L7QR4ow5SB56gKQVzw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707755329; 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=mGvJNFybfeuM3I6tYg0mnz+O7ASMIvQ9lQd4vcm3jHhf/4N75wHQimAVLf3wCh4XbNdh6qcjcRNwBdwfW9HN3pouUn4nj9IcARJF8beX0eih10QSrWQdKvmVG6+0difEQzamTY+al0oxLBEjwFJAEGqGNCw6SWmuajNdtfcdxJQ= 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=i4FPyRbs; 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 41CGSahR004148; Mon, 12 Feb 2024 10:28:36 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707755316; bh=WrDlA3MVIblMNMt/x1ENZcDUaj6UX9hq3LACckiD2VI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=i4FPyRbsyjmPOO8wC3nNU+9otcmKAlUJpjCdCZtEo9ZkAi7c6ZdvNnuDpyFcY3ttW RbU/qIIRFgQB+rnnXLnPbIw4x2hsp8q4JrfYLQgEGWfjYBeCXSE6vfzE/N99UQTY3I 3YnRcEPwpr7W75QIWiPZl23BiMP0tWuDfReiaJTQ= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41CGSaYa024858 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 12 Feb 2024 10:28:36 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 12 Feb 2024 10:28:36 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) 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; Mon, 12 Feb 2024 10:28:36 -0600 Received: from lelvsmtp5.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41CGSWR1090688; Mon, 12 Feb 2024 10:28:35 -0600 From: Andrew Davis To: Sebastian Reichel , Manivannan Sadhasivam , Cristian Ciocaltea , Florian Fainelli , Ray Jui , Scott Branden , Bjorn Andersson , Konrad Dybcio , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno CC: , , , , , , Andrew Davis Subject: [PATCH v4 05/19] power: reset: tps65086-restart: Use devm_register_sys_off_handler(RESTART) Date: Mon, 12 Feb 2024 10:28:17 -0600 Message-ID: <20240212162831.67838-6-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212162831.67838-1-afd@ti.com> References: <20240212162831.67838-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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); -- 2.39.2