diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-25 08:34:42 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-25 08:35:13 -0800 |
commit | df8dc74e8a383eaf2d9b44b80a71ec6f0e52b42e (patch) | |
tree | bc3799a43e8b94fa84b32e37b1c124d5e4868f50 /drivers/parisc/pdc_stable.c | |
parent | 556a169dab38b5100df6f4a45b655dddd3db94c1 (diff) | |
parent | 4a3ad20ccd8f4d2a0535cf98fa83f7b561ba59a9 (diff) | |
download | blackbird-op-linux-df8dc74e8a383eaf2d9b44b80a71ec6f0e52b42e.tar.gz blackbird-op-linux-df8dc74e8a383eaf2d9b44b80a71ec6f0e52b42e.zip |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6
This can be broken down into these major areas:
- Documentation updates (language translations and fixes, as
well as kobject and kset documenatation updates.)
- major kset/kobject/ktype rework and fixes. This cleans up the
kset and kobject and ktype relationship and architecture,
making sense of things now, and good documenation and samples
are provided for others to use. Also the attributes for
kobjects are much easier to handle now. This cleaned up a LOT
of code all through the kernel, making kobjects easier to use
if you want to.
- struct bus_type has been reworked to now handle the lifetime
rules properly, as the kobject is properly dynamic.
- struct driver has also been reworked, and now the lifetime
issues are resolved.
- the block subsystem has been converted to use struct device
now, and not "raw" kobjects. This patch has been in the -mm
tree for over a year now, and finally all the issues are
worked out with it. Older distros now properly work with new
kernels, and no userspace updates are needed at all.
- nozomi driver is added. This has also been in -mm for a long
time, and many people have asked for it to go in. It is now
in good enough shape to do so.
- lots of class_device conversions to use struct device instead.
The tree is almost all cleaned up now, only SCSI and IB is the
remaining code to fix up...
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6: (196 commits)
Driver core: coding style fixes
Kobject: fix coding style issues in kobject c files
Kobject: fix coding style issues in kobject.h
Driver core: fix coding style issues in device.h
spi: use class iteration api
scsi: use class iteration api
rtc: use class iteration api
power supply : use class iteration api
ieee1394: use class iteration api
Driver Core: add class iteration api
Driver core: Cleanup get_device_parent() in device_add() and device_move()
UIO: constify function pointer tables
Driver Core: constify the name passed to platform_device_register_simple
driver core: fix build with SYSFS=n
sysfs: make SYSFS_DEPRECATED depend on SYSFS
Driver core: use LIST_HEAD instead of call to INIT_LIST_HEAD in __init
kobject: add sample code for how to use ksets/ktypes/kobjects
kobject: add sample code for how to use kobjects in a simple manner.
kobject: update the kobject/kset documentation
kobject: remove old, outdated documentation.
...
Diffstat (limited to 'drivers/parisc/pdc_stable.c')
-rw-r--r-- | drivers/parisc/pdc_stable.c | 194 |
1 files changed, 96 insertions, 98 deletions
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c index ebb09e98d215..de34aa9d3136 100644 --- a/drivers/parisc/pdc_stable.c +++ b/drivers/parisc/pdc_stable.c @@ -120,7 +120,7 @@ struct pdcspath_entry pdcspath_entry_##_name = { \ }; #define PDCS_ATTR(_name, _mode, _show, _store) \ -struct subsys_attribute pdcs_attr_##_name = { \ +struct kobj_attribute pdcs_attr_##_name = { \ .attr = {.name = __stringify(_name), .mode = _mode}, \ .show = _show, \ .store = _store, \ @@ -523,15 +523,15 @@ static struct pdcspath_entry *pdcspath_entries[] = { /** * pdcs_size_read - Stable Storage size output. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The output buffer to write to. */ -static ssize_t -pdcs_size_read(struct kset *kset, char *buf) +static ssize_t pdcs_size_read(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) { char *out = buf; - if (!kset || !buf) + if (!buf) return -EINVAL; /* show the size of the stable storage */ @@ -542,17 +542,17 @@ pdcs_size_read(struct kset *kset, char *buf) /** * pdcs_auto_read - Stable Storage autoboot/search flag output. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The output buffer to write to. * @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag */ -static ssize_t -pdcs_auto_read(struct kset *kset, char *buf, int knob) +static ssize_t pdcs_auto_read(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf, int knob) { char *out = buf; struct pdcspath_entry *pathentry; - if (!kset || !buf) + if (!buf) return -EINVAL; /* Current flags are stored in primary boot path entry */ @@ -568,40 +568,37 @@ pdcs_auto_read(struct kset *kset, char *buf, int knob) /** * pdcs_autoboot_read - Stable Storage autoboot flag output. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The output buffer to write to. */ -static inline ssize_t -pdcs_autoboot_read(struct kset *kset, char *buf) +static ssize_t pdcs_autoboot_read(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) { - return pdcs_auto_read(kset, buf, PF_AUTOBOOT); + return pdcs_auto_read(kobj, attr, buf, PF_AUTOBOOT); } /** * pdcs_autosearch_read - Stable Storage autoboot flag output. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The output buffer to write to. */ -static inline ssize_t -pdcs_autosearch_read(struct kset *kset, char *buf) +static ssize_t pdcs_autosearch_read(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) { - return pdcs_auto_read(kset, buf, PF_AUTOSEARCH); + return pdcs_auto_read(kobj, attr, buf, PF_AUTOSEARCH); } /** * pdcs_timer_read - Stable Storage timer count output (in seconds). - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The output buffer to write to. * * The value of the timer field correponds to a number of seconds in powers of 2. */ -static ssize_t -pdcs_timer_read(struct kset *kset, char *buf) +static ssize_t pdcs_timer_read(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) { char *out = buf; struct pdcspath_entry *pathentry; - if (!kset || !buf) + if (!buf) return -EINVAL; /* Current flags are stored in primary boot path entry */ @@ -618,15 +615,14 @@ pdcs_timer_read(struct kset *kset, char *buf) /** * pdcs_osid_read - Stable Storage OS ID register output. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The output buffer to write to. */ -static ssize_t -pdcs_osid_read(struct kset *kset, char *buf) +static ssize_t pdcs_osid_read(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) { char *out = buf; - if (!kset || !buf) + if (!buf) return -EINVAL; out += sprintf(out, "%s dependent data (0x%.4x)\n", @@ -637,18 +633,17 @@ pdcs_osid_read(struct kset *kset, char *buf) /** * pdcs_osdep1_read - Stable Storage OS-Dependent data area 1 output. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The output buffer to write to. * * This can hold 16 bytes of OS-Dependent data. */ -static ssize_t -pdcs_osdep1_read(struct kset *kset, char *buf) +static ssize_t pdcs_osdep1_read(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) { char *out = buf; u32 result[4]; - if (!kset || !buf) + if (!buf) return -EINVAL; if (pdc_stable_read(PDCS_ADDR_OSD1, &result, sizeof(result)) != PDC_OK) @@ -664,18 +659,17 @@ pdcs_osdep1_read(struct kset *kset, char *buf) /** * pdcs_diagnostic_read - Stable Storage Diagnostic register output. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The output buffer to write to. * * I have NFC how to interpret the content of that register ;-). */ -static ssize_t -pdcs_diagnostic_read(struct kset *kset, char *buf) +static ssize_t pdcs_diagnostic_read(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) { char *out = buf; u32 result; - if (!kset || !buf) + if (!buf) return -EINVAL; /* get diagnostic */ @@ -689,18 +683,17 @@ pdcs_diagnostic_read(struct kset *kset, char *buf) /** * pdcs_fastsize_read - Stable Storage FastSize register output. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The output buffer to write to. * * This register holds the amount of system RAM to be tested during boot sequence. */ -static ssize_t -pdcs_fastsize_read(struct kset *kset, char *buf) +static ssize_t pdcs_fastsize_read(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) { char *out = buf; u32 result; - if (!kset || !buf) + if (!buf) return -EINVAL; /* get fast-size */ @@ -718,13 +711,12 @@ pdcs_fastsize_read(struct kset *kset, char *buf) /** * pdcs_osdep2_read - Stable Storage OS-Dependent data area 2 output. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The output buffer to write to. * * This can hold pdcs_size - 224 bytes of OS-Dependent data, when available. */ -static ssize_t -pdcs_osdep2_read(struct kset *kset, char *buf) +static ssize_t pdcs_osdep2_read(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) { char *out = buf; unsigned long size; @@ -736,7 +728,7 @@ pdcs_osdep2_read(struct kset *kset, char *buf) size = pdcs_size - 224; - if (!kset || !buf) + if (!buf) return -EINVAL; for (i=0; i<size; i+=4) { @@ -751,7 +743,6 @@ pdcs_osdep2_read(struct kset *kset, char *buf) /** * pdcs_auto_write - This function handles autoboot/search flag modifying. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The input buffer to read from. * @count: The number of bytes to be read. * @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag @@ -760,8 +751,9 @@ pdcs_osdep2_read(struct kset *kset, char *buf) * We expect a precise syntax: * \"n\" (n == 0 or 1) to toggle AutoBoot Off or On */ -static ssize_t -pdcs_auto_write(struct kset *kset, const char *buf, size_t count, int knob) +static ssize_t pdcs_auto_write(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, + size_t count, int knob) { struct pdcspath_entry *pathentry; unsigned char flags; @@ -771,7 +763,7 @@ pdcs_auto_write(struct kset *kset, const char *buf, size_t count, int knob) if (!capable(CAP_SYS_ADMIN)) return -EACCES; - if (!kset || !buf || !count) + if (!buf || !count) return -EINVAL; /* We'll use a local copy of buf */ @@ -826,7 +818,6 @@ parse_error: /** * pdcs_autoboot_write - This function handles autoboot flag modifying. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The input buffer to read from. * @count: The number of bytes to be read. * @@ -834,15 +825,15 @@ parse_error: * We expect a precise syntax: * \"n\" (n == 0 or 1) to toggle AutoSearch Off or On */ -static inline ssize_t -pdcs_autoboot_write(struct kset *kset, const char *buf, size_t count) +static ssize_t pdcs_autoboot_write(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) { - return pdcs_auto_write(kset, buf, count, PF_AUTOBOOT); + return pdcs_auto_write(kset, attr, buf, count, PF_AUTOBOOT); } /** * pdcs_autosearch_write - This function handles autosearch flag modifying. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The input buffer to read from. * @count: The number of bytes to be read. * @@ -850,15 +841,15 @@ pdcs_autoboot_write(struct kset *kset, const char *buf, size_t count) * We expect a precise syntax: * \"n\" (n == 0 or 1) to toggle AutoSearch Off or On */ -static inline ssize_t -pdcs_autosearch_write(struct kset *kset, const char *buf, size_t count) +static ssize_t pdcs_autosearch_write(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) { - return pdcs_auto_write(kset, buf, count, PF_AUTOSEARCH); + return pdcs_auto_write(kset, attr, buf, count, PF_AUTOSEARCH); } /** * pdcs_osdep1_write - Stable Storage OS-Dependent data area 1 input. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The input buffer to read from. * @count: The number of bytes to be read. * @@ -866,15 +857,16 @@ pdcs_autosearch_write(struct kset *kset, const char *buf, size_t count) * write approach. It's up to userspace to deal with it when constructing * its input buffer. */ -static ssize_t -pdcs_osdep1_write(struct kset *kset, const char *buf, size_t count) +static ssize_t pdcs_osdep1_write(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) { u8 in[16]; if (!capable(CAP_SYS_ADMIN)) return -EACCES; - if (!kset || !buf || !count) + if (!buf || !count) return -EINVAL; if (unlikely(pdcs_osid != OS_ID_LINUX)) @@ -895,7 +887,6 @@ pdcs_osdep1_write(struct kset *kset, const char *buf, size_t count) /** * pdcs_osdep2_write - Stable Storage OS-Dependent data area 2 input. - * @kset: An allocated and populated struct kset. We don't use it tho. * @buf: The input buffer to read from. * @count: The number of bytes to be read. * @@ -903,8 +894,9 @@ pdcs_osdep1_write(struct kset *kset, const char *buf, size_t count) * byte-by-byte write approach. It's up to userspace to deal with it when * constructing its input buffer. */ -static ssize_t -pdcs_osdep2_write(struct kset *kset, const char *buf, size_t count) +static ssize_t pdcs_osdep2_write(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) { unsigned long size; unsigned short i; @@ -913,7 +905,7 @@ pdcs_osdep2_write(struct kset *kset, const char *buf, size_t count) if (!capable(CAP_SYS_ADMIN)) return -EACCES; - if (!kset || !buf || !count) + if (!buf || !count) return -EINVAL; if (unlikely(pdcs_size <= 224)) @@ -951,21 +943,25 @@ static PDCS_ATTR(diagnostic, 0400, pdcs_diagnostic_read, NULL); static PDCS_ATTR(fastsize, 0400, pdcs_fastsize_read, NULL); static PDCS_ATTR(osdep2, 0600, pdcs_osdep2_read, pdcs_osdep2_write); -static struct subsys_attribute *pdcs_subsys_attrs[] = { - &pdcs_attr_size, - &pdcs_attr_autoboot, - &pdcs_attr_autosearch, - &pdcs_attr_timer, - &pdcs_attr_osid, - &pdcs_attr_osdep1, - &pdcs_attr_diagnostic, - &pdcs_attr_fastsize, - &pdcs_attr_osdep2, +static struct attribute *pdcs_subsys_attrs[] = { + &pdcs_attr_size.attr, + &pdcs_attr_autoboot.attr, + &pdcs_attr_autosearch.attr, + &pdcs_attr_timer.attr, + &pdcs_attr_osid.attr, + &pdcs_attr_osdep1.attr, + &pdcs_attr_diagnostic.attr, + &pdcs_attr_fastsize.attr, + &pdcs_attr_osdep2.attr, NULL, }; -static decl_subsys(paths, &ktype_pdcspath, NULL); -static decl_subsys(stable, NULL, NULL); +static struct attribute_group pdcs_attr_group = { + .attrs = pdcs_subsys_attrs, +}; + +static struct kobject *stable_kobj; +static struct kset *paths_kset; /** * pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage. @@ -995,12 +991,12 @@ pdcs_register_pathentries(void) if (err < 0) continue; - if ((err = kobject_set_name(&entry->kobj, "%s", entry->name))) - return err; - kobj_set_kset_s(entry, paths_subsys); - if ((err = kobject_register(&entry->kobj))) + entry->kobj.kset = paths_kset; + err = kobject_init_and_add(&entry->kobj, &ktype_pdcspath, NULL, + "%s", entry->name); + if (err) return err; - + /* kobject is now registered */ write_lock(&entry->rw_lock); entry->ready = 2; @@ -1012,6 +1008,7 @@ pdcs_register_pathentries(void) } write_unlock(&entry->rw_lock); + kobject_uevent(&entry->kobj, KOBJ_ADD); } return 0; @@ -1029,7 +1026,7 @@ pdcs_unregister_pathentries(void) for (i = 0; (entry = pdcspath_entries[i]); i++) { read_lock(&entry->rw_lock); if (entry->ready >= 2) - kobject_unregister(&entry->kobj); + kobject_put(&entry->kobj); read_unlock(&entry->rw_lock); } } @@ -1041,8 +1038,7 @@ pdcs_unregister_pathentries(void) static int __init pdc_stable_init(void) { - struct subsys_attribute *attr; - int i, rc = 0, error = 0; + int rc = 0, error = 0; u32 result; /* find the size of the stable storage */ @@ -1062,21 +1058,24 @@ pdc_stable_init(void) /* the actual result is 16 bits away */ pdcs_osid = (u16)(result >> 16); - /* For now we'll register the stable subsys within this driver */ - if ((rc = firmware_register(&stable_subsys))) + /* For now we'll register the directory at /sys/firmware/stable */ + stable_kobj = kobject_create_and_add("stable", firmware_kobj); + if (!stable_kobj) { + rc = -ENOMEM; goto fail_firmreg; + } /* Don't forget the root entries */ - for (i = 0; (attr = pdcs_subsys_attrs[i]) && !error; i++) - if (attr->show) - error = subsys_create_file(&stable_subsys, attr); - - /* register the paths subsys as a subsystem of stable subsys */ - kobj_set_kset_s(&paths_subsys, stable_subsys); - if ((rc = subsystem_register(&paths_subsys))) - goto fail_subsysreg; + error = sysfs_create_group(stable_kobj, pdcs_attr_group); - /* now we create all "files" for the paths subsys */ + /* register the paths kset as a child of the stable kset */ + paths_kset = kset_create_and_add("paths", NULL, stable_kobj); + if (!paths_kset) { + rc = -ENOMEM; + goto fail_ksetreg; + } + + /* now we create all "files" for the paths kset */ if ((rc = pdcs_register_pathentries())) goto fail_pdcsreg; @@ -1084,10 +1083,10 @@ pdc_stable_init(void) fail_pdcsreg: pdcs_unregister_pathentries(); - subsystem_unregister(&paths_subsys); + kset_unregister(paths_kset); -fail_subsysreg: - firmware_unregister(&stable_subsys); +fail_ksetreg: + kobject_put(stable_kobj); fail_firmreg: printk(KERN_INFO PDCS_PREFIX " bailing out\n"); @@ -1098,9 +1097,8 @@ static void __exit pdc_stable_exit(void) { pdcs_unregister_pathentries(); - subsystem_unregister(&paths_subsys); - - firmware_unregister(&stable_subsys); + kset_unregister(paths_kset); + kobject_put(stable_kobj); } |