diff mbox

[2/2] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead

Message ID 51711236.9070305@cn.fujitsu.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Gu Zheng April 19, 2013, 9:45 a.m. UTC
From 2535fb1a2502b3d9bebc31f7c7205f42392ea5f9 Mon Sep 17 00:00:00 2001
From: Gu Zheng <guz.fnst@cn.fujitsu.com>
Date: Fri, 19 Apr 2013 17:46:36 +0900
Subject: [PATCH 2/2] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead

Use the new pci_alloc_dev(bus) to replace the existing using of alloc_pci_dev(void).

Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
---
 arch/powerpc/kernel/pci_of_scan.c |    3 +--
 drivers/char/agp/alpha-agp.c      |    2 +-
 drivers/char/agp/parisc-agp.c     |    2 +-
 drivers/pci/iov.c                 |    2 +-
 drivers/pci/probe.c               |    3 +--
 drivers/scsi/megaraid.c           |    2 +-
 6 files changed, 6 insertions(+), 8 deletions(-)

Comments

Bjorn Helgaas April 19, 2013, 5:35 p.m. UTC | #1
On Fri, Apr 19, 2013 at 3:45 AM, Gu Zheng <guz.fnst@cn.fujitsu.com> wrote:
> From 2535fb1a2502b3d9bebc31f7c7205f42392ea5f9 Mon Sep 17 00:00:00 2001
> From: Gu Zheng <guz.fnst@cn.fujitsu.com>
> Date: Fri, 19 Apr 2013 17:46:36 +0900
> Subject: [PATCH 2/2] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead
>
> Use the new pci_alloc_dev(bus) to replace the existing using of alloc_pci_dev(void).

You didn't do anything with Yinghai's comment.  He's 100% correct: you
have to add the put_device() that corresponds to the new get_device()
calls you're adding.  Both have to be in the same patch.

> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
> ---
>  arch/powerpc/kernel/pci_of_scan.c |    3 +--
>  drivers/char/agp/alpha-agp.c      |    2 +-
>  drivers/char/agp/parisc-agp.c     |    2 +-
>  drivers/pci/iov.c                 |    2 +-
>  drivers/pci/probe.c               |    3 +--
>  drivers/scsi/megaraid.c           |    2 +-
>  6 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
> index 2a67e9b..24d01c4 100644
> --- a/arch/powerpc/kernel/pci_of_scan.c
> +++ b/arch/powerpc/kernel/pci_of_scan.c
> @@ -128,7 +128,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
>         const char *type;
>         struct pci_slot *slot;
>
> -       dev = alloc_pci_dev();
> +       dev = pci_alloc_dev(bus);
>         if (!dev)
>                 return NULL;
>         type = of_get_property(node, "device_type", NULL);
> @@ -137,7 +137,6 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
>
>         pr_debug("    create device, devfn: %x, type: %s\n", devfn, type);
>
> -       dev->bus = bus;
>         dev->dev.of_node = of_node_get(node);
>         dev->dev.parent = bus->bridge;
>         dev->dev.bus = &pci_bus_type;
> diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
> index dd84af4..199b8e9 100644
> --- a/drivers/char/agp/alpha-agp.c
> +++ b/drivers/char/agp/alpha-agp.c
> @@ -174,7 +174,7 @@ alpha_core_agp_setup(void)
>         /*
>          * Build a fake pci_dev struct
>          */
> -       pdev = alloc_pci_dev();
> +       pdev = pci_alloc_dev(NULL);
>         if (!pdev)
>                 return -ENOMEM;
>         pdev->vendor = 0xffff;
> diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
> index 94821ab..bf5d247 100644
> --- a/drivers/char/agp/parisc-agp.c
> +++ b/drivers/char/agp/parisc-agp.c
> @@ -333,7 +333,7 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)
>         struct agp_bridge_data *bridge;
>         int error = 0;
>
> -       fake_bridge_dev = alloc_pci_dev();
> +       fake_bridge_dev = pci_alloc_dev(NULL);
>         if (!fake_bridge_dev) {
>                 error = -ENOMEM;
>                 goto fail;
> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> index ee599f2..dba2031 100644
> --- a/drivers/pci/iov.c
> +++ b/drivers/pci/iov.c
> @@ -76,7 +76,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
>         struct resource *res;
>         struct pci_sriov *iov = dev->sriov;
>
> -       virtfn = alloc_pci_dev();
> +       virtfn = pci_alloc_dev(NULL);
>         if (!virtfn)
>                 return -ENOMEM;
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 5233fb6..59637a6 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1280,11 +1280,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
>         if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
>                 return NULL;
>
> -       dev = alloc_pci_dev();
> +       dev = pci_alloc_dev(bus);
>         if (!dev)
>                 return NULL;
>
> -       dev->bus = bus;
>         dev->devfn = devfn;
>         dev->vendor = l & 0xffff;
>         dev->device = (l >> 16) & 0xffff;
> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
> index 9504ec0..e1660ca 100644
> --- a/drivers/scsi/megaraid.c
> +++ b/drivers/scsi/megaraid.c
> @@ -2025,7 +2025,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
>  static inline int
>  make_local_pdev(adapter_t *adapter, struct pci_dev **pdev)
>  {
> -       *pdev = alloc_pci_dev();
> +       *pdev = pci_alloc_dev(NULL);
>
>         if( *pdev == NULL ) return -1;
>
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gu Zheng April 22, 2013, 3:14 a.m. UTC | #2
On 04/20/2013 01:35 AM, Bjorn Helgaas wrote:

> On Fri, Apr 19, 2013 at 3:45 AM, Gu Zheng <guz.fnst@cn.fujitsu.com> wrote:
>> From 2535fb1a2502b3d9bebc31f7c7205f42392ea5f9 Mon Sep 17 00:00:00 2001
>> From: Gu Zheng <guz.fnst@cn.fujitsu.com>
>> Date: Fri, 19 Apr 2013 17:46:36 +0900
>> Subject: [PATCH 2/2] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead
>>
>> Use the new pci_alloc_dev(bus) to replace the existing using of alloc_pci_dev(void).
> 
> You didn't do anything with Yinghai's comment.  He's 100% correct: you
> have to add the put_device() that corresponds to the new get_device()
> calls you're adding.  Both have to be in the same patch.

Hi Bjorn,
	Thanks for your reminder, Yinghai's comment is completely right, the get_device()/put_device() should come in pairs.
I'll add the put_device() in the next version.

Best regards,
Gu

> 
>> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
>> ---
>>  arch/powerpc/kernel/pci_of_scan.c |    3 +--
>>  drivers/char/agp/alpha-agp.c      |    2 +-
>>  drivers/char/agp/parisc-agp.c     |    2 +-
>>  drivers/pci/iov.c                 |    2 +-
>>  drivers/pci/probe.c               |    3 +--
>>  drivers/scsi/megaraid.c           |    2 +-
>>  6 files changed, 6 insertions(+), 8 deletions(-)
>>
>> diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
>> index 2a67e9b..24d01c4 100644
>> --- a/arch/powerpc/kernel/pci_of_scan.c
>> +++ b/arch/powerpc/kernel/pci_of_scan.c
>> @@ -128,7 +128,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
>>         const char *type;
>>         struct pci_slot *slot;
>>
>> -       dev = alloc_pci_dev();
>> +       dev = pci_alloc_dev(bus);
>>         if (!dev)
>>                 return NULL;
>>         type = of_get_property(node, "device_type", NULL);
>> @@ -137,7 +137,6 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
>>
>>         pr_debug("    create device, devfn: %x, type: %s\n", devfn, type);
>>
>> -       dev->bus = bus;
>>         dev->dev.of_node = of_node_get(node);
>>         dev->dev.parent = bus->bridge;
>>         dev->dev.bus = &pci_bus_type;
>> diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
>> index dd84af4..199b8e9 100644
>> --- a/drivers/char/agp/alpha-agp.c
>> +++ b/drivers/char/agp/alpha-agp.c
>> @@ -174,7 +174,7 @@ alpha_core_agp_setup(void)
>>         /*
>>          * Build a fake pci_dev struct
>>          */
>> -       pdev = alloc_pci_dev();
>> +       pdev = pci_alloc_dev(NULL);
>>         if (!pdev)
>>                 return -ENOMEM;
>>         pdev->vendor = 0xffff;
>> diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
>> index 94821ab..bf5d247 100644
>> --- a/drivers/char/agp/parisc-agp.c
>> +++ b/drivers/char/agp/parisc-agp.c
>> @@ -333,7 +333,7 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)
>>         struct agp_bridge_data *bridge;
>>         int error = 0;
>>
>> -       fake_bridge_dev = alloc_pci_dev();
>> +       fake_bridge_dev = pci_alloc_dev(NULL);
>>         if (!fake_bridge_dev) {
>>                 error = -ENOMEM;
>>                 goto fail;
>> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
>> index ee599f2..dba2031 100644
>> --- a/drivers/pci/iov.c
>> +++ b/drivers/pci/iov.c
>> @@ -76,7 +76,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
>>         struct resource *res;
>>         struct pci_sriov *iov = dev->sriov;
>>
>> -       virtfn = alloc_pci_dev();
>> +       virtfn = pci_alloc_dev(NULL);
>>         if (!virtfn)
>>                 return -ENOMEM;
>>
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 5233fb6..59637a6 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1280,11 +1280,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
>>         if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
>>                 return NULL;
>>
>> -       dev = alloc_pci_dev();
>> +       dev = pci_alloc_dev(bus);
>>         if (!dev)
>>                 return NULL;
>>
>> -       dev->bus = bus;
>>         dev->devfn = devfn;
>>         dev->vendor = l & 0xffff;
>>         dev->device = (l >> 16) & 0xffff;
>> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
>> index 9504ec0..e1660ca 100644
>> --- a/drivers/scsi/megaraid.c
>> +++ b/drivers/scsi/megaraid.c
>> @@ -2025,7 +2025,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
>>  static inline int
>>  make_local_pdev(adapter_t *adapter, struct pci_dev **pdev)
>>  {
>> -       *pdev = alloc_pci_dev();
>> +       *pdev = pci_alloc_dev(NULL);
>>
>>         if( *pdev == NULL ) return -1;
>>
>> --
>> 1.7.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index 2a67e9b..24d01c4 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -128,7 +128,7 @@  struct pci_dev *of_create_pci_dev(struct device_node *node,
 	const char *type;
 	struct pci_slot *slot;
 
-	dev = alloc_pci_dev();
+	dev = pci_alloc_dev(bus);
 	if (!dev)
 		return NULL;
 	type = of_get_property(node, "device_type", NULL);
@@ -137,7 +137,6 @@  struct pci_dev *of_create_pci_dev(struct device_node *node,
 
 	pr_debug("    create device, devfn: %x, type: %s\n", devfn, type);
 
-	dev->bus = bus;
 	dev->dev.of_node = of_node_get(node);
 	dev->dev.parent = bus->bridge;
 	dev->dev.bus = &pci_bus_type;
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
index dd84af4..199b8e9 100644
--- a/drivers/char/agp/alpha-agp.c
+++ b/drivers/char/agp/alpha-agp.c
@@ -174,7 +174,7 @@  alpha_core_agp_setup(void)
 	/*
 	 * Build a fake pci_dev struct
 	 */
-	pdev = alloc_pci_dev();
+	pdev = pci_alloc_dev(NULL);
 	if (!pdev)
 		return -ENOMEM;
 	pdev->vendor = 0xffff;
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index 94821ab..bf5d247 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -333,7 +333,7 @@  parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)
 	struct agp_bridge_data *bridge;
 	int error = 0;
 
-	fake_bridge_dev = alloc_pci_dev();
+	fake_bridge_dev = pci_alloc_dev(NULL);
 	if (!fake_bridge_dev) {
 		error = -ENOMEM;
 		goto fail;
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index ee599f2..dba2031 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -76,7 +76,7 @@  static int virtfn_add(struct pci_dev *dev, int id, int reset)
 	struct resource *res;
 	struct pci_sriov *iov = dev->sriov;
 
-	virtfn = alloc_pci_dev();
+	virtfn = pci_alloc_dev(NULL);
 	if (!virtfn)
 		return -ENOMEM;
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 5233fb6..59637a6 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1280,11 +1280,10 @@  static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
 	if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
 		return NULL;
 
-	dev = alloc_pci_dev();
+	dev = pci_alloc_dev(bus);
 	if (!dev)
 		return NULL;
 
-	dev->bus = bus;
 	dev->devfn = devfn;
 	dev->vendor = l & 0xffff;
 	dev->device = (l >> 16) & 0xffff;
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 9504ec0..e1660ca 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -2025,7 +2025,7 @@  megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
 static inline int
 make_local_pdev(adapter_t *adapter, struct pci_dev **pdev)
 {
-	*pdev = alloc_pci_dev();
+	*pdev = pci_alloc_dev(NULL);
 
 	if( *pdev == NULL ) return -1;