Skip to content

Commit 7a8c8aa

Browse files
MrVangregkh
authored andcommitted
regulator: pca9450: Use devm_register_sys_off_handler
[ Upstream commit 447be50 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5ff4ad5 commit 7a8c8aa

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

drivers/regulator/pca9450-regulator.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ struct pca9450 {
3434
struct device *dev;
3535
struct regmap *regmap;
3636
struct gpio_desc *sd_vsel_gpio;
37-
struct notifier_block restart_nb;
3837
enum pca9450_chip_type type;
3938
unsigned int rcnt;
4039
int irq;
@@ -967,10 +966,9 @@ static irqreturn_t pca9450_irq_handler(int irq, void *data)
967966
return IRQ_HANDLED;
968967
}
969968

970-
static int pca9450_i2c_restart_handler(struct notifier_block *nb,
971-
unsigned long action, void *data)
969+
static int pca9450_i2c_restart_handler(struct sys_off_data *data)
972970
{
973-
struct pca9450 *pca9450 = container_of(nb, struct pca9450, restart_nb);
971+
struct pca9450 *pca9450 = data->cb_data;
974972
struct i2c_client *i2c = container_of(pca9450->dev, struct i2c_client, dev);
975973

976974
dev_dbg(&i2c->dev, "Restarting device..\n");
@@ -1128,10 +1126,9 @@ static int pca9450_i2c_probe(struct i2c_client *i2c)
11281126
pca9450->sd_vsel_fixed_low =
11291127
of_property_read_bool(ldo5->dev.of_node, "nxp,sd-vsel-fixed-low");
11301128

1131-
pca9450->restart_nb.notifier_call = pca9450_i2c_restart_handler;
1132-
pca9450->restart_nb.priority = PCA9450_RESTART_HANDLER_PRIORITY;
1133-
1134-
if (register_restart_handler(&pca9450->restart_nb))
1129+
if (devm_register_sys_off_handler(&i2c->dev, SYS_OFF_MODE_RESTART,
1130+
PCA9450_RESTART_HANDLER_PRIORITY,
1131+
pca9450_i2c_restart_handler, pca9450))
11351132
dev_warn(&i2c->dev, "Failed to register restart handler\n");
11361133

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

0 commit comments

Comments
 (0)