Exemplo n.º 1
0
Arquivo: module.c Projeto: wxlong/Test
static void __exit ibmasm_remove_one(struct pci_dev *pdev)
{
	struct service_processor *sp = (struct service_processor *)pci_get_drvdata(pdev);

	ibmasm_unregister_uart(sp);
	ibmasm_send_os_state(sp, SYSTEM_STATE_OS_DOWN);
	disable_sp_interrupts(sp->base_address);
	disable_mouse_interrupts(sp);
	free_irq(sp->irq, (void *)sp);
	ibmasm_heartbeat_exit(sp);
	ibmasm_free_remote_queue(sp);
	iounmap(sp->base_address);
	ibmasm_event_buffer_exit(sp);
	kfree(sp);
}
Exemplo n.º 2
0
static void ibmasm_remove_one(struct pci_dev *pdev)
{
	struct service_processor *sp = pci_get_drvdata(pdev);

	dbg("Unregistering UART\n");
	ibmasm_unregister_uart(sp);
	dbg("Sending OS down message\n");
	if (ibmasm_send_os_state(sp, SYSTEM_STATE_OS_DOWN))
		err("failed to get repsonse to 'Send OS State' command\n");
	dbg("Disabling heartbeats\n");
	ibmasm_heartbeat_exit(sp);
	dbg("Disabling interrupts\n");
	disable_sp_interrupts(sp->base_address);
	dbg("Freeing SP irq\n");
	free_irq(sp->irq, (void *)sp);
	dbg("Cleaning up\n");
	ibmasm_free_remote_input_dev(sp);
	iounmap(sp->base_address);
	ibmasm_event_buffer_exit(sp);
	kfree(sp);
	pci_release_regions(pdev);
	pci_disable_device(pdev);
}
Exemplo n.º 3
0
static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{
    int result;
    struct service_processor *sp;

    if ((result = pci_enable_device(pdev))) {
        dev_err(&pdev->dev, "Failed to enable PCI device\n");
        return result;
    }
    if ((result = pci_request_regions(pdev, DRIVER_NAME))) {
        dev_err(&pdev->dev, "Failed to allocate PCI resources\n");
        goto error_resources;
    }
    /* vnc client won't work without bus-mastering */
    pci_set_master(pdev);

    sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL);
    if (sp == NULL) {
        dev_err(&pdev->dev, "Failed to allocate memory\n");
        result = -ENOMEM;
        goto error_kmalloc;
    }
    memset(sp, 0, sizeof(struct service_processor));

    spin_lock_init(&sp->lock);
    INIT_LIST_HEAD(&sp->command_queue);

    pci_set_drvdata(pdev, (void *)sp);
    sp->dev = &pdev->dev;
    sp->number = pdev->bus->number;
    snprintf(sp->dirname, IBMASM_NAME_SIZE, "%d", sp->number);
    snprintf(sp->devname, IBMASM_NAME_SIZE, "%s%d", DRIVER_NAME, sp->number);

    if (ibmasm_event_buffer_init(sp)) {
        dev_err(sp->dev, "Failed to allocate event buffer\n");
        goto error_eventbuffer;
    }

    if (ibmasm_heartbeat_init(sp)) {
        dev_err(sp->dev, "Failed to allocate heartbeat command\n");
        goto error_heartbeat;
    }

    sp->irq = pdev->irq;
    sp->base_address = ioremap(pci_resource_start(pdev, 0),
                               pci_resource_len(pdev, 0));
    if (sp->base_address == 0) {
        dev_err(sp->dev, "Failed to ioremap pci memory\n");
        result =  -ENODEV;
        goto error_ioremap;
    }

    result = request_irq(sp->irq, ibmasm_interrupt_handler, IRQF_SHARED, sp->devname, (void*)sp);
    if (result) {
        dev_err(sp->dev, "Failed to register interrupt handler\n");
        goto error_request_irq;
    }

    enable_sp_interrupts(sp->base_address);

    result = ibmasm_init_remote_input_dev(sp);
    if (result) {
        dev_err(sp->dev, "Failed to initialize remote queue\n");
        goto error_send_message;
    }

    result = ibmasm_send_driver_vpd(sp);
    if (result) {
        dev_err(sp->dev, "Failed to send driver VPD to service processor\n");
        goto error_send_message;
    }
    result = ibmasm_send_os_state(sp, SYSTEM_STATE_OS_UP);
    if (result) {
        dev_err(sp->dev, "Failed to send OS state to service processor\n");
        goto error_send_message;
    }
    ibmasmfs_add_sp(sp);

    ibmasm_register_uart(sp);

    return 0;

