ata: ahci_st: fixup layering violations / drvdata errors
Brian noticed while working on another SATA driver that uses libahci_platform, an error in this driver; it tries to the the driver data for its device, while libata also thinks it can set the driver data. See: ahci_platform_init_host() -> ata_host_alloc_pinfo() -> ata_host_alloc() -> dev_set_drvdata() So instead of sticking the IP-specific platform data into drvdata, let's use the plat_data variable that is reserved for this use. Addtionally plat_data isn't set until ahci_platform_init_host() has been called further down in probe(). So re-work the st_ahci_probe_resets and st_ahci_deassert_resets functions to take ahci_host_priv *hpriv as a parameter. Signed-off-by: Peter Griffin <peter.griffin@linaro.org> Suggested-by: Brian Norris <computersforpeace@gmail.com> Cc: Srinivas Kandagatla <srinivas.kandagatla@gmail.com> Cc: Maxime Coquelin <maxime.coquelin@st.com> Cc: Patrice Chotard <patrice.chotard@st.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
5df07b74f6
commit
e0e2674b92
|
@ -37,7 +37,6 @@ struct st_ahci_drv_data {
|
||||||
struct reset_control *pwr;
|
struct reset_control *pwr;
|
||||||
struct reset_control *sw_rst;
|
struct reset_control *sw_rst;
|
||||||
struct reset_control *pwr_rst;
|
struct reset_control *pwr_rst;
|
||||||
struct ahci_host_priv *hpriv;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void st_ahci_configure_oob(void __iomem *mmio)
|
static void st_ahci_configure_oob(void __iomem *mmio)
|
||||||
|
@ -55,9 +54,10 @@ static void st_ahci_configure_oob(void __iomem *mmio)
|
||||||
writel(new_val, mmio + ST_AHCI_OOBR);
|
writel(new_val, mmio + ST_AHCI_OOBR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int st_ahci_deassert_resets(struct device *dev)
|
static int st_ahci_deassert_resets(struct ahci_host_priv *hpriv,
|
||||||
|
struct device *dev)
|
||||||
{
|
{
|
||||||
struct st_ahci_drv_data *drv_data = dev_get_drvdata(dev);
|
struct st_ahci_drv_data *drv_data = hpriv->plat_data;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (drv_data->pwr) {
|
if (drv_data->pwr) {
|
||||||
|
@ -90,8 +90,8 @@ static int st_ahci_deassert_resets(struct device *dev)
|
||||||
static void st_ahci_host_stop(struct ata_host *host)
|
static void st_ahci_host_stop(struct ata_host *host)
|
||||||
{
|
{
|
||||||
struct ahci_host_priv *hpriv = host->private_data;
|
struct ahci_host_priv *hpriv = host->private_data;
|
||||||
|
struct st_ahci_drv_data *drv_data = hpriv->plat_data;
|
||||||
struct device *dev = host->dev;
|
struct device *dev = host->dev;
|
||||||
struct st_ahci_drv_data *drv_data = dev_get_drvdata(dev);
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (drv_data->pwr) {
|
if (drv_data->pwr) {
|
||||||
|
@ -103,29 +103,30 @@ static void st_ahci_host_stop(struct ata_host *host)
|
||||||
ahci_platform_disable_resources(hpriv);
|
ahci_platform_disable_resources(hpriv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int st_ahci_probe_resets(struct platform_device *pdev)
|
static int st_ahci_probe_resets(struct ahci_host_priv *hpriv,
|
||||||
|
struct device *dev)
|
||||||
{
|
{
|
||||||
struct st_ahci_drv_data *drv_data = platform_get_drvdata(pdev);
|
struct st_ahci_drv_data *drv_data = hpriv->plat_data;
|
||||||
|
|
||||||
drv_data->pwr = devm_reset_control_get(&pdev->dev, "pwr-dwn");
|
drv_data->pwr = devm_reset_control_get(dev, "pwr-dwn");
|
||||||
if (IS_ERR(drv_data->pwr)) {
|
if (IS_ERR(drv_data->pwr)) {
|
||||||
dev_info(&pdev->dev, "power reset control not defined\n");
|
dev_info(dev, "power reset control not defined\n");
|
||||||
drv_data->pwr = NULL;
|
drv_data->pwr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
drv_data->sw_rst = devm_reset_control_get(&pdev->dev, "sw-rst");
|
drv_data->sw_rst = devm_reset_control_get(dev, "sw-rst");
|
||||||
if (IS_ERR(drv_data->sw_rst)) {
|
if (IS_ERR(drv_data->sw_rst)) {
|
||||||
dev_info(&pdev->dev, "soft reset control not defined\n");
|
dev_info(dev, "soft reset control not defined\n");
|
||||||
drv_data->sw_rst = NULL;
|
drv_data->sw_rst = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
drv_data->pwr_rst = devm_reset_control_get(&pdev->dev, "pwr-rst");
|
drv_data->pwr_rst = devm_reset_control_get(dev, "pwr-rst");
|
||||||
if (IS_ERR(drv_data->pwr_rst)) {
|
if (IS_ERR(drv_data->pwr_rst)) {
|
||||||
dev_dbg(&pdev->dev, "power soft reset control not defined\n");
|
dev_dbg(dev, "power soft reset control not defined\n");
|
||||||
drv_data->pwr_rst = NULL;
|
drv_data->pwr_rst = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return st_ahci_deassert_resets(&pdev->dev);
|
return st_ahci_deassert_resets(hpriv, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ata_port_operations st_ahci_port_ops = {
|
static struct ata_port_operations st_ahci_port_ops = {
|
||||||
|
@ -154,15 +155,12 @@ static int st_ahci_probe(struct platform_device *pdev)
|
||||||
if (!drv_data)
|
if (!drv_data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
platform_set_drvdata(pdev, drv_data);
|
|
||||||
|
|
||||||
hpriv = ahci_platform_get_resources(pdev);
|
hpriv = ahci_platform_get_resources(pdev);
|
||||||
if (IS_ERR(hpriv))
|
if (IS_ERR(hpriv))
|
||||||
return PTR_ERR(hpriv);
|
return PTR_ERR(hpriv);
|
||||||
|
hpriv->plat_data = drv_data;
|
||||||
|
|
||||||
drv_data->hpriv = hpriv;
|
err = st_ahci_probe_resets(hpriv, &pdev->dev);
|
||||||
|
|
||||||
err = st_ahci_probe_resets(pdev);
|
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -170,7 +168,7 @@ static int st_ahci_probe(struct platform_device *pdev)
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
st_ahci_configure_oob(drv_data->hpriv->mmio);
|
st_ahci_configure_oob(hpriv->mmio);
|
||||||
|
|
||||||
err = ahci_platform_init_host(pdev, hpriv, &st_ahci_port_info,
|
err = ahci_platform_init_host(pdev, hpriv, &st_ahci_port_info,
|
||||||
&ahci_platform_sht);
|
&ahci_platform_sht);
|
||||||
|
@ -185,8 +183,9 @@ static int st_ahci_probe(struct platform_device *pdev)
|
||||||
#ifdef CONFIG_PM_SLEEP
|
#ifdef CONFIG_PM_SLEEP
|
||||||
static int st_ahci_suspend(struct device *dev)
|
static int st_ahci_suspend(struct device *dev)
|
||||||
{
|
{
|
||||||
struct st_ahci_drv_data *drv_data = dev_get_drvdata(dev);
|
struct ata_host *host = dev_get_drvdata(dev);
|
||||||
struct ahci_host_priv *hpriv = drv_data->hpriv;
|
struct ahci_host_priv *hpriv = host->private_data;
|
||||||
|
struct st_ahci_drv_data *drv_data = hpriv->plat_data;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = ahci_platform_suspend_host(dev);
|
err = ahci_platform_suspend_host(dev);
|
||||||
|
@ -208,21 +207,21 @@ static int st_ahci_suspend(struct device *dev)
|
||||||
|
|
||||||
static int st_ahci_resume(struct device *dev)
|
static int st_ahci_resume(struct device *dev)
|
||||||
{
|
{
|
||||||
struct st_ahci_drv_data *drv_data = dev_get_drvdata(dev);
|
struct ata_host *host = dev_get_drvdata(dev);
|
||||||
struct ahci_host_priv *hpriv = drv_data->hpriv;
|
struct ahci_host_priv *hpriv = host->private_data;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = ahci_platform_enable_resources(hpriv);
|
err = ahci_platform_enable_resources(hpriv);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
err = st_ahci_deassert_resets(dev);
|
err = st_ahci_deassert_resets(hpriv, dev);
|
||||||
if (err) {
|
if (err) {
|
||||||
ahci_platform_disable_resources(hpriv);
|
ahci_platform_disable_resources(hpriv);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
st_ahci_configure_oob(drv_data->hpriv->mmio);
|
st_ahci_configure_oob(hpriv->mmio);
|
||||||
|
|
||||||
return ahci_platform_resume_host(dev);
|
return ahci_platform_resume_host(dev);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue