@@ -64,29 +64,25 @@ static void rvt_cleanup(void)
}
module_exit(rvt_cleanup);
+/*
+ * Check driver override. If driver passes a value use it, otherwise we use our
+ * own value.
+ */
+#define CHECK_DRIVER_OVERRIDE(rdi, x) \
+ rdi->ibdev.x = rdi->ibdev.x ? : rvt_ ##x
+
int rvt_register_device(struct rvt_dev_info *rdi)
{
if (!rdi)
return -EINVAL;
- /*
- * Drivers have the option to override anything in the ibdev that they
- * want to specifically handle. VT needs to check for things it supports
- * and if the driver wants to handle that functionality let it. We may
- * come up with a better mechanism that simplifies the code at some
- * point.
- */
-
/* DMA Operations */
rdi->ibdev.dma_ops =
rdi->ibdev.dma_ops ? : &rvt_default_dma_mapping_ops;
/* Protection Domain */
- rdi->ibdev.alloc_pd =
- rdi->ibdev.alloc_pd ? : rvt_alloc_pd;
- rdi->ibdev.dealloc_pd =
- rdi->ibdev.dealloc_pd ? : rvt_dealloc_pd;
-
+ CHECK_DRIVER_OVERRIDE(rdi, alloc_pd);
+ CHECK_DRIVER_OVERRIDE(rdi, dealloc_pd);
spin_lock_init(&rdi->n_pds_lock);
rdi->n_pds_allocated = 0;