[PATCH] aic7xxx_osm build fix
[cris-mirror.git] / drivers / parisc / pdc_stable.c
blob67c8f3b44848d71fd7d35e55d8f484445346d379
1 /*
2 * Interfaces to retrieve and set PDC Stable options (firmware)
4 * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * DEV NOTE: the PDC Procedures reference states that:
22 * "A minimum of 96 bytes of Stable Storage is required. Providing more than
23 * 96 bytes of Stable Storage is optional [...]. Failure to provide the
24 * optional locations from 96 to 192 results in the loss of certain
25 * functionality during boot."
27 * Since locations between 96 and 192 are the various paths, most (if not
28 * all) PA-RISC machines should have them. Anyway, for safety reasons, the
29 * following code can deal with only 96 bytes of Stable Storage, and all
30 * sizes between 96 and 192 bytes (provided they are multiple of struct
31 * device_path size, eg: 128, 160 and 192) to provide full information.
32 * The code makes no use of data above 192 bytes. One last word: there's one
33 * path we can always count on: the primary path.
36 #undef PDCS_DEBUG
37 #ifdef PDCS_DEBUG
38 #define DPRINTK(fmt, args...) printk(KERN_DEBUG fmt, ## args)
39 #else
40 #define DPRINTK(fmt, args...)
41 #endif
43 #include <linux/module.h>
44 #include <linux/init.h>
45 #include <linux/sched.h> /* for capable() */
46 #include <linux/kernel.h>
47 #include <linux/string.h>
48 #include <linux/ctype.h>
49 #include <linux/sysfs.h>
50 #include <linux/kobject.h>
51 #include <linux/device.h>
52 #include <linux/errno.h>
54 #include <asm/pdc.h>
55 #include <asm/page.h>
56 #include <asm/uaccess.h>
57 #include <asm/hardware.h>
59 #define PDCS_VERSION "0.09"
61 #define PDCS_ADDR_PPRI 0x00
62 #define PDCS_ADDR_OSID 0x40
63 #define PDCS_ADDR_FSIZ 0x5C
64 #define PDCS_ADDR_PCON 0x60
65 #define PDCS_ADDR_PALT 0x80
66 #define PDCS_ADDR_PKBD 0xA0
68 MODULE_AUTHOR("Thibaut VARENE <varenet@parisc-linux.org>");
69 MODULE_DESCRIPTION("sysfs interface to HP PDC Stable Storage data");
70 MODULE_LICENSE("GPL");
71 MODULE_VERSION(PDCS_VERSION);
73 static unsigned long pdcs_size = 0;
75 /* This struct defines what we need to deal with a parisc pdc path entry */
76 struct pdcspath_entry {
77 short ready; /* entry record is valid if != 0 */
78 unsigned long addr; /* entry address in stable storage */
79 char *name; /* entry name */
80 struct device_path devpath; /* device path in parisc representation */
81 struct device *dev; /* corresponding device */
82 struct kobject kobj;
85 struct pdcspath_attribute {
86 struct attribute attr;
87 ssize_t (*show)(struct pdcspath_entry *entry, char *buf);
88 ssize_t (*store)(struct pdcspath_entry *entry, const char *buf, size_t count);
91 #define PDCSPATH_ENTRY(_addr, _name) \
92 struct pdcspath_entry pdcspath_entry_##_name = { \
93 .ready = 0, \
94 .addr = _addr, \
95 .name = __stringify(_name), \
98 #define PDCS_ATTR(_name, _mode, _show, _store) \
99 struct subsys_attribute pdcs_attr_##_name = { \
100 .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE}, \
101 .show = _show, \
102 .store = _store, \
105 #define PATHS_ATTR(_name, _mode, _show, _store) \
106 struct pdcspath_attribute paths_attr_##_name = { \
107 .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE}, \
108 .show = _show, \
109 .store = _store, \
112 #define to_pdcspath_attribute(_attr) container_of(_attr, struct pdcspath_attribute, attr)
113 #define to_pdcspath_entry(obj) container_of(obj, struct pdcspath_entry, kobj)
116 * pdcspath_fetch - This function populates the path entry structs.
117 * @entry: A pointer to an allocated pdcspath_entry.
119 * The general idea is that you don't read from the Stable Storage every time
120 * you access the files provided by the facilites. We store a copy of the
121 * content of the stable storage WRT various paths in these structs. We read
122 * these structs when reading the files, and we will write to these structs when
123 * writing to the files, and only then write them back to the Stable Storage.
125 static int
126 pdcspath_fetch(struct pdcspath_entry *entry)
128 struct device_path *devpath;
130 if (!entry)
131 return -EINVAL;
133 devpath = &entry->devpath;
135 DPRINTK("%s: fetch: 0x%p, 0x%p, addr: 0x%lx\n", __func__,
136 entry, devpath, entry->addr);
138 /* addr, devpath and count must be word aligned */
139 if (pdc_stable_read(entry->addr, devpath, sizeof(*devpath)) != PDC_OK)
140 return -EIO;
142 /* Find the matching device.
143 NOTE: hardware_path overlays with device_path, so the nice cast can
144 be used */
145 entry->dev = hwpath_to_device((struct hardware_path *)devpath);
147 entry->ready = 1;
149 DPRINTK("%s: device: 0x%p\n", __func__, entry->dev);
151 return 0;
155 * pdcspath_store - This function writes a path to stable storage.
156 * @entry: A pointer to an allocated pdcspath_entry.
158 * It can be used in two ways: either by passing it a preset devpath struct
159 * containing an already computed hardware path, or by passing it a device
160 * pointer, from which it'll find out the corresponding hardware path.
161 * For now we do not handle the case where there's an error in writing to the
162 * Stable Storage area, so you'd better not mess up the data :P
164 static int
165 pdcspath_store(struct pdcspath_entry *entry)
167 struct device_path *devpath;
169 if (!entry)
170 return -EINVAL;
172 devpath = &entry->devpath;
174 /* We expect the caller to set the ready flag to 0 if the hardware
175 path struct provided is invalid, so that we know we have to fill it.
176 First case, we don't have a preset hwpath... */
177 if (!entry->ready) {
178 /* ...but we have a device, map it */
179 if (entry->dev)
180 device_to_hwpath(entry->dev, (struct hardware_path *)devpath);
181 else
182 return -EINVAL;
184 /* else, we expect the provided hwpath to be valid. */
186 DPRINTK("%s: store: 0x%p, 0x%p, addr: 0x%lx\n", __func__,
187 entry, devpath, entry->addr);
189 /* addr, devpath and count must be word aligned */
190 if (pdc_stable_write(entry->addr, devpath, sizeof(*devpath)) != PDC_OK) {
191 printk(KERN_ERR "%s: an error occured when writing to PDC.\n"
192 "It is likely that the Stable Storage data has been corrupted.\n"
193 "Please check it carefully upon next reboot.\n", __func__);
194 return -EIO;
197 entry->ready = 1;
199 DPRINTK("%s: device: 0x%p\n", __func__, entry->dev);
201 return 0;
205 * pdcspath_hwpath_read - This function handles hardware path pretty printing.
206 * @entry: An allocated and populated pdscpath_entry struct.
207 * @buf: The output buffer to write to.
209 * We will call this function to format the output of the hwpath attribute file.
211 static ssize_t
212 pdcspath_hwpath_read(struct pdcspath_entry *entry, char *buf)
214 char *out = buf;
215 struct device_path *devpath;
216 unsigned short i;
218 if (!entry || !buf)
219 return -EINVAL;
221 devpath = &entry->devpath;
223 if (!entry->ready)
224 return -ENODATA;
226 for (i = 0; i < 6; i++) {
227 if (devpath->bc[i] >= 128)
228 continue;
229 out += sprintf(out, "%u/", (unsigned char)devpath->bc[i]);
231 out += sprintf(out, "%u\n", (unsigned char)devpath->mod);
233 return out - buf;
237 * pdcspath_hwpath_write - This function handles hardware path modifying.
238 * @entry: An allocated and populated pdscpath_entry struct.
239 * @buf: The input buffer to read from.
240 * @count: The number of bytes to be read.
242 * We will call this function to change the current hardware path.
243 * Hardware paths are to be given '/'-delimited, without brackets.
244 * We take care to make sure that the provided path actually maps to an existing
245 * device, BUT nothing would prevent some foolish user to set the path to some
246 * PCI bridge or even a CPU...
247 * A better work around would be to make sure we are at the end of a device tree
248 * for instance, but it would be IMHO beyond the simple scope of that driver.
249 * The aim is to provide a facility. Data correctness is left to userland.
251 static ssize_t
252 pdcspath_hwpath_write(struct pdcspath_entry *entry, const char *buf, size_t count)
254 struct hardware_path hwpath;
255 unsigned short i;
256 char in[count+1], *temp;
257 struct device *dev;
259 if (!entry || !buf || !count)
260 return -EINVAL;
262 /* We'll use a local copy of buf */
263 memset(in, 0, count+1);
264 strncpy(in, buf, count);
266 /* Let's clean up the target. 0xff is a blank pattern */
267 memset(&hwpath, 0xff, sizeof(hwpath));
269 /* First, pick the mod field (the last one of the input string) */
270 if (!(temp = strrchr(in, '/')))
271 return -EINVAL;
273 hwpath.mod = simple_strtoul(temp+1, NULL, 10);
274 in[temp-in] = '\0'; /* truncate the remaining string. just precaution */
275 DPRINTK("%s: mod: %d\n", __func__, hwpath.mod);
277 /* Then, loop for each delimiter, making sure we don't have too many.
278 we write the bc fields in a down-top way. No matter what, we stop
279 before writing the last field. If there are too many fields anyway,
280 then the user is a moron and it'll be caught up later when we'll
281 check the consistency of the given hwpath. */
282 for (i=5; ((temp = strrchr(in, '/'))) && (temp-in > 0) && (likely(i)); i--) {
283 hwpath.bc[i] = simple_strtoul(temp+1, NULL, 10);
284 in[temp-in] = '\0';
285 DPRINTK("%s: bc[%d]: %d\n", __func__, i, hwpath.bc[i]);
288 /* Store the final field */
289 hwpath.bc[i] = simple_strtoul(in, NULL, 10);
290 DPRINTK("%s: bc[%d]: %d\n", __func__, i, hwpath.bc[i]);
292 /* Now we check that the user isn't trying to lure us */
293 if (!(dev = hwpath_to_device((struct hardware_path *)&hwpath))) {
294 printk(KERN_WARNING "%s: attempt to set invalid \"%s\" "
295 "hardware path: %s\n", __func__, entry->name, buf);
296 return -EINVAL;
299 /* So far so good, let's get in deep */
300 entry->ready = 0;
301 entry->dev = dev;
303 /* Now, dive in. Write back to the hardware */
304 WARN_ON(pdcspath_store(entry)); /* this warn should *NEVER* happen */
306 /* Update the symlink to the real device */
307 sysfs_remove_link(&entry->kobj, "device");
308 sysfs_create_link(&entry->kobj, &entry->dev->kobj, "device");
310 printk(KERN_INFO "PDC Stable Storage: changed \"%s\" path to \"%s\"\n",
311 entry->name, buf);
313 return count;
317 * pdcspath_layer_read - Extended layer (eg. SCSI ids) pretty printing.
318 * @entry: An allocated and populated pdscpath_entry struct.
319 * @buf: The output buffer to write to.
321 * We will call this function to format the output of the layer attribute file.
323 static ssize_t
324 pdcspath_layer_read(struct pdcspath_entry *entry, char *buf)
326 char *out = buf;
327 struct device_path *devpath;
328 unsigned short i;
330 if (!entry || !buf)
331 return -EINVAL;
333 devpath = &entry->devpath;
335 if (!entry->ready)
336 return -ENODATA;
338 for (i = 0; devpath->layers[i] && (likely(i < 6)); i++)
339 out += sprintf(out, "%u ", devpath->layers[i]);
341 out += sprintf(out, "\n");
343 return out - buf;
347 * pdcspath_layer_write - This function handles extended layer modifying.
348 * @entry: An allocated and populated pdscpath_entry struct.
349 * @buf: The input buffer to read from.
350 * @count: The number of bytes to be read.
352 * We will call this function to change the current layer value.
353 * Layers are to be given '.'-delimited, without brackets.
354 * XXX beware we are far less checky WRT input data provided than for hwpath.
355 * Potential harm can be done, since there's no way to check the validity of
356 * the layer fields.
358 static ssize_t
359 pdcspath_layer_write(struct pdcspath_entry *entry, const char *buf, size_t count)
361 unsigned int layers[6]; /* device-specific info (ctlr#, unit#, ...) */
362 unsigned short i;
363 char in[count+1], *temp;
365 if (!entry || !buf || !count)
366 return -EINVAL;
368 /* We'll use a local copy of buf */
369 memset(in, 0, count+1);
370 strncpy(in, buf, count);
372 /* Let's clean up the target. 0 is a blank pattern */
373 memset(&layers, 0, sizeof(layers));
375 /* First, pick the first layer */
376 if (unlikely(!isdigit(*in)))
377 return -EINVAL;
378 layers[0] = simple_strtoul(in, NULL, 10);
379 DPRINTK("%s: layer[0]: %d\n", __func__, layers[0]);
381 temp = in;
382 for (i=1; ((temp = strchr(temp, '.'))) && (likely(i<6)); i++) {
383 if (unlikely(!isdigit(*(++temp))))
384 return -EINVAL;
385 layers[i] = simple_strtoul(temp, NULL, 10);
386 DPRINTK("%s: layer[%d]: %d\n", __func__, i, layers[i]);
389 /* So far so good, let's get in deep */
391 /* First, overwrite the current layers with the new ones, not touching
392 the hardware path. */
393 memcpy(&entry->devpath.layers, &layers, sizeof(layers));
395 /* Now, dive in. Write back to the hardware */
396 WARN_ON(pdcspath_store(entry)); /* this warn should *NEVER* happen */
398 printk(KERN_INFO "PDC Stable Storage: changed \"%s\" layers to \"%s\"\n",
399 entry->name, buf);
401 return count;
405 * pdcspath_attr_show - Generic read function call wrapper.
406 * @kobj: The kobject to get info from.
407 * @attr: The attribute looked upon.
408 * @buf: The output buffer.
410 static ssize_t
411 pdcspath_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
413 struct pdcspath_entry *entry = to_pdcspath_entry(kobj);
414 struct pdcspath_attribute *pdcs_attr = to_pdcspath_attribute(attr);
415 ssize_t ret = 0;
417 if (!capable(CAP_SYS_ADMIN))
418 return -EACCES;
420 if (pdcs_attr->show)
421 ret = pdcs_attr->show(entry, buf);
423 return ret;
427 * pdcspath_attr_store - Generic write function call wrapper.
428 * @kobj: The kobject to write info to.
429 * @attr: The attribute to be modified.
430 * @buf: The input buffer.
431 * @count: The size of the buffer.
433 static ssize_t
434 pdcspath_attr_store(struct kobject *kobj, struct attribute *attr,
435 const char *buf, size_t count)
437 struct pdcspath_entry *entry = to_pdcspath_entry(kobj);
438 struct pdcspath_attribute *pdcs_attr = to_pdcspath_attribute(attr);
439 ssize_t ret = 0;
441 if (!capable(CAP_SYS_ADMIN))
442 return -EACCES;
444 if (pdcs_attr->store)
445 ret = pdcs_attr->store(entry, buf, count);
447 return ret;
450 static struct sysfs_ops pdcspath_attr_ops = {
451 .show = pdcspath_attr_show,
452 .store = pdcspath_attr_store,
455 /* These are the two attributes of any PDC path. */
456 static PATHS_ATTR(hwpath, 0600, pdcspath_hwpath_read, pdcspath_hwpath_write);
457 static PATHS_ATTR(layer, 0600, pdcspath_layer_read, pdcspath_layer_write);
459 static struct attribute *paths_subsys_attrs[] = {
460 &paths_attr_hwpath.attr,
461 &paths_attr_layer.attr,
462 NULL,
465 /* Specific kobject type for our PDC paths */
466 static struct kobj_type ktype_pdcspath = {
467 .sysfs_ops = &pdcspath_attr_ops,
468 .default_attrs = paths_subsys_attrs,
471 /* We hard define the 4 types of path we expect to find */
472 static PDCSPATH_ENTRY(PDCS_ADDR_PPRI, primary);
473 static PDCSPATH_ENTRY(PDCS_ADDR_PCON, console);
474 static PDCSPATH_ENTRY(PDCS_ADDR_PALT, alternative);
475 static PDCSPATH_ENTRY(PDCS_ADDR_PKBD, keyboard);
477 /* An array containing all PDC paths we will deal with */
478 static struct pdcspath_entry *pdcspath_entries[] = {
479 &pdcspath_entry_primary,
480 &pdcspath_entry_alternative,
481 &pdcspath_entry_console,
482 &pdcspath_entry_keyboard,
483 NULL,
487 * pdcs_info_read - Pretty printing of the remaining useful data.
488 * @entry: An allocated and populated subsytem struct. We don't use it tho.
489 * @buf: The output buffer to write to.
491 * We will call this function to format the output of the 'info' attribute file.
492 * Please refer to PDC Procedures documentation, section PDC_STABLE to get a
493 * better insight of what we're doing here.
495 static ssize_t
496 pdcs_info_read(struct subsystem *entry, char *buf)
498 char *out = buf;
499 __u32 result;
500 struct device_path devpath;
501 char *tmpstr = NULL;
503 if (!entry || !buf)
504 return -EINVAL;
506 /* show the size of the stable storage */
507 out += sprintf(out, "Stable Storage size: %ld bytes\n", pdcs_size);
509 /* deal with flags */
510 if (pdc_stable_read(PDCS_ADDR_PPRI, &devpath, sizeof(devpath)) != PDC_OK)
511 return -EIO;
513 out += sprintf(out, "Autoboot: %s\n", (devpath.flags & PF_AUTOBOOT) ? "On" : "Off");
514 out += sprintf(out, "Autosearch: %s\n", (devpath.flags & PF_AUTOSEARCH) ? "On" : "Off");
515 out += sprintf(out, "Timer: %u s\n", (devpath.flags & PF_TIMER) ? (1 << (devpath.flags & PF_TIMER)) : 0);
517 /* get OSID */
518 if (pdc_stable_read(PDCS_ADDR_OSID, &result, sizeof(result)) != PDC_OK)
519 return -EIO;
521 /* the actual result is 16 bits away */
522 switch (result >> 16) {
523 case 0x0000: tmpstr = "No OS-dependent data"; break;
524 case 0x0001: tmpstr = "HP-UX dependent data"; break;
525 case 0x0002: tmpstr = "MPE-iX dependent data"; break;
526 case 0x0003: tmpstr = "OSF dependent data"; break;
527 case 0x0004: tmpstr = "HP-RT dependent data"; break;
528 case 0x0005: tmpstr = "Novell Netware dependent data"; break;
529 default: tmpstr = "Unknown"; break;
531 out += sprintf(out, "OS ID: %s (0x%.4x)\n", tmpstr, (result >> 16));
533 /* get fast-size */
534 if (pdc_stable_read(PDCS_ADDR_FSIZ, &result, sizeof(result)) != PDC_OK)
535 return -EIO;
537 out += sprintf(out, "Memory tested: ");
538 if ((result & 0x0F) < 0x0E)
539 out += sprintf(out, "%.3f MB", 0.256*(1<<(result & 0x0F)));
540 else
541 out += sprintf(out, "All");
542 out += sprintf(out, "\n");
544 return out - buf;
548 * pdcs_info_write - This function handles boot flag modifying.
549 * @entry: An allocated and populated subsytem struct. We don't use it tho.
550 * @buf: The input buffer to read from.
551 * @count: The number of bytes to be read.
553 * We will call this function to change the current boot flags.
554 * We expect a precise syntax:
555 * \"n n\" (n == 0 or 1) to toggle respectively AutoBoot and AutoSearch
557 * As of now there is no incentive on my side to provide more "knobs" to that
558 * interface, since modifying the rest of the data is pretty meaningless when
559 * the machine is running and for the expected use of that facility, such as
560 * PALO setting up the boot disk when installing a Linux distribution...
562 static ssize_t
563 pdcs_info_write(struct subsystem *entry, const char *buf, size_t count)
565 struct pdcspath_entry *pathentry;
566 unsigned char flags;
567 char in[count+1], *temp;
568 char c;
570 if (!capable(CAP_SYS_ADMIN))
571 return -EACCES;
573 if (!entry || !buf || !count)
574 return -EINVAL;
576 /* We'll use a local copy of buf */
577 memset(in, 0, count+1);
578 strncpy(in, buf, count);
580 /* Current flags are stored in primary boot path entry */
581 pathentry = &pdcspath_entry_primary;
583 /* Be nice to the existing flag record */
584 flags = pathentry->devpath.flags;
586 DPRINTK("%s: flags before: 0x%X\n", __func__, flags);
588 temp = in;
590 while (*temp && isspace(*temp))
591 temp++;
593 c = *temp++ - '0';
594 if ((c != 0) && (c != 1))
595 goto parse_error;
596 if (c == 0)
597 flags &= ~PF_AUTOBOOT;
598 else
599 flags |= PF_AUTOBOOT;
601 if (*temp++ != ' ')
602 goto parse_error;
604 c = *temp++ - '0';
605 if ((c != 0) && (c != 1))
606 goto parse_error;
607 if (c == 0)
608 flags &= ~PF_AUTOSEARCH;
609 else
610 flags |= PF_AUTOSEARCH;
612 DPRINTK("%s: flags after: 0x%X\n", __func__, flags);
614 /* So far so good, let's get in deep */
616 /* Change the path entry flags first */
617 pathentry->devpath.flags = flags;
619 /* Now, dive in. Write back to the hardware */
620 WARN_ON(pdcspath_store(pathentry)); /* this warn should *NEVER* happen */
622 printk(KERN_INFO "PDC Stable Storage: changed flags to \"%s\"\n", buf);
624 return count;
626 parse_error:
627 printk(KERN_WARNING "%s: Parse error: expect \"n n\" (n == 0 or 1) for AB and AS\n", __func__);
628 return -EINVAL;
631 /* The last attribute (the 'root' one actually) with all remaining data. */
632 static PDCS_ATTR(info, 0600, pdcs_info_read, pdcs_info_write);
634 static struct subsys_attribute *pdcs_subsys_attrs[] = {
635 &pdcs_attr_info,
636 NULL, /* maybe more in the future? */
639 static decl_subsys(paths, &ktype_pdcspath, NULL);
640 static decl_subsys(pdc, NULL, NULL);
643 * pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage.
645 * It creates kobjects corresponding to each path entry with nice sysfs
646 * links to the real device. This is where the magic takes place: when
647 * registering the subsystem attributes during module init, each kobject hereby
648 * created will show in the sysfs tree as a folder containing files as defined
649 * by path_subsys_attr[].
651 static inline int __init
652 pdcs_register_pathentries(void)
654 unsigned short i;
655 struct pdcspath_entry *entry;
657 for (i = 0; (entry = pdcspath_entries[i]); i++) {
658 if (pdcspath_fetch(entry) < 0)
659 continue;
661 kobject_set_name(&entry->kobj, "%s", entry->name);
662 kobj_set_kset_s(entry, paths_subsys);
663 kobject_register(&entry->kobj);
665 if (!entry->dev)
666 continue;
668 /* Add a nice symlink to the real device */
669 sysfs_create_link(&entry->kobj, &entry->dev->kobj, "device");
672 return 0;
676 * pdcs_unregister_pathentries - Routine called when unregistering the module.
678 static inline void __exit
679 pdcs_unregister_pathentries(void)
681 unsigned short i;
682 struct pdcspath_entry *entry;
684 for (i = 0; (entry = pdcspath_entries[i]); i++)
685 if (entry->ready)
686 kobject_unregister(&entry->kobj);
690 * For now we register the pdc subsystem with the firmware subsystem
691 * and the paths subsystem with the pdc subsystem
693 static int __init
694 pdc_stable_init(void)
696 struct subsys_attribute *attr;
697 int i, rc = 0, error = 0;
699 /* find the size of the stable storage */
700 if (pdc_stable_get_size(&pdcs_size) != PDC_OK)
701 return -ENODEV;
703 printk(KERN_INFO "PDC Stable Storage facility v%s\n", PDCS_VERSION);
705 /* For now we'll register the pdc subsys within this driver */
706 if ((rc = firmware_register(&pdc_subsys)))
707 return rc;
709 /* Don't forget the info entry */
710 for (i = 0; (attr = pdcs_subsys_attrs[i]) && !error; i++)
711 if (attr->show)
712 error = subsys_create_file(&pdc_subsys, attr);
714 /* register the paths subsys as a subsystem of pdc subsys */
715 kset_set_kset_s(&paths_subsys, pdc_subsys);
716 subsystem_register(&paths_subsys);
718 /* now we create all "files" for the paths subsys */
719 pdcs_register_pathentries();
721 return 0;
724 static void __exit
725 pdc_stable_exit(void)
727 pdcs_unregister_pathentries();
728 subsystem_unregister(&paths_subsys);
730 firmware_unregister(&pdc_subsys);
734 module_init(pdc_stable_init);
735 module_exit(pdc_stable_exit);