]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/infiniband/hw/ipath/ipath_diag.c
device create: infiniband: convert device_create_drvdata to device_create
[linux-2.6-omap-h63xx.git] / drivers / infiniband / hw / ipath / ipath_diag.c
index af59bf380ca265375e5605c24f75fa058f38785f..d4ce8b63e19eba275cc2e11235dc751ed438e1f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved.
+ * Copyright (c) 2006, 2007, 2008 QLogic Corporation. All rights reserved.
  * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -79,7 +79,7 @@ static const struct file_operations diagpkt_file_ops = {
 
 static atomic_t diagpkt_count = ATOMIC_INIT(0);
 static struct cdev *diagpkt_cdev;
-static struct class_device *diagpkt_class_dev;
+static struct device *diagpkt_dev;
 
 int ipath_diag_add(struct ipath_devdata *dd)
 {
@@ -89,7 +89,7 @@ int ipath_diag_add(struct ipath_devdata *dd)
        if (atomic_inc_return(&diagpkt_count) == 1) {
                ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR,
                                      "ipath_diagpkt", &diagpkt_file_ops,
-                                     &diagpkt_cdev, &diagpkt_class_dev);
+                                     &diagpkt_cdev, &diagpkt_dev);
 
                if (ret) {
                        ipath_dev_err(dd, "Couldn't create ipath_diagpkt "
@@ -102,7 +102,7 @@ int ipath_diag_add(struct ipath_devdata *dd)
 
        ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name,
                              &diag_file_ops, &dd->diag_cdev,
-                             &dd->diag_class_dev);
+                             &dd->diag_dev);
        if (ret)
                ipath_dev_err(dd, "Couldn't create %s device: %d",
                              name, ret);
@@ -114,9 +114,9 @@ done:
 void ipath_diag_remove(struct ipath_devdata *dd)
 {
        if (atomic_dec_and_test(&diagpkt_count))
-               ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_class_dev);
+               ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_dev);
 
-       ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_class_dev);
+       ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_dev);
 }
 
 /**
@@ -332,12 +332,17 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
        u64 val;
        u32 l_state, lt_state; /* LinkState, LinkTrainingState */
 
-       if (count != sizeof(dp)) {
+       if (count < sizeof(odp)) {
                ret = -EINVAL;
                goto bail;
        }
 
-       if (copy_from_user(&dp, data, sizeof(dp))) {
+       if (count == sizeof(dp)) {
+               if (copy_from_user(&dp, data, sizeof(dp))) {
+                       ret = -EFAULT;
+                       goto bail;
+               }
+       } else if (copy_from_user(&odp, data, sizeof(odp))) {
                ret = -EFAULT;
                goto bail;
        }