Commit 1ef48e3d authored by Ulf Hansson's avatar Ulf Hansson

mmc: core: Attach PM domain prior probing of SDIO func driver

Other subsystem buses attach PM domains during probe, but prior calling
the driver's ->probe() method. During the removal phase, detaching the PM
domain will be done after invoking the driver's ->remove() callback.

Convert the SDIO bus to follow this behavior and add error handling.
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 3056c49c
...@@ -137,6 +137,10 @@ static int sdio_bus_probe(struct device *dev) ...@@ -137,6 +137,10 @@ static int sdio_bus_probe(struct device *dev)
if (!id) if (!id)
return -ENODEV; return -ENODEV;
ret = dev_pm_domain_attach(dev, false);
if (ret == -EPROBE_DEFER)
return ret;
/* Unbound SDIO functions are always suspended. /* Unbound SDIO functions are always suspended.
* During probe, the function is set active and the usage count * During probe, the function is set active and the usage count
* is incremented. If the driver supports runtime PM, * is incremented. If the driver supports runtime PM,
...@@ -166,6 +170,7 @@ static int sdio_bus_probe(struct device *dev) ...@@ -166,6 +170,7 @@ static int sdio_bus_probe(struct device *dev)
disable_runtimepm: disable_runtimepm:
if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD)
pm_runtime_put_noidle(dev); pm_runtime_put_noidle(dev);
dev_pm_domain_detach(dev, false);
return ret; return ret;
} }
...@@ -197,6 +202,8 @@ static int sdio_bus_remove(struct device *dev) ...@@ -197,6 +202,8 @@ static int sdio_bus_remove(struct device *dev)
if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD)
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
dev_pm_domain_detach(dev, false);
return ret; return ret;
} }
...@@ -316,10 +323,8 @@ int sdio_add_func(struct sdio_func *func) ...@@ -316,10 +323,8 @@ int sdio_add_func(struct sdio_func *func)
sdio_set_of_node(func); sdio_set_of_node(func);
sdio_acpi_set_handle(func); sdio_acpi_set_handle(func);
ret = device_add(&func->dev); ret = device_add(&func->dev);
if (ret == 0) { if (ret == 0)
sdio_func_set_present(func); sdio_func_set_present(func);
dev_pm_domain_attach(&func->dev, false);
}
return ret; return ret;
} }
...@@ -335,7 +340,6 @@ void sdio_remove_func(struct sdio_func *func) ...@@ -335,7 +340,6 @@ void sdio_remove_func(struct sdio_func *func)
if (!sdio_func_present(func)) if (!sdio_func_present(func))
return; return;
dev_pm_domain_detach(&func->dev, false);
device_del(&func->dev); device_del(&func->dev);
of_node_put(func->dev.of_node); of_node_put(func->dev.of_node);
put_device(&func->dev); put_device(&func->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment