From nobody Mon Feb 9 06:34:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1635370097; cv=none; d=zohomail.com; s=zohoarc; b=g4vc2LgPowE7a9Mf3kjc8P33u8GrUuIBSl7ARgUNC06vqnE/cUWkr49/q/KRvnXMf+Hj/8qpkqxyUhaoPqQZNFtuXolsC7+qq4gT9vSD+C9wvB+DraLoOJLCn/aYVPsEHUdRygd6hN+53VNIdiKSfrZi6Hh5vtat5BAQFtmtZSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635370097; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RsN03A/v4Sm7hW8tBAQNfAIwim2Ix+phU87uldQTcUU=; b=YqTlUmQnfJXA0ykn7CSM8ZDNwo8suH7W/7OoNtZE1RaD3FE2vTFZ1uWqb+vMvKDD5D2CqdEFQoALEAPFn+DtBpeUqcb8iLBT5NZw1Ylc2xr4TG0OeZzLU1ABBJ3QxZAbv6KBBAjbYoDFyYbMdeELm4XCaBdUVV9BWf/8l8qrm6w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1635370097148822.2730059855851; Wed, 27 Oct 2021 14:28:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.217283.377297 (Exim 4.92) (envelope-from ) id 1mfqSg-0001L2-4V; Wed, 27 Oct 2021 21:27:54 +0000 Received: by outflank-mailman (output) from mailman id 217283.377297; Wed, 27 Oct 2021 21:27:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSf-0001G3-Os; Wed, 27 Oct 2021 21:27:53 +0000 Received: by outflank-mailman (input) for mailman id 217283; Wed, 27 Oct 2021 21:27:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqLC-0000sJ-Bf for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:20:10 +0000 Received: from mail-lj1-x229.google.com (unknown [2a00:1450:4864:20::229]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e3b334e6-cd33-456a-ab3a-269c6b97cb7a; Wed, 27 Oct 2021 21:18:38 +0000 (UTC) Received: by mail-lj1-x229.google.com with SMTP id d23so5638600ljj.10 for ; Wed, 27 Oct 2021 14:18:38 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:37 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e3b334e6-cd33-456a-ab3a-269c6b97cb7a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RsN03A/v4Sm7hW8tBAQNfAIwim2Ix+phU87uldQTcUU=; b=aSBcb4MObsGcKwVtxhkQi6r6MrllJ5Wvhx4AXr7+3ZZIOmNeNayjB4H7wS3yJIQaI0 vfLkw8dEY0bAB5FpyHupYLxHHW8temP9OImGFFR4LDmE7/mvPRk5uTYf1q52vThLv1Ot CBrv1hpmeU5p/gGow8523dqz9J8N1faFeN/IXFxxWyp7mhT8fq2Z7acBEZ06y9nx6CF2 oI6Bf+jKcKCu1O6+i0B6l4EesA9cDqHIJQrezIg8dnd+TlutJ/VurnoBCjdUW8FVuBfF rgIrNrWNCUTYVjuoeGUx+HMg9DODFrvmZsdKkZzK15Dx1U5yq0D3h61n1EAZrJfufwr8 qWRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RsN03A/v4Sm7hW8tBAQNfAIwim2Ix+phU87uldQTcUU=; b=OHfHyq85RsRt/yzp0dtbFhmdlQQbtE9RDQFutPsx65jgZ3GCcOnJLc9G/gfVhNzWGD OoKDcdqKybndotrveSIVAMk6C+dJqNKtIPiTX5s3YOvHsyaYuLFIkic6c4re2CeNWPE1 kekf3suRqBASTL+apcpeV32KNtPDi87fHSr2Dmb7ohS0gAe/+SznOjfuXDU/eBIZmCPC sJZvIzTLPFU42/BPqAhHOQ9Lz0IeHz0kZVVgdCHTETalKIaFs5+ZZoRu0PBFZCU2Gtj+ Q3Fori8AmaIAcY2PtRWt9p0cFzsc1KDKDWiP+piIz5imLoK9Tbywr3SHIZ2+4w3DLuXS u7Bw== X-Gm-Message-State: AOAM533haRxmYCqMCQCg0OtJokdBKv2hU4J3jVErmuPcxivSt/74OUQl gPwtdGX50V65VjQocRonLs4= X-Google-Smtp-Source: ABdhPJwvRw65HVRl6UYG4kSDngjOw+VDWoznyGC0SQFAdeVNXxGihIuJGUkpMtbqNUFYMuUZsUPclw== X-Received: by 2002:a2e:3e08:: with SMTP id l8mr351596lja.194.1635369517590; Wed, 27 Oct 2021 14:18:37 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 24/45] regulator: pfuze100: Use devm_register_power_handler() Date: Thu, 28 Oct 2021 00:16:54 +0300 Message-Id: <20211027211715.12671-25-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1635370098666100007 Content-Type: text/plain; charset="utf-8" Use devm_register_power_handler() that replaces global pm_power_off_prepare variable and allows to register multiple power-off handlers. Signed-off-by: Dmitry Osipenko Acked-by: Mark Brown --- drivers/regulator/pfuze100-regulator.c | 39 ++++++++++---------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfu= ze100-regulator.c index d60d7d1b7fa2..73d5baf9d3ea 100644 --- a/drivers/regulator/pfuze100-regulator.c +++ b/drivers/regulator/pfuze100-regulator.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -76,6 +77,7 @@ struct pfuze_chip { struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR]; struct regulator_dev *regulators[PFUZE100_MAX_REGULATOR]; struct pfuze_regulator *pfuze_regulators; + struct power_handler power_handler; }; =20 static const int pfuze100_swbst[] =3D { @@ -569,10 +571,10 @@ static inline struct device_node *match_of_node(int i= ndex) return pfuze_matches[index].of_node; } =20 -static struct pfuze_chip *syspm_pfuze_chip; - -static void pfuze_power_off_prepare(void) +static void pfuze_power_off_prepare(struct power_off_prep_data *data) { + struct pfuze_chip *syspm_pfuze_chip =3D data->cb_data; + dev_info(syspm_pfuze_chip->dev, "Configure standby mode for power off"); =20 /* Switch from default mode: APS/APS to APS/Off */ @@ -611,24 +613,24 @@ static void pfuze_power_off_prepare(void) =20 static int pfuze_power_off_prepare_init(struct pfuze_chip *pfuze_chip) { + int err; + if (pfuze_chip->chip_id !=3D PFUZE100) { dev_warn(pfuze_chip->dev, "Requested pm_power_off_prepare handler for no= t supported chip\n"); return -ENODEV; } =20 - if (pm_power_off_prepare) { - dev_warn(pfuze_chip->dev, "pm_power_off_prepare is already registered.\n= "); - return -EBUSY; - } + pfuze_chip->power_handler.power_off_prepare_cb =3D pfuze_power_off_prepar= e; + pfuze_chip->power_handler.cb_data =3D pfuze_chip; =20 - if (syspm_pfuze_chip) { - dev_warn(pfuze_chip->dev, "syspm_pfuze_chip is already set.\n"); - return -EBUSY; + err =3D devm_register_power_handler(pfuze_chip->dev, + &pfuze_chip->power_handler); + if (err) { + dev_err(pfuze_chip->dev, + "failed to register power handler: %d\n", err); + return err; } =20 - syspm_pfuze_chip =3D pfuze_chip; - pm_power_off_prepare =3D pfuze_power_off_prepare; - return 0; } =20 @@ -837,23 +839,12 @@ static int pfuze100_regulator_probe(struct i2c_client= *client, return 0; } =20 -static int pfuze100_regulator_remove(struct i2c_client *client) -{ - if (syspm_pfuze_chip) { - syspm_pfuze_chip =3D NULL; - pm_power_off_prepare =3D NULL; - } - - return 0; -} - static struct i2c_driver pfuze_driver =3D { .driver =3D { .name =3D "pfuze100-regulator", .of_match_table =3D pfuze_dt_ids, }, .probe =3D pfuze100_regulator_probe, - .remove =3D pfuze100_regulator_remove, }; module_i2c_driver(pfuze_driver); =20 --=20 2.33.1