From patchwork Mon Feb 12 16:28:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 199903 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp30371dyb; Mon, 12 Feb 2024 08:34:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX20uHXiG/4byBv/JHSyh4soqt2CDu9ODioWhTKLfVRyzeGKUn5Emi1yCXftVDAc/iiKGUG7zSufZL4lkCqdFoEB/EqNw== X-Google-Smtp-Source: AGHT+IG4x8K2E02JLZbl4JqnyeblgrlbfSMqFUNTPwOWdyvCwWOv2IAAGGPBWlujBh+kJWYRMQE/ X-Received: by 2002:a17:906:dfd1:b0:a3b:fd6e:c725 with SMTP id jt17-20020a170906dfd100b00a3bfd6ec725mr4285763ejc.52.1707755652799; Mon, 12 Feb 2024 08:34:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707755652; cv=pass; d=google.com; s=arc-20160816; b=0S+bXUuUxJSgPUXeeQAGEEsY7fUtaOjNWhq/Bfw6MQK+zzm02FNjerPO1oxxN8J0jI e4j7m2IcHgGr1NHViFffsDGpONFJwn3xAVj6GJiVlbFqCrNEjPeHCMkCms02A3nsy8VT Gy9qnaKS4hY/8OE32dHRxjzh8dk1IU9fRj31SH0G3t0emG9QnMnt8AntlvQvp/PGJoZN AU4ZSHQBK8Wdeq+fO3CpVJfcwPOi2A+J3NCJWXSFQoOZ1MjVYGHezssWhLXhT1hCHJvk s5+KnYR87jWW8ZzJhbzvRnW5YyAGl8z3lLZuSalISxwIM29qaC+rMyL5GkM157OpOA5H GRsg== 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=gfivSID3vqOpx1sziIZWULfRmsljT4OMplCG26mClDM=; b=waHeeHhp86hpDmuB/50HVzARZ/GF8m7cHA8mf7goGqgOfs+O7rw6bAjWvAI3MCX3fN k5YkvrLV3QQUSFOhmhpSJFACBWWY7Z9QDgi7OoGdsZROr4BxcoqYRzAPuO52Ijr9CQek nkYl5pNOvVUK1/otFDyP1h64AQkQa8NPqT/8Y7LGCAnL0hbHkJplKGpZoi6r3rcHyi+b dYgLgueuLatYK8fRCpQmtmGAAsoUpmixxi+9EFqKbjzBbQ3JnvIypeg38Qw4QdL9WGGj 6Q8MMwG1Ki6OH4T9lUXHkYQycrB1ZJii6bq8XSOyc5k8/iWnCWgt5ShRpBiaMX2TmFN8 KkCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ufBQhUhO; 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-61971-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61971-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=2; AJvYcCWSS3wgr6H0Uylj8TXXg4vzDnyRx5xdCi6XzUHRh+6Tb8R53M0sR7YIo3I82oHMRZInc6+u6Xy8y1J0tY42bruR1XrZCg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kb9-20020a1709070f8900b00a3cc7df3f96si324663ejc.827.2024.02.12.08.34.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 08:34:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61971-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=ufBQhUhO; 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-61971-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61971-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 6C4641F2227A for ; Mon, 12 Feb 2024 16:34:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33E574D5BF; Mon, 12 Feb 2024 16:28:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ufBQhUhO" 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 40BE74177B; Mon, 12 Feb 2024 16:28:53 +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=1707755336; cv=none; b=dcEmOH26+4UUZFLBo8LZQILZ9I7GIp7GpU1UiB0QIEB9bKBiF99X5qEu9xQvbZPYHngSks5PqBOCfwWGqjanyA3P0v8Ui5TobaJ6PsPOgpYWApEhyOSOa1DbS0whNh49SmnQ3L2RGLYnw0S8wKh3tEHyP8M+/Awf9N/w6MInaaw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707755336; c=relaxed/simple; bh=piMJuCp6Oyf7VRRgvElf9jQlTaTY6OoJDvy6PpEE/uE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O6DJYMT/pVbuQWomiM5TUL5Amfjeuj4YpQ434oqvgHubbrrpAD2AU+oBth8G0KVRa0M7I3zbTTiteBiYPahbx9mI1MhCeVHiyo6InZL5MhycwtbLcrufK6o+4yZWkSBjVq4hYOtjjxR6gDcPU8QsQ53UV56SkwBBX7mkICTN0uc= 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=ufBQhUhO; 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 fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41CGSgGE080193; Mon, 12 Feb 2024 10:28:42 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707755322; bh=psW+zR+255VuGRBEiZa3qV2ZSoJCA9HDeWGIZlh4BNU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ufBQhUhOyaz2OXgHddw1pyKot9JJBbujcj2DIYnCdqvz+9fZzLXva/cjBiwxQRQdu H1LT4uHDVyujlDr2v2W5Ol4d/Lge+5afSF3YrJKFkJU+c0T8/b7vAG8EmvHUDvciJI kxgqr71fi2ZXqzcpwSyasJ+0wHpAYojBYYjjhKO0= 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 41CGSg2x041990 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 12 Feb 2024 10:28:42 -0600 Received: from DFLE114.ent.ti.com (10.64.6.35) 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; Mon, 12 Feb 2024 10:28:42 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) 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; Mon, 12 Feb 2024 10:28:42 -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 41CGSWRB090688; Mon, 12 Feb 2024 10:28:41 -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 15/19] power: reset: as3722-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Mon, 12 Feb 2024 10:28:27 -0600 Message-ID: <20240212162831.67838-16-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212162831.67838-1-afd@ti.com> References: <20240212162831.67838-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790711591682929070 X-GMAIL-MSGID: 1790711591682929070 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);