Skip to content

Commit

Permalink
[libata] pata_bf54x: Add proper PM operation
Browse files Browse the repository at this point in the history
[akpm@linux-foundation.org: remove ifdefs, make things static]
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
  • Loading branch information
Sonic Zhang authored and Jeff Garzik committed Sep 29, 2008
1 parent 47d692a commit 67e3e22
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions drivers/ata/pata_bf54x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,8 @@ static int __devinit bfin_atapi_probe(struct platform_device *pdev)
return -ENODEV;
}

dev_set_drvdata(&pdev->dev, host);

return 0;
}

Expand All @@ -1648,34 +1650,52 @@ static int __devexit bfin_atapi_remove(struct platform_device *pdev)
struct ata_host *host = dev_get_drvdata(dev);

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

peripheral_free_list(atapi_io_port);

return 0;
}

#ifdef CONFIG_PM
int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state)
static int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state)
{
return 0;
struct ata_host *host = dev_get_drvdata(&pdev->dev);
if (host)
return ata_host_suspend(host, state);
else
return 0;
}

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

if (host) {
ret = bfin_reset_controller(host);
if (ret) {
printk(KERN_ERR DRV_NAME ": Error during HW init\n");
return ret;
}
ata_host_resume(host);
}

return 0;
}
#else
#define bfin_atapi_suspend NULL
#define bfin_atapi_resume NULL
#endif

static struct platform_driver bfin_atapi_driver = {
.probe = bfin_atapi_probe,
.remove = __devexit_p(bfin_atapi_remove),
.suspend = bfin_atapi_suspend,
.resume = bfin_atapi_resume,
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
#ifdef CONFIG_PM
.suspend = bfin_atapi_suspend,
.resume = bfin_atapi_resume,
#endif
},
};

Expand Down

0 comments on commit 67e3e22

Please sign in to comment.