+#endif
+
+/* __create_vx_info()
+
+ * create the requested context
+ * get() it and hash it */
+
+static struct vx_info * __create_vx_info(int id)
+{
+ struct vx_info *new, *vxi = NULL;
+
+ vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
+
+ if (!(new = __alloc_vx_info(id))) {
+ return ERR_PTR(-ENOMEM);
+ }
+
+ /* required to make dynamic xids unique */
+ spin_lock(&vx_info_hash_lock);
+
+ /* dynamic context requested */
+ if (id == VX_DYNAMIC_ID) {
+ id = __vx_dynamic_id();
+ if (!id) {
+ printk(KERN_ERR "no dynamic context available.\n");
+ vxi = ERR_PTR(-EAGAIN);
+ goto out_unlock;
+ }
+ new->vx_id = id;
+ }
+ /* existing context requested */
+ else if ((vxi = __lookup_vx_info(id))) {
+ vxdprintk(VXD_CBIT(xid, 0),
+ "create_vx_info(%d) = %p (already there)", id, vxi);
+ if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
+ vxi = ERR_PTR(-EBUSY);
+ else
+ vxi = ERR_PTR(-EEXIST);
+ goto out_unlock;
+ }
+ /* dynamic xid creation blocker */
+ else if (id >= MIN_D_CONTEXT) {
+ vxdprintk(VXD_CBIT(xid, 0),
+ "create_vx_info(%d) (dynamic rejected)", id);
+ vxi = ERR_PTR(-EINVAL);
+ goto out_unlock;
+ }
+
+ /* new context requested */
+ vxdprintk(VXD_CBIT(xid, 0),
+ "create_vx_info(%d) = %p (new)", id, new);
+ __hash_vx_info(get_vx_info(new));
+ vxi = new, new = NULL;
+
+out_unlock:
+ spin_unlock(&vx_info_hash_lock);
+ vxh_create_vx_info(id, IS_ERR(vxi)?NULL:vxi);
+ if (new)
+ __dealloc_vx_info(new);
+ return vxi;
+}