Skip to content

Commit

Permalink
ata: use platform_{get,set}_drvdata()
Browse files Browse the repository at this point in the history
Use the wrapper functions for getting and setting the driver data using
platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev,
so we can directly pass a struct platform_device.

Also, unnecessary dev_set_drvdata() is removed, because the driver core
clears the driver data to NULL after device_release or on probe failure.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Jingoo Han authored and Tejun Heo committed May 24, 2013
1 parent b29900e commit d89995d
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion drivers/ata/pata_arasan_cf.c
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ static int arasan_cf_probe(struct platform_device *pdev)

static int arasan_cf_remove(struct platform_device *pdev)
{
struct ata_host *host = dev_get_drvdata(&pdev->dev);
struct ata_host *host = platform_get_drvdata(pdev);
struct arasan_cf_dev *acdev = host->ports[0]->private_data;

ata_host_detach(host);
Expand Down
2 changes: 1 addition & 1 deletion drivers/ata/pata_at91.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ static int pata_at91_probe(struct platform_device *pdev)

static int pata_at91_remove(struct platform_device *pdev)
{
struct ata_host *host = dev_get_drvdata(&pdev->dev);
struct ata_host *host = platform_get_drvdata(pdev);
struct at91_ide_info *info;

if (!host)
Expand Down
10 changes: 4 additions & 6 deletions drivers/ata/pata_bf54x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ static int bfin_atapi_probe(struct platform_device *pdev)
return -ENODEV;
}

dev_set_drvdata(&pdev->dev, host);
platform_set_drvdata(pdev, host);

return 0;
}
Expand All @@ -1610,11 +1610,9 @@ static int bfin_atapi_probe(struct platform_device *pdev)
*/
static int bfin_atapi_remove(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct ata_host *host = dev_get_drvdata(dev);
struct ata_host *host = platform_get_drvdata(pdev);

ata_host_detach(host);
dev_set_drvdata(&pdev->dev, NULL);

peripheral_free_list(atapi_io_port);

Expand All @@ -1624,7 +1622,7 @@ static int bfin_atapi_remove(struct platform_device *pdev)
#ifdef CONFIG_PM
static int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state)
{
struct ata_host *host = dev_get_drvdata(&pdev->dev);
struct ata_host *host = platform_get_drvdata(pdev);
if (host)
return ata_host_suspend(host, state);
else
Expand All @@ -1633,7 +1631,7 @@ static int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state)

static int bfin_atapi_resume(struct platform_device *pdev)
{
struct ata_host *host = dev_get_drvdata(&pdev->dev);
struct ata_host *host = platform_get_drvdata(pdev);
int ret;

if (host) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/ata/pata_imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static int pata_imx_probe(struct platform_device *pdev)

static int pata_imx_remove(struct platform_device *pdev)
{
struct ata_host *host = dev_get_drvdata(&pdev->dev);
struct ata_host *host = platform_get_drvdata(pdev);
struct pata_imx_priv *priv = host->private_data;

ata_host_detach(host);
Expand Down
4 changes: 2 additions & 2 deletions drivers/ata/pata_mpc52xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,15 +825,15 @@ mpc52xx_ata_remove(struct platform_device *op)
static int
mpc52xx_ata_suspend(struct platform_device *op, pm_message_t state)
{
struct ata_host *host = dev_get_drvdata(&op->dev);
struct ata_host *host = platform_get_drvdata(op);

return ata_host_suspend(host, state);
}

static int
mpc52xx_ata_resume(struct platform_device *op)
{
struct ata_host *host = dev_get_drvdata(&op->dev);
struct ata_host *host = platform_get_drvdata(op);
struct mpc52xx_ata_priv *priv = host->private_data;
int rv;

Expand Down
2 changes: 1 addition & 1 deletion drivers/ata/pata_pxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ static int pxa_ata_probe(struct platform_device *pdev)

static int pxa_ata_remove(struct platform_device *pdev)
{
struct ata_host *host = dev_get_drvdata(&pdev->dev);
struct ata_host *host = platform_get_drvdata(pdev);
struct pata_pxa_data *data = host->ports[0]->private_data;

pxa_free_dma(data->dma_channel);
Expand Down
14 changes: 5 additions & 9 deletions drivers/ata/sata_fsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,7 @@ static int sata_fsl_probe(struct platform_device *ofdev)
ata_host_activate(host, irq, sata_fsl_interrupt, SATA_FSL_IRQ_FLAG,
&sata_fsl_sht);

dev_set_drvdata(&ofdev->dev, host);
platform_set_drvdata(ofdev, host);

host_priv->intr_coalescing.show = fsl_sata_intr_coalescing_show;
host_priv->intr_coalescing.store = fsl_sata_intr_coalescing_store;
Expand All @@ -1558,10 +1558,8 @@ static int sata_fsl_probe(struct platform_device *ofdev)

error_exit_with_cleanup:

if (host) {
dev_set_drvdata(&ofdev->dev, NULL);
if (host)
ata_host_detach(host);
}

if (hcr_base)
iounmap(hcr_base);
Expand All @@ -1572,16 +1570,14 @@ static int sata_fsl_probe(struct platform_device *ofdev)

static int sata_fsl_remove(struct platform_device *ofdev)
{
struct ata_host *host = dev_get_drvdata(&ofdev->dev);
struct ata_host *host = platform_get_drvdata(ofdev);
struct sata_fsl_host_priv *host_priv = host->private_data;

device_remove_file(&ofdev->dev, &host_priv->intr_coalescing);
device_remove_file(&ofdev->dev, &host_priv->rx_watermark);

ata_host_detach(host);

dev_set_drvdata(&ofdev->dev, NULL);

irq_dispose_mapping(host_priv->irq);
iounmap(host_priv->hcr_base);
kfree(host_priv);
Expand All @@ -1592,13 +1588,13 @@ static int sata_fsl_remove(struct platform_device *ofdev)
#ifdef CONFIG_PM
static int sata_fsl_suspend(struct platform_device *op, pm_message_t state)
{
struct ata_host *host = dev_get_drvdata(&op->dev);
struct ata_host *host = platform_get_drvdata(op);
return ata_host_suspend(host, state);
}

static int sata_fsl_resume(struct platform_device *op)
{
struct ata_host *host = dev_get_drvdata(&op->dev);
struct ata_host *host = platform_get_drvdata(op);
struct sata_fsl_host_priv *host_priv = host->private_data;
int ret;
void __iomem *hcr_base = host_priv->hcr_base;
Expand Down
2 changes: 1 addition & 1 deletion drivers/ata/sata_rcar.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ static int sata_rcar_probe(struct platform_device *pdev)

static int sata_rcar_remove(struct platform_device *pdev)
{
struct ata_host *host = dev_get_drvdata(&pdev->dev);
struct ata_host *host = platform_get_drvdata(pdev);
struct sata_rcar_priv *priv = host->private_data;

ata_host_detach(host);
Expand Down

0 comments on commit d89995d

Please sign in to comment.