示例#1
0
文件: irqdesc.c 项目: avagin/linux
static struct irq_desc *alloc_desc(int irq, int node, unsigned int flags,
				   const struct cpumask *affinity,
				   struct module *owner)
{
	struct irq_desc *desc;

	desc = kzalloc_node(sizeof(*desc), GFP_KERNEL, node);
	if (!desc)
		return NULL;
	/* allocate based on nr_cpu_ids */
	desc->kstat_irqs = alloc_percpu(unsigned int);
	if (!desc->kstat_irqs)
		goto err_desc;

	if (alloc_masks(desc, node))
		goto err_kstat;

	raw_spin_lock_init(&desc->lock);
	lockdep_set_class(&desc->lock, &irq_desc_lock_class);
	mutex_init(&desc->request_mutex);
	init_rcu_head(&desc->rcu);

	desc_set_defaults(irq, desc, node, affinity, owner);
	irqd_set(&desc->irq_data, flags);
	kobject_init(&desc->kobj, &irq_kobj_type);

	return desc;

err_kstat:
	free_percpu(desc->kstat_irqs);
err_desc:
	kfree(desc);
	return NULL;
}
示例#2
0
struct command *ibmasm_new_command(struct service_processor *sp, size_t buffer_size)
{
	struct command *cmd;

	if (buffer_size > IBMASM_CMD_MAX_BUFFER_SIZE)
		return NULL;

	cmd = kzalloc(sizeof(struct command), GFP_KERNEL);
	if (cmd == NULL)
		return NULL;


	cmd->buffer = kzalloc(buffer_size, GFP_KERNEL);
	if (cmd->buffer == NULL) {
		kfree(cmd);
		return NULL;
	}
	cmd->buffer_size = buffer_size;

	kobject_init(&cmd->kobj);
	cmd->kobj.ktype = &ibmasm_cmd_kobj_type;
	cmd->lock = &sp->lock;

	cmd->status = IBMASM_CMD_PENDING;
	init_waitqueue_head(&cmd->wait);
	INIT_LIST_HEAD(&cmd->queue_node);

	atomic_inc(&command_count);
	dbg("command count: %d\n", atomic_read(&command_count));

