All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Samuel Holland <samuel@sholland.org>
Cc: Chen-Yu Tsai <wens@csie.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mfd: axp20x: Switch to the sys-off handler API
Date: Mon, 9 Jan 2023 17:11:52 +0000	[thread overview]
Message-ID: <Y7xK2AkHlr7hIzwC@google.com> (raw)
In-Reply-To: <20221228162752.14204-1-samuel@sholland.org>

On Wed, 28 Dec 2022, Samuel Holland wrote:

> This removes a layer of indirection through pm_power_off() and allows
> the PMIC handler to be used as a fallback when firmware power off fails.
> This happens on boards like the Clockwork DevTerm R-01 where OpenSBI
> does not know how to use the PMIC to power off the board.
> 
> Move the check for AXP288 to avoid registering a dummy handler.
> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
> Note: this patch depends on updating the PSCI driver first[1] to keep
> the existing callback priority.
> 
> [1]: https://lore.kernel.org/lkml/20221105214841.7828-1-samuel@sholland.org/
> 
>  drivers/mfd/axp20x.c | 26 +++++++++++---------------
>  1 file changed, 11 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index 47fd700f284f..58f82f1f4b43 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -23,7 +23,7 @@
>  #include <linux/mfd/core.h>
>  #include <linux/module.h>
>  #include <linux/of_device.h>
> -#include <linux/pm_runtime.h>
> +#include <linux/reboot.h>
>  #include <linux/regmap.h>
>  #include <linux/regulator/consumer.h>
>  
> @@ -825,17 +825,17 @@ static const struct mfd_cell axp813_cells[] = {
>  	},
>  };
>  
> -static struct axp20x_dev *axp20x_pm_power_off;
> -static void axp20x_power_off(void)
> +static int axp20x_power_off(struct sys_off_data *data)
>  {
> -	if (axp20x_pm_power_off->variant == AXP288_ID)
> -		return;
> +	struct axp20x_dev *axp20x = data->cb_data;
>  
> -	regmap_write(axp20x_pm_power_off->regmap, AXP20X_OFF_CTRL,
> +	regmap_write(axp20x->regmap, AXP20X_OFF_CTRL,
>  		     AXP20X_OFF);

Nit: Can you pop this on the line above now, thanks.

In fact, forget it, I'll do it.

>  	/* Give capacitors etc. time to drain to avoid kernel panic msg. */
>  	mdelay(500);
> +
> +	return NOTIFY_DONE;
>  }
>  
>  int axp20x_match_device(struct axp20x_dev *axp20x)
> @@ -1002,10 +1002,11 @@ int axp20x_device_probe(struct axp20x_dev *axp20x)
>  		return ret;
>  	}
>  
> -	if (!pm_power_off) {
> -		axp20x_pm_power_off = axp20x;
> -		pm_power_off = axp20x_power_off;
> -	}
> +	if (axp20x->variant != AXP288_ID)
> +		devm_register_sys_off_handler(axp20x->dev,
> +					      SYS_OFF_MODE_POWER_OFF,
> +					      SYS_OFF_PRIO_DEFAULT,
> +					      axp20x_power_off, axp20x);
>  
>  	dev_info(axp20x->dev, "AXP20X driver loaded\n");
>  
> @@ -1015,11 +1016,6 @@ EXPORT_SYMBOL(axp20x_device_probe);
>  
>  void axp20x_device_remove(struct axp20x_dev *axp20x)
>  {
> -	if (axp20x == axp20x_pm_power_off) {
> -		axp20x_pm_power_off = NULL;
> -		pm_power_off = NULL;
> -	}
> -
>  	mfd_remove_devices(axp20x->dev);
>  	regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc);
>  }

Applied, thanks

-- 
Lee Jones [李琼斯]

      reply	other threads:[~2023-01-09 17:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-28 16:27 [PATCH] mfd: axp20x: Switch to the sys-off handler API Samuel Holland
2023-01-09 17:11 ` Lee Jones [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y7xK2AkHlr7hIzwC@google.com \
    --to=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samuel@sholland.org \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.