2019-07-23 15:15:11

by Chuhong Yuan

[permalink] [raw]
Subject: [PATCH] drivers: ata: Use dev_get_drvdata where possible

Instead of using to_pci_dev + pci_get_drvdata,
use dev_get_drvdata to make code simpler.

Signed-off-by: Chuhong Yuan <[email protected]>
---
drivers/ata/ahci.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index f7652baa6337..58a981cdc83f 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -836,8 +836,7 @@ static void ahci_pci_disable_interrupts(struct ata_host *host)

static int ahci_pci_device_runtime_suspend(struct device *dev)
{
- struct pci_dev *pdev = to_pci_dev(dev);
- struct ata_host *host = pci_get_drvdata(pdev);
+ struct ata_host *host = dev_get_drvdata(dev);

ahci_pci_disable_interrupts(host);
return 0;
@@ -845,8 +844,7 @@ static int ahci_pci_device_runtime_suspend(struct device *dev)

static int ahci_pci_device_runtime_resume(struct device *dev)
{
- struct pci_dev *pdev = to_pci_dev(dev);
- struct ata_host *host = pci_get_drvdata(pdev);
+ struct ata_host *host = dev_get_drvdata(dev);
int rc;

rc = ahci_pci_reset_controller(host);
@@ -859,12 +857,11 @@ static int ahci_pci_device_runtime_resume(struct device *dev)
#ifdef CONFIG_PM_SLEEP
static int ahci_pci_device_suspend(struct device *dev)
{
- struct pci_dev *pdev = to_pci_dev(dev);
- struct ata_host *host = pci_get_drvdata(pdev);
+ struct ata_host *host = dev_get_drvdata(dev);
struct ahci_host_priv *hpriv = host->private_data;

if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
- dev_err(&pdev->dev,
+ dev_err(dev,
"BIOS update required for suspend/resume\n");
return -EIO;
}
--
2.20.1