Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp416399rdb; Thu, 8 Feb 2024 09:24:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEo7pDeZrMtDI3pjKolD2icyghgmJ+LJEKSxI1chqQVboqIYHktV5fduVgp1bLOTeA/2Pg X-Received: by 2002:a05:6a20:a41d:b0:19e:4abc:dcc3 with SMTP id z29-20020a056a20a41d00b0019e4abcdcc3mr193991pzk.32.1707413068986; Thu, 08 Feb 2024 09:24:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707413068; cv=pass; d=google.com; s=arc-20160816; b=R7O64GAONIe9PInEVFbe/c4WsmYH6k41Wj7y/n+dKQ58bLWPpoZk8yrK375UscK5cX 0sMkrGINIX9btHzV9VkiESeesBP96N7eIDg0KX4kKx1KkS581i/4q+fOmzYSj2hNTE2B QrVjAKOpDpHjBZ1dBYq35BBC/Ck0OyVaj7nBLG8KCN7dB6gY0caZL3+PbebvK0inul0n k6KuzWMM31CY9ZP7U5BvjmGS0ZGnd386/PVdBogwHR1cGBIe/Dzcy5kAZgJ1AMuBj1Z7 5VAO15UX41lYi/0XjZOveVI0K8ZIlaed00qcGDQbq+jFYuhu6tuGhcrnxEw5jJfOhz03 uEcw== 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=RTkUbtPyEm+6mvKtUXjBquaTd4Bthuxz3rsU8JfjWqs=; b=Bmvb6wwr93PO0e0gc3FKPZxHkVz1SSQibixu8L5eC8hg7k9yPj7SxT0IUSMcrc1Q+6 /fN9YWT/tHzRVqN+RZEOqp84jVyKnISFOPMSExvDWWSG3biOd5q/oheJTQhRGTyEQLVo aCx43WHDkMXQKVLZaLVO9SOIblr+zf5W/vj+uTraQaT08rRkiuT/jLNsbjcrwuxFg9Y1 EmEbpp20SHnt9YbfT9Ez+Lt4Ktaq0zf5QJphQlqGgmEX6S2lnGSLrc4+UnCHPAn3ASL4 7BQKLFFbJYaoEgJmTww8bvPSDutpNpSKNlY8TGAd/bRtGRGmpb6C6R9G8F6mR7P4nUtG y9vQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=zLcHt427; 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-58417-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58417-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; AJvYcCVLNit0TA7KY+RoDzhHI7KvAObtYLIikJVGGfX0va6jndvcvvXL+LLT4WtSvbhTswYd8i4lvtc9LBnMoGko0wQxrE6v7L1l3Wa1E2jsPQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g3-20020a170902740300b001d91e56ea5esi8154pll.242.2024.02.08.09.24.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 09:24:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58417-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=zLcHt427; 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-58417-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58417-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4D91AB2A14A for ; Thu, 8 Feb 2024 17:08:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DBD212C53C; Thu, 8 Feb 2024 17:04:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="zLcHt427" 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 D544186130; Thu, 8 Feb 2024 17:04:38 +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=1707411880; cv=none; b=WwNHADeW6fPQqfQtRzCCglUi/KM8LMRB9txdOM8BrED3ebYXanTJCwAzrXj9rgcFr5yDFvaCI0HTEy13ZG0JGgg4Io95dXQylBX3ATB2wSFvx5iL+1FggOkjzMrS8Sup2REJM/JS3hgn3OWmUpOrzdB+AVl0Zt5tH2Vo9bwxzWc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707411880; c=relaxed/simple; bh=piMJuCp6Oyf7VRRgvElf9jQlTaTY6OoJDvy6PpEE/uE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IYNEN6W9lSdXqR6YwluNiwisuiBibHRNCTUduepLTStxaTel+z7fg9nZjsUh1QYjSDc6RzlFCEHpAwd20byXjVl2w8nQ5/y2DOAa0FOszCRt0HOStXksu3AKUIVwwr4kFTwJ79F3wyEhwQjBf8SWF0DJOeJQXczQ/WOTrDDWlH8= 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=zLcHt427; 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 418H4MEK018175; Thu, 8 Feb 2024 11:04:22 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707411862; bh=psW+zR+255VuGRBEiZa3qV2ZSoJCA9HDeWGIZlh4BNU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=zLcHt427J2BUoe/KDA52pXGKTzQNoczPHE15XaQ3V0MAsbJ0KseVT860zD1lZA6CZ Z8NGIcJst3hMAjLj6g+8Dv+hSuxKM2opvEv9P4LvIxjBGSA16LnENMf0HODkmsTssK H5KCdguw6XpVj/W3T8XTkAqe6w90JB3J1IZRwQ8M= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 418H4M2b042472 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 8 Feb 2024 11:04:22 -0600 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 8 Feb 2024 11:04:22 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE104.ent.ti.com (10.64.6.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, 8 Feb 2024 11:04:21 -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 418H4B6H091006; Thu, 8 Feb 2024 11:04:21 -0600 From: Andrew Davis To: Sebastian Reichel , Manivannan Sadhasivam , Cristian Ciocaltea , Florian Fainelli , Ray Jui , Scott Branden , Bjorn Andersson , Konrad Dybcio , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno CC: , , , , , , Andrew Davis Subject: [PATCH v3 15/19] power: reset: as3722-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Thu, 8 Feb 2024 11:04:06 -0600 Message-ID: <20240208170410.67975-16-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240208170410.67975-1-afd@ti.com> References: <20240208170410.67975-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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/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); -- 2.39.2