	return cmd;
}
示例#3
0
int dim2_sysfs_probe(struct medialb_bus *bus, struct kobject *parent_kobj)
{
	int err;

	kobject_init(&bus->kobj_group, &bus_ktype);
	err = kobject_add(&bus->kobj_group, parent_kobj, "bus");
	if (err) {
		pr_err("kobject_add() failed: %d\n", err);
		goto err_kobject_add;
	}

	err = sysfs_create_group(&bus->kobj_group, &bus_attr_group);
	if (err) {
		pr_err("sysfs_create_group() failed: %d\n", err);
		goto err_create_group;
	}

	return 0;

err_create_group:
	kobject_put(&bus->kobj_group);

err_kobject_add:
	return err;
}
示例#4
0
int rfs_sysfs_create(void)
{
    int rv;

    rfs_kobj = kzalloc(sizeof(struct kobject), GFP_KERNEL);
    if (!rfs_kobj)
        return -ENOMEM;

    kobject_init(rfs_kobj);
    rfs_kobj->ktype = &rfs_kobj_ktype;
    rfs_kobj->parent = &fs_subsys.kobj;
    rv = kobject_set_name(rfs_kobj, "%s", "redirfs");
    if (rv) {
        kobject_put(rfs_kobj);
        return rv;
    }

    rv = kobject_register(rfs_kobj);
    if (rv) {
        kobject_put(rfs_kobj);
        return rv;
    }

    rv = -ENOMEM;
    rfs_flt_kset = kzalloc(sizeof(struct kset), GFP_KERNEL);
    if (!rfs_flt_kset)
        goto err_kobj;

    kobject_init(&rfs_flt_kset->kobj);
    rfs_flt_kset->kobj.ktype = &rfs_kobj_ktype;
    rfs_flt_kset->kobj.parent = rfs_kobj;
    rv = kobject_set_name(&rfs_flt_kset->kobj, "%s", "filters");
    if (rv) 
        goto err_kset;

    rv = kset_register(rfs_flt_kset);
    if (rv)
        goto err_kset;

    return 0;

err_kset:
    kset_put(rfs_flt_kset);
err_kobj:
    kobject_unregister(rfs_kobj);
    return rv;
}
示例#5
0
文件: core.c 项目: kzlin129/tt-gpl
void device_initialize(struct device *dev)
{
	kobj_set_kset_s(dev, devices_subsys);
	kobject_init(&dev->kobj);
	klist_init(&dev->klist_children);
	INIT_LIST_HEAD(&dev->dma_pools);
	init_MUTEX(&dev->sem);
}
static int _init_iostash_kobjects(void)
{
	int err = 0;

	static struct kobj_type ctl_kobj_type = {
                .release       = ctl_kobj_release,
                .sysfs_ops     = &ctl_sysfs_ops,
                .default_attrs = ctl_attrs,
        };

	memset(&gctx.ctl_kobj, 0, sizeof(gctx.ctl_kobj));
	kobject_init(&gctx.ctl_kobj, &ctl_kobj_type);

	err = kobject_add(&gctx.ctl_kobj,
			  (&(THIS_MODULE)->mkobj.kobj),
			  "%s",
			  CTL_KOBJ_NAME);
	if (err)
	{
		kobject_put(&gctx.ctl_kobj);
		err = -ENOMEM;
		goto out;
	}

	gctx.ssd_kset = kset_create_and_add
		(SSD_KSET_NAME, NULL, (&(THIS_MODULE)->mkobj.kobj));
	if (!gctx.ssd_kset)
	{
		err = -ENOMEM;
		goto kobj_del;
	}

	gctx.hdd_kset = kset_create_and_add
		(HDD_KSET_NAME, NULL, (&(THIS_MODULE)->mkobj.kobj));
	if (!gctx.hdd_kset)
	{
		err = -ENOMEM;
		goto unreg_ssd_kset;
	}

	BUG_ON(0 != err);

	return 0;

kobj_del:
	kobject_del(&gctx.ctl_kobj);
	kobject_put(&gctx.ctl_kobj);

unreg_ssd_kset:
	kset_unregister(gctx.ssd_kset);

out:
	return err;
}
示例#7
0
static struct elog_obj *create_elog_obj(uint64_t id, size_t size, uint64_t type)
{
	struct elog_obj *elog;
	int rc;

	elog = kzalloc(sizeof(*elog), GFP_KERNEL);
	if (!elog)
		return NULL;

	elog->kobj.kset = elog_kset;

	kobject_init(&elog->kobj, &elog_ktype);

	sysfs_bin_attr_init(&elog->raw_attr);

	elog->raw_attr.attr.name = "raw";
	elog->raw_attr.attr.mode = 0400;
	elog->raw_attr.size = size;
	elog->raw_attr.read = raw_attr_read;

	elog->id = id;
	elog->size = size;
	elog->type = type;

	elog->buffer = kzalloc(elog->size, GFP_KERNEL);

	if (elog->buffer) {
		rc = opal_read_elog(__pa(elog->buffer),
					 elog->size, elog->id);
		if (rc != OPAL_SUCCESS) {
			pr_err("ELOG: log read failed for log-id=%llx\n",
			       elog->id);
			kfree(elog->buffer);
			elog->buffer = NULL;
		}
	}

	rc = kobject_add(&elog->kobj, NULL, "0x%llx", id);
	if (rc) {
		kobject_put(&elog->kobj);
		return NULL;
	}

	rc = sysfs_create_bin_file(&elog->kobj, &elog->raw_attr);
	if (rc) {
		kobject_put(&elog->kobj);
		return NULL;
	}

	kobject_uevent(&elog->kobj, KOBJ_ADD);

