aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/i2o/i2o_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message/i2o/i2o_config.c')
-rw-r--r--drivers/message/i2o/i2o_config.c156
1 files changed, 2 insertions, 154 deletions
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index 383e89a5c9f0..849d90aad779 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -30,27 +30,11 @@
30 * 2 of the License, or (at your option) any later version. 30 * 2 of the License, or (at your option) any later version.
31 */ 31 */
32 32
33#include <linux/module.h>
34#include <linux/kernel.h>
35#include <linux/pci.h>
36#include <linux/i2o.h>
37#include <linux/errno.h>
38#include <linux/init.h>
39#include <linux/slab.h>
40#include <linux/miscdevice.h> 33#include <linux/miscdevice.h>
41#include <linux/mm.h>
42#include <linux/spinlock.h>
43#include <linux/smp_lock.h> 34#include <linux/smp_lock.h>
44#include <linux/ioctl32.h>
45#include <linux/compat.h> 35#include <linux/compat.h>
46#include <linux/syscalls.h>
47 36
48#include <asm/uaccess.h> 37#include <asm/uaccess.h>
49#include <asm/io.h>
50
51#define OSM_NAME "config-osm"
52#define OSM_VERSION "$Rev$"
53#define OSM_DESCRIPTION "I2O Configuration OSM"
54 38
55extern int i2o_parm_issue(struct i2o_device *, int, void *, int, void *, int); 39extern int i2o_parm_issue(struct i2o_device *, int, void *, int, void *, int);
56 40
@@ -80,125 +64,6 @@ struct i2o_cfg_info {
80static struct i2o_cfg_info *open_files = NULL; 64static struct i2o_cfg_info *open_files = NULL;
81static ulong i2o_cfg_info_id = 0; 65static ulong i2o_cfg_info_id = 0;
82 66
83/**
84 * i2o_config_read_hrt - Returns the HRT of the controller
85 * @kob: kernel object handle
86 * @buf: buffer into which the HRT should be copied
87 * @off: file offset
88 * @count: number of bytes to read
89 *
90 * Put @count bytes starting at @off into @buf from the HRT of the I2O
91 * controller corresponding to @kobj.
92 *
93 * Returns number of bytes copied into buffer.
94 */
95static ssize_t i2o_config_read_hrt(struct kobject *kobj, char *buf,
96 loff_t offset, size_t count)
97{
98 struct i2o_controller *c = to_i2o_controller(container_of(kobj,
99 struct device,
100 kobj));
101 i2o_hrt *hrt = c->hrt.virt;
102
103 u32 size = (hrt->num_entries * hrt->entry_len + 2) * 4;
104
105 if(offset > size)
106 return 0;
107
108 if(offset + count > size)
109 count = size - offset;
110
111 memcpy(buf, (u8 *) hrt + offset, count);
112
113 return count;
114};
115
116/**
117 * i2o_config_read_lct - Returns the LCT of the controller
118 * @kob: kernel object handle
119 * @buf: buffer into which the LCT should be copied
120 * @off: file offset
121 * @count: number of bytes to read
122 *
123 * Put @count bytes starting at @off into @buf from the LCT of the I2O
124 * controller corresponding to @kobj.
125 *
126 * Returns number of bytes copied into buffer.
127 */
128static ssize_t i2o_config_read_lct(struct kobject *kobj, char *buf,
129 loff_t offset, size_t count)
130{
131 struct i2o_controller *c = to_i2o_controller(container_of(kobj,
132 struct device,
133 kobj));
134 u32 size = c->lct->table_size * 4;
135
136 if(offset > size)
137 return 0;
138
139 if(offset + count > size)
140 count = size - offset;
141
142 memcpy(buf, (u8 *) c->lct + offset, count);
143
144 return count;
145};
146
147/* attribute for HRT in sysfs */
148static struct bin_attribute i2o_config_hrt_attr = {
149 .attr = {
150 .name = "hrt",
151 .mode = S_IRUGO,
152 .owner = THIS_MODULE
153 },
154 .size = 0,
155 .read = i2o_config_read_hrt
156};
157
158/* attribute for LCT in sysfs */
159static struct bin_attribute i2o_config_lct_attr = {
160 .attr = {
161 .name = "lct",
162 .mode = S_IRUGO,
163 .owner = THIS_MODULE
164 },
165 .size = 0,
166 .read = i2o_config_read_lct
167};
168
169/**
170 * i2o_config_notify_controller_add - Notify of added controller
171 * @c: the controller which was added
172 *
173 * If a I2O controller is added, we catch the notification to add sysfs
174 * entries.
175 */
176static void i2o_config_notify_controller_add(struct i2o_controller *c)
177{
178 sysfs_create_bin_file(&(c->device.kobj), &i2o_config_hrt_attr);
179 sysfs_create_bin_file(&(c->device.kobj), &i2o_config_lct_attr);
180};
181
182/**
183 * i2o_config_notify_controller_remove - Notify of removed controller
184 * @c: the controller which was removed
185 *
186 * If a I2O controller is removed, we catch the notification to remove the
187 * sysfs entries.
188 */
189static void i2o_config_notify_controller_remove(struct i2o_controller *c)
190{
191 sysfs_remove_bin_file(&c->device.kobj, &i2o_config_lct_attr);
192 sysfs_remove_bin_file(&c->device.kobj, &i2o_config_hrt_attr);
193};
194
195/* Config OSM driver struct */
196static struct i2o_driver i2o_config_driver = {
197 .name = OSM_NAME,
198 .notify_controller_add = i2o_config_notify_controller_add,
199 .notify_controller_remove = i2o_config_notify_controller_remove
200};
201
202static int i2o_cfg_getiops(unsigned long arg) 67static int i2o_cfg_getiops(unsigned long arg)
203{ 68{
204 struct i2o_controller *c; 69 struct i2o_controller *c;
@@ -1257,37 +1122,20 @@ static struct miscdevice i2o_miscdev = {
1257 &config_fops 1122 &config_fops
1258}; 1123};
1259 1124
1260static int __init i2o_config_init(void) 1125static int __init i2o_config_old_init(void)
1261{ 1126{
1262 printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
1263
1264 spin_lock_init(&i2o_config_lock); 1127 spin_lock_init(&i2o_config_lock);
1265 1128
1266 if (misc_register(&i2o_miscdev) < 0) { 1129 if (misc_register(&i2o_miscdev) < 0) {
1267 osm_err("can't register device.\n"); 1130 osm_err("can't register device.\n");
1268 return -EBUSY; 1131 return -EBUSY;
1269 } 1132 }
1270 /*
1271 * Install our handler
1272 */
1273 if (i2o_driver_register(&i2o_config_driver)) {
1274 osm_err("handler register failed.\n");
1275 misc_deregister(&i2o_miscdev);
1276 return -EBUSY;
1277 }
1278 return 0; 1133 return 0;
1279} 1134}
1280 1135
1281static void i2o_config_exit(void) 1136static void i2o_config_old_exit(void)
1282{ 1137{
1283 misc_deregister(&i2o_miscdev); 1138 misc_deregister(&i2o_miscdev);
1284 i2o_driver_unregister(&i2o_config_driver);
1285} 1139}
1286 1140
1287MODULE_AUTHOR("Red Hat Software"); 1141MODULE_AUTHOR("Red Hat Software");
1288MODULE_LICENSE("GPL");
1289MODULE_DESCRIPTION(OSM_DESCRIPTION);
1290MODULE_VERSION(OSM_VERSION);
1291
1292module_init(i2o_config_init);
1293module_exit(i2o_config_exit);