Example #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;
}
Example #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;
}
Example #3
0
/*D:105
 * Fairly early in boot, lguest_devices_init() is called to set up the
 * lguest device infrastructure.  We check that we are a Guest by checking
 * pv_info.name: there are other ways of checking, but this seems most
 * obvious to me.
 *
 * So we can access the "struct lguest_device_desc"s easily, we map that memory
 * and store the pointer in the global "lguest_devices".  Then we register a
 * root device from which all our devices will hang (this seems to be the
 * correct sysfs incantation).
 *
 * Finally we call scan_devices() which adds all the devices found in the
 * lguest_devices page.
 */
static int __init lguest_devices_init(void)
{
	if (strcmp(pv_info.name, "lguest") != 0)
		return 0;

	lguest_root = root_device_register("lguest");
	if (IS_ERR(lguest_root))
		panic("Could not register lguest root");

	/* Devices are in a single page above top of "normal" mem */
	lguest_devices = lguest_map(max_pfn<<PAGE_SHIFT, 1);

	scan_devices();
	return 0;
}
Example #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;
}