	return elog;
}
int kgsl_pwrscale_init(struct kgsl_device *device)
{
	int ret;

	ret = kobject_init_and_add(&device->pwrscale_kobj, &ktype_pwrscale,
		&device->dev->kobj, "pwrscale");

	if (ret)
		return ret;

	kobject_init(&device->pwrscale.kobj, &ktype_pwrscale_policy);
	return ret;
}
示例#9
0
static int rk28_sdmmc0_add_attr( struct platform_device *pdev )
{
        int result;
		 struct kobject *parentkobject; 
        struct kobject * me = kmalloc(sizeof(struct kobject) , GFP_KERNEL );
        if( !me )
                return -ENOMEM;
        memset(me ,0,sizeof(struct kobject));
        kobject_init( me , &mmc_kset_ktype );
        //result = kobject_add( me , &pdev->dev.kobj , "%s", "RESET" );
        parentkobject = &pdev->dev.kobj ;
		 result = kobject_add( me , parentkobject->parent->parent, "%s", "resetSdCard" );	
        return result;
}
示例#10
0
int rfs_flt_sysfs_init(struct rfs_flt *rflt)
{
    int rv;

    rflt->kobj.kset = rfs_flt_kset;
    kobject_init(&rflt->kobj, &rfs_flt_ktype);

    rv = kobject_add(&rflt->kobj, NULL, "%s", rflt->name);
    if (rv)
        return rv;

    kobject_uevent(&rflt->kobj, KOBJ_ADD);

    rfs_flt_get(rflt);

    return 0;
}
示例#11
0
static int __init cpuinfo_regs_init(void)
{
	int cpu, ret;

	for_each_possible_cpu(cpu) {
		struct cpuinfo_arm64 *info = &per_cpu(cpu_data, cpu);

		kobject_init(&info->kobj, &cpuregs_kobj_type);
	}

	ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "arm64/cpuinfo:online",
				cpuid_cpu_online, cpuid_cpu_offline);
	if (ret < 0) {
		pr_err("cpuinfo: failed to register hotplug callbacks.\n");
		return ret;
	}
	return 0;
}
示例#12
0
int cavan_input_add_kobject(struct kobject *kobj, const char *name)
{
	int ret;

	if (kobj->state_initialized == 0)
	{
		kobject_init(kobj, &cavan_input_kobj_type);
	}

	ret = kobject_add(kobj, NULL, name);
	if (ret < 0)
	{
		pr_red_info("kobject_add");
		return ret;
	}

	return 0;
}
示例#13
0
文件: opal-dump.c 项目: MaybeS/linux
static struct dump_obj *create_dump_obj(uint32_t id, size_t size,
					uint32_t type)
{
	struct dump_obj *dump;
	int rc;

	dump = kzalloc(sizeof(*dump), GFP_KERNEL);
	if (!dump)
		return NULL;

	dump->kobj.kset = dump_kset;

	kobject_init(&dump->kobj, &dump_ktype);

	sysfs_bin_attr_init(&dump->dump_attr);

	dump->dump_attr.attr.name = "dump";
	dump->dump_attr.attr.mode = 0400;
	dump->dump_attr.size = size;
	dump->dump_attr.read = dump_attr_read;

	dump->id = id;
	dump->size = size;
	dump->type = type;

	rc = kobject_add(&dump->kobj, NULL, "0x%x-0x%x", type, id);
	if (rc) {
		kobject_put(&dump->kobj);
		return NULL;
	}

	rc = sysfs_create_bin_file(&dump->kobj, &dump->dump_attr);
	if (rc) {
		kobject_put(&dump->kobj);
		return NULL;
	}

	pr_info("%s: New platform dump. ID = 0x%x Size %u\n",
		__func__, dump->id, dump->size);

	kobject_uevent(&dump->kobj, KOBJ_ADD);

	return dump;
}
示例#14
0
文件: calc.c 项目: Ignatks/Lab4-5
static int __init sysfsexample_module_init(void)
{
	int err = -1;

	calc_obj = kzalloc(sizeof(*calc_obj), GFP_KERNEL);
	if (calc_obj) {
		//kobject_init — initialize a kobject structure
		kobject_init(calc_obj, &calc_type);
		//The kobject name is set and added to the kobject hierarchy in this function.
		if (kobject_add(calc_obj, NULL, "%s", PARENT_DIR)) {
			 err = -1;
			 printk("Sysfs creation failed\n");
			 kobject_put(calc_obj);
			 calc_obj = NULL;
		}
		err = 0;
	}
	return err;
}
struct mcde_overlay *mcde_dss_create_overlay(struct mcde_display_device *ddev,
	struct mcde_overlay_info *info)
{
	struct mcde_overlay *ovly;

