Use .default_attrs for 'address' file. This can simplify the code.
Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
---
drivers/pci/slot.c | 36 +++++++++---------------------------
1 file changed, 9 insertions(+), 27 deletions(-)
Index: linux-2.6.25-rc6/drivers/pci/slot.c
===================================================================
--- linux-2.6.25-rc6.orig/drivers/pci/slot.c
+++ linux-2.6.25-rc6/drivers/pci/slot.c
@@ -39,25 +39,6 @@ static ssize_t address_read_file(struct
slot->bus->number, slot->number);
}
-static struct pci_slot_attribute pci_slot_attr_address = {
- .attr = { .name = "address", .mode = S_IFREG | S_IRUGO },
- .show = address_read_file,
-};
-
-static void remove_sysfs_files(struct pci_slot *slot)
-{
- sysfs_remove_file(&slot->kobj, &pci_slot_attr_address.attr);
-}
-
-static int create_sysfs_files(struct pci_slot *slot)
-{
- int result;
-
- result = sysfs_create_file(&slot->kobj, &pci_slot_attr_address.attr);
-
- return result;
-}
-
static void pci_slot_release(struct kobject *kobj)
{
struct pci_slot *slot = to_pci_slot(kobj);
@@ -67,13 +48,21 @@ static void pci_slot_release(struct kobj
list_del(&slot->list);
- remove_sysfs_files(slot);
kfree(slot);
}
+static struct pci_slot_attribute pci_slot_attr_address =
+ __ATTR(address, (S_IFREG | S_IRUGO), address_read_file, NULL);
+
+static struct attribute *pci_slot_default_attrs[] = {
+ &pci_slot_attr_address.attr,
+ NULL,
+};
+
static struct kobj_type pci_slot_ktype = {
.sysfs_ops = &pci_slot_sysfs_ops,
.release = &pci_slot_release,
+ .default_attrs = pci_slot_default_attrs,
};
struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
@@ -114,10 +103,6 @@ struct pci_slot *pci_create_slot(struct
goto err;
}
- err = create_sysfs_files(slot);
- if (err)
- goto unregister;
-
INIT_LIST_HEAD(&slot->list);
list_add(&slot->list, &parent->slots);
@@ -127,9 +112,6 @@ struct pci_slot *pci_create_slot(struct
out:
up_write(&pci_bus_sem);
return slot;
-
- unregister:
- kobject_put(&slot->kobj);
err:
kfree(slot);
slot = ERR_PTR(err);
--
| David Miller | Slow DOWN, please!!! |
| Tomasz Kłoczko | Is it time for remove (crap) ALSA from kernel tree ? |
| holzheu | [RFC/PATCH] Documentation of kernel messages |
| Jiri Kosina | HID merge plans for 2.6.28 |
git: | |
| ir0s | Local branch ahead of tracked remote branch but git push claims everything up-to-d... |
| Elijah Newren | Trying to use git-filter-branch to compress history by removing large, obsolete bi... |
| Shawn O. Pearce | Re: pack operation is thrashing my server |
| Aubrey Li | git proxy issue |
| KOSAKI Motohiro | [bug?] tg3: Failed to load firmware "tigon/tg3_tso.bin" |
| Jussi Kivilinna | [PATCH 01/14] Fix sparse warning: returning void-valued expression |
| Roland Dreier | Re: setsockopt() |
| Shyam_Iyer | RE: [RFC][PATCH 1/1] cxgb3i: cxgb3 iSCSI initiator |
| L. V. Lammert | 'Nother broken package - git-1.5.4.2 |
| Jason Dixon | Wasting our Freedom |
| Pau | acer aspire one dmesg? |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| high memory | 52 minutes ago | Linux kernel |
| semaphore access speed | 3 hours ago | Applications and Utilities |
| the kernel how to power off the machine | 4 hours ago | Linux kernel |
| Easter Eggs in windows XP | 7 hours ago | Windows |
| Shared swap partition | 8 hours ago | Linux general |
| Root password | 8 hours ago | Linux general |
| Where/when DNOTIFY is used? | 10 hours ago | Linux kernel |
| How to convert Linux Kernel built-in module into a loadable module | 12 hours ago | Linux kernel |
| Linux 2.6.24 and I/O schedulers | 13 hours ago | Linux kernel |
| USB Driver -- Interrupt Polling -- A Little Help Please | 18 hours ago | Linux general |
