new_smi->ipmi_version_major, new_smi->ipmi_version_minor, 
ipmi_version_major(&new_smi->device_id), ipmi_version_minor(&new_smi->device_id), 
static int init_one_smi(int intf_num, struct smi_info **smi){	int		rv;	struct smi_info *new_smi;	rv = try_init_mem(intf_num, &new_smi);	if (rv)		rv = try_init_port(intf_num, &new_smi);#ifdef CONFIG_ACPI_INTERPRETER	if ((rv) && (si_trydefaults)) {		rv = try_init_acpi(intf_num, &new_smi);	}#endif#ifdef CONFIG_X86	if ((rv) && (si_trydefaults)) {		rv = try_init_smbios(intf_num, &new_smi);        }#endif	if ((rv) && (si_trydefaults)) {		rv = try_init_plug_and_play(intf_num, &new_smi);	}	if (rv)		return rv;	/* So we know not to free it unless we have allocated one. */	new_smi->intf = NULL;	new_smi->si_sm = NULL;	new_smi->handlers = NULL;	if (!new_smi->irq_setup) {		new_smi->irq = irqs[intf_num];		new_smi->irq_setup = std_irq_setup;		new_smi->irq_cleanup = std_irq_cleanup;	}	/* Default to KCS if no type is specified. */	if (si_type[intf_num] == NULL) {		if (si_trydefaults)			si_type[intf_num] = "kcs";		else {			rv = -EINVAL;			goto out_err;		}	}	/* Set up the state machine to use. */	if (strcmp(si_type[intf_num], "kcs") == 0) {		new_smi->handlers = &kcs_smi_handlers;		new_smi->si_type = SI_KCS;	} else if (strcmp(si_type[intf_num], "smic") == 0) {		new_smi->handlers = &smic_smi_handlers;		new_smi->si_type = SI_SMIC;	} else if (strcmp(si_type[intf_num], "bt") == 0) {		new_smi->handlers = &bt_smi_handlers;		new_smi->si_type = SI_BT;	} else {		/* No support for anything else yet. */		rv = -EIO;		goto out_err;	}	/* Allocate the state machine's data and initialize it. */	new_smi->si_sm = kmalloc(new_smi->handlers->size(), GFP_KERNEL);	if (!new_smi->si_sm) {		printk(" Could not allocate state machine memory\n");		rv = -ENOMEM;		goto out_err;	}	new_smi->io_size = new_smi->handlers->init_data(new_smi->si_sm,							&new_smi->io);	/* Now that we know the I/O size, we can set up the I/O. */	rv = new_smi->io_setup(new_smi);	if (rv) {		printk(" Could not set up I/O space\n");		goto out_err;	}	spin_lock_init(&(new_smi->si_lock));	spin_lock_init(&(new_smi->msg_lock));	spin_lock_init(&(new_smi->count_lock));	/* Do low-level detection first. */	if (new_smi->handlers->detect(new_smi->si_sm)) {		rv = -ENODEV;		goto out_err;	}	/* Attempt a get device id command.  If it fails, we probably           don't have a SMI here. */	rv = try_get_dev_id(new_smi);	if (rv)		goto out_err;	/* Try to claim any interrupts. */	new_smi->irq_setup(new_smi);	INIT_LIST_HEAD(&(new_smi->xmit_msgs));	INIT_LIST_HEAD(&(new_smi->hp_xmit_msgs));	new_smi->curr_msg = NULL;	atomic_set(&new_smi->req_events, 0);	new_smi->run_to_completion = 0;	new_smi->interrupt_disabled = 0;	new_smi->timer_stopped = 0;	new_smi->stop_operation = 0;	/* Start clearing the flags before we enable interrupts or the	   timer to avoid racing with the timer. */	start_clear_flags(new_smi);	/* IRQ is defined to be set when non-zero. */	if (new_smi->irq)		new_smi->si_state = SI_CLEARING_FLAGS_THEN_SET_IRQ;	/* The ipmi_register_smi() code does some operations to	   determine the channel information, so we must be ready to	   handle operations before it is called.  This means we have	   to stop the timer if we get an error after this point. */	init_timer(&(new_smi->si_timer));	new_smi->si_timer.data = (long) new_smi;	new_smi->si_timer.function = smi_timeout;	new_smi->last_timeout_jiffies = jiffies;	new_smi->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES;	add_timer(&(new_smi->si_timer));	rv = ipmi_register_smi(&handlers,			       new_smi,			       new_smi->ipmi_version_major,			       new_smi->ipmi_version_minor,			       new_smi->slave_addr,			       &(new_smi->intf));	if (rv) {		printk(KERN_ERR		       "ipmi_si: Unable to register device: error %d\n",		       rv);		goto out_err_stop_timer;	}	rv = ipmi_smi_add_proc_entry(new_smi->intf, "type",				     type_file_read_proc, NULL,				     new_smi, THIS_MODULE);	if (rv) {		printk(KERN_ERR		       "ipmi_si: Unable to create proc entry: %d\n",		       rv);		goto out_err_stop_timer;	}	rv = ipmi_smi_add_proc_entry(new_smi->intf, "si_stats",				     stat_file_read_proc, NULL,				     new_smi, THIS_MODULE);	if (rv) {		printk(KERN_ERR		       "ipmi_si: Unable to create proc entry: %d\n",		       rv);		goto out_err_stop_timer;	}	*smi = new_smi;	printk(" IPMI %s interface initialized\n", si_type[intf_num]);	return 0; out_err_stop_timer:	new_smi->stop_operation = 1;	/* Wait for the timer to stop.  This avoids problems with race	   conditions removing the timer here. */	while (!new_smi->timer_stopped) {		set_current_state(TASK_UNINTERRUPTIBLE);		schedule_timeout(1);	} out_err:	if (new_smi->intf)		ipmi_unregister_smi(new_smi->intf);	new_smi->irq_cleanup(new_smi);	/* Wait until we know that we are out of any interrupt	   handlers might have been running before we freed the	   interrupt. */	synchronize_sched();	if (new_smi->si_sm) {		if (new_smi->handlers)			new_smi->handlers->cleanup(new_smi->si_sm);		kfree(new_smi->si_sm);	}	new_smi->io_cleanup(new_smi);	return rv;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/3ae0e0f9b15b95a2c3e64088d2a85e3f4a707681/ipmi_si_intf.c/clean/drivers/char/ipmi/ipmi_si_intf.c