	ovly = kzalloc(sizeof(struct mcde_overlay), GFP_KERNEL);
	if (!ovly)
		return NULL;

	kobject_init(&ovly->kobj, &ovly_type); /* Local ref */
	kobject_get(&ovly->kobj); /* Creator ref */
	INIT_LIST_HEAD(&ovly->list);
	mutex_lock(&ddev->display_lock);
	list_add(&ddev->ovlys, &ovly->list);
	mutex_unlock(&ddev->display_lock);
	ovly->info = *info;
	ovly->ddev = ddev;

	return ovly;
}
示例#16
0
/*
 * kernel_param_sysfs_setup - wrapper for built-in params support
 */
static void __init kernel_param_sysfs_setup(const char *name,
					    struct kernel_param *kparam,
					    unsigned int num_params,
					    unsigned int name_skip)
{
	struct module_kobject *mk;
	int ret;

	mk = kzalloc(sizeof(struct module_kobject), GFP_KERNEL);
	BUG_ON(!mk);

	mk->mod = THIS_MODULE;
	kobj_set_kset_s(mk, module_subsys);
	kobject_set_name(&mk->kobj, name);
	kobject_init(&mk->kobj);
	ret = kobject_add(&mk->kobj);
	BUG_ON(ret < 0);
	param_sysfs_setup(mk, kparam, num_params, name_skip);
	kobject_uevent(&mk->kobj, KOBJ_ADD);
}
示例#17
0
static int recovery_button_prep_sysfs(void)
{
	int err = 0;

	/* prep the sysfs interface for use */
	kobject_set_name(&recovery_button_driver.kset.kobj, "recovery-button");
	recovery_button_driver.kset.kobj.ktype = &ktype_recovery_button;

	err = kset_register(&recovery_button_driver.kset);
	if (err)
		return err;

	/* setup hotplugging */
	recovery_button_driver.kset.uevent_ops = &recovery_button_uevent_ops;

	/* setup the heirarchy, the name will be set on detection */
	kobject_init(&recovery_button_driver.recovery_button,recovery_button_driver.kset.kobj.ktype);
	recovery_button_driver.recovery_button.kset = kset_get(&recovery_button_driver.kset);
	recovery_button_driver.recovery_button.parent = &recovery_button_driver.kset.kobj;

	return 0;
}
示例#18
0
int sysedp_consumer_add_kobject(struct sysedp_consumer *consumer)
{
	int ret;

	consumer->kobj.kset = consumers_kset;
	kobject_init(&consumer->kobj, &ktype_consumer);

	ret = kobject_add(&consumer->kobj, NULL, consumer->name);
	if (ret) {
		pr_err("%s: failed to add sysfs consumer entry\n",
		       consumer->name);
		return ret;
	}

	ret = kobject_uevent(&consumer->kobj, KOBJ_ADD);
	if (ret) {
		pr_err("%s: failed to send uevent\n",
		       consumer->name);
		kobject_put(&consumer->kobj);
		return ret;
	}
	return 0;
}
示例#19
0
/* This is strictly temporary, until PCMCIA devices get integrated into the device model. */
static struct device *atmel_device(void)
{
	static char *kobj_name = "atmel_cs";

	static struct device dev = {
		.bus_id    = "pcmcia",
	};
	dev.kobj.k_name = kmalloc(strlen(kobj_name)+1, GFP_KERNEL);
	strcpy(dev.kobj.k_name, kobj_name);
	kobject_init(&dev.kobj);
	
	return &dev;
}

