Skip to content

Commit 447be50

Browse files
MrVanbroonie
authored andcommitted
regulator: pca9450: Use devm_register_sys_off_handler
With module test, there is error dump: ------------[ cut here ]------------ notifier callback pca9450_i2c_restart_handler already registered WARNING: kernel/notifier.c:23 at notifier_chain_register+0x5c/0x88, CPU#0: kworker/u16:3/50 Call trace: notifier_chain_register+0x5c/0x88 (P) atomic_notifier_chain_register+0x30/0x58 register_restart_handler+0x1c/0x28 pca9450_i2c_probe+0x418/0x538 i2c_device_probe+0x220/0x3d0 really_probe+0x114/0x410 __driver_probe_device+0xa0/0x150 driver_probe_device+0x40/0x114 __device_attach_driver+0xd4/0x12c So use devm_register_sys_off_handler to let kernel handle the resource free to avoid kernel dump. Fixes: 6157e62 ("regulator: pca9450: Add restart handler") Signed-off-by: Peng Fan <peng.fan@nxp.com> Link: https://patch.msgid.link/20250815-pca9450-v1-1-7748e362dc97@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 4b0ad96 commit 447be50

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

drivers/regulator/pca9450-regulator.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ struct pca9450 {
4040
struct device *dev;
4141
struct regmap *regmap;
4242
struct gpio_desc *sd_vsel_gpio;
43-
struct notifier_block restart_nb;
4443
enum pca9450_chip_type type;
4544
unsigned int rcnt;
4645
int irq;
@@ -1100,10 +1099,9 @@ static irqreturn_t pca9450_irq_handler(int irq, void *data)
11001099
return IRQ_HANDLED;
11011100
}
11021101

1103-
static int pca9450_i2c_restart_handler(struct notifier_block *nb,
1104-
unsigned long action, void *data)
1102+
static int pca9450_i2c_restart_handler(struct sys_off_data *data)
11051103
{
1106-
struct pca9450 *pca9450 = container_of(nb, struct pca9450, restart_nb);
1104+
struct pca9450 *pca9450 = data->cb_data;
11071105
struct i2c_client *i2c = container_of(pca9450->dev, struct i2c_client, dev);
11081106

11091107
dev_dbg(&i2c->dev, "Restarting device..\n");
@@ -1261,10 +1259,9 @@ static int pca9450_i2c_probe(struct i2c_client *i2c)
12611259
pca9450->sd_vsel_fixed_low =
12621260
of_property_read_bool(ldo5->dev.of_node, "nxp,sd-vsel-fixed-low");
12631261

1264-
pca9450->restart_nb.notifier_call = pca9450_i2c_restart_handler;
1265-
pca9450->restart_nb.priority = PCA9450_RESTART_HANDLER_PRIORITY;
1266-
1267-
if (register_restart_handler(&pca9450->restart_nb))
1262+
if (devm_register_sys_off_handler(&i2c->dev, SYS_OFF_MODE_RESTART,
1263+
PCA9450_RESTART_HANDLER_PRIORITY,
1264+
pca9450_i2c_restart_handler, pca9450))
12681265
dev_warn(&i2c->dev, "Failed to register restart handler\n");
12691266

12701267
dev_info(&i2c->dev, "%s probed.\n",

0 commit comments

Comments
 (0)