aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-11-02 18:25:00 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-24 23:40:21 -0500
commit7f548217860a7cf8a345d87792a07512450dfbff (patch)
tree92737794046bb8fcab8d563a286412e6a3b307e4 /drivers
parentd91885bef25be2bab686bed082a5d82e358333b9 (diff)
kobject: convert parisc/pdc_stable to kobj_attr interface
This makes the code a bit simpler and and gets us one step closer to deleting the deprecated subsys_attr code. NOTE, this needs the next patch in the series in order to work properly. This will build, but the sysfs files will not properly operate. Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Thibaut VARENE <varenet@parisc-linux.org> Cc: Matthew Wilcox <matthew@wil.cx> Cc: Grant Grundler <grundler@parisc-linux.org> Cc: Kyle McMartin <kyle@parisc-linux.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/parisc/pdc_stable.c147
1 files changed, 70 insertions, 77 deletions
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index 1382be64cc3f..e1b9cbaf4456 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,19 +943,23 @@ 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
959static struct attribute_group pdcs_attr_group = {
960 .attrs = pdcs_subsys_attrs,
961};
962
967static decl_subsys(paths, NULL); 963static decl_subsys(paths, NULL);
968static decl_subsys(stable, NULL); 964static decl_subsys(stable, NULL);
969 965
@@ -1042,8 +1038,7 @@ pdcs_unregister_pathentries(void)
1042static int __init 1038static int __init
1043pdc_stable_init(void) 1039pdc_stable_init(void)
1044{ 1040{
1045 struct subsys_attribute *attr; 1041 int rc = 0, error = 0;
1046 int i, rc = 0, error = 0;
1047 u32 result; 1042 u32 result;
1048 1043
1049 /* find the size of the stable storage */ 1044 /* find the size of the stable storage */
@@ -1068,10 +1063,8 @@ pdc_stable_init(void)
1068 goto fail_firmreg; 1063 goto fail_firmreg;
1069 1064
1070 /* Don't forget the root entries */ 1065 /* Don't forget the root entries */
1071 for (i = 0; (attr = pdcs_subsys_attrs[i]) && !error; i++) 1066 error = sysfs_create_group(&stable_subsys.kobj, pdcs_attr_group);
1072 if (attr->show) 1067
1073 error = subsys_create_file(&stable_subsys, attr);
1074
1075 /* register the paths subsys as a subsystem of stable subsys */ 1068 /* register the paths subsys as a subsystem of stable subsys */
1076 paths_subsys.kobj.kset = &stable_subsys; 1069 paths_subsys.kobj.kset = &stable_subsys;
1077 if ((rc = subsystem_register(&paths_subsys))) 1070 if ((rc = subsystem_register(&paths_subsys)))