Skip to contentSkip to conversation

thunderbolt: Use dev_get_drvdata where possible

PATCH New Chuhong Yuan 1 participant 1 message Jul 24, 2019 Thunderbolt driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thunderbolt: Use dev_get_drvdata where possible

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

---
 drivers/thunderbolt/nhi.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/thunderbolt/nhi.c +7 -12
index 27fbe62c7ddd..76f490759944 100644
@@ -847,8 +847,7 @@ static irqreturn_t nhi_msi(int irq, void *data)
 
 static int nhi_suspend_noirq(struct device *dev)
 {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct tb *tb = pci_get_drvdata(pdev);
+	struct tb *tb = dev_get_drvdata(dev);
 
 	return tb_domain_suspend_noirq(tb);
 }
@@ -889,40 +888,36 @@ static int nhi_resume_noirq(struct device *dev)
 
 static int nhi_suspend(struct device *dev)
 {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct tb *tb = pci_get_drvdata(pdev);
+	struct tb *tb = dev_get_drvdata(dev);
 
 	return tb_domain_suspend(tb);
 }
 
 static void nhi_complete(struct device *dev)
 {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct tb *tb = pci_get_drvdata(pdev);
+	struct tb *tb = dev_get_drvdata(dev);
 
 	/*
 	 * If we were runtime suspended when system suspend started,
 	 * schedule runtime resume now. It should bring the domain back
 	 * to functional state.
 	 */
-	if (pm_runtime_suspended(&pdev->dev))
-		pm_runtime_resume(&pdev->dev);
+	if (pm_runtime_suspended(dev))
+		pm_runtime_resume(dev);
 	else
 		tb_domain_complete(tb);
 }
 
 static int nhi_runtime_suspend(struct device *dev)
 {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct tb *tb = pci_get_drvdata(pdev);
+	struct tb *tb = dev_get_drvdata(dev);
 
 	return tb_domain_runtime_suspend(tb);
 }
 
 static int nhi_runtime_resume(struct device *dev)
 {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct tb *tb = pci_get_drvdata(pdev);
+	struct tb *tb = dev_get_drvdata(dev);
 
 	nhi_enable_int_throttling(tb->nhi);
 	return tb_domain_runtime_resume(tb);
Signature · 1 line
2.20.1