Skip to content

Commit 0f35dc4

Browse files
charleskeepaxlag-linaro
authored andcommitted
mfd: cs42l43: Use devres for remove as well
Currently the device is powered down in the remove callback, however all other clean up is done through devres. The problem here is the MFD children are cleaned up through devres. As this happens after the remove callback has run, this leads to the incorrect ordering where the child remove functions run after the device has been powered down. Put the power down into devres as well such that everything runs in the expected order. Signed-off-by: Charles Keepax <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 47dde1a commit 0f35dc4

File tree

4 files changed

+13
-27
lines changed

4 files changed

+13
-27
lines changed

drivers/mfd/cs42l43-i2c.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ static int cs42l43_i2c_probe(struct i2c_client *i2c)
5656
return cs42l43_dev_probe(cs42l43);
5757
}
5858

59-
static void cs42l43_i2c_remove(struct i2c_client *i2c)
60-
{
61-
struct cs42l43 *cs42l43 = dev_get_drvdata(&i2c->dev);
62-
63-
cs42l43_dev_remove(cs42l43);
64-
}
65-
6659
#if IS_ENABLED(CONFIG_OF)
6760
static const struct of_device_id cs42l43_of_match[] = {
6861
{ .compatible = "cirrus,cs42l43", },
@@ -88,7 +81,6 @@ static struct i2c_driver cs42l43_i2c_driver = {
8881
},
8982

9083
.probe = cs42l43_i2c_probe,
91-
.remove = cs42l43_i2c_remove,
9284
};
9385
module_i2c_driver(cs42l43_i2c_driver);
9486

drivers/mfd/cs42l43-sdw.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,6 @@ static int cs42l43_sdw_probe(struct sdw_slave *sdw, const struct sdw_device_id *
187187
return cs42l43_dev_probe(cs42l43);
188188
}
189189

190-
static int cs42l43_sdw_remove(struct sdw_slave *sdw)
191-
{
192-
struct cs42l43 *cs42l43 = dev_get_drvdata(&sdw->dev);
193-
194-
cs42l43_dev_remove(cs42l43);
195-
196-
return 0;
197-
}
198-
199190
static const struct sdw_device_id cs42l43_sdw_id[] = {
200191
SDW_SLAVE_ENTRY(0x01FA, 0x4243, 0),
201192
{}
@@ -209,7 +200,6 @@ static struct sdw_driver cs42l43_sdw_driver = {
209200
},
210201

211202
.probe = cs42l43_sdw_probe,
212-
.remove = cs42l43_sdw_remove,
213203
.id_table = cs42l43_sdw_id,
214204
.ops = &cs42l43_sdw_ops,
215205
};

drivers/mfd/cs42l43.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,15 @@ static int cs42l43_power_down(struct cs42l43 *cs42l43)
10381038
return 0;
10391039
}
10401040

1041+
static void cs42l43_dev_remove(void *data)
1042+
{
1043+
struct cs42l43 *cs42l43 = data;
1044+
1045+
cancel_work_sync(&cs42l43->boot_work);
1046+
1047+
cs42l43_power_down(cs42l43);
1048+
}
1049+
10411050
int cs42l43_dev_probe(struct cs42l43 *cs42l43)
10421051
{
10431052
int i, ret;
@@ -1084,6 +1093,10 @@ int cs42l43_dev_probe(struct cs42l43 *cs42l43)
10841093
if (ret)
10851094
return ret;
10861095

1096+
ret = devm_add_action_or_reset(cs42l43->dev, cs42l43_dev_remove, cs42l43);
1097+
if (ret)
1098+
return ret;
1099+
10871100
pm_runtime_set_autosuspend_delay(cs42l43->dev, CS42L43_AUTOSUSPEND_TIME_MS);
10881101
pm_runtime_use_autosuspend(cs42l43->dev);
10891102
pm_runtime_set_active(cs42l43->dev);
@@ -1102,14 +1115,6 @@ int cs42l43_dev_probe(struct cs42l43 *cs42l43)
11021115
}
11031116
EXPORT_SYMBOL_NS_GPL(cs42l43_dev_probe, MFD_CS42L43);
11041117

1105-
void cs42l43_dev_remove(struct cs42l43 *cs42l43)
1106-
{
1107-
cancel_work_sync(&cs42l43->boot_work);
1108-
1109-
cs42l43_power_down(cs42l43);
1110-
}
1111-
EXPORT_SYMBOL_NS_GPL(cs42l43_dev_remove, MFD_CS42L43);
1112-
11131118
static int cs42l43_suspend(struct device *dev)
11141119
{
11151120
struct cs42l43 *cs42l43 = dev_get_drvdata(dev);

drivers/mfd/cs42l43.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,5 @@ bool cs42l43_precious_register(struct device *dev, unsigned int reg);
2525
bool cs42l43_volatile_register(struct device *dev, unsigned int reg);
2626

2727
int cs42l43_dev_probe(struct cs42l43 *cs42l43);
28-
void cs42l43_dev_remove(struct cs42l43 *cs42l43);
2928

3029
#endif /* CS42L43_CORE_INT_H */

0 commit comments

Comments
 (0)