9 #include <linux/slab.h>
10 #include <linux/module.h>
11 #include <linux/pci.h>
23 return attribute->
show ? attribute->
show(slot, buf) : -
EIO;
27 struct attribute *attr,
const char *buf,
size_t len)
31 return attribute->
store ? attribute->
store(slot, buf, len) : -
EIO;
34 static const struct sysfs_ops pci_slot_sysfs_ops = {
35 .show = pci_slot_attr_show,
36 .store = pci_slot_attr_store,
42 return sprintf(buf,
"%04x:%02x\n",
46 return sprintf(buf,
"%04x:%02x:%02x\n",
53 static const char *pci_bus_speed_strings[] = {
84 speed_string = pci_bus_speed_strings[speed];
86 speed_string =
"Unknown";
88 return sprintf(buf,
"%s\n", speed_string);
93 return bus_speed_read(slot->
bus->max_bus_speed, buf);
98 return bus_speed_read(slot->
bus->cur_bus_speed, buf);
101 static void pci_slot_release(
struct kobject *kobj)
106 dev_dbg(&slot->
bus->dev,
"dev %02x, released physical slot %s\n",
107 slot->
number, pci_slot_name(slot));
121 __ATTR(max_bus_speed, (
S_IFREG | S_IRUGO), max_speed_read_file, NULL);
123 __ATTR(cur_bus_speed, (
S_IFREG | S_IRUGO), cur_speed_read_file, NULL);
125 static
struct attribute *pci_slot_default_attrs[] = {
126 &pci_slot_attr_address.attr,
127 &pci_slot_attr_max_speed.attr,
128 &pci_slot_attr_cur_speed.attr,
132 static struct kobj_type pci_slot_ktype = {
133 .sysfs_ops = &pci_slot_sysfs_ops,
134 .release = &pci_slot_release,
135 .default_attrs = pci_slot_default_attrs,
138 static char *make_slot_name(
const char *
name)
170 sprintf(new_name,
"%s-%d", name, dup++);
176 static int rename_slot(
struct pci_slot *slot,
const char *name)
181 if (
strcmp(pci_slot_name(slot), name) == 0)
184 slot_name = make_slot_name(name);
254 char *slot_name =
NULL;
265 slot = get_slot(parent, slot_nr);
269 || (err = rename_slot(slot, name))) {
290 slot_name = make_slot_name(name);
301 INIT_LIST_HEAD(&slot->
list);
308 dev_dbg(&parent->
dev,
"dev %02x, created physical slot %s\n",
309 slot_nr, pci_slot_name(slot));
358 dev_dbg(&slot->
bus->dev,
"dev %02x, dec refcount to %d\n",
367 #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE)
378 struct hotplug_slot *slot = pci_slot->
hotplug;
382 if (!slot || !slot->ops)
399 void pci_hp_remove_module_link(
struct pci_slot *pci_slot)
406 static int pci_slot_init(
void)
408 struct kset *pci_bus_kset;
412 &pci_bus_kset->
kobj);
413 if (!pci_slots_kset) {