aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/parisc/pdc_stable.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 11:34:42 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 11:35:13 -0500
commitdf8dc74e8a383eaf2d9b44b80a71ec6f0e52b42e (patch)
treebc3799a43e8b94fa84b32e37b1c124d5e4868f50 /drivers/parisc/pdc_stable.c
parent556a169dab38b5100df6f4a45b655dddd3db94c1 (diff)
parent4a3ad20ccd8f4d2a0535cf98fa83f7b561ba59a9 (diff)
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.c194
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 = { \
120}; 120};
121 121
122#define PDCS_ATTR(_name, _mode, _show, _store) \ 122#define PDCS_ATTR(_name, _mode, _show, _store) \
123struct subsys_attribute pdcs_attr_##_name = { \ 123struct kobj_attribute pdcs_attr_##_name = { \
124 .attr = {.name = __stringify(_name), .mode = _mode}, \ 124 .attr = {.name = __stringify(_name), .mode = _mode}, \
125 .show = _show, \ 125 .show = _show, \
126 .store = _store, \ 126 .store = _store, \
@@ -523,15 +523,15 @@ static struct pdcspath_entry *pdcspath_entries[] = {
523 523
524/** 524/**
525 * pdcs_size_read - Stable Storage size output. 525 * pdcs_size_read - Stable Storage size output.
526 * @kset: An allocated and populated struct kset. We don't use it tho.
527 * @buf: The output buffer to write to. 526 * @buf: The output buffer to write to.
528 */ 527 */
529static ssize_t 528static ssize_t pdcs_size_read(struct kobject *kobj,
530pdcs_size_read(struct kset *kset, char *buf) 529 struct kobj_attribute *attr,
530 char *buf)
531{ 531{
532 char *out = buf; 532 char *out = buf;
533 533
534 if (!kset || !buf) 534 if (!buf)
535 return -EINVAL; 535 return -EINVAL;
536 536
537 /* show the size of the stable storage */ 537 /* show the size of the stable storage */
@@ -542,17 +542,17 @@ pdcs_size_read(struct kset *kset, char *buf)
542 542
543/** 543/**
544 * pdcs_auto_read - Stable Storage autoboot/search flag output. 544 * pdcs_auto_read - Stable Storage autoboot/search flag output.
545 * @kset: An allocated and populated struct kset. We don't use it tho.
546 * @buf: The output buffer to write to. 545 * @buf: The output buffer to write to.
547 * @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag 546 * @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag
548 */ 547 */
549static ssize_t 548static ssize_t pdcs_auto_read(struct kobject *kobj,
550pdcs_auto_read(struct kset *kset, char *buf, int knob) 549 struct kobj_attribute *attr,
550 char *buf, int knob)
551{ 551{
552 char *out = buf; 552 char *out = buf;
553 struct pdcspath_entry *pathentry; 553 struct pdcspath_entry *pathentry;
554 554
555 if (!kset || !buf) 555 if (!buf)
556 return -EINVAL; 556 return -EINVAL;
557 557
558 /* Current flags are stored in primary boot path entry */ 558 /* Current flags are stored in primary boot path entry */
@@ -568,40 +568,37 @@ pdcs_auto_read(struct kset *kset, char *buf, int knob)
568 568
569/** 569/**
570 * pdcs_autoboot_read - Stable Storage autoboot flag output. 570 * pdcs_autoboot_read - Stable Storage autoboot flag output.
571 * @kset: An allocated and populated struct kset. We don't use it tho.
572 * @buf: The output buffer to write to. 571 * @buf: The output buffer to write to.
573 */ 572 */
574static inline ssize_t 573static ssize_t pdcs_autoboot_read(struct kobject *kobj,
575pdcs_autoboot_read(struct kset *kset, char *buf) 574 struct kobj_attribute *attr, char *buf)
576{ 575{
577 return pdcs_auto_read(kset, buf, PF_AUTOBOOT); 576 return pdcs_auto_read(kobj, attr, buf, PF_AUTOBOOT);
578} 577}
579 578
580/** 579/**
581 * pdcs_autosearch_read - Stable Storage autoboot flag output. 580 * pdcs_autosearch_read - Stable Storage autoboot flag output.
582 * @kset: An allocated and populated struct kset. We don't use it tho.
583 * @buf: The output buffer to write to. 581 * @buf: The output buffer to write to.
584 */ 582 */
585static inline ssize_t 583static ssize_t pdcs_autosearch_read(struct kobject *kobj,
586pdcs_autosearch_read(struct kset *kset, char *buf) 584 struct kobj_attribute *attr, char *buf)
587{ 585{
588 return pdcs_auto_read(kset, buf, PF_AUTOSEARCH); 586 return pdcs_auto_read(kobj, attr, buf, PF_AUTOSEARCH);
589} 587}
590 588
591/** 589/**
592 * pdcs_timer_read - Stable Storage timer count output (in seconds). 590 * pdcs_timer_read - Stable Storage timer count output (in seconds).
593 * @kset: An allocated and populated struct kset. We don't use it tho.
594 * @buf: The output buffer to write to. 591 * @buf: The output buffer to write to.
595 * 592 *
596 * The value of the timer field correponds to a number of seconds in powers of 2. 593 * The value of the timer field correponds to a number of seconds in powers of 2.
597 */ 594 */
598static ssize_t 595static ssize_t pdcs_timer_read(struct kobject *kobj,
599pdcs_timer_read(struct kset *kset, char *buf) 596 struct kobj_attribute *attr, char *buf)
600{ 597{
601 char *out = buf; 598 char *out = buf;
602 struct pdcspath_entry *pathentry; 599 struct pdcspath_entry *pathentry;
603 600
604 if (!kset || !buf) 601 if (!buf)
605 return -EINVAL; 602 return -EINVAL;
606 603
607 /* Current flags are stored in primary boot path entry */ 604 /* Current flags are stored in primary boot path entry */
@@ -618,15 +615,14 @@ pdcs_timer_read(struct kset *kset, char *buf)
618 615
619/** 616/**
620 * pdcs_osid_read - Stable Storage OS ID register output. 617 * pdcs_osid_read - Stable Storage OS ID register output.
621 * @kset: An allocated and populated struct kset. We don't use it tho.
622 * @buf: The output buffer to write to. 618 * @buf: The output buffer to write to.
623 */ 619 */
624static ssize_t 620static ssize_t pdcs_osid_read(struct kobject *kobj,
625pdcs_osid_read(struct kset *kset, char *buf) 621 struct kobj_attribute *attr, char *buf)
626{ 622{
627 char *out = buf; 623 char *out = buf;
628 624
629 if (!kset || !buf) 625 if (!buf)
630 return -EINVAL; 626 return -EINVAL;
631 627
632 out += sprintf(out, "%s dependent data (0x%.4x)\n", 628 out += sprintf(out, "%s dependent data (0x%.4x)\n",
@@ -637,18 +633,17 @@ pdcs_osid_read(struct kset *kset, char *buf)
637 633
638/** 634/**
639 * pdcs_osdep1_read - Stable Storage OS-Dependent data area 1 output. 635 * pdcs_osdep1_read - Stable Storage OS-Dependent data area 1 output.
640 * @kset: An allocated and populated struct kset. We don't use it tho.
641 * @buf: The output buffer to write to. 636 * @buf: The output buffer to write to.
642 * 637 *
643 * This can hold 16 bytes of OS-Dependent data. 638 * This can hold 16 bytes of OS-Dependent data.
644 */ 639 */
645static ssize_t 640static ssize_t pdcs_osdep1_read(struct kobject *kobj,
646pdcs_osdep1_read(struct kset *kset, char *buf) 641 struct kobj_attribute *attr, char *buf)
647{ 642{
648 char *out = buf; 643 char *out = buf;
649 u32 result[4]; 644 u32 result[4];
650 645
651 if (!kset || !buf) 646 if (!buf)
652 return -EINVAL; 647 return -EINVAL;
653 648
654 if (pdc_stable_read(PDCS_ADDR_OSD1, &result, sizeof(result)) != PDC_OK) 649 if (pdc_stable_read(PDCS_ADDR_OSD1, &result, sizeof(result)) != PDC_OK)
@@ -664,18 +659,17 @@ pdcs_osdep1_read(struct kset *kset, char *buf)
664 659
665/** 660/**
666 * pdcs_diagnostic_read - Stable Storage Diagnostic register output. 661 * pdcs_diagnostic_read - Stable Storage Diagnostic register output.
667 * @kset: An allocated and populated struct kset. We don't use it tho.
668 * @buf: The output buffer to write to. 662 * @buf: The output buffer to write to.
669 * 663 *
670 * I have NFC how to interpret the content of that register ;-). 664 * I have NFC how to interpret the content of that register ;-).
671 */ 665 */
672static ssize_t 666static ssize_t pdcs_diagnostic_read(struct kobject *kobj,
673pdcs_diagnostic_read(struct kset *kset, char *buf) 667 struct kobj_attribute *attr, char *buf)
674{ 668{
675 char *out = buf; 669 char *out = buf;
676 u32 result; 670 u32 result;
677 671
678 if (!kset || !buf) 672 if (!buf)
679 return -EINVAL; 673 return -EINVAL;
680 674
681 /* get diagnostic */ 675 /* get diagnostic */
@@ -689,18 +683,17 @@ pdcs_diagnostic_read(struct kset *kset, char *buf)
689 683
690/** 684/**
691 * pdcs_fastsize_read - Stable Storage FastSize register output. 685 * pdcs_fastsize_read - Stable Storage FastSize register output.
692 * @kset: An allocated and populated struct kset. We don't use it tho.
693 * @buf: The output buffer to write to. 686 * @buf: The output buffer to write to.
694 * 687 *
695 * This register holds the amount of system RAM to be tested during boot sequence. 688 * This register holds the amount of system RAM to be tested during boot sequence.
696 */ 689 */
697static ssize_t 690static ssize_t pdcs_fastsize_read(struct kobject *kobj,
698pdcs_fastsize_read(struct kset *kset, char *buf) 691 struct kobj_attribute *attr, char *buf)
699{ 692{
700 char *out = buf; 693 char *out = buf;
701 u32 result; 694 u32 result;
702 695
703 if (!kset || !buf) 696 if (!buf)
704 return -EINVAL; 697 return -EINVAL;
705 698
706 /* get fast-size */ 699 /* get fast-size */
@@ -718,13 +711,12 @@ pdcs_fastsize_read(struct kset *kset, char *buf)
718 711
719/** 712/**
720 * pdcs_osdep2_read - Stable Storage OS-Dependent data area 2 output. 713 * pdcs_osdep2_read - Stable Storage OS-Dependent data area 2 output.
721 * @kset: An allocated and populated struct kset. We don't use it tho.
722 * @buf: The output buffer to write to. 714 * @buf: The output buffer to write to.
723 * 715 *
724 * This can hold pdcs_size - 224 bytes of OS-Dependent data, when available. 716 * This can hold pdcs_size - 224 bytes of OS-Dependent data, when available.
725 */ 717 */
726static ssize_t 718static ssize_t pdcs_osdep2_read(struct kobject *kobj,
727pdcs_osdep2_read(struct kset *kset, char *buf) 719 struct kobj_attribute *attr, char *buf)
728{ 720{
729 char *out = buf; 721 char *out = buf;
730 unsigned long size; 722 unsigned long size;
@@ -736,7 +728,7 @@ pdcs_osdep2_read(struct kset *kset, char *buf)
736 728
737 size = pdcs_size - 224; 729 size = pdcs_size - 224;
738 730
739 if (!kset || !buf) 731 if (!buf)
740 return -EINVAL; 732 return -EINVAL;
741 733
742 for (i=0; i<size; i+=4) { 734 for (i=0; i<size; i+=4) {
@@ -751,7 +743,6 @@ pdcs_osdep2_read(struct kset *kset, char *buf)
751 743
752/** 744/**
753 * pdcs_auto_write - This function handles autoboot/search flag modifying. 745 * pdcs_auto_write - This function handles autoboot/search flag modifying.
754 * @kset: An allocated and populated struct kset. We don't use it tho.
755 * @buf: The input buffer to read from. 746 * @buf: The input buffer to read from.
756 * @count: The number of bytes to be read. 747 * @count: The number of bytes to be read.
757 * @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag 748 * @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag
@@ -760,8 +751,9 @@ pdcs_osdep2_read(struct kset *kset, char *buf)
760 * We expect a precise syntax: 751 * We expect a precise syntax:
761 * \"n\" (n == 0 or 1) to toggle AutoBoot Off or On 752 * \"n\" (n == 0 or 1) to toggle AutoBoot Off or On
762 */ 753 */
763static ssize_t 754static ssize_t pdcs_auto_write(struct kobject *kobj,
764pdcs_auto_write(struct kset *kset, const char *buf, size_t count, int knob) 755 struct kobj_attribute *attr, const char *buf,
756 size_t count, int knob)
765{ 757{
766 struct pdcspath_entry *pathentry; 758 struct pdcspath_entry *pathentry;
767 unsigned char flags; 759 unsigned char flags;
@@ -771,7 +763,7 @@ pdcs_auto_write(struct kset *kset, const char *buf, size_t count, int knob)
771 if (!capable(CAP_SYS_ADMIN)) 763 if (!capable(CAP_SYS_ADMIN))
772 return -EACCES; 764 return -EACCES;
773 765
774 if (!kset || !buf || !count) 766 if (!buf || !count)
775 return -EINVAL; 767 return -EINVAL;
776 768
777 /* We'll use a local copy of buf */ 769 /* We'll use a local copy of buf */
@@ -826,7 +818,6 @@ parse_error:
826 818
827/** 819/**
828 * pdcs_autoboot_write - This function handles autoboot flag modifying. 820 * pdcs_autoboot_write - This function handles autoboot flag modifying.
829 * @kset: An allocated and populated struct kset. We don't use it tho.
830 * @buf: The input buffer to read from. 821 * @buf: The input buffer to read from.
831 * @count: The number of bytes to be read. 822 * @count: The number of bytes to be read.
832 * 823 *
@@ -834,15 +825,15 @@ parse_error:
834 * We expect a precise syntax: 825 * We expect a precise syntax:
835 * \"n\" (n == 0 or 1) to toggle AutoSearch Off or On 826 * \"n\" (n == 0 or 1) to toggle AutoSearch Off or On
836 */ 827 */
837static inline ssize_t 828static ssize_t pdcs_autoboot_write(struct kobject *kobj,
838pdcs_autoboot_write(struct kset *kset, const char *buf, size_t count) 829 struct kobj_attribute *attr,
830 const char *buf, size_t count)
839{ 831{
840 return pdcs_auto_write(kset, buf, count, PF_AUTOBOOT); 832 return pdcs_auto_write(kset, attr, buf, count, PF_AUTOBOOT);
841} 833}
842 834
843/** 835/**
844 * pdcs_autosearch_write - This function handles autosearch flag modifying. 836 * pdcs_autosearch_write - This function handles autosearch flag modifying.
845 * @kset: An allocated and populated struct kset. We don't use it tho.
846 * @buf: The input buffer to read from. 837 * @buf: The input buffer to read from.
847 * @count: The number of bytes to be read. 838 * @count: The number of bytes to be read.
848 * 839 *
@@ -850,15 +841,15 @@ pdcs_autoboot_write(struct kset *kset, const char *buf, size_t count)
850 * We expect a precise syntax: 841 * We expect a precise syntax:
851 * \"n\" (n == 0 or 1) to toggle AutoSearch Off or On 842 * \"n\" (n == 0 or 1) to toggle AutoSearch Off or On
852 */ 843 */
853static inline ssize_t 844static ssize_t pdcs_autosearch_write(struct kobject *kobj,
854pdcs_autosearch_write(struct kset *kset, const char *buf, size_t count) 845 struct kobj_attribute *attr,
846 const char *buf, size_t count)
855{ 847{
856 return pdcs_auto_write(kset, buf, count, PF_AUTOSEARCH); 848 return pdcs_auto_write(kset, attr, buf, count, PF_AUTOSEARCH);
857} 849}
858 850
859/** 851/**
860 * pdcs_osdep1_write - Stable Storage OS-Dependent data area 1 input. 852 * pdcs_osdep1_write - Stable Storage OS-Dependent data area 1 input.
861 * @kset: An allocated and populated struct kset. We don't use it tho.
862 * @buf: The input buffer to read from. 853 * @buf: The input buffer to read from.
863 * @count: The number of bytes to be read. 854 * @count: The number of bytes to be read.
864 * 855 *
@@ -866,15 +857,16 @@ pdcs_autosearch_write(struct kset *kset, const char *buf, size_t count)
866 * write approach. It's up to userspace to deal with it when constructing 857 * write approach. It's up to userspace to deal with it when constructing
867 * its input buffer. 858 * its input buffer.
868 */ 859 */
869static ssize_t 860static ssize_t pdcs_osdep1_write(struct kobject *kobj,
870pdcs_osdep1_write(struct kset *kset, const char *buf, size_t count) 861 struct kobj_attribute *attr,
862 const char *buf, size_t count)
871{ 863{
872 u8 in[16]; 864 u8 in[16];
873 865
874 if (!capable(CAP_SYS_ADMIN)) 866 if (!capable(CAP_SYS_ADMIN))
875 return -EACCES; 867 return -EACCES;
876 868
877 if (!kset || !buf || !count) 869 if (!buf || !count)
878 return -EINVAL; 870 return -EINVAL;
879 871
880 if (unlikely(pdcs_osid != OS_ID_LINUX)) 872 if (unlikely(pdcs_osid != OS_ID_LINUX))
@@ -895,7 +887,6 @@ pdcs_osdep1_write(struct kset *kset, const char *buf, size_t count)
895 887
896/** 888/**
897 * pdcs_osdep2_write - Stable Storage OS-Dependent data area 2 input. 889 * pdcs_osdep2_write - Stable Storage OS-Dependent data area 2 input.
898 * @kset: An allocated and populated struct kset. We don't use it tho.
899 * @buf: The input buffer to read from. 890 * @buf: The input buffer to read from.
900 * @count: The number of bytes to be read. 891 * @count: The number of bytes to be read.
901 * 892 *
@@ -903,8 +894,9 @@ pdcs_osdep1_write(struct kset *kset, const char *buf, size_t count)
903 * byte-by-byte write approach. It's up to userspace to deal with it when 894 * byte-by-byte write approach. It's up to userspace to deal with it when
904 * constructing its input buffer. 895 * constructing its input buffer.
905 */ 896 */
906static ssize_t 897static ssize_t pdcs_osdep2_write(struct kobject *kobj,
907pdcs_osdep2_write(struct kset *kset, const char *buf, size_t count) 898 struct kobj_attribute *attr,
899 const char *buf, size_t count)
908{ 900{
909 unsigned long size; 901 unsigned long size;
910 unsigned short i; 902 unsigned short i;
@@ -913,7 +905,7 @@ pdcs_osdep2_write(struct kset *kset, const char *buf, size_t count)
913 if (!capable(CAP_SYS_ADMIN)) 905 if (!capable(CAP_SYS_ADMIN))
914 return -EACCES; 906 return -EACCES;
915 907
916 if (!kset || !buf || !count) 908 if (!buf || !count)
917 return -EINVAL; 909 return -EINVAL;
918 910
919 if (unlikely(pdcs_size <= 224)) 911 if (unlikely(pdcs_size <= 224))
@@ -951,21 +943,25 @@ static PDCS_ATTR(diagnostic, 0400, pdcs_diagnostic_read, NULL);
951static PDCS_ATTR(fastsize, 0400, pdcs_fastsize_read, NULL); 943static PDCS_ATTR(fastsize, 0400, pdcs_fastsize_read, NULL);
952static PDCS_ATTR(osdep2, 0600, pdcs_osdep2_read, pdcs_osdep2_write); 944static PDCS_ATTR(osdep2, 0600, pdcs_osdep2_read, pdcs_osdep2_write);
953 945
954static struct subsys_attribute *pdcs_subsys_attrs[] = { 946static struct attribute *pdcs_subsys_attrs[] = {
955 &pdcs_attr_size, 947 &pdcs_attr_size.attr,
956 &pdcs_attr_autoboot, 948 &pdcs_attr_autoboot.attr,
957 &pdcs_attr_autosearch, 949 &pdcs_attr_autosearch.attr,
958 &pdcs_attr_timer, 950 &pdcs_attr_timer.attr,
959 &pdcs_attr_osid, 951 &pdcs_attr_osid.attr,
960 &pdcs_attr_osdep1, 952 &pdcs_attr_osdep1.attr,
961 &pdcs_attr_diagnostic, 953 &pdcs_attr_diagnostic.attr,
962 &pdcs_attr_fastsize, 954 &pdcs_attr_fastsize.attr,
963 &pdcs_attr_osdep2, 955 &pdcs_attr_osdep2.attr,
964 NULL, 956 NULL,
965}; 957};
966 958
967static decl_subsys(paths, &ktype_pdcspath, NULL); 959static struct attribute_group pdcs_attr_group = {
968static decl_subsys(stable, NULL, NULL); 960 .attrs = pdcs_subsys_attrs,
961};
962
963static struct kobject *stable_kobj;
964static struct kset *paths_kset;
969 965
970/** 966/**
971 * pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage. 967 * pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage.
@@ -995,12 +991,12 @@ pdcs_register_pathentries(void)
995 if (err < 0) 991 if (err < 0)
996 continue; 992 continue;
997 993
998 if ((err = kobject_set_name(&entry->kobj, "%s", entry->name))) 994 entry->kobj.kset = paths_kset;
999 return err; 995 err = kobject_init_and_add(&entry->kobj, &ktype_pdcspath, NULL,
1000 kobj_set_kset_s(entry, paths_subsys); 996 "%s", entry->name);
1001 if ((err = kobject_register(&entry->kobj))) 997 if (err)
1002 return err; 998 return err;
1003 999
1004 /* kobject is now registered */ 1000 /* kobject is now registered */
1005 write_lock(&entry->rw_lock); 1001 write_lock(&entry->rw_lock);
1006 entry->ready = 2; 1002 entry->ready = 2;
@@ -1012,6 +1008,7 @@ pdcs_register_pathentries(void)
1012 } 1008 }
1013 1009
1014 write_unlock(&entry->rw_lock); 1010 write_unlock(&entry->rw_lock);
1011 kobject_uevent(&entry->kobj, KOBJ_ADD);
1015 } 1012 }
1016 1013
1017 return 0; 1014 return 0;
@@ -1029,7 +1026,7 @@ pdcs_unregister_pathentries(void)
1029 for (i = 0; (entry = pdcspath_entries[i]); i++) { 1026 for (i = 0; (entry = pdcspath_entries[i]); i++) {
1030 read_lock(&entry->rw_lock); 1027 read_lock(&entry->rw_lock);
1031 if (entry->ready >= 2) 1028 if (entry->ready >= 2)
1032 kobject_unregister(&entry->kobj); 1029 kobject_put(&entry->kobj);
1033 read_unlock(&entry->rw_lock); 1030 read_unlock(&entry->rw_lock);
1034 } 1031 }
1035} 1032}
@@ -1041,8 +1038,7 @@ pdcs_unregister_pathentries(void)
1041static int __init 1038static int __init
1042pdc_stable_init(void) 1039pdc_stable_init(void)
1043{ 1040{
1044 struct subsys_attribute *attr; 1041 int rc = 0, error = 0;
1045 int i, rc = 0, error = 0;
1046 u32 result; 1042 u32 result;
1047 1043
1048 /* find the size of the stable storage */ 1044 /* find the size of the stable storage */
@@ -1062,21 +1058,24 @@ pdc_stable_init(void)
1062 /* the actual result is 16 bits away */ 1058 /* the actual result is 16 bits away */
1063 pdcs_osid = (u16)(result >> 16); 1059 pdcs_osid = (u16)(result >> 16);
1064 1060
1065 /* For now we'll register the stable subsys within this driver */ 1061 /* For now we'll register the directory at /sys/firmware/stable */
1066 if ((rc = firmware_register(&stable_subsys))) 1062 stable_kobj = kobject_create_and_add("stable", firmware_kobj);
1063 if (!stable_kobj) {
1064 rc = -ENOMEM;
1067 goto fail_firmreg; 1065 goto fail_firmreg;
1066 }
1068 1067
1069 /* Don't forget the root entries */ 1068 /* Don't forget the root entries */
1070 for (i = 0; (attr = pdcs_subsys_attrs[i]) && !error; i++) 1069 error = sysfs_create_group(stable_kobj, pdcs_attr_group);
1071 if (attr->show)
1072 error = subsys_create_file(&stable_subsys, attr);
1073
1074 /* register the paths subsys as a subsystem of stable subsys */
1075 kobj_set_kset_s(&paths_subsys, stable_subsys);
1076 if ((rc = subsystem_register(&paths_subsys)))
1077 goto fail_subsysreg;
1078 1070
1079 /* now we create all "files" for the paths subsys */ 1071 /* register the paths kset as a child of the stable kset */
1072 paths_kset = kset_create_and_add("paths", NULL, stable_kobj);
1073 if (!paths_kset) {
1074 rc = -ENOMEM;
1075 goto fail_ksetreg;
1076 }
1077
1078 /* now we create all "files" for the paths kset */
1080 if ((rc = pdcs_register_pathentries())) 1079 if ((rc = pdcs_register_pathentries()))
1081 goto fail_pdcsreg; 1080 goto fail_pdcsreg;
1082 1081
@@ -1084,10 +1083,10 @@ pdc_stable_init(void)
1084 1083
1085fail_pdcsreg: 1084fail_pdcsreg:
1086 pdcs_unregister_pathentries(); 1085 pdcs_unregister_pathentries();
1087 subsystem_unregister(&paths_subsys); 1086 kset_unregister(paths_kset);
1088 1087
1089fail_subsysreg: 1088fail_ksetreg:
1090 firmware_unregister(&stable_subsys); 1089 kobject_put(stable_kobj);
1091 1090
1092fail_firmreg: 1091fail_firmreg:
1093 printk(KERN_INFO PDCS_PREFIX " bailing out\n"); 1092 printk(KERN_INFO PDCS_PREFIX " bailing out\n");
@@ -1098,9 +1097,8 @@ static void __exit
1098pdc_stable_exit(void) 1097pdc_stable_exit(void)
1099{ 1098{
1100 pdcs_unregister_pathentries(); 1099 pdcs_unregister_pathentries();
1101 subsystem_unregister(&paths_subsys); 1100 kset_unregister(paths_kset);
1102 1101 kobject_put(stable_kobj);
1103 firmware_unregister(&stable_subsys);
1104} 1102}
1105 1103
1106 1104