static void atmel_config(dev_link_t *link)
{
	client_handle_t handle;
	tuple_t tuple;
	cisparse_t parse;
	local_info_t *dev;
	int last_fn, last_ret;
	u_char buf[64];
	int card_index = -1, done = 0;
	
	handle = link->handle;
	dev = link->priv;

	DEBUG(0, "atmel_config(0x%p)\n", link);
	
	tuple.Attributes = 0;
	tuple.TupleData = buf;
	tuple.TupleDataMax = sizeof(buf);
	tuple.TupleOffset = 0;
	
	tuple.DesiredTuple = CISTPL_MANFID;
	if (pcmcia_get_first_tuple(handle, &tuple) == 0) {
		int i;
		cistpl_manfid_t *manfid;
		CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
		CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
		manfid = &(parse.manfid);
		for (i = 0; i < sizeof(card_table)/sizeof(card_table[0]); i++) {
			if (!card_table[i].ver1 &&
			    manfid->manf == card_table[i].manf &&
			    manfid->card == card_table[i].card) {
				card_index = i;
				done = 1;
			}
		}
	}

	tuple.DesiredTuple = CISTPL_VERS_1;
	if (!done && (pcmcia_get_first_tuple(handle, &tuple) == 0)) {
		int i, j, k;
		cistpl_vers_1_t *ver1;
		CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
		CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
		ver1 = &(parse.version_1);
		
		for (i = 0; i < sizeof(card_table)/sizeof(card_table[0]); i++) {
			for (j = 0; j < ver1->ns; j++) {
				char *p = card_table[i].ver1;
				char *q = &ver1->str[ver1->ofs[j]];
				if (!p)
					goto mismatch;
				for (k = 0; k < j; k++) {
					while ((*p != '\0') && (*p != '/')) p++;
					if (*p == '\0') {
						if (*q != '\0')
							goto mismatch;
					} else {
						p++;
					}
				}
				while((*q != '\0') && (*p != '\0') && 
				      (*p != '/') && (*p == *q)) p++, q++;
				if (((*p != '\0') && *p != '/') || *q != '\0')
					goto mismatch;
			}
			card_index = i;
			break;	/* done */
			
		mismatch:
			j = 0; /* dummy stmt to shut up compiler */
		}
	}		

	/*
	  This reads the card's CONFIG tuple to find its configuration
	  registers.
	*/
	tuple.DesiredTuple = CISTPL_CONFIG;
	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
	CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
	CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
	link->conf.ConfigBase = parse.config.base;
	link->conf.Present = parse.config.rmask[0];
	
	/* Configure card */
	link->state |= DEV_CONFIG;
	
	/*
	  In this loop, we scan the CIS for configuration table entries,
	  each of which describes a valid card configuration, including
	  voltage, IO window, memory window, and interrupt settings.
	  
	  We make no assumptions about the card to be configured: we use
	  just the information available in the CIS.  In an ideal world,
	  this would work for any PCMCIA card, but it requires a complete
	  and accurate CIS.  In practice, a driver usually "knows" most of
	  these things without consulting the CIS, and most client drivers
	  will only use the CIS to fill in implementation-defined details.
	*/
	tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
	while (1) {
		cistpl_cftable_entry_t dflt = { 0 };
		cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
		if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
				pcmcia_parse_tuple(handle, &tuple, &parse) != 0)
			goto next_entry;
		
		if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
		if (cfg->index == 0) goto next_entry;
		link->conf.ConfigIndex = cfg->index;
		
		/* Does this card need audio output? */
		if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
			link->conf.Attributes |= CONF_ENABLE_SPKR;
			link->conf.Status = CCSR_AUDIO_ENA;
		}
		
		/* Use power settings for Vcc and Vpp if present */
		/*  Note that the CIS values need to be rescaled */
		if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM))
			link->conf.Vcc = cfg->vcc.param[CISTPL_POWER_VNOM]/10000;
		else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM))
			link->conf.Vcc = dflt.vcc.param[CISTPL_POWER_VNOM]/10000;
		
		if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
			link->conf.Vpp1 = link->conf.Vpp2 =
				cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
		else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM))
			link->conf.Vpp1 = link->conf.Vpp2 =
				dflt.vpp1.param[CISTPL_POWER_VNOM]/10000;
		
		/* Do we need to allocate an interrupt? */
		if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
			link->conf.Attributes |= CONF_ENABLE_IRQ;
		
		/* IO window settings */
		link->io.NumPorts1 = link->io.NumPorts2 = 0;
		if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
			cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
			link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
			if (!(io->flags & CISTPL_IO_8BIT))
				link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
			if (!(io->flags & CISTPL_IO_16BIT))
				link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
			link->io.BasePort1 = io->win[0].base;
			link->io.NumPorts1 = io->win[0].len;
			if (io->nwin > 1) {
				link->io.Attributes2 = link->io.Attributes1;
				link->io.BasePort2 = io->win[1].base;
				link->io.NumPorts2 = io->win[1].len;
			}
		}
		
		/* This reserves IO space but doesn't actually enable it */
		if (pcmcia_request_io(link->handle, &link->io) != 0)
			goto next_entry;

		/* If we got this far, we're cool! */
		break;
		
	next_entry:
		CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
	}
	
	/*
	  Allocate an interrupt line.  Note that this does not assign a
	  handler to the interrupt, unless the 'Handler' member of the
	  irq structure is initialized.
	*/
	if (link->conf.Attributes & CONF_ENABLE_IRQ)
		CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
	
	/*
	  This actually configures the PCMCIA socket -- setting up
	  the I/O windows and the interrupt mapping, and putting the
	  card and host interface into "Memory and IO" mode.
	*/
	CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
	
	if (link->irq.AssignedIRQ == 0) {
		printk(KERN_ALERT 
		       "atmel: cannot assign IRQ: check that CONFIG_ISA is set in kernel config.");
		goto cs_failed;
	}
       
	((local_info_t*)link->priv)->eth_dev = 
		init_atmel_card(link->irq.AssignedIRQ,
				link->io.BasePort1,
				card_index == -1 ? NULL :  card_table[card_index].firmware,
				atmel_device(),
				card_present, 
				link);
	if (!((local_info_t*)link->priv)->eth_dev) 
		goto cs_failed;
	
	/*
	  At this point, the dev_node_t structure(s) need to be
	  initialized and arranged in a linked list at link->dev.
	*/
	strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name );
	dev->node.major = dev->node.minor = 0;
	link->dev = &dev->node;
	
	/* Finally, report what we've done */
	printk(KERN_INFO "%s: %s%sindex 0x%02x: Vcc %d.%d",
	       dev->node.dev_name,
	       card_index == -1 ? "" :  card_table[card_index].name,
	       card_index == -1 ? "" : " ",
	       link->conf.ConfigIndex,
	       link->conf.Vcc/10, link->conf.Vcc%10);
	if (link->conf.Vpp1)
		printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10);
	if (link->conf.Attributes & CONF_ENABLE_IRQ)
		printk(", irq %d", link->irq.AssignedIRQ);
	if (link->io.NumPorts1)
		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
		       link->io.BasePort1+link->io.NumPorts1-1);
	if (link->io.NumPorts2)
		printk(" & 0x%04x-0x%04x", link->io.BasePort2,
		       link->io.BasePort2+link->io.NumPorts2-1);
	printk("\n");
	
	link->state &= ~DEV_CONFIG_PENDING;
	return;
	
 cs_failed:
	cs_error(link->handle, last_fn, last_ret);
	atmel_release(link);
}
示例#20
0
文件: uio.c 项目: civato/9005-LL-DEV
/*
 * device functions
 */
