tree-wide: fix assorted typos all over the place
[safe/jmp/linux-2.6] / drivers / s390 / cio / chp.c
index 62df43b..c268a2e 100644 (file)
@@ -17,8 +17,8 @@
 #include <linux/errno.h>
 #include <asm/chpid.h>
 #include <asm/sclp.h>
+#include <asm/crw.h>
 
-#include "../s390mach.h"
 #include "cio.h"
 #include "css.h"
 #include "ioasm.h"
@@ -65,7 +65,7 @@ static void set_chp_logically_online(struct chp_id chpid, int onoff)
        chpid_to_chp(chpid)->state = onoff;
 }
 
-/* On succes return 0 if channel-path is varied offline, 1 if it is varied
+/* On success return 0 if channel-path is varied offline, 1 if it is varied
  * online. Return -ENODEV if channel-path is not registered. */
 int chp_get_status(struct chp_id chpid)
 {
@@ -123,11 +123,8 @@ static int s390_vary_chpid(struct chp_id chpid, int on)
        CIO_TRACE_EVENT(2, dbf_text);
 
        status = chp_get_status(chpid);
-       if (!on && !status) {
-               printk(KERN_ERR "cio: chpid %x.%02x is already offline\n",
-                      chpid.cssid, chpid.id);
-               return -EINVAL;
-       }
+       if (!on && !status)
+               return 0;
 
        set_chp_logically_online(chpid, on);
        chsc_chp_vary(chpid, on);
@@ -143,21 +140,14 @@ static ssize_t chp_measurement_chars_read(struct kobject *kobj,
 {
        struct channel_path *chp;
        struct device *device;
-       unsigned int size;
 
        device = container_of(kobj, struct device, kobj);
        chp = to_channelpath(device);
        if (!chp->cmg_chars)
                return 0;
 
-       size = sizeof(struct cmg_chars);
-
-       if (off > size)
-               return 0;
-       if (off + count > size)
-               count = size - off;
-       memcpy(buf, chp->cmg_chars + off, count);
-       return count;
+       return memory_read_from_buffer(buf, count, &off,
+                               chp->cmg_chars, sizeof(struct cmg_chars));
 }
 
 static struct bin_attribute chp_measurement_chars_attr = {
@@ -403,11 +393,9 @@ int chp_new(struct chp_id chpid)
        chp->state = 1;
        chp->dev.parent = &channel_subsystems[chpid.cssid]->device;
        chp->dev.release = chp_release;
-       snprintf(chp->dev.bus_id, BUS_ID_SIZE, "chp%x.%02x", chpid.cssid,
-                chpid.id);
 
        /* Obtain channel path description and fill it in. */
-       ret = chsc_determine_channel_path_description(chpid, &chp->desc);
+       ret = chsc_determine_base_channel_path_desc(chpid, &chp->desc);
        if (ret)
                goto out_free;
        if ((chp->desc.flags & 0x80) == 0) {
@@ -422,18 +410,20 @@ int chp_new(struct chp_id chpid)
        } else {
                chp->cmg = -1;
        }
+       dev_set_name(&chp->dev, "chp%x.%02x", chpid.cssid, chpid.id);
 
        /* make it known to the system */
        ret = device_register(&chp->dev);
        if (ret) {
                CIO_MSG_EVENT(0, "Could not register chp%x.%02x: %d\n",
                              chpid.cssid, chpid.id, ret);
-               goto out_free;
+               put_device(&chp->dev);
+               goto out;
        }
        ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group);
        if (ret) {
                device_unregister(&chp->dev);
-               goto out_free;
+               goto out;
        }
        mutex_lock(&channel_subsystems[chpid.cssid]->mutex);
        if (channel_subsystems[chpid.cssid]->cm_enabled) {
@@ -442,14 +432,15 @@ int chp_new(struct chp_id chpid)
                        sysfs_remove_group(&chp->dev.kobj, &chp_attr_group);
                        device_unregister(&chp->dev);
                        mutex_unlock(&channel_subsystems[chpid.cssid]->mutex);
-                       goto out_free;
+                       goto out;
                }
        }
        channel_subsystems[chpid.cssid]->chps[chpid.id] = chp;
        mutex_unlock(&channel_subsystems[chpid.cssid]->mutex);
-       return ret;
+       goto out;
 out_free:
        kfree(chp);
+out:
        return ret;
 }
 
@@ -525,7 +516,7 @@ static void chp_process_crw(struct crw *crw0, struct crw *crw1,
        }
 }
 
-int chp_ssd_get_mask(struct chsc_ssd_info *ssd, struct res_acc_data *data)
+int chp_ssd_get_mask(struct chsc_ssd_info *ssd, struct chp_link *link)
 {
        int i;
        int mask;
@@ -534,10 +525,10 @@ int chp_ssd_get_mask(struct chsc_ssd_info *ssd, struct res_acc_data *data)
                mask = 0x80 >> i;
                if (!(ssd->path_mask & mask))
                        continue;
-               if (!chp_id_is_equal(&ssd->chpid[i], &data->chpid))
+               if (!chp_id_is_equal(&ssd->chpid[i], &link->chpid))
                        continue;
                if ((ssd->fla_valid_mask & mask) &&
-                   ((ssd->fla[i] & data->fla_mask) != data->fla))
+                   ((ssd->fla[i] & link->fla_mask) != link->fla))
                        continue;
                return mask;
        }
@@ -624,6 +615,7 @@ static void cfg_func(struct work_struct *work)
 {
        struct chp_id chpid;
        enum cfg_task_t t;
+       int rc;
 
        mutex_lock(&cfg_lock);
        t = cfg_none;
@@ -638,14 +630,24 @@ static void cfg_func(struct work_struct *work)
 
        switch (t) {
        case cfg_configure:
-               sclp_chp_configure(chpid);
-               info_expire();
-               chsc_chp_online(chpid);
+               rc = sclp_chp_configure(chpid);
+               if (rc)
+                       CIO_MSG_EVENT(2, "chp: sclp_chp_configure(%x.%02x)="
+                                     "%d\n", chpid.cssid, chpid.id, rc);
+               else {
+                       info_expire();
+                       chsc_chp_online(chpid);
+               }
                break;
        case cfg_deconfigure:
-               sclp_chp_deconfigure(chpid);
-               info_expire();
-               chsc_chp_offline(chpid);
+               rc = sclp_chp_deconfigure(chpid);
+               if (rc)
+                       CIO_MSG_EVENT(2, "chp: sclp_chp_deconfigure(%x.%02x)="
+                                     "%d\n", chpid.cssid, chpid.id, rc);
+               else {
+                       info_expire();
+                       chsc_chp_offline(chpid);
+               }
                break;
        case cfg_none:
                /* Get updated information after last change. */
@@ -705,12 +707,12 @@ static int __init chp_init(void)
        struct chp_id chpid;
        int ret;
 
-       ret = s390_register_crw_handler(CRW_RSC_CPATH, chp_process_crw);
+       ret = crw_register_handler(CRW_RSC_CPATH, chp_process_crw);
        if (ret)
                return ret;
        chp_wq = create_singlethread_workqueue("cio_chp");
        if (!chp_wq) {
-               s390_unregister_crw_handler(CRW_RSC_CPATH);
+               crw_unregister_handler(CRW_RSC_CPATH);
                return -ENOMEM;
        }
        INIT_WORK(&cfg_work, cfg_func);