From nobody Thu Nov 14 16:25:25 2024 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="rm1XIA5e" 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 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Content-Type: text/plain; charset="utf-8" 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/sy= scon-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 =20 struct syscon_poweroff_data { @@ -22,23 +23,30 @@ struct syscon_poweroff_data { u32 mask; }; =20 -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 =3D off_data->cb_data; + /* Issue the poweroff */ regmap_update_bits(data->map, data->offset, data->mask, data->value); =20 mdelay(1000); =20 pr_emerg("Unable to poweroff system\n"); + + return NOTIFY_DONE; } =20 static int syscon_poweroff_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; + struct syscon_poweroff_data *data; int mask_err, value_err; =20 + data =3D devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + data->map =3D syscon_regmap_lookup_by_phandle(dev->of_node, "regmap"); if (IS_ERR(data->map)) { data->map =3D syscon_node_to_regmap(dev->parent->of_node); @@ -69,21 +77,10 @@ static int syscon_poweroff_probe(struct platform_device= *pdev) data->mask =3D 0xFFFFFFFF; } =20 - if (pm_power_off) { - dev_err(dev, "pm_power_off already claimed for %ps", - pm_power_off); - return -EBUSY; - } - - pm_power_off =3D syscon_poweroff; - - return 0; -} - -static void syscon_poweroff_remove(struct platform_device *pdev) -{ - if (pm_power_off =3D=3D syscon_poweroff) - pm_power_off =3D NULL; + return devm_register_sys_off_handler(&pdev->dev, + SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_DEFAULT, + syscon_poweroff, data); } =20 static const struct of_device_id syscon_poweroff_of_match[] =3D { @@ -93,7 +90,6 @@ static const struct of_device_id syscon_poweroff_of_match= [] =3D { =20 static struct platform_driver syscon_poweroff_driver =3D { .probe =3D syscon_poweroff_probe, - .remove_new =3D syscon_poweroff_remove, .driver =3D { .name =3D "syscon-poweroff", .of_match_table =3D syscon_poweroff_of_match, --=20 2.39.2