From patchwork Thu Feb 8 17:04:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 198502 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp315478dyd; Thu, 8 Feb 2024 09:09:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX5bmiGZbGRuvnDe4Y8AAduZQuD1Tn81aU9Vfv9ZOxsPB8FelUf8KJ+xhragPDZS4FqVLzm9hfTjFuRP9E0GS0NnTn1Og== X-Google-Smtp-Source: AGHT+IHFMllHu20Q9zX6w5f6DJqjZ+nHkwrg3CRA8A1KJpbNIBBIPUpm2m0cyJ6zwmB3n7r4oWJd X-Received: by 2002:a05:620a:28c4:b0:785:536a:c4e1 with SMTP id l4-20020a05620a28c400b00785536ac4e1mr127631qkp.57.1707412160054; Thu, 08 Feb 2024 09:09:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707412160; cv=pass; d=google.com; s=arc-20160816; b=VvuV5nNNdw0EB1pZSJk3zd8h7pBNKfuoiI5SfC+B/TFs+1Sx/rEGBe/pVusDMjigYH vfaj1GdrrBznvn4PYoOz+ZhmdbkZ0UWYGM1Y8RGY/danP/QdKyZvoEmm0hU/EHExgQGA R4dLc+G8p5yrKbhYV5Vmn63uotV2eFXOnekfbBp5qPKigBCri2/KKur31+oJZtYqp9vg 3nJ7GoR8cSdfzShskn5mzdXQK/bZjlONobOxLOHonDbXmaUT5Ez2IbwFuafJoFV0JQ4V n3e8hmmtvUaT6PlhzazySMrriPDvwVVd3CTfMRXybqof7CtNZzJ7++TJa43TnuynM/8v psNg== 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=02OFTyFPSetJhqM531rwM+FnWOr4DKLsjxwo2mjiGEc=; b=pk8bCrLtYDnUar0sEPu4XVCTFhsjUJm/ZbI18mYTXO9Vb+H8wAsZ280wge3EiehFZw CGBIIuvZL/r6ZObqgids0a3Ji94BuMZppF5+/h9ndke4xBgOFckyeTG8DiQWLTP0q205 I0lI1LjP0Loth9P8RCqVkQSwtmu1eoCNXssAlv3WyalIwIt+LW1O5GkAUbEhKkdiQrjR i06xB2d93e+wUm1L27tVzQvtGKcp6zSmi+sG2Ub+NET1PdmSSjYcQx2Wg+Ym3MDYQJB3 ngElAJC+oqqYoEJMsl2kCiER/BKFxr4EIhgvPDOjhufHJ8R8q1iMPx1h2zDOxEEwqa2g 9iKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=FFWITdHo; 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-58413-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58413-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=2; AJvYcCVSI0E7QfMVco68BcFrbiGwAXK/kzSdz01NUjJfYc6MYAXa1HjXbYEbeibIp3jWzemMx9doluGu+ID3JgmzIimJ9dWwsg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v7-20020a05620a440700b0078596900928si447234qkp.628.2024.02.08.09.09.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 09:09:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58413-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=FFWITdHo; 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-58413-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58413-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 D0FAE1C21130 for ; Thu, 8 Feb 2024 17:09:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8A3F132C09; Thu, 8 Feb 2024 17:04:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="FFWITdHo" 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 B609382D84; Thu, 8 Feb 2024 17:04:37 +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=1707411879; cv=none; b=g7EkK//uuJZ8rRH1YnM1hR4MXDhBjQV6ZRYjxIbK+rnK02/sWibDhVYeEh4jgTWvnzgnekgAQmk63ZDd52Pvnb7VilRm74J/ubys7wzmIw601iQeYRzxuDyxYPTaFIttG5yl9VmBp7mqkpAZYHU00JiJhfH9+fsqCYB59QcO/fY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707411879; c=relaxed/simple; bh=HDoP9l78EFZDdW16hNeR9IATxUCA5uyr6j+jeh40ipg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dkt25HuXHVIXcWAVWKm2e/gSyp3LPgIvdEab2LH37B1NR6GR4WnOkIAC+2ib7CSYKUocRsVjLKR+dIIuS7W4wW0B8Pmr8gXHMgdtSH36H11GCum0Gzb84sem75CThTWYnr7A+2p/tM6aBw9fDT1p+FsQN3i5v8V8L6V3qBL9c0o= 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=FFWITdHo; 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 418H4N30018180; Thu, 8 Feb 2024 11:04:23 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707411863; bh=WzOWw71XNiTDn9UhRVmQ1YL+kbl79QddxFr5AngwFzk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=FFWITdHo0BdV2CFmQNlXBS6gqu3VbRAgn1fajWZ9PxxNEPibvR/OJxfM2S6k68PVs VVJZJnmF/uQ3T1GY251ts/5vNSx1oafnOj7q1cHgU40Ugzy4qd2FiW3DC/fCQD9J56 nrJaxDkkurkZW37mYcyy2dhOEHItXcIWsR7eDY/M= 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 418H4NgW042486 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 8 Feb 2024 11:04:23 -0600 Received: from DLEE115.ent.ti.com (157.170.170.26) 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, 8 Feb 2024 11:04:23 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) 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, 8 Feb 2024 11:04:22 -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 418H4B6I091006; Thu, 8 Feb 2024 11:04:22 -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 16/19] power: reset: gemini-poweroff: Use devm_register_sys_off_handler(POWER_OFF) Date: Thu, 8 Feb 2024 11:04:07 -0600 Message-ID: <20240208170410.67975-17-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 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790351413437716043 X-GMAIL-MSGID: 1790351413437716043 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");