From: Gu Zheng <guz.fnst@cn.fujitsu.com>
To: Bjorn Helgaas <bhelgaas@google.com>, Yinghai Lu <yinghai@kernel.org>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>,
Taku Izumi <izumi.taku@jp.fujitsu.com>,
Jiang Liu <jiang.liu@huawei.com>,
tangchen <tangchen@cn.fujitsu.com>,
Lin Feng <linfeng@cn.fujitsu.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
guz.fnst@cn.fujitsu.com
Subject: [PATCH v2 1/4] PCI: Introduce pci_alloc_dev(struct pci_bus*) to replace alloc_pci_dev()
Date: Tue, 30 Apr 2013 19:31:21 +0800 [thread overview]
Message-ID: <517FAB89.6080702@cn.fujitsu.com> (raw)
In-Reply-To: <CAErSpo65ARR_fZwsGCZDJqbPWktHYUkufgPt-2mWwur=nPR1Qg@mail.gmail.com>
>From 888e824c01f9c039622a2ab74c3df3b884fd7b12 Mon Sep 17 00:00:00 2001
From: Gu Zheng <guz.fnst@cn.fujitsu.com>
Date: Mon, 22 Apr 2013 19:04:07 +0900
Subject: [PATCH v2 1/4] PCI: Introduce pci_alloc_dev(struct pci_bus*) to replace
alloc_pci_dev()
Now here we introduce a new struct pci_dev *pci_alloc_dev(struct pci_bus *bus) to replace alloc_pci_dev().
It take a "struct pci_bus *" argument, so we can alloc a pci device on a target pci bus, and it acquire
the reference of the pci_bus.
We use pci_alloc_dev(NULL) to simplify the old alloc_pci_dev(), and keep it for a while but mark it as __deprecated.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
---
drivers/pci/probe.c | 13 ++++++++++++-
include/linux/pci.h | 4 +++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 43ece5d..89db76a 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1201,7 +1201,7 @@ static void pci_release_bus_bridge_dev(struct device *dev)
kfree(bridge);
}
-struct pci_dev *alloc_pci_dev(void)
+struct pci_dev *pci_alloc_dev(struct pci_bus *bus)
{
struct pci_dev *dev;
@@ -1211,8 +1211,19 @@ struct pci_dev *alloc_pci_dev(void)
INIT_LIST_HEAD(&dev->bus_list);
+ if (bus) {
+ get_device(&bus->dev);
+ dev->bus = bus;
+ }
+
return dev;
}
+EXPORT_SYMBOL(pci_alloc_dev);
+
+struct pci_dev *alloc_pci_dev(void)
+{
+ return pci_alloc_dev(NULL);
+}
EXPORT_SYMBOL(alloc_pci_dev);
bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e73dfa3..6c09949 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -364,7 +364,9 @@ static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
return dev;
}
-struct pci_dev *alloc_pci_dev(void);
+struct pci_dev *pci_alloc_dev(struct pci_bus *bus);
+
+__deprecated struct pci_dev *alloc_pci_dev(void);
#define to_pci_dev(n) container_of(n, struct pci_dev, dev)
#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
--
1.7.7
next parent reply other threads:[~2013-04-30 11:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <516FB647.5030203@cn.fujitsu.com>
[not found] ` <CAErSpo65ARR_fZwsGCZDJqbPWktHYUkufgPt-2mWwur=nPR1Qg@mail.gmail.com>
2013-04-30 11:31 ` Gu Zheng [this message]
2013-04-30 11:31 ` [PATCH v2 2/4] PCI: introduce pci_bus_get()/pci_bus_put() to hide pci_bus' reference management Gu Zheng
2013-04-30 11:31 ` [PATCH v2 3/4] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead Gu Zheng
2013-04-30 11:31 ` [PATCH v2 4/4] PCI: Check if the pci device get removed from pci tree already in remove_callback() Gu Zheng
2013-05-08 22:32 ` Bjorn Helgaas
2013-05-09 2:23 ` Gu Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=517FAB89.6080702@cn.fujitsu.com \
--to=guz.fnst@cn.fujitsu.com \
--cc=bhelgaas@google.com \
--cc=isimatu.yasuaki@jp.fujitsu.com \
--cc=izumi.taku@jp.fujitsu.com \
--cc=jiang.liu@huawei.com \
--cc=linfeng@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=tangchen@cn.fujitsu.com \
--cc=yinghai@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox