From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, pcihpd-discuss@lists.sourceforge.net
Subject: Re: [PATCH] PCI Hotplug changes for 2.5.59
Date: Wed, 5 Feb 2003 20:08 -0800 [thread overview]
Message-ID: <1044504487837@kroah.com> (raw)
In-Reply-To: <10445044863071@kroah.com>
ChangeSet 1.947.23.7, 2003/02/05 17:19:09+11:00, greg@kroah.com
[PATCH] PCI Hotplug: Make pci_hp_change_slot_info() work again
Relies on sysfs_update_file() to be present in the kernel.
diff -Nru a/drivers/hotplug/pci_hotplug_core.c b/drivers/hotplug/pci_hotplug_core.c
--- a/drivers/hotplug/pci_hotplug_core.c Thu Feb 6 14:51:57 2003
+++ b/drivers/hotplug/pci_hotplug_core.c Thu Feb 6 14:51:57 2003
@@ -39,7 +39,6 @@
#include <linux/mount.h>
#include <linux/namei.h>
#include <linux/pci.h>
-#include <linux/dnotify.h>
#include <asm/uaccess.h>
#include <linux/kobject.h>
#include <linux/sysfs.h>
@@ -385,58 +384,119 @@
.store = test_write_file
};
-static int fs_add_slot (struct hotplug_slot *slot)
+static int has_power_file (struct hotplug_slot *slot)
{
+ if ((!slot) || (!slot->ops))
+ return -ENODEV;
if ((slot->ops->enable_slot) ||
(slot->ops->disable_slot) ||
(slot->ops->get_power_status))
- sysfs_create_file(&slot->kobj, &hotplug_slot_attr_power.attr);
+ return 0;
+ return -ENOENT;
+}
+static int has_attention_file (struct hotplug_slot *slot)
+{
+ if ((!slot) || (!slot->ops))
+ return -ENODEV;
if ((slot->ops->set_attention_status) ||
(slot->ops->get_attention_status))
- sysfs_create_file(&slot->kobj, &hotplug_slot_attr_attention.attr);
+ return 0;
+ return -ENOENT;
+}
+static int has_latch_file (struct hotplug_slot *slot)
+{
+ if ((!slot) || (!slot->ops))
+ return -ENODEV;
if (slot->ops->get_latch_status)
- sysfs_create_file(&slot->kobj, &hotplug_slot_attr_latch.attr);
+ return 0;
+ return -ENOENT;
+}
+static int has_adapter_file (struct hotplug_slot *slot)
+{
+ if ((!slot) || (!slot->ops))
+ return -ENODEV;
if (slot->ops->get_adapter_status)
- sysfs_create_file(&slot->kobj, &hotplug_slot_attr_presence.attr);
+ return 0;
+ return -ENOENT;
+}
+static int has_max_bus_speed_file (struct hotplug_slot *slot)
+{
+ if ((!slot) || (!slot->ops))
+ return -ENODEV;
if (slot->ops->get_max_bus_speed)
- sysfs_create_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr);
+ return 0;
+ return -ENOENT;
+}
+static int has_cur_bus_speed_file (struct hotplug_slot *slot)
+{
+ if ((!slot) || (!slot->ops))
+ return -ENODEV;
if (slot->ops->get_cur_bus_speed)
- sysfs_create_file(&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr);
+ return 0;
+ return -ENOENT;
+}
+static int has_test_file (struct hotplug_slot *slot)
+{
+ if ((!slot) || (!slot->ops))
+ return -ENODEV;
if (slot->ops->hardware_test)
+ return 0;
+ return -ENOENT;
+}
+
+static int fs_add_slot (struct hotplug_slot *slot)
+{
+ if (has_power_file(slot) == 0)
+ sysfs_create_file(&slot->kobj, &hotplug_slot_attr_power.attr);
+
+ if (has_attention_file(slot) == 0)
+ sysfs_create_file(&slot->kobj, &hotplug_slot_attr_attention.attr);
+
+ if (has_latch_file(slot) == 0)
+ sysfs_create_file(&slot->kobj, &hotplug_slot_attr_latch.attr);
+
+ if (has_adapter_file(slot) == 0)
+ sysfs_create_file(&slot->kobj, &hotplug_slot_attr_presence.attr);
+
+ if (has_max_bus_speed_file(slot) == 0)
+ sysfs_create_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr);
+
+ if (has_cur_bus_speed_file(slot) == 0)
+ sysfs_create_file(&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr);
+
+ if (has_test_file(slot) == 0)
sysfs_create_file(&slot->kobj, &hotplug_slot_attr_test.attr);
+
return 0;
}
static void fs_remove_slot (struct hotplug_slot *slot)
{
- if ((slot->ops->enable_slot) ||
- (slot->ops->disable_slot) ||
- (slot->ops->get_power_status))
+ if (has_power_file(slot) == 0)
sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_power.attr);
- if ((slot->ops->set_attention_status) ||
- (slot->ops->get_attention_status))
+ if (has_attention_file(slot) == 0)
sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_attention.attr);
- if (slot->ops->get_latch_status)
+ if (has_latch_file(slot) == 0)
sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_latch.attr);
- if (slot->ops->get_adapter_status)
+ if (has_adapter_file(slot) == 0)
sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_presence.attr);
- if (slot->ops->get_max_bus_speed)
+ if (has_max_bus_speed_file(slot) == 0)
sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr);
- if (slot->ops->get_cur_bus_speed)
+ if (has_cur_bus_speed_file(slot) == 0)
sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr);
- if (slot->ops->hardware_test)
+ if (has_test_file(slot) == 0)
sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_test.attr);
}
@@ -536,10 +596,42 @@
* hotplug subsystem previously with a call to pci_hp_register().
*
* Returns 0 if successful, anything else for an error.
- * Not supported by sysfs now.
*/
int pci_hp_change_slot_info (struct hotplug_slot *slot, struct hotplug_slot_info *info)
{
+ if ((slot == NULL) || (info == NULL))
+ return -ENODEV;
+
+ /*
+ * check all fields in the info structure, and update timestamps
+ * for the files referring to the fields that have now changed.
+ */
+ if ((has_power_file(slot) == 0) &&
+ (slot->info->power_status != info->power_status))
+ sysfs_update_file(&slot->kobj, &hotplug_slot_attr_power.attr);
+
+ if ((has_attention_file(slot) == 0) &&
+ (slot->info->attention_status != info->attention_status))
+ sysfs_update_file(&slot->kobj, &hotplug_slot_attr_attention.attr);
+
+ if ((has_latch_file(slot) == 0) &&
+ (slot->info->latch_status != info->latch_status))
+ sysfs_update_file(&slot->kobj, &hotplug_slot_attr_latch.attr);
+
+ if ((has_adapter_file(slot) == 0) &&
+ (slot->info->adapter_status != info->adapter_status))
+ sysfs_update_file(&slot->kobj, &hotplug_slot_attr_presence.attr);
+
+ if ((has_max_bus_speed_file(slot) == 0) &&
+ (slot->info->max_bus_speed != info->max_bus_speed))
+ sysfs_update_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr);
+
+ if ((has_cur_bus_speed_file(slot) == 0) &&
+ (slot->info->cur_bus_speed != info->cur_bus_speed))
+ sysfs_update_file(&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr);
+
+ memcpy (slot->info, info, sizeof (struct hotplug_slot_info));
+
return 0;
}
next prev parent reply other threads:[~2003-02-06 4:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-06 4:03 [BK PATCH] PCI Hotplug changes for 2.5.59 Greg KH
2003-02-06 4:08 ` [PATCH] " Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH [this message]
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
2003-02-06 4:08 ` Greg KH
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=1044504487837@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pcihpd-discuss@lists.sourceforge.net \
/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