static int uio_dev_add_attributes(struct uio_device *idev)
{
	int ret;
	int mi, pi;
	int map_found = 0;
	int portio_found = 0;
	struct uio_mem *mem;
	struct uio_map *map;
	struct uio_port *port;
	struct uio_portio *portio;

	for (mi = 0; mi < MAX_UIO_MAPS; mi++) {
		mem = &idev->info->mem[mi];
		if (mem->size == 0)
			break;
		if (!map_found) {
			map_found = 1;
			idev->map_dir = kobject_create_and_add("maps",
							&idev->dev->kobj);
			if (!idev->map_dir)
				goto err_map;
		}
		map = kzalloc(sizeof(*map), GFP_KERNEL);
		if (!map)
			goto err_map;
		kobject_init(&map->kobj, &map_attr_type);
		map->mem = mem;
		mem->map = map;
		ret = kobject_add(&map->kobj, idev->map_dir, "map%d", mi);
		if (ret)
			goto err_map;
		ret = kobject_uevent(&map->kobj, KOBJ_ADD);
		if (ret)
			goto err_map;
	}

	for (pi = 0; pi < MAX_UIO_PORT_REGIONS; pi++) {
		port = &idev->info->port[pi];
		if (port->size == 0)
			break;
		if (!portio_found) {
			portio_found = 1;
			idev->portio_dir = kobject_create_and_add("portio",
							&idev->dev->kobj);
			if (!idev->portio_dir)
				goto err_portio;
		}
		portio = kzalloc(sizeof(*portio), GFP_KERNEL);
		if (!portio)
			goto err_portio;
		kobject_init(&portio->kobj, &portio_attr_type);
		portio->port = port;
		port->portio = portio;
		ret = kobject_add(&portio->kobj, idev->portio_dir,
							"port%d", pi);
		if (ret)
			goto err_portio;
		ret = kobject_uevent(&portio->kobj, KOBJ_ADD);
		if (ret)
			goto err_portio;
	}

	return 0;

err_portio:
	for (pi--; pi >= 0; pi--) {
		port = &idev->info->port[pi];
		portio = port->portio;
		kobject_put(&portio->kobj);
	}
	kobject_put(idev->portio_dir);
err_map:
	for (mi--; mi>=0; mi--) {
		mem = &idev->info->mem[mi];
		map = mem->map;
		kobject_put(&map->kobj);
	}
	kobject_put(idev->map_dir);
	dev_err(idev->dev, "error creating sysfs files (%d)\n", ret);
	return ret;
}
示例#21
0
/**
 * musb_platform_init() - Initialize the platform USB driver.
 * @musb: struct musb pointer.
 *
 * This function initialize the USB controller and Phy.
 */
