Merge current mainline tree into linux-omap tree
[pandora-kernel.git] / arch / arm / plat-omap / component-version.c
1 /*
2  *  linux/arch/arm/plat-omap/component-version.c
3  *
4  *  Copyright (C) 2005 Nokia Corporation
5  *  Written by Juha Yrjölä <juha.yrjola@nokia.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  */
11
12 #include <linux/init.h>
13 #include <linux/module.h>
14 #include <linux/err.h>
15 #include <linux/proc_fs.h>
16 #include <mach/board.h>
17 #include <mach/board-nokia.h>
18
19 static int component_version_read_proc(char *page, char **start, off_t off,
20                                        int count, int *eof, void *data)
21 {
22         int len, i;
23         const struct omap_version_config *ver;
24         char *p;
25
26         i = 0;
27         p = page;
28         while ((ver = omap_get_nr_config(OMAP_TAG_VERSION_STR,
29                                          struct omap_version_config, i)) != NULL) {
30                 p += sprintf(p, "%-12s%s\n", ver->component, ver->version);
31                 i++;
32         }
33
34         len = (p - page) - off;
35         if (len < 0)
36                 len = 0;
37
38         *eof = (len <= count) ? 1 : 0;
39         *start = page + off;
40
41         return len;
42 }
43
44 static int __init component_version_init(void)
45 {
46         if (omap_get_config(OMAP_TAG_VERSION_STR, struct omap_version_config) == NULL)
47                 return -ENODEV;
48         if (!create_proc_read_entry("component_version", S_IRUGO, NULL,
49                                     component_version_read_proc, NULL))
50                 return -ENOMEM;
51
52         return 0;
53 }
54
55 static void __exit component_version_exit(void)
56 {
57         remove_proc_entry("component_version", NULL);
58 }
59
60 late_initcall(component_version_init);
61 module_exit(component_version_exit);
62
63 MODULE_AUTHOR("Juha Yrjölä <juha.yrjola@nokia.com>");
64 MODULE_DESCRIPTION("Component version driver");
65 MODULE_LICENSE("GPL");