From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI and PCI Hotplug update for 2.6.6-rc1
Date: Thu, 15 Apr 2004 10:23:46 -0700 [thread overview]
Message-ID: <1082049826704@kroah.com> (raw)
In-Reply-To: <10820498261812@kroah.com>
ChangeSet 1.1692.3.12, 2004/04/12 16:57:12-07:00, lxiep@us.ibm.com
[PATCH] PCI Hotplug: php_phy_location.patch
Adds a file to show the pci hotplug slot location for the ppc64 driver
only.
drivers/pci/hotplug/rpadlpar_core.c | 23 +++-------
drivers/pci/hotplug/rpaphp.h | 2
drivers/pci/hotplug/rpaphp_core.c | 23 +++-------
drivers/pci/hotplug/rpaphp_slot.c | 80 ++++++++++++++++++------------------
4 files changed, 59 insertions(+), 69 deletions(-)
diff -Nru a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
--- a/drivers/pci/hotplug/rpadlpar_core.c Thu Apr 15 10:03:42 2004
+++ b/drivers/pci/hotplug/rpadlpar_core.c Thu Apr 15 10:03:42 2004
@@ -79,25 +79,18 @@
return np;
}
-static inline struct hotplug_slot *find_php_slot(char *drc_name)
-{
- struct kobject *k;
-
- k = kset_find_obj(&pci_hotplug_slots_subsys.kset, drc_name);
- if (!k)
- return NULL;
-
- return to_hotplug_slot(k);
-}
-
static struct slot *find_slot(char *drc_name)
{
- struct hotplug_slot *php_slot = find_php_slot(drc_name);
+ struct list_head *tmp, *n;
+ struct slot *slot;
- if (!php_slot)
- return NULL;
+ list_for_each_safe(tmp, n, &rpaphp_slot_head) {
+ slot = list_entry(tmp, struct slot, rpaphp_slot_list);
+ if (strcmp(slot->location, drc_name) == 0)
+ return slot;
+ }
- return (struct slot *) php_slot->private;
+ return NULL;
}
static void rpadlpar_claim_one_bus(struct pci_bus *b)
diff -Nru a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
--- a/drivers/pci/hotplug/rpaphp.h Thu Apr 15 10:03:42 2004
+++ b/drivers/pci/hotplug/rpaphp.h Thu Apr 15 10:03:42 2004
@@ -85,6 +85,7 @@
u32 type;
u32 power_domain;
char *name;
+ char *location;
struct device_node *dn; /* slot's device_node in OFDT */
/* dn has phb info */
struct pci_dev *bridge; /* slot's pci_dev in pci_devices */
@@ -129,5 +130,6 @@
extern int register_slot(struct slot *slot);
extern int rpaphp_get_power_status(struct slot *slot, u8 * value);
extern int rpaphp_set_attention_status(struct slot *slot, u8 status);
+extern void rpaphp_sysfs_remove_attr_location(struct hotplug_slot *slot);
#endif /* _PPC64PHP_H */
diff -Nru a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
--- a/drivers/pci/hotplug/rpaphp_core.c Thu Apr 15 10:03:42 2004
+++ b/drivers/pci/hotplug/rpaphp_core.c Thu Apr 15 10:03:42 2004
@@ -246,17 +246,14 @@
int rpaphp_remove_slot(struct slot *slot)
{
int retval = 0;
- char *rm_link;
+ struct hotplug_slot *php_slot = slot->hotplug_slot;
- dbg("%s - Entry: slot[%s]\n", __FUNCTION__, slot->name);
- if (slot->dev_type == PCI_DEV)
- rm_link = pci_name(slot->bridge);
- else
- rm_link = strstr(slot->dn->full_name, "@");
-
- sysfs_remove_link(slot->hotplug_slot->kobj.parent, rm_link);
list_del(&slot->rpaphp_slot_list);
- retval = pci_hp_deregister(slot->hotplug_slot);
+
+ /* remove "php_location" file */
+ rpaphp_sysfs_remove_attr_location(php_slot);
+
+ retval = pci_hp_deregister(php_slot);
if (retval)
err("Problem unregistering a slot %s\n", slot->name);
@@ -380,14 +377,7 @@
*/
list_for_each_safe(tmp, n, &rpaphp_slot_head) {
- char *rm_link;
-
slot = list_entry(tmp, struct slot, rpaphp_slot_list);
- if (slot->dev_type == PCI_DEV)
- rm_link = pci_name(slot->bridge);
- else
- rm_link = strstr(slot->dn->full_name, "@");
- sysfs_remove_link(slot->hotplug_slot->kobj.parent, rm_link);
list_del(&slot->rpaphp_slot_list);
pci_hp_deregister(slot->hotplug_slot);
}
@@ -478,3 +468,4 @@
EXPORT_SYMBOL_GPL(rpaphp_add_slot);
EXPORT_SYMBOL_GPL(rpaphp_remove_slot);
+EXPORT_SYMBOL_GPL(rpaphp_slot_head);
diff -Nru a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
--- a/drivers/pci/hotplug/rpaphp_slot.c Thu Apr 15 10:03:42 2004
+++ b/drivers/pci/hotplug/rpaphp_slot.c Thu Apr 15 10:03:42 2004
@@ -29,8 +29,36 @@
#include <linux/pci.h>
#include "rpaphp.h"
-/* free up the memory user by a slot */
+static ssize_t location_read_file (struct hotplug_slot *php_slot, char *buf)
+{
+ char *value;
+ int retval = -ENOENT;
+ struct slot *slot = (struct slot *)php_slot->private;
+
+ if (!slot)
+ return retval;
+
+ value = slot->location;
+ retval = sprintf (buf, "%s\n", value);
+ return retval;
+}
+static struct hotplug_slot_attribute hotplug_slot_attr_location = {
+ .attr = {.name = "phy_location", .mode = S_IFREG | S_IRUGO},
+ .show = location_read_file,
+};
+
+static void rpaphp_sysfs_add_attr_location (struct hotplug_slot *slot)
+{
+ sysfs_create_file(&slot->kobj, &hotplug_slot_attr_location.attr);
+}
+
+void rpaphp_sysfs_remove_attr_location (struct hotplug_slot *slot)
+{
+ sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_location.attr);
+}
+
+/* free up the memory user by a slot */
static void rpaphp_release_slot(struct hotplug_slot *hotplug_slot)
{
struct slot *slot = hotplug_slot? (struct slot *) hotplug_slot->private:NULL;
@@ -76,17 +104,25 @@
return (NULL);
}
memset(slot->hotplug_slot->info, 0, sizeof (struct hotplug_slot_info));
- slot->hotplug_slot->name = kmalloc(strlen(drc_name) + 1, GFP_KERNEL);
+ slot->hotplug_slot->name = kmalloc(BUS_ID_SIZE + 1, GFP_KERNEL);
if (!slot->hotplug_slot->name) {
kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot);
kfree(slot);
return (NULL);
}
+ slot->location = kmalloc(strlen(drc_name) + 1, GFP_KERNEL);
+ if (!slot->location) {
+ kfree(slot->hotplug_slot->info);
+ kfree(slot->hotplug_slot->name);
+ kfree(slot->hotplug_slot);
+ kfree(slot);
+ return (NULL);
+ }
slot->name = slot->hotplug_slot->name;
slot->dn = dn;
slot->index = drc_index;
- strcpy(slot->name, drc_name);
+ strcpy(slot->location, drc_name);
slot->power_domain = power_domain;
slot->magic = SLOT_MAGIC;
slot->hotplug_slot->private = slot;
@@ -110,41 +146,9 @@
rpaphp_release_slot(slot->hotplug_slot);
return (retval);
}
- switch (slot->dev_type) {
- case PCI_DEV:
- /* create symlink between slot->name and it's bus_id */
-
- dbg("%s: sysfs_create_link: %s --> %s\n", __FUNCTION__,
- pci_name(slot->bridge), slot->name);
-
- retval = sysfs_create_link(slot->hotplug_slot->kobj.parent,
- &slot->hotplug_slot->kobj,
- pci_name(slot->bridge));
- if (retval) {
- err("sysfs_create_link failed with error %d\n", retval);
- rpaphp_release_slot(slot->hotplug_slot);
- return (retval);
- }
- break;
- case VIO_DEV:
- /* create symlink between slot->name and it's uni-address */
- vio_uni_addr = strchr(slot->dn->full_name, '@');
- if (!vio_uni_addr)
- return (1);
- dbg("%s: sysfs_create_link: %s --> %s\n", __FUNCTION__,
- vio_uni_addr, slot->name);
- retval = sysfs_create_link(slot->hotplug_slot->kobj.parent,
- &slot->hotplug_slot->kobj,
- vio_uni_addr);
- if (retval) {
- err("sysfs_create_link failed with error %d\n", retval);
- rpaphp_release_slot(slot->hotplug_slot);
- return (retval);
- }
- break;
- default:
- return (1);
- }
+
+ /* create "phy_locatoin" file */
+ rpaphp_sysfs_add_attr_location(slot->hotplug_slot);
/* add slot to our internal list */
dbg("%s adding slot[%s] to rpaphp_slot_list\n",
prev parent reply other threads:[~2004-04-15 19:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-15 17:19 [BK PATCH] PCI and PCI Hotplug update for 2.6.6-rc1 Greg KH
2004-04-15 17:23 ` [PATCH] " Greg KH
2004-04-15 17:23 ` Greg KH
2004-04-15 17:23 ` Greg KH
2004-04-15 17:23 ` Greg KH
2004-04-15 17:23 ` Greg KH
2004-04-15 17:23 ` Greg KH
2004-04-15 17:23 ` Greg KH
2004-04-15 17:23 ` Greg KH
2004-04-15 17:23 ` Greg KH
2004-04-15 17:23 ` Greg KH
2004-04-15 17:23 ` Greg KH
2004-04-15 17:23 ` Greg KH [this message]
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=1082049826704@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.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 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.