10 #define KMSG_COMPONENT "cio"
11 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
17 #include <linux/ctype.h>
18 #include <linux/device.h>
21 #include <asm/uaccess.h>
38 #define __BL_DEV_WORDS ((__MAX_SUBCHANNEL + (8*sizeof(long) - 1)) / \
48 unsigned int to_ssid,
unsigned int from,
49 unsigned int to,
int msgtrigger)
51 if ((from_ssid > to_ssid) || ((from_ssid == to_ssid) && (from > to))) {
53 pr_warning(
"0.%x.%04x to 0.%x.%04x is not a valid "
54 "range for cio_ignore\n", from_ssid, from,
60 while ((from_ssid < to_ssid) || ((from_ssid == to_ssid) &&
63 set_bit(from, bl_dev[from_ssid]);
76 static int pure_hex(
char **
cp,
unsigned int *
val,
int min_digit,
77 int max_digit,
int max_val)
84 while (diff <= max_digit) {
89 *val = *val * 16 +
value;
94 if ((diff < min_digit) || (diff > max_digit) || (*val > max_val))
100 static int parse_busid(
char *
str,
unsigned int *
cssid,
unsigned int *
ssid,
101 unsigned int *
devno,
int msgtrigger)
115 if (*str_work ==
'\0') {
127 ret = pure_hex(&str_work, cssid, 1, 2,
__MAX_CSSID);
128 if (ret || (str_work[0] !=
'.'))
131 ret = pure_hex(&str_work, ssid, 1, 1,
__MAX_SSID);
132 if (ret || (str_work[0] !=
'.'))
136 if (ret || (str_work[0] !=
'\0'))
141 if (rc && msgtrigger)
142 pr_warning(
"%s is not a valid device for the cio_ignore "
143 "kernel parameter\n", str);
148 static int blacklist_parse_parameters(
char *str,
range_action action,
151 unsigned int from_cssid, to_cssid, from_ssid, to_ssid,
from, to;
158 while ((parm =
strsep(&str,
","))) {
168 if (
strcmp(parm,
"all") == 0) {
176 rc = parse_busid(
strsep(&parm,
"-"), &from_cssid,
177 &from_ssid, &from, msgtrigger);
180 rc = parse_busid(parm, &to_cssid,
184 to_cssid = from_cssid;
191 rc = blacklist_range(ra, from_ssid, to_ssid, from, to,
203 blacklist_setup (
char *str)
206 if (blacklist_parse_parameters(str,
add, 1))
211 __setup (
"cio_ignore=", blacklist_setup);
224 return test_bit (devno, bl_dev[ssid]);
227 #ifdef CONFIG_PROC_FS
232 static int blacklist_parse_proc_parameters(
char *
buf)
239 if (
strcmp(
"free", parm) == 0)
240 rc = blacklist_parse_parameters(buf,
free, 0);
241 else if (
strcmp(
"add", parm) == 0)
242 rc = blacklist_parse_parameters(buf,
add, 0);
243 else if (
strcmp(
"purge", parm) == 0)
263 struct ccwdev_iter *iter = s->
private;
267 memset(iter, 0,
sizeof(*iter));
274 cio_ignore_proc_seq_stop(
struct seq_file *s,
void *it)
279 cio_ignore_proc_seq_next(
struct seq_file *s,
void *it, loff_t *offset)
281 struct ccwdev_iter *iter;
298 cio_ignore_proc_seq_show(
struct seq_file *s,
void *it)
300 struct ccwdev_iter *iter;
306 if (!iter->in_range) {
312 iter->ssid, iter->devno);
314 return seq_printf(s,
"0.%x.%04x-", iter->ssid, iter->devno);
320 return seq_printf(s,
"0.%x.%04x\n", iter->ssid, iter->devno);
326 cio_ignore_write(
struct file *
file,
const char __user *user_buf,
327 size_t user_len, loff_t *offset)
334 if (user_len > 65536)
346 while ((i >= 0) && (
isspace(buf[i]) || (buf[i] == 0))) {
350 ret = blacklist_parse_proc_parameters(buf);
362 .
start = cio_ignore_proc_seq_start,
363 .stop = cio_ignore_proc_seq_stop,
364 .next = cio_ignore_proc_seq_next,
365 .show = cio_ignore_proc_seq_show,
369 cio_ignore_proc_open(
struct inode *
inode,
struct file *file)
372 sizeof(
struct ccwdev_iter));
376 .
open = cio_ignore_proc_open,
380 .write = cio_ignore_write,
384 cio_ignore_proc_init (
void)
389 &cio_ignore_proc_fops);