tree-wide: fix assorted typos all over the place
[safe/jmp/linux-2.6] / drivers / s390 / cio / cmf.c
index f4c132a..2985eb4 100644 (file)
@@ -25,6 +25,9 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#define KMSG_COMPONENT "cio"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
 #include <linux/bootmem.h>
 #include <linux/device.h>
 #include <linux/init.h>
@@ -185,56 +188,19 @@ static inline void cmf_activate(void *area, unsigned int onoff)
 static int set_schib(struct ccw_device *cdev, u32 mme, int mbfc,
                     unsigned long address)
 {
-       int ret;
-       int retry;
        struct subchannel *sch;
-       struct schib *schib;
 
        sch = to_subchannel(cdev->dev.parent);
-       schib = &sch->schib;
-       /* msch can silently fail, so do it again if necessary */
-       for (retry = 0; retry < 3; retry++) {
-               /* prepare schib */
-               stsch(sch->schid, schib);
-               schib->pmcw.mme  = mme;
-               schib->pmcw.mbfc = mbfc;
-               /* address can be either a block address or a block index */
-               if (mbfc)
-                       schib->mba = address;
-               else
-                       schib->pmcw.mbi = address;
-
-               /* try to submit it */
-               switch(ret = msch_err(sch->schid, schib)) {
-                       case 0:
-                               break;
-                       case 1:
-                       case 2: /* in I/O or status pending */
-                               ret = -EBUSY;
-                               break;
-                       case 3: /* subchannel is no longer valid */
-                               ret = -ENODEV;
-                               break;
-                       default: /* msch caught an exception */
-                               ret = -EINVAL;
-                               break;
-               }
-               stsch(sch->schid, schib); /* restore the schib */
-
-               if (ret)
-                       break;
-
-               /* check if it worked */
-               if (schib->pmcw.mme  == mme &&
-                   schib->pmcw.mbfc == mbfc &&
-                   (mbfc ? (schib->mba == address)
-                         : (schib->pmcw.mbi == address)))
-                       return 0;
 
-               ret = -EINVAL;
-       }
+       sch->config.mme = mme;
+       sch->config.mbfc = mbfc;
+       /* address can be either a block address or a block index */
+       if (mbfc)
+               sch->config.mba = address;
+       else
+               sch->config.mbi = address;
 
-       return ret;
+       return cio_commit_config(sch);
 }
 
 struct set_schib_struct {
@@ -338,15 +304,15 @@ static int cmf_copy_block(struct ccw_device *cdev)
 
        sch = to_subchannel(cdev->dev.parent);
 
-       if (stsch(sch->schid, &sch->schib))
+       if (cio_update_schib(sch))
                return -ENODEV;
 
-       if (sch->schib.scsw.fctl & SCSW_FCTL_START_FUNC) {
+       if (scsw_fctl(&sch->schib.scsw) & SCSW_FCTL_START_FUNC) {
                /* Don't copy if a start function is in progress. */
-               if ((!(sch->schib.scsw.actl & SCSW_ACTL_SUSPENDED)) &&
-                   (sch->schib.scsw.actl &
+               if ((!(scsw_actl(&sch->schib.scsw) & SCSW_ACTL_SUSPENDED)) &&
+                   (scsw_actl(&sch->schib.scsw) &
                     (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT)) &&
-                   (!(sch->schib.scsw.stctl & SCSW_STCTL_SEC_STATUS)))
+                   (!(scsw_stctl(&sch->schib.scsw) & SCSW_STCTL_SEC_STATUS)))
                        return -EBUSY;
        }
        cmb_data = cdev->private->cmb;
@@ -496,7 +462,7 @@ static struct cmb_area cmb_area = {
  * block of memory, which can not be moved as long as any channel
  * is active. Therefore, a maximum number of subchannels needs to
  * be defined somewhere. This is a module parameter, defaulting to
- * a resonable value of 1024, or 32 kb of memory.
+ * a reasonable value of 1024, or 32 kb of memory.
  * Current kernels don't allow kmalloc with more than 128kb, so the
  * maximum is 4096.
  */
@@ -612,9 +578,6 @@ static int alloc_cmb(struct ccw_device *cdev)
                        free_pages((unsigned long)mem, get_order(size));
                } else if (!mem) {
                        /* no luck */
-                       printk(KERN_WARNING "cio: failed to allocate area "
-                              "for measuring %d subchannels\n",
-                              cmb_area.num_channels);
                        ret = -ENOMEM;
                        goto out;
                } else {
@@ -1219,19 +1182,20 @@ static ssize_t cmb_enable_store(struct device *dev,
 {
        struct ccw_device *cdev;
        int ret;
+       unsigned long val;
+
+       ret = strict_strtoul(buf, 16, &val);
+       if (ret)
+               return ret;
 
        cdev = to_ccwdev(dev);
 
-       switch (buf[0]) {
-       case '0':
+       switch (val) {
+       case 0:
                ret = disable_cmf(cdev);
-               if (ret)
-                       dev_info(&cdev->dev, "disable_cmf failed (%d)\n", ret);
                break;
-       case '1':
+       case 1:
                ret = enable_cmf(cdev);
-               if (ret && ret != -EBUSY)
-                       dev_info(&cdev->dev, "enable_cmf failed (%d)\n", ret);
                break;
        }
 
@@ -1240,6 +1204,11 @@ static ssize_t cmb_enable_store(struct device *dev,
 
 DEVICE_ATTR(cmb_enable, 0644, cmb_enable_show, cmb_enable_store);
 
+int ccw_set_cmf(struct ccw_device *cdev, int enable)
+{
+       return cmbops->set(cdev, enable ? 2 : 0);
+}
+
 /**
  * enable_cmf() - switch on the channel measurement for a specific device
  *  @cdev:     The ccw device to be enabled
@@ -1339,8 +1308,7 @@ static int __init init_cmf(void)
         * to basic mode.
         */
        if (format == CMF_AUTODETECT) {
-               if (!css_characteristics_avail ||
-                   !css_general_characteristics.ext_mb) {
+               if (!css_general_characteristics.ext_mb) {
                        format = CMF_BASIC;
                } else {
                        format = CMF_EXTENDED;
@@ -1360,13 +1328,10 @@ static int __init init_cmf(void)
                cmbops = &cmbops_extended;
                break;
        default:
-               printk(KERN_ERR "cio: Invalid format %d for channel "
-                       "measurement facility\n", format);
                return 1;
        }
-
-       printk(KERN_INFO "cio: Channel measurement facility using %s "
-              "format (%s)\n", format_string, detect_string);
+       pr_info("Channel measurement facility initialized using format "
+               "%s (mode %s)\n", format_string, detect_string);
        return 0;
 }