From: Alex Chiang <achiang@hp.com>
To: gregkh@suse.de, kristen.c.accardi@intel.com, lenb@kernel.org,
matthew@wil.cx, rick.jones2@hp.com, linux-kernel@vger.kernel.org,
linux-pci@atrey.karlin.mff.cuni.cz,
pcihpd-discuss@lists.sourceforge.net, linux-acpi@vger.kernel.org,
achiang@hp.com
Subject: [PATCH 5/5] Add pci_slot_add_hotplug() interface
Date: Mon, 12 Nov 2007 17:18:48 -0700 [thread overview]
Message-ID: <20071113001848.GF13341@ldl.fc.hp.com> (raw)
In-Reply-To: <20071113001707.GE13341@ldl.fc.hp.com>
Change the semantics of pci_create_slot() such that it does not
require a hotplug release() method when creating a slot. Now, we
can use this interface to create a pci_slot for any physical PCI
slots, not just hotpluggable ones.
Add new pci_slot_add_hotplug() interface so that various PCI hotplug
drivers can add hotplug release() methods to pre-existing physical
slots.
Signed-off-by: Alex Chiang <achiang@hp.com>
---
drivers/pci/hotplug/pci_hotplug_core.c | 2 +-
drivers/pci/slot.c | 39 +++++++++++++++++++++++++++-----
include/linux/pci.h | 4 ++-
3 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index 96c21e2..91afa8e 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -568,7 +568,7 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
return -EINVAL;
}
- pci_slot = pci_create_slot(bus, slot_nr, slot->name, hotplug_release);
+ pci_slot = pci_slot_add_hotplug(bus, slot_nr, hotplug_release);
if (IS_ERR(pci_slot))
return PTR_ERR(pci_slot);
slot->pci_slot = pci_slot;
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index 5d830d4..3e91491 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -70,20 +70,48 @@ static int create_sysfs_files(struct pci_slot *slot)
return result;
}
+struct pci_slot *pci_slot_add_hotplug(struct pci_bus *parent, int slot_nr,
+ void (*release)(struct pci_slot *))
+{
+ struct pci_slot *slot;
+ int found = 0;
+
+ down_write(&pci_bus_sem);
+
+ /* This slot should have already been created, so look for it. If
+ * we can't find it, return -EEXIST.
+ */
+ for (slot = parent->slot; slot; slot = slot->next)
+ if (slot->number == slot_nr) {
+ found = 1;
+ break;
+ }
+
+ if (!found) {
+ slot = ERR_PTR(-EEXIST);
+ goto out;
+ }
+
+ slot->release = release;
+ out:
+ up_write(&pci_bus_sem);
+ return slot;
+}
+EXPORT_SYMBOL_GPL(pci_slot_add_hotplug);
+
struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
- const char *name, void (*release)(struct pci_slot *))
+ const char *name)
{
struct pci_slot *slot;
int err;
down_write(&pci_bus_sem);
- /* If we've already created this slot, return -EEXIST. The same slot
- * may be described twice (eg, by ACPI and PCIe) */
+ /* If we've already created this slot, just return. */
for (slot = parent->slot; slot; slot = slot->next) {
- if (slot->number != slot_nr)
+ if (slot->number != slot_nr) {
continue;
- slot = ERR_PTR(-EEXIST);
+ }
goto out;
}
@@ -95,7 +123,6 @@ struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
slot->bus = parent;
slot->number = slot_nr;
- slot->release = release;
kobject_set_name(&slot->kobj, "%s", name);
kobj_set_kset_s(slot, pci_slots_subsys);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index a075667..62116a5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -483,7 +483,9 @@ static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *s
struct pci_bus *pci_create_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata);
struct pci_bus * pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr);
struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
- const char *name, void (*release)(struct pci_slot *));
+ const char *name);
+struct pci_slot *pci_slot_add_hotplug(struct pci_bus *parent, int slot_nr,
+ void (*release)(struct pci_slot *));
int pci_scan_slot(struct pci_bus *bus, int devfn);
struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn);
void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
--
1.5.3.1.1.g1e61
next prev parent reply other threads:[~2007-11-13 0:19 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-13 0:08 [PATCH 0/5][RFC] Physical PCI slot objects Alex Chiang
2007-11-13 0:12 ` [PATCH 1/5] Remove path attribute from sgi_hotplug Alex Chiang
2007-11-13 0:13 ` [PATCH 2/5] Construct one fakephp slot per pci slot Alex Chiang
2007-11-13 19:48 ` Linas Vepstas
2007-11-13 19:52 ` Matthew Wilcox
2007-11-14 12:39 ` [Pcihpd-discuss] " Rolf Eike Beer
2007-11-14 14:17 ` Alex Chiang
2007-11-14 14:49 ` Rolf Eike Beer
2007-11-14 15:01 ` Alex Chiang
2007-11-13 0:14 ` [PATCH 3/5, RFC] Introduce pci_slot Alex Chiang
2007-11-13 19:56 ` Linas Vepstas
2007-11-13 20:03 ` Matthew Wilcox
2007-11-13 0:17 ` [PATCH 4/5, RFC] ACPI PCI slot detection driver Alex Chiang
2007-11-13 0:18 ` Alex Chiang [this message]
2007-11-13 17:01 ` [PATCH 0/5][RFC] Physical PCI slot objects Greg KH
2007-11-13 18:33 ` Matthew Wilcox
2007-11-13 18:51 ` Greg KH
2007-11-13 20:11 ` Matthew Wilcox
2007-11-13 20:19 ` Greg KH
2007-11-13 23:08 ` Gary Hade
2007-11-14 1:37 ` Alex Chiang
2007-11-15 0:40 ` Gary Hade
2007-11-15 17:36 ` Alex Chiang
2007-11-15 23:38 ` Gary Hade
2007-11-14 14:42 ` Alex Chiang
2007-11-14 18:13 ` Gary Hade
2007-11-14 18:36 ` Alex Chiang
2007-11-13 20:36 ` Alex Chiang
2007-11-13 21:30 ` Greg KH
2007-11-13 22:01 ` Bjorn Helgaas
2007-11-13 22:16 ` Greg KH
2007-11-13 21:15 ` Matt Domsch
2007-11-13 21:31 ` Alex Chiang
2007-11-13 21:36 ` Greg KH
2007-11-13 23:14 ` Alex Chiang
2007-11-13 21:32 ` Greg KH
2007-11-13 20:21 ` Alex Chiang
2007-11-13 20:26 ` Greg KH
2007-11-13 22:51 ` Rick Jones
2007-11-13 22:56 ` Greg KH
2007-11-13 23:04 ` Matthew Wilcox
2007-11-13 23:07 ` Greg KH
2007-11-14 6:00 ` Scott Murray
2007-11-13 23:33 ` Kristen Carlson Accardi
2007-11-14 0:10 ` Matthew Wilcox
2007-11-14 9:55 ` Kenji Kaneshige
2007-11-14 18:38 ` Kristen Carlson Accardi
2007-11-13 22:59 ` Kristen Carlson Accardi
2007-11-14 17:37 ` Bjorn Helgaas
2007-11-14 17:53 ` Greg KH
2007-11-14 19:53 ` Alex Chiang
2007-11-14 21:24 ` Alex Chiang
2007-11-14 21:42 ` Alex Chiang
2007-11-14 22:00 ` Greg KH
2007-11-15 20:20 ` Alex Chiang
2007-11-14 17:44 ` Matthew Garrett
2007-11-14 17:51 ` Greg KH
2007-11-14 18:03 ` Matthew Garrett
2007-11-13 20:24 ` Linas Vepstas
2007-11-13 20:59 ` Alex Chiang
2007-11-13 21:41 ` Linas Vepstas
2007-11-13 21:58 ` Matthew Wilcox
2007-11-14 1:07 ` Andi Kleen
2007-11-14 14:17 ` Matthew Wilcox
2007-11-14 14:35 ` Andi Kleen
2007-11-14 15:00 ` Matthew Wilcox
2007-11-14 15:08 ` Andi Kleen
2007-11-14 15:12 ` Matthew Wilcox
2007-11-14 15:20 ` Alex Chiang
2007-11-14 11:43 ` Kenji Kaneshige
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=20071113001848.GF13341@ldl.fc.hp.com \
--to=achiang@hp.com \
--cc=gregkh@suse.de \
--cc=kristen.c.accardi@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@atrey.karlin.mff.cuni.cz \
--cc=matthew@wil.cx \
--cc=pcihpd-discuss@lists.sourceforge.net \
--cc=rick.jones2@hp.com \
/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