Skip to content

Commit

Permalink
cs42l43 fix
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Ujfalusi <[email protected]>
  • Loading branch information
ujfalusi committed Dec 10, 2024
1 parent 89c8c62 commit 7868d16
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 66 deletions.
8 changes: 0 additions & 8 deletions drivers/mfd/cs42l43-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ static int cs42l43_i2c_probe(struct i2c_client *i2c)
return cs42l43_dev_probe(cs42l43);
}

static void cs42l43_i2c_remove(struct i2c_client *i2c)
{
struct cs42l43 *cs42l43 = dev_get_drvdata(&i2c->dev);

cs42l43_dev_remove(cs42l43);
}

#if IS_ENABLED(CONFIG_OF)
static const struct of_device_id cs42l43_of_match[] = {
{ .compatible = "cirrus,cs42l43", },
Expand All @@ -88,7 +81,6 @@ static struct i2c_driver cs42l43_i2c_driver = {
},

.probe = cs42l43_i2c_probe,
.remove = cs42l43_i2c_remove,
};
module_i2c_driver(cs42l43_i2c_driver);

Expand Down
10 changes: 0 additions & 10 deletions drivers/mfd/cs42l43-sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,6 @@ static int cs42l43_sdw_probe(struct sdw_slave *sdw, const struct sdw_device_id *
return cs42l43_dev_probe(cs42l43);
}

static int cs42l43_sdw_remove(struct sdw_slave *sdw)
{
struct cs42l43 *cs42l43 = dev_get_drvdata(&sdw->dev);

cs42l43_dev_remove(cs42l43);

return 0;
}

static const struct sdw_device_id cs42l43_sdw_id[] = {
SDW_SLAVE_ENTRY(0x01FA, 0x4243, 0),
{}
Expand All @@ -209,7 +200,6 @@ static struct sdw_driver cs42l43_sdw_driver = {
},

.probe = cs42l43_sdw_probe,
.remove = cs42l43_sdw_remove,
.id_table = cs42l43_sdw_id,
.ops = &cs42l43_sdw_ops,
};
Expand Down
75 changes: 40 additions & 35 deletions drivers/mfd/cs42l43.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,42 @@ static int cs42l43_irq_config(struct cs42l43 *cs42l43)
return 0;
}

static int cs42l43_power_down(struct cs42l43 *cs42l43)
{
int ret;

ret = regulator_disable(cs42l43->vdd_d);
if (ret) {
dev_err(cs42l43->dev, "Failed to disable vdd-d: %d\n", ret);
return ret;
}

ret = regulator_bulk_disable(CS42L43_N_SUPPLIES, cs42l43->core_supplies);
if (ret) {
dev_err(cs42l43->dev, "Failed to disable core supplies: %d\n", ret);
return ret;
}

gpiod_set_value_cansleep(cs42l43->reset, 0);

ret = regulator_disable(cs42l43->vdd_p);
if (ret) {
dev_err(cs42l43->dev, "Failed to disable vdd-p: %d\n", ret);
return ret;
}

return 0;
}

static void cs42l43_dev_remove(void *data)
{
struct cs42l43 *cs42l43 = data;

cancel_work_sync(&cs42l43->boot_work);

cs42l43_power_down(cs42l43);
}

static void cs42l43_boot_work(struct work_struct *work)
{
struct cs42l43 *cs42l43 = container_of(work, struct cs42l43, boot_work);
Expand Down Expand Up @@ -1009,33 +1045,6 @@ static int cs42l43_power_up(struct cs42l43 *cs42l43)
return ret;
}

static int cs42l43_power_down(struct cs42l43 *cs42l43)
{
int ret;

ret = regulator_disable(cs42l43->vdd_d);
if (ret) {
dev_err(cs42l43->dev, "Failed to disable vdd-d: %d\n", ret);
return ret;
}

ret = regulator_bulk_disable(CS42L43_N_SUPPLIES, cs42l43->core_supplies);
if (ret) {
dev_err(cs42l43->dev, "Failed to disable core supplies: %d\n", ret);
return ret;
}

gpiod_set_value_cansleep(cs42l43->reset, 0);

ret = regulator_disable(cs42l43->vdd_p);
if (ret) {
dev_err(cs42l43->dev, "Failed to disable vdd-p: %d\n", ret);
return ret;
}

return 0;
}

int cs42l43_dev_probe(struct cs42l43 *cs42l43)
{
int i, ret;
Expand Down Expand Up @@ -1080,6 +1089,10 @@ int cs42l43_dev_probe(struct cs42l43 *cs42l43)
if (ret)
return ret;

ret = devm_add_action_or_reset(cs42l43->dev, cs42l43_dev_remove, cs42l43);
if (ret)
return ret;

pm_runtime_set_autosuspend_delay(cs42l43->dev, CS42L43_AUTOSUSPEND_TIME_MS);
pm_runtime_use_autosuspend(cs42l43->dev);
pm_runtime_set_active(cs42l43->dev);
Expand All @@ -1098,14 +1111,6 @@ int cs42l43_dev_probe(struct cs42l43 *cs42l43)
}
EXPORT_SYMBOL_NS_GPL(cs42l43_dev_probe, MFD_CS42L43);

void cs42l43_dev_remove(struct cs42l43 *cs42l43)
{
cancel_work_sync(&cs42l43->boot_work);

cs42l43_power_down(cs42l43);
}
EXPORT_SYMBOL_NS_GPL(cs42l43_dev_remove, MFD_CS42L43);

static int cs42l43_suspend(struct device *dev)
{
struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
Expand Down
1 change: 0 additions & 1 deletion drivers/mfd/cs42l43.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ bool cs42l43_precious_register(struct device *dev, unsigned int reg);
bool cs42l43_volatile_register(struct device *dev, unsigned int reg);

int cs42l43_dev_probe(struct cs42l43 *cs42l43);
void cs42l43_dev_remove(struct cs42l43 *cs42l43);

#endif /* CS42L43_CORE_INT_H */
6 changes: 5 additions & 1 deletion drivers/soundwire/intel_auxdevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ static void intel_link_remove(struct auxiliary_device *auxdev)
struct sdw_cdns *cdns = auxiliary_get_drvdata(auxdev);
struct sdw_intel *sdw = cdns_to_intel(cdns);
struct sdw_bus *bus = &cdns->bus;
bool disable_interrupt = false;

/*
* Since pm_runtime is already disabled, we don't decrease
Expand All @@ -477,9 +478,12 @@ static void intel_link_remove(struct auxiliary_device *auxdev)
if (!bus->prop.hw_disabled) {
sdw_intel_debugfs_exit(sdw);
cancel_delayed_work_sync(&cdns->attach_dwork);
sdw_cdns_enable_interrupt(cdns, false);
disable_interrupt = true;
}
sdw_bus_master_delete(bus);

if (disable_interrupt)
sdw_cdns_enable_interrupt(cdns, false);
}

int intel_link_process_wakeen_event(struct auxiliary_device *auxdev)
Expand Down
11 changes: 0 additions & 11 deletions sound/soc/codecs/cs42l42-sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,16 +585,6 @@ static int cs42l42_sdw_probe(struct sdw_slave *peripheral, const struct sdw_devi
return 0;
}

static int cs42l42_sdw_remove(struct sdw_slave *peripheral)
{
struct cs42l42_private *cs42l42 = dev_get_drvdata(&peripheral->dev);

cs42l42_common_remove(cs42l42);
pm_runtime_disable(cs42l42->dev);

return 0;
}

static const struct dev_pm_ops cs42l42_sdw_pm = {
SET_SYSTEM_SLEEP_PM_OPS(cs42l42_suspend, cs42l42_sdw_resume)
SET_RUNTIME_PM_OPS(cs42l42_sdw_runtime_suspend, cs42l42_sdw_runtime_resume, NULL)
Expand All @@ -612,7 +602,6 @@ static struct sdw_driver cs42l42_sdw_driver = {
.pm = &cs42l42_sdw_pm,
},
.probe = cs42l42_sdw_probe,
.remove = cs42l42_sdw_remove,
.ops = &cs42l42_sdw_ops,
.id_table = cs42l42_sdw_id,
};
Expand Down

0 comments on commit 7868d16

Please sign in to comment.