pdc_stable.c (f62ed9e33b3ccff54d66b08f82d11940bb9e269b) pdc_stable.c (c829a5b49858a83cc7bb5e1e730796575f5bb261)
1/*
2 * Interfaces to retrieve and set PDC Stable options (firmware)
3 *
4 * Copyright (C) 2005-2006 Thibaut VARENE <varenet@parisc-linux.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 2, as
8 * published by the Free Software Foundation.

--- 946 unchanged lines hidden (view full) ---

955 &pdcs_attr_osdep2.attr,
956 NULL,
957};
958
959static struct attribute_group pdcs_attr_group = {
960 .attrs = pdcs_subsys_attrs,
961};
962
1/*
2 * Interfaces to retrieve and set PDC Stable options (firmware)
3 *
4 * Copyright (C) 2005-2006 Thibaut VARENE <varenet@parisc-linux.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 2, as
8 * published by the Free Software Foundation.

--- 946 unchanged lines hidden (view full) ---

955 &pdcs_attr_osdep2.attr,
956 NULL,
957};
958
959static struct attribute_group pdcs_attr_group = {
960 .attrs = pdcs_subsys_attrs,
961};
962
963static struct kset *stable_kset;
963static struct kobject *stable_kobj;
964static struct kset *paths_kset;
965
966/**
967 * pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage.
968 *
969 * It creates kobjects corresponding to each path entry with nice sysfs
970 * links to the real device. This is where the magic takes place: when
971 * registering the subsystem attributes during module init, each kobject hereby

--- 81 unchanged lines hidden (view full) ---

1053
1054 /* get OSID */
1055 if (pdc_stable_read(PDCS_ADDR_OSID, &result, sizeof(result)) != PDC_OK)
1056 return -EIO;
1057
1058 /* the actual result is 16 bits away */
1059 pdcs_osid = (u16)(result >> 16);
1060
964static struct kset *paths_kset;
965
966/**
967 * pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage.
968 *
969 * It creates kobjects corresponding to each path entry with nice sysfs
970 * links to the real device. This is where the magic takes place: when
971 * registering the subsystem attributes during module init, each kobject hereby

--- 81 unchanged lines hidden (view full) ---

1053
1054 /* get OSID */
1055 if (pdc_stable_read(PDCS_ADDR_OSID, &result, sizeof(result)) != PDC_OK)
1056 return -EIO;
1057
1058 /* the actual result is 16 bits away */
1059 pdcs_osid = (u16)(result >> 16);
1060
1061 /* For now we'll register the stable kset within this driver */
1062 stable_kset = kset_create_and_add("stable", NULL, firmware_kobj);
1063 if (!stable_kset) {
1061 /* For now we'll register the directory at /sys/firmware/stable */
1062 stable_kobj = kobject_create_and_add("stable", firmware_kobj);
1063 if (!stable_kobj) {
1064 rc = -ENOMEM;
1065 goto fail_firmreg;
1066 }
1067
1068 /* Don't forget the root entries */
1064 rc = -ENOMEM;
1065 goto fail_firmreg;
1066 }
1067
1068 /* Don't forget the root entries */
1069 error = sysfs_create_group(&stable_kset->kobj, pdcs_attr_group);
1069 error = sysfs_create_group(stable_kobj, pdcs_attr_group);
1070
1071 /* register the paths kset as a child of the stable kset */
1070
1071 /* register the paths kset as a child of the stable kset */
1072 paths_kset = kset_create_and_add("paths", NULL, &stable_kset->kobj);
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 */
1079 if ((rc = pdcs_register_pathentries()))
1080 goto fail_pdcsreg;
1081
1082 return rc;
1083
1084fail_pdcsreg:
1085 pdcs_unregister_pathentries();
1086 kset_unregister(paths_kset);
1087
1088fail_ksetreg:
1073 if (!paths_kset) {
1074 rc = -ENOMEM;
1075 goto fail_ksetreg;
1076 }
1077
1078 /* now we create all "files" for the paths kset */
1079 if ((rc = pdcs_register_pathentries()))
1080 goto fail_pdcsreg;
1081
1082 return rc;
1083
1084fail_pdcsreg:
1085 pdcs_unregister_pathentries();
1086 kset_unregister(paths_kset);
1087
1088fail_ksetreg:
1089 kset_unregister(stable_kset);
1089 kobject_unregister(stable_kobj);
1090
1091fail_firmreg:
1092 printk(KERN_INFO PDCS_PREFIX " bailing out\n");
1093 return rc;
1094}
1095
1096static void __exit
1097pdc_stable_exit(void)
1098{
1099 pdcs_unregister_pathentries();
1100 kset_unregister(paths_kset);
1090
1091fail_firmreg:
1092 printk(KERN_INFO PDCS_PREFIX " bailing out\n");
1093 return rc;
1094}
1095
1096static void __exit
1097pdc_stable_exit(void)
1098{
1099 pdcs_unregister_pathentries();
1100 kset_unregister(paths_kset);
1101 kset_unregister(stable_kset);
1101 kobject_unregister(stable_kobj);
1102}
1103
1104
1105module_init(pdc_stable_init);
1106module_exit(pdc_stable_exit);
1102}
1103
1104
1105module_init(pdc_stable_init);
1106module_exit(pdc_stable_exit);