error_send_message:
    disable_sp_interrupts(sp->base_address);
    ibmasm_free_remote_input_dev(sp);
    free_irq(sp->irq, (void *)sp);
error_request_irq:
    iounmap(sp->base_address);
error_ioremap:
    ibmasm_heartbeat_exit(sp);
error_heartbeat:
    ibmasm_event_buffer_exit(sp);
error_eventbuffer:
    pci_set_drvdata(pdev, NULL);
    kfree(sp);
error_kmalloc:
    pci_release_regions(pdev);
error_resources:
    pci_disable_device(pdev);

    return result;
}
Exemplo n.º 4
0
Arquivo: module.c Projeto: wxlong/Test
static int __init ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{
	int result = -ENOMEM;
	struct service_processor *sp;

	sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL);
	if (sp == NULL) {
		dev_err(&pdev->dev, "Failed to allocate memory\n");
		return result;
	}
	memset(sp, 0, sizeof(struct service_processor));

	pci_set_drvdata(pdev, (void *)sp);
	sp->dev = &pdev->dev;
	sp->number = pdev->bus->number;
	snprintf(sp->dirname, IBMASM_NAME_SIZE, "%d", sp->number);
	snprintf(sp->devname, IBMASM_NAME_SIZE, "%s%d", DRIVER_NAME, sp->number);

	if (ibmasm_event_buffer_init(sp)) {
		dev_err(sp->dev, "Failed to allocate event buffer\n");
		goto error_eventbuffer;
	}

	if (ibmasm_heartbeat_init(sp)) {
		dev_err(sp->dev, "Failed to allocate heartbeat command\n");
		goto error_heartbeat;
	}

	sp->irq = pdev->irq;
	sp->base_address = ioremap(pci_resource_start(pdev, 0), 
					pci_resource_len(pdev, 0));
	if (sp->base_address == 0) {
		dev_err(sp->dev, "Failed to ioremap pci memory\n");
		result =  -ENODEV;
		goto error_ioremap;
	}

	result = ibmasm_init_remote_queue(sp);
	if (result) {
		dev_err(sp->dev, "Failed to initialize remote queue\n");
		goto error_remote_queue;
	}

	sp->lock = SPIN_LOCK_UNLOCKED;
	INIT_LIST_HEAD(&sp->command_queue);

	result = request_irq(sp->irq, ibmasm_interrupt_handler, SA_SHIRQ, sp->devname, (void*)sp);
	if (result) {
		dev_err(sp->dev, "Failed to register interrupt handler\n");
		goto error_request_irq;
	}

	enable_sp_interrupts(sp->base_address);
	disable_mouse_interrupts(sp);

	result = ibmasm_send_driver_vpd(sp);
	if (result) {
		dev_err(sp->dev, "Failed to send driver VPD to service processor\n");
		goto error_send_message;
	}
	result = ibmasm_send_os_state(sp, SYSTEM_STATE_OS_UP);
	if (result) {
		dev_err(sp->dev, "Failed to send OS state to service processor\n");
		goto error_send_message;
	}
	ibmasmfs_add_sp(sp);

	ibmasm_register_uart(sp);

	return 0;

error_send_message:
	disable_sp_interrupts(sp->base_address);
	free_irq(sp->irq, (void *)sp);
error_request_irq:
	ibmasm_free_remote_queue(sp);
error_remote_queue:
	iounmap(sp->base_address);
error_ioremap:
	ibmasm_heartbeat_exit(sp);
