lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 19 Oct 2021 16:31:29 +0100
From:   Lee Jones <lee.jones@...aro.org>
To:     Dmitry Osipenko <digetx@...il.com>
Cc:     Thierry Reding <thierry.reding@...il.com>,
        Jonathan Hunter <jonathanh@...dia.com>,
        "Rafael J . Wysocki" <rafael@...nel.org>,
        Mark Brown <broonie@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Guenter Roeck <linux@...ck-us.net>,
        Russell King <linux@...linux.org.uk>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Ulf Hansson <ulf.hansson@...aro.org>, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-tegra@...r.kernel.org
Subject: Re: [PATCH v1 4/6] mfd: max77620: Use power off call chain API

On Thu, 07 Oct 2021, Dmitry Osipenko wrote:

> Use new power off call chain API which allows multiple power off handlers
> to coexist. Nexus 7 Android tablet can be powered off using MAX77663 PMIC
> and using a special bootloader command. At first the bootloader option
> should be tried, it will have a higher priority than the PMIC.
> 
> Signed-off-by: Dmitry Osipenko <digetx@...il.com>
> ---
>  drivers/mfd/max77620.c       | 22 +++++++++++++++-------
>  include/linux/mfd/max77620.h |  2 ++
>  2 files changed, 17 insertions(+), 7 deletions(-)

I don't have a problem with the approach in general.

I guess it's up to the relevant maintainers to decide.

> diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c
> index fec2096474ad..ad40eed1f0c6 100644
> --- a/drivers/mfd/max77620.c
> +++ b/drivers/mfd/max77620.c
> @@ -31,11 +31,10 @@
>  #include <linux/init.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> +#include <linux/reboot.h>
>  #include <linux/regmap.h>
>  #include <linux/slab.h>
>  
> -static struct max77620_chip *max77620_scratch;
> -
>  static const struct resource gpio_resources[] = {
>  	DEFINE_RES_IRQ(MAX77620_IRQ_TOP_GPIO),
>  };
> @@ -483,13 +482,17 @@ static int max77620_read_es_version(struct max77620_chip *chip)
>  	return ret;
>  }
>  
> -static void max77620_pm_power_off(void)
> +static int max77620_pm_power_off(struct notifier_block *nb,
> +				 unsigned long reboot_mode, void *data)
>  {
> -	struct max77620_chip *chip = max77620_scratch;
> +	struct max77620_chip *chip = container_of(nb, struct max77620_chip,
> +						  pm_off_nb);
>  
>  	regmap_update_bits(chip->rmap, MAX77620_REG_ONOFFCNFG1,
>  			   MAX77620_ONOFFCNFG1_SFT_RST,
>  			   MAX77620_ONOFFCNFG1_SFT_RST);
> +
> +	return NOTIFY_DONE;
>  }
>  
>  static int max77620_probe(struct i2c_client *client,
> @@ -566,9 +569,14 @@ static int max77620_probe(struct i2c_client *client,
>  	}
>  
>  	pm_off = of_device_is_system_power_controller(client->dev.of_node);
> -	if (pm_off && !pm_power_off) {
> -		max77620_scratch = chip;
> -		pm_power_off = max77620_pm_power_off;
> +	if (pm_off) {
> +		chip->pm_off_nb.notifier_call = max77620_pm_power_off;
> +		chip->pm_off_nb.priority = 128;
> +
> +		ret = devm_register_poweroff_handler(chip->dev, &chip->pm_off_nb);
> +		if (ret < 0)
> +			dev_err(chip->dev,
> +				"Failed to register poweroff handler: %d\n", ret);
>  	}
>  
>  	return 0;
> diff --git a/include/linux/mfd/max77620.h b/include/linux/mfd/max77620.h
> index f552ef5b1100..99de4f8c9cbf 100644
> --- a/include/linux/mfd/max77620.h
> +++ b/include/linux/mfd/max77620.h
> @@ -8,6 +8,7 @@
>  #ifndef _MFD_MAX77620_H_
>  #define _MFD_MAX77620_H_
>  
> +#include <linux/notifier.h>
>  #include <linux/types.h>
>  
>  /* GLOBAL, PMIC, GPIO, FPS, ONOFFC, CID Registers */
> @@ -327,6 +328,7 @@ enum max77620_chip_id {
>  struct max77620_chip {
>  	struct device *dev;
>  	struct regmap *rmap;
> +	struct notifier_block pm_off_nb;
>  
>  	int chip_irq;
>  

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