示例#1
0
static int __init cpcihp_generic_init(void)
{
	int status;
	struct resource *r;
	struct pci_dev *dev;

	info(DRIVER_DESC " version: " DRIVER_VERSION);
	status = validate_parameters();
	if (status)
		return status;

	r = request_region(port, 1, "#ENUM hotswap signal register");
	if (!r)
		return -EBUSY;

	dev = pci_get_domain_bus_and_slot(0, bridge_busnr,
					  PCI_DEVFN(bridge_slot, 0));
	if (!dev || dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
		err("Invalid bridge device %s", bridge);
		pci_dev_put(dev);
		return -EINVAL;
	}
	bus = dev->subordinate;
	pci_dev_put(dev);

	memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
	generic_hpc.ops = &generic_hpc_ops;

	status = cpci_hp_register_controller(&generic_hpc);
	if (status != 0) {
		err("Could not register cPCI hotplug controller");
		return -ENODEV;
	}
	dbg("registered controller");

	status = cpci_hp_register_bus(bus, first_slot, last_slot);
	if (status != 0) {
		err("Could not register cPCI hotplug bus");
		goto init_bus_register_error;
	}
	dbg("registered bus");

	status = cpci_hp_start();
	if (status != 0) {
		err("Could not started cPCI hotplug system");
		goto init_start_error;
	}
	dbg("started cpci hp system");
	return 0;
init_start_error:
	cpci_hp_unregister_bus(bus);
init_bus_register_error:
	cpci_hp_unregister_controller(&generic_hpc);
	err("status = %d", status);
	return status;

}
示例#2
0
static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{
    int status;

    status = zt5550_hc_config(pdev);
    if(status != 0) {
        return status;
    }
    dbg("returned from zt5550_hc_config");

    memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
    zt5550_hpc.ops = &zt5550_hpc_ops;
    if(!poll) {
        zt5550_hpc.irq = hc_dev->irq;
        zt5550_hpc.irq_flags = IRQF_SHARED;
        zt5550_hpc.dev_id = hc_dev;

        pax_open_kernel();
        *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
        *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
        *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
        pax_open_kernel();
    } else {
        info("using ENUM# polling mode");
    }

    status = cpci_hp_register_controller(&zt5550_hpc);
    if(status != 0) {
        err("could not register cPCI hotplug controller");
        goto init_hc_error;
    }
    dbg("registered controller");

    /* Look for first device matching cPCI bus's bridge vendor and device IDs */
    if(!(bus0_dev = pci_get_device(PCI_VENDOR_ID_DEC,
                                   PCI_DEVICE_ID_DEC_21154, NULL))) {
        status = -ENODEV;
        goto init_register_error;
    }
    bus0 = bus0_dev->subordinate;
    pci_dev_put(bus0_dev);

    status = cpci_hp_register_bus(bus0, 0x0a, 0x0f);
    if(status != 0) {
        err("could not register cPCI hotplug bus");
        goto init_register_error;
    }
    dbg("registered bus");

    status = cpci_hp_start();
    if(status != 0) {
        err("could not started cPCI hotplug system");
        cpci_hp_unregister_bus(bus0);
        goto init_register_error;
    }
    dbg("started cpci hp system");

    return 0;
init_register_error:
    cpci_hp_unregister_controller(&zt5550_hpc);
init_hc_error:
    err("status = %d", status);
    zt5550_hc_cleanup();
    return status;

}