error_heartbeat:
	ibmasm_event_buffer_exit(sp);
error_eventbuffer:
	kfree(sp);

	return result;
}
Exemplo n.º 5
0
static int __init ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{
	int err, result = -ENOMEM;
	struct service_processor *sp;

	if ((err = pci_enable_device(pdev))) {
		printk(KERN_ERR "%s: can't enable PCI device at %s\n",
			DRIVER_NAME, pci_name(pdev));
		return err;
	}

	sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL);
	if (sp == NULL) {
		dev_err(&pdev->dev, "Failed to allocate memory\n");
		result = -ENOMEM;
		goto error_kmalloc;
	}
	memset(sp, 0, sizeof(struct service_processor));

	pci_set_drvdata(pdev, (void *)sp);
	sp->dev = &pdev->dev;
	sp->number = pdev->bus->number;
	snprintf(sp->dirname, IBMASM_NAME_SIZE, "%d", sp->number);
	snprintf(sp->devname, IBMASM_NAME_SIZE, "%s%d", DRIVER_NAME, sp->number);

	if (ibmasm_event_buffer_init(sp)) {
		dev_err(sp->dev, "Failed to allocate event buffer\n");
		goto error_eventbuffer;
	}

	if (ibmasm_heartbeat_init(sp)) {
		dev_err(sp->dev, "Failed to allocate heartbeat command\n");
		goto error_heartbeat;
	}

	sp->irq = pdev->irq;
	sp->base_address = ioremap(pci_resource_start(pdev, 0), 
					pci_resource_len(pdev, 0));
	if (sp->base_address == 0) {
		dev_err(sp->dev, "Failed to ioremap pci memory\n");
		result =  -ENODEV;
		goto error_ioremap;
	}

	result = ibmasm_init_remote_queue(sp);
	if (result) {
		dev_err(sp->dev, "Failed to initialize remote queue\n");
		goto error_remote_queue;
	}

	spin_lock_init(&sp->lock);
	INIT_LIST_HEAD(&sp->command_queue);

	result = request_irq(sp->irq, ibmasm_interrupt_handler, SA_SHIRQ, sp->devname, (void*)sp);
	if (result) {
		dev_err(sp->dev, "Failed to register interrupt handler\n");
		goto error_request_irq;
	}

	enable_sp_interrupts(sp->base_address);
	disable_mouse_interrupts(sp);

	result = ibmasm_send_driver_vpd(sp);
	if (result) {
		dev_err(sp->dev, "Failed to send driver VPD to service processor\n");
		goto error_send_message;
	}
	result = ibmasm_send_os_state(sp, SYSTEM_STATE_OS_UP);
	if (result) {
		dev_err(sp->dev, "Failed to send OS state to service processor\n");
		goto error_send_message;
	}
	ibmasmfs_add_sp(sp);

	ibmasm_register_uart(sp);

	dev_printk(KERN_DEBUG, &pdev->dev, "WARNING: This software may not be supported or function\n");
	dev_printk(KERN_DEBUG, &pdev->dev, "correctly on your IBM server. Please consult the IBM\n");
	dev_printk(KERN_DEBUG, &pdev->dev, "ServerProven website\n");
	dev_printk(KERN_DEBUG, &pdev->dev, "http://www.pc.ibm.com/ww/eserver/xseries/serverproven\n");
	dev_printk(KERN_DEBUG, &pdev->dev, "for information on the specific driver level and support\n");
	dev_printk(KERN_DEBUG, &pdev->dev, "statement for your IBM server.\n");

	return 0;

error_send_message:
	disable_sp_interrupts(sp->base_address);
	free_irq(sp->irq, (void *)sp);
error_request_irq:
	ibmasm_free_remote_queue(sp);
error_remote_queue:
	iounmap(sp->base_address);
error_ioremap:
	ibmasm_heartbeat_exit(sp);
error_heartbeat:
	ibmasm_event_buffer_exit(sp);
error_eventbuffer:
	kfree(sp);
error_kmalloc:
	pci_disable_device(pdev);

	return result;
}