Skip to contentSkip to conversation

media: pci: Use dev_get_drvdata where possible

PATCH Superseded Chuhong Yuan 3 participants 4 messages Jul 23, 2019 – Jul 25, 2019

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: pci: Use dev_get_drvdata where possible

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

---
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 3 +--
 drivers/media/pci/pt1/pt1.c              | 6 ++----
 drivers/media/pci/pt3/pt3.c              | 6 ++----
 3 files changed, 5 insertions(+), 10 deletions(-)
drivers/media/pci/intel/ipu3/ipu3-cio2.c +1 -2
index c1d133e17e4b..50a34bcd4d14 100644
@@ -2000,8 +2000,7 @@ static int __maybe_unused cio2_suspend(struct device *dev)
 
 static int __maybe_unused cio2_resume(struct device *dev)
 {
-	struct pci_dev *pci_dev = to_pci_dev(dev);
-	struct cio2_device *cio2 = pci_get_drvdata(pci_dev);
+	struct cio2_device *cio2 = dev_get_drvdata(dev);
 	int r = 0;
 	struct cio2_queue *q = cio2->cur_queue;
 
drivers/media/pci/pt1/pt1.c +2 -4
index e51c80bc4646..72b191cfeb54 100644
@@ -1217,8 +1217,7 @@ static void pt1_i2c_init(struct pt1 *pt1)
 
 static int pt1_suspend(struct device *dev)
 {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct pt1 *pt1 = pci_get_drvdata(pdev);
+	struct pt1 *pt1 = dev_get_drvdata(dev);
 
 	pt1_init_streams(pt1);
 	pt1_disable_ram(pt1);
@@ -1230,8 +1229,7 @@ static int pt1_suspend(struct device *dev)
 
 static int pt1_resume(struct device *dev)
 {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct pt1 *pt1 = pci_get_drvdata(pdev);
+	struct pt1 *pt1 = dev_get_drvdata(dev);
 	int ret;
 	int i;
 
drivers/media/pci/pt3/pt3.c +2 -4
index 7a7afae4c84c..c0bc86793355 100644
@@ -626,8 +626,7 @@ static void pt3_cleanup_adapter(struct pt3_board *pt3, int index)
 
 static int pt3_suspend(struct device *dev)
 {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct pt3_board *pt3 = pci_get_drvdata(pdev);
+	struct pt3_board *pt3 = dev_get_drvdata(dev);
 	int i;
 	struct pt3_adapter *adap;
 
@@ -646,8 +645,7 @@ static int pt3_suspend(struct device *dev)
 
 static int pt3_resume(struct device *dev)
 {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct pt3_board *pt3 = pci_get_drvdata(pdev);
+	struct pt3_board *pt3 = dev_get_drvdata(dev);
 	int i, ret;
 	struct pt3_adapter *adap;
 
Signature · 1 line
2.20.1
#1 lore raw

________________________
BRs,
Bingbu Cao

-----Original Message-----
From: Chuhong Yuan <[email protected]>
Sent: Tuesday, July 23, 2019 7:50 PM
Cc: Zhi, Yong <[email protected]>; Sakari Ailus <[email protected]>; Cao, Bingbu <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Akihiro Tsukada <[email protected]>; [email protected]; [email protected]; Chuhong Yuan <[email protected]>
Subject: [PATCH] media: pci: Use dev_get_drvdata where possible

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

---
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 3 +--
 drivers/media/pci/pt1/pt1.c              | 6 ++----
 drivers/media/pci/pt3/pt3.c              | 6 ++----
 3 files changed, 5 insertions(+), 10 deletions(-)
drivers/media/pci/intel/ipu3/ipu3-cio2.c +1 -2
index c1d133e17e4b..50a34bcd4d14 100644
@@ -2000,8 +2000,7 @@ static int __maybe_unused cio2_suspend(struct device *dev)
 
 static int __maybe_unused cio2_resume(struct device *dev)  {
-	struct pci_dev *pci_dev = to_pci_dev(dev);
-	struct cio2_device *cio2 = pci_get_drvdata(pci_dev);
+	struct cio2_device *cio2 = dev_get_drvdata(dev);
 

Thanks for your patch.
I think using pci_get_drvdata() here mainly make a pair with the pci_set_drvdata() in probe.

int r = 0;
struct cio2_queue *q = cio2->cur_queue;

drivers/media/pci/pt1/pt1.c +2 -4
@@ -1217,8 +1217,7 @@ static void pt1_i2c_init(struct pt1 *pt1)
 
 static int pt1_suspend(struct device *dev)  {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct pt1 *pt1 = pci_get_drvdata(pdev);
+	struct pt1 *pt1 = dev_get_drvdata(dev);
 
 	pt1_init_streams(pt1);
 	pt1_disable_ram(pt1);
@@ -1230,8 +1229,7 @@ static int pt1_suspend(struct device *dev)
 
 static int pt1_resume(struct device *dev)  {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct pt1 *pt1 = pci_get_drvdata(pdev);
+	struct pt1 *pt1 = dev_get_drvdata(dev);
 	int ret;
 	int i;
 
drivers/media/pci/pt3/pt3.c +2 -5
@@ -626,8 +626,7 @@ static void pt3_cleanup_adapter(struct pt3_board *pt3, int index)
 
 static int pt3_suspend(struct device *dev)  {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct pt3_board *pt3 = pci_get_drvdata(pdev);
+	struct pt3_board *pt3 = dev_get_drvdata(dev);
 	int i;
 	struct pt3_adapter *adap;
 
@@ -646,8 +645,7 @@ static int pt3_suspend(struct device *dev)
 
 static int pt3_resume(struct device *dev)  {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct pt3_board *pt3 = pci_get_drvdata(pdev);
+	struct pt3_board *pt3 = dev_get_drvdata(dev);
 	int i, ret;
 	struct pt3_adapter *adap;
 
--

2.20.1

#2 lore raw
Quoted 34 lines · Bingbu

________________________
BRs,
Bingbu Cao

-----Original Message-----
From: Chuhong Yuan <[email protected]>
Sent: Tuesday, July 23, 2019 7:50 PM
Cc: Zhi, Yong <[email protected]>; Sakari Ailus <[email protected]>; Cao, Bingbu <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Akihiro Tsukada <[email protected]>; [email protected]; [email protected]; Chuhong Yuan <[email protected]>
Subject: [PATCH] media: pci: Use dev_get_drvdata where possible

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

---
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 3 +--
 drivers/media/pci/pt1/pt1.c              | 6 ++----
 drivers/media/pci/pt3/pt3.c              | 6 ++----
 3 files changed, 5 insertions(+), 10 deletions(-)
drivers/media/pci/intel/ipu3/ipu3-cio2.c +1 -2
index c1d133e17e4b..50a34bcd4d14 100644
@@ -2000,8 +2000,7 @@ static int __maybe_unused cio2_suspend(struct device *dev)
 
 static int __maybe_unused cio2_resume(struct device *dev)  {
-       struct pci_dev *pci_dev = to_pci_dev(dev);
-       struct cio2_device *cio2 = pci_get_drvdata(pci_dev);
+       struct cio2_device *cio2 = dev_get_drvdata(dev);
 
Quoted 2 lines

Thanks for your patch.
I think using pci_get_drvdata() here mainly make a pair with the pci_set_drvdata() in probe.

Thanks for your reply.
I will change pci_set_drvdata() to dev_set_drvdata() in the next version to keep their consistency.

Quoted 49 lines
        int r = 0;
        struct cio2_queue *q = cio2->cur_queue;
drivers/media/pci/pt1/pt1.c +2 -4
@@ -1217,8 +1217,7 @@ static void pt1_i2c_init(struct pt1 *pt1)
 
 static int pt1_suspend(struct device *dev)  {
-       struct pci_dev *pdev = to_pci_dev(dev);
-       struct pt1 *pt1 = pci_get_drvdata(pdev);
+       struct pt1 *pt1 = dev_get_drvdata(dev);
 
        pt1_init_streams(pt1);
        pt1_disable_ram(pt1);
@@ -1230,8 +1229,7 @@ static int pt1_suspend(struct device *dev)
 
 static int pt1_resume(struct device *dev)  {
-       struct pci_dev *pdev = to_pci_dev(dev);
-       struct pt1 *pt1 = pci_get_drvdata(pdev);
+       struct pt1 *pt1 = dev_get_drvdata(dev);
        int ret;
        int i;
 
drivers/media/pci/pt3/pt3.c +2 -5
@@ -626,8 +626,7 @@ static void pt3_cleanup_adapter(struct pt3_board *pt3, int index)
 
 static int pt3_suspend(struct device *dev)  {
-       struct pci_dev *pdev = to_pci_dev(dev);
-       struct pt3_board *pt3 = pci_get_drvdata(pdev);
+       struct pt3_board *pt3 = dev_get_drvdata(dev);
        int i;
        struct pt3_adapter *adap;
 
@@ -646,8 +645,7 @@ static int pt3_suspend(struct device *dev)
 
 static int pt3_resume(struct device *dev)  {
-       struct pci_dev *pdev = to_pci_dev(dev);
-       struct pt3_board *pt3 = pci_get_drvdata(pdev);
+       struct pt3_board *pt3 = dev_get_drvdata(dev);
        int i, ret;
        struct pt3_adapter *adap;
 
--

2.20.1

maintainer
#3 lore raw
Quoted 35 lines · Chuhong Yuan
Quoted 34 lines · Bingbu

________________________
BRs,
Bingbu Cao

-----Original Message-----
From: Chuhong Yuan <[email protected]>
Sent: Tuesday, July 23, 2019 7:50 PM
Cc: Zhi, Yong <[email protected]>; Sakari Ailus <[email protected]>; Cao, Bingbu <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Akihiro Tsukada <[email protected]>; [email protected]; [email protected]; Chuhong Yuan <[email protected]>
Subject: [PATCH] media: pci: Use dev_get_drvdata where possible

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

---
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 3 +--
 drivers/media/pci/pt1/pt1.c              | 6 ++----
 drivers/media/pci/pt3/pt3.c              | 6 ++----
 3 files changed, 5 insertions(+), 10 deletions(-)
drivers/media/pci/intel/ipu3/ipu3-cio2.c +1 -2
index c1d133e17e4b..50a34bcd4d14 100644
@@ -2000,8 +2000,7 @@ static int __maybe_unused cio2_suspend(struct device *dev)
 
 static int __maybe_unused cio2_resume(struct device *dev)  {
-       struct pci_dev *pci_dev = to_pci_dev(dev);
-       struct cio2_device *cio2 = pci_get_drvdata(pci_dev);
+       struct cio2_device *cio2 = dev_get_drvdata(dev);
 
Quoted 6 lines
Quoted 2 lines

Thanks for your patch.
I think using pci_get_drvdata() here mainly make a pair with the pci_set_drvdata() in probe.

Thanks for your reply.
I will change pci_set_drvdata() to dev_set_drvdata() in the next version to keep their consistency.

Sorry guys; I like this one better. These pci_*() functions are just wrappers around the dev_*() equivalents; you can use the one you like at any given occasion. In this case the pci prefixed one is more convenient.

Signature · 4 lines
Kind regards,

Sakari Ailus
[email protected]