linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: pci: Use dev_get_drvdata where possible
@ 2019-07-23 11:50 Chuhong Yuan
  2019-07-23 14:39 ` Cao, Bingbu
  0 siblings, 1 reply; 4+ messages in thread
From: Chuhong Yuan @ 2019-07-23 11:50 UTC (permalink / raw)
  Cc: Yong Zhi, Sakari Ailus, Bingbu Cao, Mauro Carvalho Chehab,
	Akihiro Tsukada, linux-media, linux-kernel, Chuhong Yuan

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

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
 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(-)

diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
index c1d133e17e4b..50a34bcd4d14 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
@@ -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;
 
diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c
index e51c80bc4646..72b191cfeb54 100644
--- a/drivers/media/pci/pt1/pt1.c
+++ b/drivers/media/pci/pt1/pt1.c
@@ -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;
 
diff --git a/drivers/media/pci/pt3/pt3.c b/drivers/media/pci/pt3/pt3.c
index 7a7afae4c84c..c0bc86793355 100644
--- a/drivers/media/pci/pt3/pt3.c
+++ b/drivers/media/pci/pt3/pt3.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH] media: pci: Use dev_get_drvdata where possible
  2019-07-23 11:50 [PATCH] media: pci: Use dev_get_drvdata where possible Chuhong Yuan
@ 2019-07-23 14:39 ` Cao, Bingbu
  2019-07-24  1:23   ` Chuhong Yuan
  0 siblings, 1 reply; 4+ messages in thread
From: Cao, Bingbu @ 2019-07-23 14:39 UTC (permalink / raw)
  To: Chuhong Yuan
  Cc: Zhi, Yong, Sakari Ailus, Mauro Carvalho Chehab, Akihiro Tsukada,
	linux-media, linux-kernel



________________________
BRs,  
Bingbu Cao                          


-----Original Message-----
From: Chuhong Yuan <hslester96@gmail.com> 
Sent: Tuesday, July 23, 2019 7:50 PM
Cc: Zhi, Yong <yong.zhi@intel.com>; Sakari Ailus <sakari.ailus@linux.intel.com>; Cao, Bingbu <bingbu.cao@intel.com>; Mauro Carvalho Chehab <mchehab@kernel.org>; Akihiro Tsukada <tskd08@gmail.com>; linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; Chuhong Yuan <hslester96@gmail.com>
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.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
 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(-)

diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
index c1d133e17e4b..50a34bcd4d14 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
@@ -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;
 
diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c index e51c80bc4646..72b191cfeb54 100644
--- a/drivers/media/pci/pt1/pt1.c
+++ b/drivers/media/pci/pt1/pt1.c
@@ -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;
 
diff --git a/drivers/media/pci/pt3/pt3.c b/drivers/media/pci/pt3/pt3.c index 7a7afae4c84c..c0bc86793355 100644
--- a/drivers/media/pci/pt3/pt3.c
+++ b/drivers/media/pci/pt3/pt3.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: pci: Use dev_get_drvdata where possible
  2019-07-23 14:39 ` Cao, Bingbu
@ 2019-07-24  1:23   ` Chuhong Yuan
  2019-07-25  9:14     ` Sakari Ailus
  0 siblings, 1 reply; 4+ messages in thread
From: Chuhong Yuan @ 2019-07-24  1:23 UTC (permalink / raw)
  To: Cao, Bingbu
  Cc: Zhi, Yong, Sakari Ailus, Mauro Carvalho Chehab, Akihiro Tsukada,
	linux-media, linux-kernel

On Tue, Jul 23, 2019 at 10:39 PM Cao, Bingbu <bingbu.cao@intel.com> wrote:
>
>
>
> ________________________
> BRs,
> Bingbu Cao
>
>
> -----Original Message-----
> From: Chuhong Yuan <hslester96@gmail.com>
> Sent: Tuesday, July 23, 2019 7:50 PM
> Cc: Zhi, Yong <yong.zhi@intel.com>; Sakari Ailus <sakari.ailus@linux.intel.com>; Cao, Bingbu <bingbu.cao@intel.com>; Mauro Carvalho Chehab <mchehab@kernel.org>; Akihiro Tsukada <tskd08@gmail.com>; linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; Chuhong Yuan <hslester96@gmail.com>
> 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.
>
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> ---
>  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(-)
>
> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> index c1d133e17e4b..50a34bcd4d14 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> @@ -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.

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

>
>         int r = 0;
>         struct cio2_queue *q = cio2->cur_queue;
>
> diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c index e51c80bc4646..72b191cfeb54 100644
> --- a/drivers/media/pci/pt1/pt1.c
> +++ b/drivers/media/pci/pt1/pt1.c
> @@ -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;
>
> diff --git a/drivers/media/pci/pt3/pt3.c b/drivers/media/pci/pt3/pt3.c index 7a7afae4c84c..c0bc86793355 100644
> --- a/drivers/media/pci/pt3/pt3.c
> +++ b/drivers/media/pci/pt3/pt3.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: pci: Use dev_get_drvdata where possible
  2019-07-24  1:23   ` Chuhong Yuan
@ 2019-07-25  9:14     ` Sakari Ailus
  0 siblings, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2019-07-25  9:14 UTC (permalink / raw)
  To: Chuhong Yuan
  Cc: Cao, Bingbu, Zhi, Yong, Mauro Carvalho Chehab, Akihiro Tsukada,
	linux-media, linux-kernel

On Wed, Jul 24, 2019 at 09:23:41AM +0800, Chuhong Yuan wrote:
> On Tue, Jul 23, 2019 at 10:39 PM Cao, Bingbu <bingbu.cao@intel.com> wrote:
> >
> >
> >
> > ________________________
> > BRs,
> > Bingbu Cao
> >
> >
> > -----Original Message-----
> > From: Chuhong Yuan <hslester96@gmail.com>
> > Sent: Tuesday, July 23, 2019 7:50 PM
> > Cc: Zhi, Yong <yong.zhi@intel.com>; Sakari Ailus <sakari.ailus@linux.intel.com>; Cao, Bingbu <bingbu.cao@intel.com>; Mauro Carvalho Chehab <mchehab@kernel.org>; Akihiro Tsukada <tskd08@gmail.com>; linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; Chuhong Yuan <hslester96@gmail.com>
> > 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.
> >
> > Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> > ---
> >  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(-)
> >
> > diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> > index c1d133e17e4b..50a34bcd4d14 100644
> > --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> > +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> > @@ -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.
> 
> 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.

-- 
Kind regards,

Sakari Ailus
sakari.ailus@linux.intel.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-07-25  9:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-23 11:50 [PATCH] media: pci: Use dev_get_drvdata where possible Chuhong Yuan
2019-07-23 14:39 ` Cao, Bingbu
2019-07-24  1:23   ` Chuhong Yuan
2019-07-25  9:14     ` Sakari Ailus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).