From: Alex Chiang <achiang@hp.com>
To: Gary Hade <garyhade@us.ibm.com>, Matthew Wilcox <matthew@wil.cx>,
Greg KH <greg@kroah.com>,
gregkh@suse.de, kristen.c.accardi@intel.com, lenb@kernel.org,
rick.jones2@hp.com, linux-ker
Subject: [PATCH 4/5] Add pci_slot_add_hotplug()
Date: Wed, 14 Nov 2007 12:38:36 -0700 [thread overview]
Message-ID: <20071114193836.GE25002@ldl.fc.hp.com> (raw)
In-Reply-To: <20071114193605.GA25002@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 | 36 +++++++++++++++++++++++++++----
include/linux/pci.h | 4 ++-
3 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index c667684..c4b3e61 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 5f0b69b..61e86b2 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -71,20 +71,47 @@ 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)
continue;
- slot = ERR_PTR(-EEXIST);
goto out;
}
@@ -96,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
WARNING: multiple messages have this Message-ID (diff)
From: Alex Chiang <achiang@hp.com>
To: Gary Hade <garyhade@us.ibm.com>, Matthew Wilcox <matthew@wil.cx>,
Greg KH <greg@kroah.com>,
gregkh@suse.de, kristen.c.accardi@intel.com, lenb@kernel.org,
rick.jones2@hp.com, linux-kernel@vger.kernel.org,
linux-pci@atrey.karlin.mff.cuni.cz,
kaneshige.kenji@jp.fujitsu.com,
pcihpd-discuss@lists.sourceforge.net, linux-acpi@vger.kernel.org
Subject: [PATCH 4/5] Add pci_slot_add_hotplug()
Date: Wed, 14 Nov 2007 12:38:36 -0700 [thread overview]
Message-ID: <20071114193836.GE25002@ldl.fc.hp.com> (raw)
In-Reply-To: <20071114193605.GA25002@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 | 36 +++++++++++++++++++++++++++----
include/linux/pci.h | 4 ++-
3 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index c667684..c4b3e61 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 5f0b69b..61e86b2 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -71,20 +71,47 @@ 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)
continue;
- slot = ERR_PTR(-EEXIST);
goto out;
}
@@ -96,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-14 19:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-14 19:36 [PATCH 0/5, v2] Physical PCI slot objects Alex Chiang
2007-11-14 19:37 ` [PATCH 1/5] Remove path attribute from sgi_hotplug Alex Chiang
2007-11-14 19:37 ` Alex Chiang
2007-11-14 19:37 ` [PATCH 2/5] Construct one fakephp slot per pci slot Alex Chiang
2007-11-14 19:37 ` Alex Chiang
2007-11-14 20:12 ` Matthew Wilcox
2007-11-14 20:12 ` Matthew Wilcox
2007-11-14 20:55 ` Alex Chiang
2007-11-15 11:57 ` Rolf Eike Beer
2007-11-15 17:40 ` Alex Chiang
2007-11-14 21:04 ` Alex Chiang
2007-11-14 19:37 ` [PATCH 3/5] Introduce pci_slot Alex Chiang
2007-11-14 19:37 ` Alex Chiang
2007-11-14 19:38 ` Alex Chiang [this message]
2007-11-14 19:38 ` [PATCH 4/5] Add pci_slot_add_hotplug() Alex Chiang
2007-11-14 19:39 ` [PATCH 5/5] ACPI PCI slot detection driver Alex Chiang
2007-11-14 19:39 ` Alex Chiang
2007-11-15 0:39 ` [PATCH 0/5, v2] Physical PCI slot objects Gary Hade
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=20071114193836.GE25002@ldl.fc.hp.com \
--to=achiang@hp.com \
--cc=garyhade@us.ibm.com \
--cc=greg@kroah.com \
--cc=gregkh@suse.de \
--cc=kristen.c.accardi@intel.com \
--cc=lenb@kernel.org \
--cc=matthew@wil.cx \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.