Esempio n. 1
0
/*
 * Called from tcm_loop_fabric_init() in tcl_loop_fabric.c to load the emulated
 * tcm_loop SCSI bus.
 */
static int tcm_loop_alloc_core_bus(void)
{
    int ret;

    tcm_loop_primary = root_device_register("tcm_loop_0");
    if (IS_ERR(tcm_loop_primary)) {
        pr_err("Unable to allocate tcm_loop_primary\n");
        return PTR_ERR(tcm_loop_primary);
    }

    ret = bus_register(&tcm_loop_lld_bus);
    if (ret) {
        pr_err("bus_register() failed for tcm_loop_lld_bus\n");
        goto dev_unreg;
    }

    ret = driver_register(&tcm_loop_driverfs);
    if (ret) {
        pr_err("driver_register() failed for"
               "tcm_loop_driverfs\n");
        goto bus_unreg;
    }

    pr_debug("Initialized TCM Loop Core Bus\n");
    return ret;

bus_unreg:
    bus_unregister(&tcm_loop_lld_bus);
dev_unreg:
    root_device_unregister(tcm_loop_primary);
    return ret;
}
Esempio n. 2
0
/*
 * Init function for virtio
 * devices are in a single page above top of "normal" mem
 */
static int __init kvm_devices_init(void)
{
	int rc;

	if (!MACHINE_IS_KVM)
		return -ENODEV;

	kvm_root = root_device_register("kvm_s390");
	if (IS_ERR(kvm_root)) {
		rc = PTR_ERR(kvm_root);
		printk(KERN_ERR "Could not register kvm_s390 root device");
		return rc;
	}

	rc = vmem_add_mapping(real_memory_size, PAGE_SIZE);
	if (rc) {
		root_device_unregister(kvm_root);
		return rc;
	}

	kvm_devices = (void *) real_memory_size;

	INIT_WORK(&hotplug_work, hotplug_devices);

	service_subclass_irq_register();
	register_external_interrupt(0x2603, kvm_extint_handler);

	scan_devices();
	return 0;
}
Esempio n. 3
0
static void tcm_loop_release_core_bus(void)
{
    driver_unregister(&tcm_loop_driverfs);
    bus_unregister(&tcm_loop_lld_bus);
    root_device_unregister(tcm_loop_primary);

    pr_debug("Releasing TCM Loop Core BUS\n");
}
Esempio n. 4
0
static int vfio_ap_matrix_dev_create(void)
{
	int ret;
	struct device *root_device;

	root_device = root_device_register(VFIO_AP_ROOT_NAME);
	if (IS_ERR(root_device))
		return PTR_ERR(root_device);

	matrix_dev = kzalloc(sizeof(*matrix_dev), GFP_KERNEL);
	if (!matrix_dev) {
		ret = -ENOMEM;
		goto matrix_alloc_err;
	}

	/* Fill in config info via PQAP(QCI), if available */
	if (test_facility(12)) {
		ret = ap_qci(&matrix_dev->info);
		if (ret)
			goto matrix_alloc_err;
	}

	mutex_init(&matrix_dev->lock);
	INIT_LIST_HEAD(&matrix_dev->mdev_list);

	matrix_dev->device.type = &vfio_ap_dev_type;
	dev_set_name(&matrix_dev->device, "%s", VFIO_AP_DEV_NAME);
	matrix_dev->device.parent = root_device;
	matrix_dev->device.release = vfio_ap_matrix_dev_release;
	matrix_dev->device.driver = &vfio_ap_drv.driver;

	ret = device_register(&matrix_dev->device);
	if (ret)
		goto matrix_reg_err;

	return 0;

matrix_reg_err:
	put_device(&matrix_dev->device);
matrix_alloc_err:
	root_device_unregister(root_device);

	return ret;
}
/*
 * Init function for virtio.
 * devices are in a single page above the top of "normal" mem.
 */
static int __init kvm_devices_init(void)
{
	int rc = -ENOMEM;

	kvm_root = root_device_register("kvm_tile");
	if (IS_ERR(kvm_root)) {
		rc = PTR_ERR(kvm_root);
		pr_err("Could not register kvm_tile root device");
		return rc;
	}

	kvm_devices = generic_remap_prot(PFN_PHYS(max_pfn), PAGE_SIZE,
					 0, io_prot());
	if (!kvm_devices) {
		kvm_devices = NULL;
		root_device_unregister(kvm_root);
		return rc;
	}

	scan_devices();
	return 0;
}
Esempio n. 6
0
static void vfio_ap_matrix_dev_destroy(void)
{
	device_unregister(&matrix_dev->device);
	root_device_unregister(matrix_dev->device.parent);
}