int __init musb_platform_init(struct musb *musb, void *board_data)
{
	int ret;

	usb_nop_xceiv_register();

	musb->xceiv = otg_get_transceiver();
	if (!musb->xceiv) {
		pr_err("U8500 USB : no transceiver configured\n");
		ret = -ENODEV;
		goto cleanup0;
	}

	ret = musb_stm_hs_otg_init(musb);
	if (ret < 0) {
		pr_err("U8500 USB: Failed to init the OTG object\n");
		goto cleanup1;
	}

	if (is_host_enabled(musb))
		musb->board_set_vbus = set_vbus;
	if (is_peripheral_enabled(musb))
		musb->xceiv->set_power = set_power;

	ret = musb_phy_en(musb->board_mode);
	if (ret < 0) {
		pr_err("U8500 USB: Failed to enable PHY\n");
		goto cleanup1;
	}

	if (musb_status == NULL) {
		musb_status = musb;
		spin_lock_init(&musb_ulpi_spinlock);
	}

	/* Registering usb device  for sysfs */
	usbstatus_kobj = kzalloc(sizeof(struct kobject), GFP_KERNEL);

	if (usbstatus_kobj == NULL) {
		ret = -ENOMEM;
		goto cleanup1;
	}
	usbstatus_kobj->ktype = &ktype_usbstatus;
	kobject_init(usbstatus_kobj, usbstatus_kobj->ktype);

	ret = kobject_set_name(usbstatus_kobj, "usb_status");
	if (ret)
		goto cleanup2;

	ret = kobject_add(usbstatus_kobj, NULL, "usb_status");
	if (ret) {
		goto cleanup2;
	}

	if (musb->board_mode != MUSB_PERIPHERAL) {
		init_timer(&notify_timer);
		notify_timer.expires = jiffies + msecs_to_jiffies(1000);
		notify_timer.function = funct_host_notify_timer;
		notify_timer.data = (unsigned long)musb;
		add_timer(&notify_timer);
	}

	stm_usb_power_wq = create_singlethread_workqueue(
						"stm_usb_power_wq");
	if (stm_usb_power_wq == NULL) {
		ret = -ENOMEM;
		goto cleanup2;
	}

	INIT_WORK(&stm_prcmu_qos, stm_prcmu_qos_work);

	ret = musb_force_detect(musb->board_mode);
	if (ret < 0)
		goto cleanup2;

	return 0;

cleanup2:
	kfree(usbstatus_kobj);
	if (musb->board_mode != MUSB_PERIPHERAL)
		del_timer_sync(&notify_timer);

cleanup1:
	otg_put_transceiver(musb->xceiv);
cleanup0:
	usb_nop_xceiv_unregister();
	return ret;

}