aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiogo Ivo <diogo.ivo@tecnico.ulisboa.pt>2026-05-14 16:47:20 +0200
committerLee Jones <lee@kernel.org>2026-06-17 11:32:41 +0100
commitf01e402bebf8a2f3843990b209b3f50cf536dbf8 (patch)
tree5622c4fa8468254b5dcf422da50c7941693361ce
parent7502c035b884b73f51669cada3f4022cd11e8f5c (diff)
mfd: max77620: Convert poweroff support to sys-off API
Convert max77620_pm_power_off() to the sys-off callback prototype and register it with the sys-off API when the device tree marks the PMIC as a system power controller. This also removes the global max77620_scratch pointer by passing the chip instance through the callback data. This modernizes the driver's poweroff handling and aligns it with the kernel sys-off infrastructure. Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt> Link: https://patch.msgid.link/20260514-smaug-poweroff-v1-2-30f9a4688966@tecnico.ulisboa.pt Signed-off-by: Lee Jones <lee@kernel.org>
-rw-r--r--drivers/mfd/max77620.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c
index 3af2974b3023..c4f89a9681f3 100644
--- a/drivers/mfd/max77620.c
+++ b/drivers/mfd/max77620.c
@@ -31,11 +31,10 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/of.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),
};
@@ -484,13 +483,15 @@ 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 sys_off_data *data)
{
- struct max77620_chip *chip = max77620_scratch;
+ struct max77620_chip *chip = data->cb_data;
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)
@@ -501,7 +502,6 @@ static int max77620_probe(struct i2c_client *client)
struct regmap_irq_chip *chip_desc;
const struct mfd_cell *mfd_cells;
int n_mfd_cells;
- bool pm_off;
int ret;
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
@@ -573,10 +573,14 @@ static int max77620_probe(struct i2c_client *client)
return ret;
}
- 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 (of_device_is_system_power_controller(client->dev.of_node)) {
+ ret = devm_register_sys_off_handler(&client->dev,
+ SYS_OFF_MODE_POWER_OFF,
+ SYS_OFF_PRIO_DEFAULT,
+ max77620_pm_power_off, chip);
+ if (ret)
+ return dev_err_probe(&client->dev, ret,
+ "failed to register power-off handler\n");
}
return 0;