include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / s390 / cio / blacklist.c
index 9c21b8f..13cb601 100644 (file)
@@ -9,9 +9,11 @@
  *              Arnd Bergmann (arndb@de.ibm.com)
  */
 
+#define KMSG_COMPONENT "cio"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
 #include <linux/init.h>
 #include <linux/vmalloc.h>
-#include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/ctype.h>
 
 #include <asm/cio.h>
 #include <asm/uaccess.h>
-#include <asm/cio.h>
 
 #include "blacklist.h"
 #include "cio.h"
 #include "cio_debug.h"
 #include "css.h"
+#include "device.h"
 
 /*
  * "Blacklisting" of certain devices:
@@ -50,9 +52,10 @@ static int blacklist_range(range_action action, unsigned int from_ssid,
 {
        if ((from_ssid > to_ssid) || ((from_ssid == to_ssid) && (from > to))) {
                if (msgtrigger)
-                       printk(KERN_WARNING "cio: Invalid cio_ignore range "
-                              "0.%x.%04x-0.%x.%04x\n", from_ssid, from,
-                              to_ssid, to);
+                       pr_warning("0.%x.%04x to 0.%x.%04x is not a valid "
+                                  "range for cio_ignore\n", from_ssid, from,
+                                  to_ssid, to);
+
                return 1;
        }
 
@@ -98,8 +101,8 @@ static int pure_hex(char **cp, unsigned int *val, int min_digit,
        return 0;
 }
 
-static int parse_busid(char *str, int *cssid, int *ssid, int *devno,
-                      int msgtrigger)
+static int parse_busid(char *str, unsigned int *cssid, unsigned int *ssid,
+                      unsigned int *devno, int msgtrigger)
 {
        char *str_work;
        int val, rc, ret;
@@ -140,8 +143,8 @@ static int parse_busid(char *str, int *cssid, int *ssid, int *devno,
        rc = 0;
 out:
        if (rc && msgtrigger)
-               printk(KERN_WARNING "cio: Invalid cio_ignore device '%s'\n",
-                      str);
+               pr_warning("%s is not a valid device for the cio_ignore "
+                          "kernel parameter\n", str);
 
        return rc;
 }
@@ -149,7 +152,7 @@ out:
 static int blacklist_parse_parameters(char *str, range_action action,
                                      int msgtrigger)
 {
-       int from_cssid, to_cssid, from_ssid, to_ssid, from, to;
+       unsigned int from_cssid, to_cssid, from_ssid, to_ssid, from, to;
        int rc, totalrc;
        char *parm;
        range_action ra;
@@ -192,9 +195,9 @@ static int blacklist_parse_parameters(char *str, range_action action,
                        rc = blacklist_range(ra, from_ssid, to_ssid, from, to,
                                             msgtrigger);
                        if (rc)
-                               totalrc = 1;
+                               totalrc = -EINVAL;
                } else
-                       totalrc = 1;
+                       totalrc = -EINVAL;
        }
 
        return totalrc;
@@ -241,8 +244,10 @@ static int blacklist_parse_proc_parameters(char *buf)
                rc = blacklist_parse_parameters(buf, free, 0);
        else if (strcmp("add", parm) == 0)
                rc = blacklist_parse_parameters(buf, add, 0);
+       else if (strcmp("purge", parm) == 0)
+               return ccw_purge_blacklisted();
        else
-               return 1;
+               return -EINVAL;
 
        css_schedule_reprobe();
 
@@ -259,13 +264,11 @@ struct ccwdev_iter {
 static void *
 cio_ignore_proc_seq_start(struct seq_file *s, loff_t *offset)
 {
-       struct ccwdev_iter *iter;
+       struct ccwdev_iter *iter = s->private;
 
        if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1))
                return NULL;
-       iter = kzalloc(sizeof(struct ccwdev_iter), GFP_KERNEL);
-       if (!iter)
-               return ERR_PTR(-ENOMEM);
+       memset(iter, 0, sizeof(*iter));
        iter->ssid = *offset / (__MAX_SUBCHANNEL + 1);
        iter->devno = *offset % (__MAX_SUBCHANNEL + 1);
        return iter;
@@ -274,8 +277,6 @@ cio_ignore_proc_seq_start(struct seq_file *s, loff_t *offset)
 static void
 cio_ignore_proc_seq_stop(struct seq_file *s, void *it)
 {
-       if (!IS_ERR(it))
-               kfree(it);
 }
 
 static void *
@@ -330,8 +331,7 @@ cio_ignore_write(struct file *file, const char __user *user_buf,
                 size_t user_len, loff_t *offset)
 {
        char *buf;
-       size_t i;
-       ssize_t rc, ret;
+       ssize_t rc, ret, i;
 
        if (*offset)
                return -EINVAL;
@@ -354,7 +354,7 @@ cio_ignore_write(struct file *file, const char __user *user_buf,
        }
        ret = blacklist_parse_proc_parameters(buf);
        if (ret)
-               rc = -EINVAL;
+               rc = ret;
        else
                rc = user_len;
 
@@ -373,14 +373,15 @@ static const struct seq_operations cio_ignore_proc_seq_ops = {
 static int
 cio_ignore_proc_open(struct inode *inode, struct file *file)
 {
-       return seq_open(file, &cio_ignore_proc_seq_ops);
+       return seq_open_private(file, &cio_ignore_proc_seq_ops,
+                               sizeof(struct ccwdev_iter));
 }
 
 static const struct file_operations cio_ignore_proc_fops = {
        .open    = cio_ignore_proc_open,
        .read    = seq_read,
        .llseek  = seq_lseek,
-       .release = seq_release,
+       .release = seq_release_private,
        .write   = cio_ignore_write,
 };