]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/infiniband/hw/amso1100/c2_provider.c
IB: Drop code after return statement
[linux-2.6-omap-h63xx.git] / drivers / infiniband / hw / amso1100 / c2_provider.c
index 7a6cece6ea9d1ba0060ee630b3ab7a5931f8f638..69580e282af012a918fb6bf258333a34f258a584 100644 (file)
@@ -67,7 +67,7 @@ static int c2_query_device(struct ib_device *ibdev,
 {
        struct c2_dev *c2dev = to_c2dev(ibdev);
 
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
 
        *props = c2dev->props;
        return 0;
@@ -76,7 +76,7 @@ static int c2_query_device(struct ib_device *ibdev,
 static int c2_query_port(struct ib_device *ibdev,
                         u8 port, struct ib_port_attr *props)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
 
        props->max_mtu = IB_MTU_4096;
        props->lid = 0;
@@ -102,14 +102,14 @@ static int c2_modify_port(struct ib_device *ibdev,
                          u8 port, int port_modify_mask,
                          struct ib_port_modify *props)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        return 0;
 }
 
 static int c2_query_pkey(struct ib_device *ibdev,
                         u8 port, u16 index, u16 * pkey)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        *pkey = 0;
        return 0;
 }
@@ -119,7 +119,7 @@ static int c2_query_gid(struct ib_device *ibdev, u8 port,
 {
        struct c2_dev *c2dev = to_c2dev(ibdev);
 
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        memset(&(gid->raw[0]), 0, sizeof(gid->raw));
        memcpy(&(gid->raw[0]), c2dev->pseudo_netdev->dev_addr, 6);
 
@@ -134,7 +134,7 @@ static struct ib_ucontext *c2_alloc_ucontext(struct ib_device *ibdev,
 {
        struct c2_ucontext *context;
 
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        context = kmalloc(sizeof(*context), GFP_KERNEL);
        if (!context)
                return ERR_PTR(-ENOMEM);
@@ -144,14 +144,14 @@ static struct ib_ucontext *c2_alloc_ucontext(struct ib_device *ibdev,
 
 static int c2_dealloc_ucontext(struct ib_ucontext *context)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        kfree(context);
        return 0;
 }
 
 static int c2_mmap_uar(struct ib_ucontext *context, struct vm_area_struct *vma)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        return -ENOSYS;
 }
 
@@ -162,7 +162,7 @@ static struct ib_pd *c2_alloc_pd(struct ib_device *ibdev,
        struct c2_pd *pd;
        int err;
 
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
 
        pd = kmalloc(sizeof(*pd), GFP_KERNEL);
        if (!pd)
@@ -187,7 +187,7 @@ static struct ib_pd *c2_alloc_pd(struct ib_device *ibdev,
 
 static int c2_dealloc_pd(struct ib_pd *pd)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        c2_pd_free(to_c2dev(pd->device), to_c2pd(pd));
        kfree(pd);
 
@@ -196,13 +196,13 @@ static int c2_dealloc_pd(struct ib_pd *pd)
 
 static struct ib_ah *c2_ah_create(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        return ERR_PTR(-ENOSYS);
 }
 
 static int c2_ah_destroy(struct ib_ah *ah)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        return -ENOSYS;
 }
 
@@ -230,7 +230,7 @@ struct ib_qp *c2_get_qp(struct ib_device *device, int qpn)
 
        qp = c2_find_qpn(c2dev, qpn);
        pr_debug("%s Returning QP=%p for QPN=%d, device=%p, refcount=%d\n",
-               __FUNCTION__, qp, qpn, device,
+               __func__, qp, qpn, device,
                (qp?atomic_read(&qp->refcount):0));
 
        return (qp?&qp->ibqp:NULL);
@@ -243,13 +243,16 @@ static struct ib_qp *c2_create_qp(struct ib_pd *pd,
        struct c2_qp *qp;
        int err;
 
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
+
+       if (init_attr->create_flags)
+               return ERR_PTR(-EINVAL);
 
        switch (init_attr->qp_type) {
        case IB_QPT_RC:
                qp = kzalloc(sizeof(*qp), GFP_KERNEL);
                if (!qp) {
-                       pr_debug("%s: Unable to allocate QP\n", __FUNCTION__);
+                       pr_debug("%s: Unable to allocate QP\n", __func__);
                        return ERR_PTR(-ENOMEM);
                }
                spin_lock_init(&qp->lock);
@@ -266,10 +269,9 @@ static struct ib_qp *c2_create_qp(struct ib_pd *pd,
 
                break;
        default:
-               pr_debug("%s: Invalid QP type: %d\n", __FUNCTION__,
+               pr_debug("%s: Invalid QP type: %d\n", __func__,
                        init_attr->qp_type);
                return ERR_PTR(-EINVAL);
-               break;
        }
 
        if (err) {
@@ -285,7 +287,7 @@ static int c2_destroy_qp(struct ib_qp *ib_qp)
        struct c2_qp *qp = to_c2qp(ib_qp);
 
        pr_debug("%s:%u qp=%p,qp->state=%d\n",
-               __FUNCTION__, __LINE__,ib_qp,qp->state);
+               __func__, __LINE__, ib_qp, qp->state);
        c2_free_qp(to_c2dev(ib_qp->device), qp);
        kfree(qp);
        return 0;
@@ -300,13 +302,13 @@ static struct ib_cq *c2_create_cq(struct ib_device *ibdev, int entries, int vect
 
        cq = kmalloc(sizeof(*cq), GFP_KERNEL);
        if (!cq) {
-               pr_debug("%s: Unable to allocate CQ\n", __FUNCTION__);
+               pr_debug("%s: Unable to allocate CQ\n", __func__);
                return ERR_PTR(-ENOMEM);
        }
 
        err = c2_init_cq(to_c2dev(ibdev), entries, NULL, cq);
        if (err) {
-               pr_debug("%s: error initializing CQ\n", __FUNCTION__);
+               pr_debug("%s: error initializing CQ\n", __func__);
                kfree(cq);
                return ERR_PTR(err);
        }
@@ -318,7 +320,7 @@ static int c2_destroy_cq(struct ib_cq *ib_cq)
 {
        struct c2_cq *cq = to_c2cq(ib_cq);
 
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
 
        c2_free_cq(to_c2dev(ib_cq->device), cq);
        kfree(cq);
@@ -400,7 +402,7 @@ static struct ib_mr *c2_reg_phys_mr(struct ib_pd *ib_pd,
        mr->umem = NULL;
        pr_debug("%s - page shift %d, pbl_depth %d, total_len %u, "
                "*iova_start %llx, first pa %llx, last pa %llx\n",
-               __FUNCTION__, page_shift, pbl_depth, total_len,
+               __func__, page_shift, pbl_depth, total_len,
                (unsigned long long) *iova_start,
                (unsigned long long) page_list[0],
                (unsigned long long) page_list[pbl_depth-1]);
@@ -422,7 +424,7 @@ static struct ib_mr *c2_get_dma_mr(struct ib_pd *pd, int acc)
        struct ib_phys_buf bl;
        u64 kva = 0;
 
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
 
        /* AMSO1100 limit */
        bl.size = 0xffffffff;
@@ -442,14 +444,14 @@ static struct ib_mr *c2_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
        struct c2_pd *c2pd = to_c2pd(pd);
        struct c2_mr *c2mr;
 
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
 
        c2mr = kmalloc(sizeof(*c2mr), GFP_KERNEL);
        if (!c2mr)
                return ERR_PTR(-ENOMEM);
        c2mr->pd = c2pd;
 
-       c2mr->umem = ib_umem_get(pd->uobject->context, start, length, acc);
+       c2mr->umem = ib_umem_get(pd->uobject->context, start, length, acc, 0);
        if (IS_ERR(c2mr->umem)) {
                err = PTR_ERR(c2mr->umem);
                kfree(c2mr);
@@ -506,7 +508,7 @@ static int c2_dereg_mr(struct ib_mr *ib_mr)
        struct c2_mr *mr = to_c2mr(ib_mr);
        int err;
 
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
 
        err = c2_stag_dealloc(to_c2dev(ib_mr->device), ib_mr->lkey);
        if (err)
@@ -520,45 +522,49 @@ static int c2_dereg_mr(struct ib_mr *ib_mr)
        return err;
 }
 
-static ssize_t show_rev(struct class_device *cdev, char *buf)
+static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
-       struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev);
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
-       return sprintf(buf, "%x\n", dev->props.hw_ver);
+       struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev);
+       pr_debug("%s:%u\n", __func__, __LINE__);
+       return sprintf(buf, "%x\n", c2dev->props.hw_ver);
 }
 
-static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
+static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr,
+                          char *buf)
 {
-       struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev);
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        return sprintf(buf, "%x.%x.%x\n",
-                      (int) (dev->props.fw_ver >> 32),
-                      (int) (dev->props.fw_ver >> 16) & 0xffff,
-                      (int) (dev->props.fw_ver & 0xffff));
+                      (int) (c2dev->props.fw_ver >> 32),
+                      (int) (c2dev->props.fw_ver >> 16) & 0xffff,
+                      (int) (c2dev->props.fw_ver & 0xffff));
 }
 
-static ssize_t show_hca(struct class_device *cdev, char *buf)
+static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        return sprintf(buf, "AMSO1100\n");
 }
 
-static ssize_t show_board(struct class_device *cdev, char *buf)
+static ssize_t show_board(struct device *dev, struct device_attribute *attr,
+                         char *buf)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        return sprintf(buf, "%.*s\n", 32, "AMSO1100 Board ID");
 }
 
-static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
-static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
-static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
+static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
+static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
+static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
+static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
 
-static struct class_device_attribute *c2_class_attributes[] = {
-       &class_device_attr_hw_rev,
-       &class_device_attr_fw_ver,
-       &class_device_attr_hca_type,
-       &class_device_attr_board_id
+static struct device_attribute *c2_dev_attributes[] = {
+       &dev_attr_hw_rev,
+       &dev_attr_fw_ver,
+       &dev_attr_hca_type,
+       &dev_attr_board_id
 };
 
 static int c2_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
@@ -575,13 +581,13 @@ static int c2_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 
 static int c2_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        return -ENOSYS;
 }
 
 static int c2_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        return -ENOSYS;
 }
 
@@ -592,13 +598,13 @@ static int c2_process_mad(struct ib_device *ibdev,
                          struct ib_grh *in_grh,
                          struct ib_mad *in_mad, struct ib_mad *out_mad)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        return -ENOSYS;
 }
 
 static int c2_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
 
        /* Request a connection */
        return c2_llp_connect(cm_id, iw_param);
@@ -606,7 +612,7 @@ static int c2_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param)
 
 static int c2_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
 
        /* Accept the new connection */
        return c2_llp_accept(cm_id, iw_param);
@@ -616,7 +622,7 @@ static int c2_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
 {
        int err;
 
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
 
        err = c2_llp_reject(cm_id, pdata, pdata_len);
        return err;
@@ -626,10 +632,10 @@ static int c2_service_create(struct iw_cm_id *cm_id, int backlog)
 {
        int err;
 
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        err = c2_llp_service_create(cm_id, backlog);
        pr_debug("%s:%u err=%d\n",
-               __FUNCTION__, __LINE__,
+               __func__, __LINE__,
                err);
        return err;
 }
@@ -637,7 +643,7 @@ static int c2_service_create(struct iw_cm_id *cm_id, int backlog)
 static int c2_service_destroy(struct iw_cm_id *cm_id)
 {
        int err;
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
 
        err = c2_llp_service_destroy(cm_id);
 
@@ -743,7 +749,7 @@ static struct net_device *c2_pseudo_netdev_init(struct c2_dev *c2dev)
        netdev = alloc_netdev(sizeof(*netdev), name, setup);
        if (!netdev) {
                printk(KERN_ERR PFX "%s -  etherdev alloc failed",
-                       __FUNCTION__);
+                       __func__);
                return NULL;
        }
 
@@ -780,7 +786,7 @@ int c2_register_device(struct c2_dev *dev)
        if (ret)
                goto out2;
 
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        strlcpy(dev->ibdev.name, "amso%d", IB_DEVICE_NAME_MAX);
        dev->ibdev.owner = THIS_MODULE;
        dev->ibdev.uverbs_cmd_mask =
@@ -858,9 +864,9 @@ int c2_register_device(struct c2_dev *dev)
        if (ret)
                goto out1;
 
-       for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) {
-               ret = class_device_create_file(&dev->ibdev.class_dev,
-                                              c2_class_attributes[i]);
+       for (i = 0; i < ARRAY_SIZE(c2_dev_attributes); ++i) {
+               ret = device_create_file(&dev->ibdev.dev,
+                                              c2_dev_attributes[i]);
                if (ret)
                        goto out0;
        }
@@ -873,13 +879,13 @@ out1:
 out2:
        free_netdev(dev->pseudo_netdev);
 out3:
-       pr_debug("%s:%u ret=%d\n", __FUNCTION__, __LINE__, ret);
+       pr_debug("%s:%u ret=%d\n", __func__, __LINE__, ret);
        return ret;
 }
 
 void c2_unregister_device(struct c2_dev *dev)
 {
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
+       pr_debug("%s:%u\n", __func__, __LINE__);
        unregister_netdev(dev->pseudo_netdev);
        free_netdev(dev->pseudo_netdev);
        ib_unregister_device(&dev->ibdev);