Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * drivers/s390/cio/blacklist.c |
| 3 | * S/390 common I/O routines -- blacklisting of specific devices |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, |
| 6 | * IBM Corporation |
| 7 | * Author(s): Ingo Adlung (adlung@de.ibm.com) |
Cornelia Huck | 4ce3b30 | 2006-01-14 13:21:04 -0800 | [diff] [blame] | 8 | * Cornelia Huck (cornelia.huck@de.ibm.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * Arnd Bergmann (arndb@de.ibm.com) |
| 10 | */ |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/init.h> |
| 13 | #include <linux/vmalloc.h> |
| 14 | #include <linux/slab.h> |
| 15 | #include <linux/proc_fs.h> |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 16 | #include <linux/seq_file.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/ctype.h> |
| 18 | #include <linux/device.h> |
| 19 | |
| 20 | #include <asm/cio.h> |
| 21 | #include <asm/uaccess.h> |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 22 | #include <asm/cio.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | |
| 24 | #include "blacklist.h" |
| 25 | #include "cio.h" |
| 26 | #include "cio_debug.h" |
| 27 | #include "css.h" |
| 28 | |
| 29 | /* |
| 30 | * "Blacklisting" of certain devices: |
| 31 | * Device numbers given in the commandline as cio_ignore=... won't be known |
| 32 | * to Linux. |
| 33 | * |
| 34 | * These can be single devices or ranges of devices |
| 35 | */ |
| 36 | |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 37 | /* 65536 bits for each set to indicate if a devno is blacklisted or not */ |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 38 | #define __BL_DEV_WORDS ((__MAX_SUBCHANNEL + (8*sizeof(long) - 1)) / \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | (8*sizeof(long))) |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 40 | static unsigned long bl_dev[__MAX_SSID + 1][__BL_DEV_WORDS]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | typedef enum {add, free} range_action; |
| 42 | |
| 43 | /* |
| 44 | * Function: blacklist_range |
| 45 | * (Un-)blacklist the devices from-to |
| 46 | */ |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 47 | static int blacklist_range(range_action action, unsigned int from_ssid, |
| 48 | unsigned int to_ssid, unsigned int from, |
| 49 | unsigned int to, int msgtrigger) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | { |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 51 | if ((from_ssid > to_ssid) || ((from_ssid == to_ssid) && (from > to))) { |
| 52 | if (msgtrigger) |
| 53 | printk(KERN_WARNING "cio: Invalid cio_ignore range " |
| 54 | "0.%x.%04x-0.%x.%04x\n", from_ssid, from, |
| 55 | to_ssid, to); |
| 56 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | } |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 58 | |
| 59 | while ((from_ssid < to_ssid) || ((from_ssid == to_ssid) && |
| 60 | (from <= to))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | if (action == add) |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 62 | set_bit(from, bl_dev[from_ssid]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | else |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 64 | clear_bit(from, bl_dev[from_ssid]); |
| 65 | from++; |
| 66 | if (from > __MAX_SUBCHANNEL) { |
| 67 | from_ssid++; |
| 68 | from = 0; |
| 69 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 75 | static int pure_hex(char **cp, unsigned int *val, int min_digit, |
| 76 | int max_digit, int max_val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | { |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 78 | int diff; |
| 79 | unsigned int value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 81 | diff = 0; |
| 82 | *val = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 84 | while (isxdigit(**cp) && (diff <= max_digit)) { |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 85 | |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 86 | if (isdigit(**cp)) |
| 87 | value = **cp - '0'; |
| 88 | else |
| 89 | value = tolower(**cp) - 'a' + 10; |
| 90 | *val = *val * 16 + value; |
| 91 | (*cp)++; |
| 92 | diff++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | } |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 94 | |
| 95 | if ((diff < min_digit) || (diff > max_digit) || (*val > max_val)) |
| 96 | return 1; |
| 97 | |
| 98 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 101 | static int parse_busid(char *str, int *cssid, int *ssid, int *devno, |
| 102 | int msgtrigger) |
| 103 | { |
| 104 | char *str_work; |
| 105 | int val, rc, ret; |
| 106 | |
| 107 | rc = 1; |
| 108 | |
| 109 | if (*str == '\0') |
| 110 | goto out; |
| 111 | |
| 112 | /* old style */ |
| 113 | str_work = str; |
| 114 | val = simple_strtoul(str, &str_work, 16); |
| 115 | |
| 116 | if (*str_work == '\0') { |
| 117 | if (val <= __MAX_SUBCHANNEL) { |
| 118 | *devno = val; |
| 119 | *ssid = 0; |
| 120 | *cssid = 0; |
| 121 | rc = 0; |
| 122 | } |
| 123 | goto out; |
| 124 | } |
| 125 | |
| 126 | /* new style */ |
| 127 | str_work = str; |
| 128 | ret = pure_hex(&str_work, cssid, 1, 2, __MAX_CSSID); |
| 129 | if (ret || (str_work[0] != '.')) |
| 130 | goto out; |
| 131 | str_work++; |
| 132 | ret = pure_hex(&str_work, ssid, 1, 1, __MAX_SSID); |
| 133 | if (ret || (str_work[0] != '.')) |
| 134 | goto out; |
| 135 | str_work++; |
| 136 | ret = pure_hex(&str_work, devno, 4, 4, __MAX_SUBCHANNEL); |
| 137 | if (ret || (str_work[0] != '\0')) |
| 138 | goto out; |
| 139 | |
| 140 | rc = 0; |
| 141 | out: |
| 142 | if (rc && msgtrigger) |
| 143 | printk(KERN_WARNING "cio: Invalid cio_ignore device '%s'\n", |
| 144 | str); |
| 145 | |
| 146 | return rc; |
| 147 | } |
| 148 | |
| 149 | static int blacklist_parse_parameters(char *str, range_action action, |
| 150 | int msgtrigger) |
| 151 | { |
| 152 | int from_cssid, to_cssid, from_ssid, to_ssid, from, to; |
| 153 | int rc, totalrc; |
| 154 | char *parm; |
| 155 | range_action ra; |
| 156 | |
| 157 | totalrc = 0; |
| 158 | |
| 159 | while ((parm = strsep(&str, ","))) { |
| 160 | rc = 0; |
| 161 | ra = action; |
| 162 | if (*parm == '!') { |
| 163 | if (ra == add) |
| 164 | ra = free; |
| 165 | else |
| 166 | ra = add; |
| 167 | parm++; |
| 168 | } |
| 169 | if (strcmp(parm, "all") == 0) { |
| 170 | from_cssid = 0; |
| 171 | from_ssid = 0; |
| 172 | from = 0; |
| 173 | to_cssid = __MAX_CSSID; |
| 174 | to_ssid = __MAX_SSID; |
| 175 | to = __MAX_SUBCHANNEL; |
| 176 | } else { |
| 177 | rc = parse_busid(strsep(&parm, "-"), &from_cssid, |
| 178 | &from_ssid, &from, msgtrigger); |
| 179 | if (!rc) { |
| 180 | if (parm != NULL) |
| 181 | rc = parse_busid(parm, &to_cssid, |
| 182 | &to_ssid, &to, |
| 183 | msgtrigger); |
| 184 | else { |
| 185 | to_cssid = from_cssid; |
| 186 | to_ssid = from_ssid; |
| 187 | to = from; |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | if (!rc) { |
| 192 | rc = blacklist_range(ra, from_ssid, to_ssid, from, to, |
| 193 | msgtrigger); |
| 194 | if (rc) |
| 195 | totalrc = 1; |
| 196 | } else |
| 197 | totalrc = 1; |
| 198 | } |
| 199 | |
| 200 | return totalrc; |
| 201 | } |
| 202 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | static int __init |
| 204 | blacklist_setup (char *str) |
| 205 | { |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 206 | CIO_MSG_EVENT(6, "Reading blacklist parameters\n"); |
| 207 | if (blacklist_parse_parameters(str, add, 1)) |
| 208 | return 0; |
| 209 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | __setup ("cio_ignore=", blacklist_setup); |
| 213 | |
| 214 | /* Checking if devices are blacklisted */ |
| 215 | |
| 216 | /* |
| 217 | * Function: is_blacklisted |
| 218 | * Returns 1 if the given devicenumber can be found in the blacklist, |
| 219 | * otherwise 0. |
| 220 | * Used by validate_subchannel() |
| 221 | */ |
| 222 | int |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 223 | is_blacklisted (int ssid, int devno) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | { |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 225 | return test_bit (devno, bl_dev[ssid]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | #ifdef CONFIG_PROC_FS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | /* |
| 230 | * Function: blacklist_parse_proc_parameters |
| 231 | * parse the stuff which is piped to /proc/cio_ignore |
| 232 | */ |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 233 | static int blacklist_parse_proc_parameters(char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | { |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 235 | int rc; |
| 236 | char *parm; |
| 237 | |
| 238 | parm = strsep(&buf, " "); |
| 239 | |
| 240 | if (strcmp("free", parm) == 0) |
| 241 | rc = blacklist_parse_parameters(buf, free, 0); |
| 242 | else if (strcmp("add", parm) == 0) |
| 243 | rc = blacklist_parse_parameters(buf, add, 0); |
| 244 | else |
| 245 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | |
Peter Oberparleiter | 40154b8 | 2006-06-29 14:57:03 +0200 | [diff] [blame] | 247 | css_schedule_reprobe(); |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 248 | |
| 249 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | } |
| 251 | |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 252 | /* Iterator struct for all devices. */ |
| 253 | struct ccwdev_iter { |
| 254 | int devno; |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 255 | int ssid; |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 256 | int in_range; |
| 257 | }; |
| 258 | |
| 259 | static void * |
| 260 | cio_ignore_proc_seq_start(struct seq_file *s, loff_t *offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | { |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 262 | struct ccwdev_iter *iter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 264 | if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1)) |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 265 | return NULL; |
Cornelia Huck | 3b79306 | 2006-01-06 00:19:26 -0800 | [diff] [blame] | 266 | iter = kzalloc(sizeof(struct ccwdev_iter), GFP_KERNEL); |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 267 | if (!iter) |
| 268 | return ERR_PTR(-ENOMEM); |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 269 | iter->ssid = *offset / (__MAX_SUBCHANNEL + 1); |
| 270 | iter->devno = *offset % (__MAX_SUBCHANNEL + 1); |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 271 | return iter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | } |
| 273 | |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 274 | static void |
| 275 | cio_ignore_proc_seq_stop(struct seq_file *s, void *it) |
| 276 | { |
| 277 | if (!IS_ERR(it)) |
| 278 | kfree(it); |
| 279 | } |
| 280 | |
| 281 | static void * |
| 282 | cio_ignore_proc_seq_next(struct seq_file *s, void *it, loff_t *offset) |
| 283 | { |
| 284 | struct ccwdev_iter *iter; |
| 285 | |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 286 | if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1)) |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 287 | return NULL; |
Cornelia Huck | 3b79306 | 2006-01-06 00:19:26 -0800 | [diff] [blame] | 288 | iter = it; |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 289 | if (iter->devno == __MAX_SUBCHANNEL) { |
| 290 | iter->devno = 0; |
| 291 | iter->ssid++; |
| 292 | if (iter->ssid > __MAX_SSID) |
| 293 | return NULL; |
| 294 | } else |
| 295 | iter->devno++; |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 296 | (*offset)++; |
| 297 | return iter; |
| 298 | } |
| 299 | |
| 300 | static int |
| 301 | cio_ignore_proc_seq_show(struct seq_file *s, void *it) |
| 302 | { |
| 303 | struct ccwdev_iter *iter; |
| 304 | |
Cornelia Huck | 3b79306 | 2006-01-06 00:19:26 -0800 | [diff] [blame] | 305 | iter = it; |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 306 | if (!is_blacklisted(iter->ssid, iter->devno)) |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 307 | /* Not blacklisted, nothing to output. */ |
| 308 | return 0; |
| 309 | if (!iter->in_range) { |
| 310 | /* First device in range. */ |
| 311 | if ((iter->devno == __MAX_SUBCHANNEL) || |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 312 | !is_blacklisted(iter->ssid, iter->devno + 1)) |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 313 | /* Singular device. */ |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 314 | return seq_printf(s, "0.%x.%04x\n", |
| 315 | iter->ssid, iter->devno); |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 316 | iter->in_range = 1; |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 317 | return seq_printf(s, "0.%x.%04x-", iter->ssid, iter->devno); |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 318 | } |
| 319 | if ((iter->devno == __MAX_SUBCHANNEL) || |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 320 | !is_blacklisted(iter->ssid, iter->devno + 1)) { |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 321 | /* Last device in range. */ |
| 322 | iter->in_range = 0; |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 323 | return seq_printf(s, "0.%x.%04x\n", iter->ssid, iter->devno); |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 324 | } |
| 325 | return 0; |
| 326 | } |
| 327 | |
| 328 | static ssize_t |
| 329 | cio_ignore_write(struct file *file, const char __user *user_buf, |
| 330 | size_t user_len, loff_t *offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | { |
| 332 | char *buf; |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 333 | size_t i; |
| 334 | ssize_t rc, ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 336 | if (*offset) |
| 337 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | if (user_len > 65536) |
| 339 | user_len = 65536; |
| 340 | buf = vmalloc (user_len + 1); /* maybe better use the stack? */ |
| 341 | if (buf == NULL) |
| 342 | return -ENOMEM; |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 343 | memset(buf, 0, user_len + 1); |
| 344 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | if (strncpy_from_user (buf, user_buf, user_len) < 0) { |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 346 | rc = -EFAULT; |
| 347 | goto out_free; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 350 | i = user_len - 1; |
| 351 | while ((i >= 0) && (isspace(buf[i]) || (buf[i] == 0))) { |
| 352 | buf[i] = '\0'; |
| 353 | i--; |
| 354 | } |
| 355 | ret = blacklist_parse_proc_parameters(buf); |
| 356 | if (ret) |
| 357 | rc = -EINVAL; |
| 358 | else |
| 359 | rc = user_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 361 | out_free: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | vfree (buf); |
Michael Ernst | 5b89098 | 2008-05-07 09:22:55 +0200 | [diff] [blame^] | 363 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | } |
| 365 | |
Jan Engelhardt | 5c81cdb | 2008-01-26 14:11:29 +0100 | [diff] [blame] | 366 | static const struct seq_operations cio_ignore_proc_seq_ops = { |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 367 | .start = cio_ignore_proc_seq_start, |
| 368 | .stop = cio_ignore_proc_seq_stop, |
| 369 | .next = cio_ignore_proc_seq_next, |
| 370 | .show = cio_ignore_proc_seq_show, |
| 371 | }; |
| 372 | |
| 373 | static int |
| 374 | cio_ignore_proc_open(struct inode *inode, struct file *file) |
| 375 | { |
| 376 | return seq_open(file, &cio_ignore_proc_seq_ops); |
| 377 | } |
| 378 | |
Arjan van de Ven | d54b1fd | 2007-02-12 00:55:34 -0800 | [diff] [blame] | 379 | static const struct file_operations cio_ignore_proc_fops = { |
Cornelia Huck | 678a395 | 2006-01-06 00:19:24 -0800 | [diff] [blame] | 380 | .open = cio_ignore_proc_open, |
| 381 | .read = seq_read, |
| 382 | .llseek = seq_lseek, |
| 383 | .release = seq_release, |
| 384 | .write = cio_ignore_write, |
| 385 | }; |
| 386 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | static int |
| 388 | cio_ignore_proc_init (void) |
| 389 | { |
| 390 | struct proc_dir_entry *entry; |
| 391 | |
Denis V. Lunev | 8b59400 | 2008-04-29 01:02:20 -0700 | [diff] [blame] | 392 | entry = proc_create("cio_ignore", S_IFREG | S_IRUGO | S_IWUSR, NULL, |
| 393 | &cio_ignore_proc_fops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | if (!entry) |
Cornelia Huck | a7fbf6b | 2006-04-10 22:53:45 -0700 | [diff] [blame] | 395 | return -ENOENT; |
Cornelia Huck | a7fbf6b | 2006-04-10 22:53:45 -0700 | [diff] [blame] | 396 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | __initcall (cio_ignore_proc_init); |
| 400 | |
| 401 | #endif /* CONFIG_PROC_FS */ |