コード例 #1
0
ファイル: kset.c プロジェクト: LuckJC/i-driver
static int __init mkset_init(void)
{
	/* 创建并注册一个kset */
	kset_p = kset_create_and_add("zjj", &mkset_ops, NULL);
	if(kset_p == NULL)
		return - EFAULT;
	
	kobject_set_name(&kset_c.kobj, "hc");
	kset_c.kobj.kset = kset_p;
	kset_register(&kset_c);
	
	return 0;
}
コード例 #2
0
ファイル: rfs_sysfs.c プロジェクト: Vadim-Stupakov/RedirFS
int rfs_sysfs_create(void)
{
    rfs_kobj = kobject_create_and_add("redirfs", fs_kobj);
    if (!rfs_kobj)
        return -ENOMEM;

    rfs_flt_kset = kset_create_and_add("filters", NULL, rfs_kobj);
    if (!rfs_flt_kset) {
        kobject_put(rfs_kobj);
        return -ENOMEM;
    }

    return 0;
}
コード例 #3
0
static int __init sphinx_init(void)
{
	int ret;

	/* Create a simple kobject with the name of "sphinx" located under /sys/kernel/ */
	sphinx_kset = kset_create_and_add("digestmanager", NULL, kernel_kobj);
	if(!sphinx_kset) return -ENOMEM;

	ret = sphinx_create_kobject(&elfloader_data);
	ret = sphinx_create_kobject(&provenprocess_data);
	ret = sphinx_create_kobject(&secure_data);
	ret = sphinx_create_kobject(&package_data);

	return ret;
}
コード例 #4
0
ファイル: super.c プロジェクト: SiddheshK15/WR2-Kernel
static int __init init_f2fs_fs(void)
{
	int err;

	f2fs_build_trace_ios();

	err = init_inodecache();
	if (err)
		goto fail;
	err = create_node_manager_caches();
	if (err)
		goto free_inodecache;
	err = create_segment_manager_caches();
	if (err)
		goto free_node_manager_caches;
	err = create_checkpoint_caches();
	if (err)
		goto free_segment_manager_caches;
	err = create_extent_cache();
	if (err)
		goto free_checkpoint_caches;
	f2fs_kset = kset_create_and_add("f2fs", NULL, fs_kobj);
	if (!f2fs_kset) {
		err = -ENOMEM;
		goto free_extent_cache;
	}
	err = register_filesystem(&f2fs_fs_type);
	if (err)
		goto free_kset;
	f2fs_create_root_stats();
	f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
	return 0;

free_kset:
	kset_unregister(f2fs_kset);
free_extent_cache:
	destroy_extent_cache();
free_checkpoint_caches:
	destroy_checkpoint_caches();
free_segment_manager_caches:
	destroy_segment_manager_caches();
free_node_manager_caches:
	destroy_node_manager_caches();
free_inodecache:
	destroy_inodecache();
fail:
	return err;
}
コード例 #5
0
static int init_hdmi_obj(void)
{
	cb_hdmi_kset = kset_create_and_add("disp", &uevent_ops, kernel_kobj);
	if (!cb_hdmi_kset)
		return -ENOMEM;

	cb_hdmi_notifier = cb_create_hdmi_obj("hdmi");
	if (cb_hdmi_notifier == NULL) {
		kset_unregister(cb_hdmi_kset);
		cb_hdmi_kset = NULL;
		cb_hdmi_notifier = NULL;
		return -ENOMEM;
	}

	return 0;
}
コード例 #6
0
static int htc_simhotswap_probe(struct platform_device *pdev)
{
	int ret = 0;
	printk(KERN_INFO"delay work version %s\n",__func__);

	mutex_init(&htc_hotswap_info.lock);

	//INIT_WORK(&htc_hotswap_info.hotswap_work, hotswap_work_func);
	INIT_DELAYED_WORK(&htc_hotswap_info.hotswap_work, hotswap_work_func);
	htc_hotswap_info.hotswap_wq = create_singlethread_workqueue("htc_simhotswap");

	ret = misc_register(&sim_hotswap_misc);
	if (ret) {
		pr_err("failed to register misc device!\n");
		goto fail;
	}

	htc_hotswap_kset = kset_create_and_add("event", NULL,
			kobject_get(&sim_hotswap_misc.this_device->kobj));
	if (!htc_hotswap_kset) {
		ret = -ENOMEM;
		goto fail;
	}

	htc_hotswap_info.simhotswap_kobj.kset = htc_hotswap_kset;

	ret = kobject_init_and_add(&htc_hotswap_info.simhotswap_kobj,
			&htc_hotswap_ktype, NULL, "simhotswap");
	if (ret) {
		kobject_put(&htc_hotswap_info.simhotswap_kobj);
		goto fail;
	}	
	oldStatus = gpio_get_value(SIM_DETECT);
	pr_info("htc_simhotswap_probe(): finish SIM init status=%d\n",oldStatus);

	ret = request_irq(gpio_to_irq(SIM_DETECT),
			sim_detect_irq,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"sim_detect", NULL);
	if (ret) {
		pr_err("%s:Failed to request irq, ret=%d\n", __func__, ret);
	}

fail:

	return ret;
}
コード例 #7
0
static int __init ocf_init(void)
{
	int rc;

	INIT_WORK(&sclp_ocf_change_work, sclp_ocf_change_notify);
	ocf_kset = kset_create_and_add("ocf", NULL, firmware_kobj);
	if (!ocf_kset)
		return -ENOMEM;

	rc = sysfs_create_group(&ocf_kset->kobj, &ocf_attr_group);
	if (rc) {
		kset_unregister(ocf_kset);
		return rc;
	}

	return sclp_register(&sclp_ocf_event);
}
コード例 #8
0
int __init sysaufs_init(void)
{
	int err;

	get_random_bytes(&au_si_mask, sizeof(au_si_mask));

	au_kset = kset_create_and_add(AUFS_NAME, NULL, fs_kobj);
	err = PTR_ERR(au_kset);
	if (IS_ERR(au_kset))
		goto out;
	err = sysfs_create_group(&au_kset->kobj, au_attr_group);
	if (unlikely(err))
		kset_unregister(au_kset);

 out:
	AuTraceErr(err);
	return err;
}
コード例 #9
0
ファイル: main.c プロジェクト: demyanenko/ioperf
static int __init init(void)
{
        printk(KERN_INFO "init\n");
        
        utility_kset = kset_create_and_add("ioperf_cache_utility", NULL, NULL);
        if (!utility_kset) {
            return -ENOMEM;
        }
        
        force_cache_obj = create_utility_obj("force_cache");
        if (!force_cache_obj)
                goto force_error;
        
        enumer_page_obj = create_utility_obj("enumerate_cached_pages");        
        if (!enumer_page_obj)
                goto enum_error;
        if (init_enumer_page_obj(enumer_page_obj) < 0)
                goto init_enum_error;
       


        add_range_obj = create_utility_obj("add_page_range");
        if (!add_range_obj)
                goto add_range_error;
      
        if (init_add_range_obj(add_range_obj) < 0)
                goto init_range_error;
       
        return 0;

init_range_error:
        destroy_utility_obj(add_range_obj);
init_enum_error:
        ;
add_range_error:
        destroy_utility_obj(enumer_page_obj);        
enum_error:
        destroy_utility_obj(force_cache_obj);
force_error:
        return -EINVAL;

}
コード例 #10
0
ファイル: kobj_demo.c プロジェクト: phybio/external
static int kobj_demo_init(void)
{
    int err;

    parent = kobject_create_and_add("pa_obj", NULL);
    child = kzalloc(sizeof(*child), GFP_KERNEL);
    if(!child)
        return PTR_ERR(child);

    c_kset = kset_create_and_add("c_kset", NULL, parent);
    if(!c_kset)
        return -1;
    child->kset = c_kset;

    err = kobject_init_and_add(child, &cld_ktype, parent, "cld_obj");
    if(err)
        return err;
    err = sysfs_create_file(child, &cld_att);
    
    return err;
}
コード例 #11
0
static int __init shproc_init( void )
{
    int ret;

    /* Create a kset with the name of "shproc" */
    /* located under /sys/kernel/ */
    shproc_kset = kset_create_and_add( "shproc", NULL, kernel_kobj );
    if( !shproc_kset ){
        printk( "%s : line %d error\n", __FUNCTION__, __LINE__ );
        return -ENOMEM;
    }

    data.kobj->kset = shproc_kset;
    ret = kobject_init_and_add( data.kobj, data.ktype, NULL, "%s", data.name );
    if( ret ){
        printk( "%s : line %d error\n", __FUNCTION__, __LINE__ );
        kobject_put( data.kobj );
    }

    return ret;
}
コード例 #12
0
ファイル: ipcp-factories.c プロジェクト: javiergll/stack
struct ipcp_factories * ipcpf_init(struct kobject * parent)
{
        struct ipcp_factories * temp;

        LOG_DBG("Initializing layer");

        temp = rkzalloc(sizeof(*temp), GFP_KERNEL);
        if (!temp)
                return NULL;

        temp->set = kset_create_and_add("ipcp-factories", NULL, parent);
        if (!temp->set) {
                LOG_ERR("Cannot initialize layer");
                return NULL;
        }

        ASSERT(temp->set != NULL);

        LOG_DBG("Layer initialized successfully");

        return temp;
}
コード例 #13
0
ファイル: sysaufs.c プロジェクト: ArthySundaram/firstrepo
int __init sysaufs_init(void)
{
	int err;

	do {
		get_random_bytes(&sysaufs_si_mask, sizeof(sysaufs_si_mask));
	} while (!sysaufs_si_mask);

	sysaufs_ket = kset_create_and_add(AUFS_NAME, NULL, fs_kobj);
	err = PTR_ERR(sysaufs_ket);
	if (IS_ERR(sysaufs_ket))
		goto out;
	err = sysfs_create_group(&sysaufs_ket->kobj, sysaufs_attr_group);
	if (unlikely(err)) {
		kset_unregister(sysaufs_ket);
		goto out;
	}

	err = dbgaufs_init();
	if (unlikely(err))
		sysaufs_fin();
 out:
	return err;
}
コード例 #14
0
static int __init user_recovery_button_init(void)
{
	int err = 0;
	unsigned long flags;

	/* Prepare the sysfs interface for use */
	user_recovery_button_driver.kset = kset_create_and_add("user_recovery_button", &user_recovery_button_uevent_ops, kernel_kobj);
	if (!user_recovery_button_driver.kset) {
		printk(KERN_ERR "user_recovery_button_init() Failed to create kset\n");
		return -ENOMEM;
	}

	user_recovery_button_driver.kobject.kset = user_recovery_button_driver.kset;
	err = kobject_init_and_add(&user_recovery_button_driver.kobject,
		&ktype_user_recovery_button, NULL, "%d", 0);
	if (err) {
		printk(KERN_ERR "user_recovery_button_init() Failed to add kobject\n");
		kset_unregister(user_recovery_button_driver.kset);
		kobject_put(&user_recovery_button_driver.kobject);
		return -EINVAL;
	}

	/* Setup the timer that will time how long the user holds down the user
	   recovery button */
	init_timer(&timer);
	timer.data = 0;
	timer.function = timer_handler;

	/* Install a shared interrupt handler on the appropriate GPIO bank's
	   interrupt line */
	if (request_irq(IRQ_NUM, int_handler, IRQF_SHARED, "User Recovery Button", &user_recovery_button_driver)) {
		printk(KERN_ERR "User Recovery Button: cannot register IRQ %d\n", IRQ_NUM);
		del_timer_sync(&timer);
		return -EIO;
	}

	spin_lock_irqsave(&oxnas_gpio_spinlock, flags);
	/* Disable primary, secondary and teriary GPIO functions on switch lines */
#if defined(CONFIG_ARCH_OXNAS)
#if (CONFIG_OXNAS_USER_RECOVERY_BUTTON_GPIO < SYS_CTRL_NUM_PINS)
    writel(readl(SYS_CTRL_GPIO_PRIMSEL_CTRL_0) & ~SWITCH_MASK, SYS_CTRL_GPIO_PRIMSEL_CTRL_0);
    writel(readl(SYS_CTRL_GPIO_SECSEL_CTRL_0)  & ~SWITCH_MASK, SYS_CTRL_GPIO_SECSEL_CTRL_0);
    writel(readl(SYS_CTRL_GPIO_TERTSEL_CTRL_0) & ~SWITCH_MASK, SYS_CTRL_GPIO_TERTSEL_CTRL_0);
#else
    writel(readl(SYS_CTRL_GPIO_PRIMSEL_CTRL_1) & ~SWITCH_MASK, SYS_CTRL_GPIO_PRIMSEL_CTRL_1);
    writel(readl(SYS_CTRL_GPIO_SECSEL_CTRL_1)  & ~SWITCH_MASK, SYS_CTRL_GPIO_SECSEL_CTRL_1);
    writel(readl(SYS_CTRL_GPIO_TERTSEL_CTRL_1) & ~SWITCH_MASK, SYS_CTRL_GPIO_TERTSEL_CTRL_1);
#endif
#elif defined(CONFIG_ARCH_OX820)
#if (CONFIG_OXNAS_USER_RECOVERY_BUTTON_GPIO < SYS_CTRL_NUM_PINS)
    writel(readl(SYS_CTRL_SECONDARY_SEL)   & ~SWITCH_MASK, SYS_CTRL_SECONDARY_SEL);
    writel(readl(SYS_CTRL_TERTIARY_SEL)    & ~SWITCH_MASK, SYS_CTRL_TERTIARY_SEL);
    writel(readl(SYS_CTRL_QUATERNARY_SEL)  & ~SWITCH_MASK, SYS_CTRL_QUATERNARY_SEL);
    writel(readl(SYS_CTRL_DEBUG_SEL)       & ~SWITCH_MASK, SYS_CTRL_DEBUG_SEL);
    writel(readl(SYS_CTRL_ALTERNATIVE_SEL) & ~SWITCH_MASK, SYS_CTRL_ALTERNATIVE_SEL);
#else
    writel(readl(SEC_CTRL_SECONDARY_SEL)   & ~SWITCH_MASK, SEC_CTRL_SECONDARY_SEL);
    writel(readl(SEC_CTRL_TERTIARY_SEL)    & ~SWITCH_MASK, SEC_CTRL_TERTIARY_SEL);
    writel(readl(SEC_CTRL_QUATERNARY_SEL)  & ~SWITCH_MASK, SEC_CTRL_QUATERNARY_SEL);
    writel(readl(SEC_CTRL_DEBUG_SEL)       & ~SWITCH_MASK, SEC_CTRL_DEBUG_SEL);
    writel(readl(SEC_CTRL_ALTERNATIVE_SEL) & ~SWITCH_MASK, SEC_CTRL_ALTERNATIVE_SEL);
#endif
#endif

	/* Enable GPIO input on switch line */
	writel(SWITCH_MASK, SWITCH_CLR_OE_REG);

	/* Set up the user recovery button GPIO line for active low, debounced interrupt */
	writel(readl(DEBOUNCE_REG)    | SWITCH_MASK, DEBOUNCE_REG);
	writel(readl(LEVEL_INT_REG)   | SWITCH_MASK, LEVEL_INT_REG);
	writel(readl(FALLING_INT_REG) | SWITCH_MASK, FALLING_INT_REG);
	spin_unlock_irqrestore(&oxnas_gpio_spinlock, flags);

	printk(KERN_INFO "User recovery button driver registered\n");
	return 0;
}
コード例 #15
0
/**
 * bus_register - register a bus with the system.
 * @bus: bus.
 *
 * Once we have that, we registered the bus with the kobject
 * infrastructure, then register the children subsystems it has:
 * the devices and drivers that belong to the bus.
 */
int bus_register(struct bus_type *bus)
{
	int retval;
	struct bus_type_private *priv;

	priv = kzalloc(sizeof(struct bus_type_private), GFP_KERNEL);
	if (!priv)
		return -ENOMEM;

	priv->bus = bus;
	bus->p = priv;

	BLOCKING_INIT_NOTIFIER_HEAD(&priv->bus_notifier);

	retval = kobject_set_name(&priv->subsys.kobj, "%s", bus->name);
	if (retval)
		goto out;

	priv->subsys.kobj.kset = bus_kset;
	priv->subsys.kobj.ktype = &bus_ktype;
	priv->drivers_autoprobe = 1;

	retval = kset_register(&priv->subsys);
	if (retval)
		goto out;

	retval = bus_create_file(bus, &bus_attr_uevent);
	if (retval)
		goto bus_uevent_fail;

	priv->devices_kset = kset_create_and_add("devices", NULL,
						 &priv->subsys.kobj);
	if (!priv->devices_kset) {
		retval = -ENOMEM;
		goto bus_devices_fail;
	}

	priv->drivers_kset = kset_create_and_add("drivers", NULL,
						 &priv->subsys.kobj);
	if (!priv->drivers_kset) {
		retval = -ENOMEM;
		goto bus_drivers_fail;
	}

	klist_init(&priv->klist_devices, klist_devices_get, klist_devices_put);
	klist_init(&priv->klist_drivers, NULL, NULL);

	retval = add_probe_files(bus);
	if (retval)
		goto bus_probe_files_fail;

	retval = bus_add_attrs(bus);
	if (retval)
		goto bus_attrs_fail;

	pr_debug("bus: '%s': registered\n", bus->name);
	return 0;

bus_attrs_fail:
	remove_probe_files(bus);
bus_probe_files_fail:
	kset_unregister(bus->p->drivers_kset);
bus_drivers_fail:
	kset_unregister(bus->p->devices_kset);
bus_devices_fail:
	bus_remove_file(bus, &bus_attr_uevent);
bus_uevent_fail:
	kset_unregister(&bus->p->subsys);
	kfree(bus->p);
out:
	bus->p = NULL;
	return retval;
}
コード例 #16
0
static int baseband_xmm_power2_driver_probe(struct platform_device *device)
{
	struct baseband_power_platform_data *data
		= (struct baseband_power_platform_data *)
			device->dev.platform_data;

	int err=0;
	int err_radio = -EPERM;
	
	pr_debug("%s 0704 - polling mechanism to find ttyACM0.\n", __func__);

	if (data == NULL) {
		pr_err("%s: no platform data\n", __func__);
		return -EINVAL;
	}
	if (data->modem.xmm.hsic_device == NULL) {
		pr_err("%s: no hsic device\n", __func__);
		return -EINVAL;
	}

	/* save platform data */
	baseband_power2_driver_data = data;

	/* OEM specific initialization */
#ifdef BB_XMM_OEM1

		/*kobj_hsic_device =
			 kobject_get(&baseband_power2_driver_data->modem.xmm.hsic_device->dev.kobj);*/
		kobj_hsic_device = kobject_create_and_add("modem-dump-kobj", NULL);
		if (!kobj_hsic_device) {
			pr_err("[FLS] can not get modem_kobject\n");
			goto fail;
		}

		/* radio detect*/
		radio_detect_status = RADIO_STATUS_UNKNOWN;
		if (Modem_is_6260())
		{
			pr_debug( "modem is 6260, request CORE_DUMP_DETECT FALLING" );
			err_radio = request_irq(gpio_to_irq(CORE_DUMP_DETECT),
				radio_det_irq,
				IRQF_TRIGGER_FALLING,
				"RADIO_DETECT",
				&modem_info);
		}
		else if (Modem_is_6360())
		{
			pr_debug( "modem is 6360, request CORE_DUMP_DETECT RISING" );
			err_radio = request_irq(gpio_to_irq(CORE_DUMP_DETECT),
				radio_det_irq,
				IRQF_TRIGGER_RISING,
				"RADIO_DETECT",
				&modem_info);
		}
		else
		{
			pr_debug( "modem is unknown, set default as 6260, request CORE_DUMP_DETECT FALLING" );
			err_radio = request_irq(gpio_to_irq(CORE_DUMP_DETECT),
				radio_det_irq,
				IRQF_TRIGGER_FALLING,
				"RADIO_DETECT",
				&modem_info);
		}

		if (err_radio < 0) {
			pr_err("%s - request irq RADIO_DETECT failed\n", __func__);
		}

		radio_detect_status = RADIO_STATUS_READY;
		err_radio = gpio_get_value(CORE_DUMP_DETECT/* 106*/);
		pr_debug("gpio CORE_DUMP_DETECT value is %d\n", err_radio);
		modem_kset_radio = kset_create_and_add("modem_coreDump", NULL, kobj_hsic_device);
		if (!modem_kset_radio) {
			kobject_put(kobj_hsic_device);
			pr_err("[FLS] can not allocate modem_kset_radiomodem_kset_radio%d\n", err);
			goto fail;
		}
		pr_debug("init and add core dump into kobject\n");
		modem_info.modem_core_dump_kobj.kset = modem_kset_radio;
		err = kobject_init_and_add(&modem_info.modem_core_dump_kobj,
			&htc_modem_ktype, NULL, "htc_modem_radioio_det");
		if (err) {
			pr_err("init kobject modem_kset_radio failed.");
			kobject_put(&modem_info.modem_core_dump_kobj);
			kset_unregister(modem_kset_radio);
			modem_kset_radio = NULL;
			kobject_put(kobj_hsic_device);
			goto fail;

		}
#endif /* BB_XMM_OEM1 */

	/* init work queue */
	pr_debug("%s: init work queue\n", __func__);
	workqueue = create_singlethread_workqueue
		("baseband_xmm_power2_workqueue");
	if (!workqueue) {
		pr_err("cannot create workqueue\n");
		return -1;
	}
	baseband_xmm_power2_work = (struct baseband_xmm_power_work_t *)
		kmalloc(sizeof(struct baseband_xmm_power_work_t), GFP_KERNEL);
	if (!baseband_xmm_power2_work) {
		pr_err("cannot allocate baseband_xmm_power2_work\n");
		return -1;
	}
	pr_debug("%s: BBXMM_WORK_INIT\n", __func__);
	INIT_WORK((struct work_struct *) baseband_xmm_power2_work,
		baseband_xmm_power2_work_func);
	baseband_xmm_power2_work->state = BBXMM_WORK_INIT;
	queue_work(workqueue,
		(struct work_struct *) baseband_xmm_power2_work);

	/* OEM specific - init work queue */
#ifdef BB_XMM_OEM1
	INIT_WORK(&radio_detect_work_struct, radio_detect_work_handler);
fail:
#endif /* BB_XMM_OEM1 */

	return 0;
}
コード例 #17
0
ファイル: bus.c プロジェクト: yl849646685/linux-2.6.32
/**
 * bus_register - register a bus with the system.
 * @bus: bus.
 *
 * Once we have that, we registered the bus with the kobject
 * infrastructure, then register the children subsystems it has:
 * the devices and drivers that belong to the bus.
 */
int bus_register(struct bus_type *bus)
{
	int retval;
	struct bus_type_private *priv;

	priv = kzalloc(sizeof(struct bus_type_private), GFP_KERNEL);
	if (!priv)
		return -ENOMEM;

	priv->bus = bus;
	bus->p = priv;

	BLOCKING_INIT_NOTIFIER_HEAD(&priv->bus_notifier);

	/*设置bus对象的名字*/
	retval = kobject_set_name(&priv->subsys.kobj, "%s", bus->name);
	if (retval)
		goto out;

	/*待注册的总线属于nus_kset集合,因此,位于/sys/bus/目录下*/
	priv->subsys.kobj.kset = bus_kset;
	priv->subsys.kobj.ktype = &bus_ktype;
	priv->drivers_autoprobe = 1;

	/*将bus对象增加到bus_sket容器中去*/
	retval = kset_register(&priv->subsys);
	if (retval)
		goto out;

	/*为bus创建属性文件*/
	retval = bus_create_file(bus, &bus_attr_uevent);
	if (retval)
		goto bus_uevent_fail;

	/*在bus->subsys,kobj目录项下创建"devices"与"drivers目录容器"*/
	priv->devices_kset = kset_create_and_add("devices", NULL,
						 &priv->subsys.kobj);
	if (!priv->devices_kset) {
		retval = -ENOMEM;
		goto bus_devices_fail;
	}

	priv->drivers_kset = kset_create_and_add("drivers", NULL,
						 &priv->subsys.kobj);
	if (!priv->drivers_kset) {
		retval = -ENOMEM;
		goto bus_drivers_fail;
	}

	klist_init(&priv->klist_devices, klist_devices_get, klist_devices_put);
	klist_init(&priv->klist_drivers, NULL, NULL);

	/*增加总线探测与自动探测属性文件*/
	retval = add_probe_files(bus);
	if (retval)
		goto bus_probe_files_fail;

	/*创建bus的默认属性文件*/
	retval = bus_add_attrs(bus);
	if (retval)
		goto bus_attrs_fail;

	pr_debug("bus: '%s': registered\n", bus->name);
	return 0;

bus_attrs_fail:
	remove_probe_files(bus);
bus_probe_files_fail:
	kset_unregister(bus->p->drivers_kset);
bus_drivers_fail:
	kset_unregister(bus->p->devices_kset);
bus_devices_fail:
	bus_remove_file(bus, &bus_attr_uevent);
bus_uevent_fail:
	kset_unregister(&bus->p->subsys);
	kfree(bus->p);
out:
	bus->p = NULL;
	return retval;
}
コード例 #18
0
ファイル: super25.c プロジェクト: asmalldev/linux
static int __init lustre_init(void)
{
	struct lnet_process_id lnet_id;
	struct timespec64 ts;
	int i, rc, seed[2];

	BUILD_BUG_ON(sizeof(LUSTRE_VOLATILE_HDR) != LUSTRE_VOLATILE_HDR_LEN + 1);

	/* print an address of _any_ initialized kernel symbol from this
	 * module, to allow debugging with gdb that doesn't support data
	 * symbols from modules.
	 */
	CDEBUG(D_INFO, "Lustre client module (%p).\n",
	       &lustre_super_operations);

	rc = -ENOMEM;
	ll_inode_cachep = kmem_cache_create("lustre_inode_cache",
					    sizeof(struct ll_inode_info), 0,
					    SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT,
					    NULL);
	if (!ll_inode_cachep)
		goto out_cache;

	ll_file_data_slab = kmem_cache_create("ll_file_data",
					      sizeof(struct ll_file_data), 0,
					      SLAB_HWCACHE_ALIGN, NULL);
	if (!ll_file_data_slab)
		goto out_cache;

	llite_root = debugfs_create_dir("llite", debugfs_lustre_root);
	if (IS_ERR_OR_NULL(llite_root)) {
		rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM;
		llite_root = NULL;
		goto out_cache;
	}

	llite_kset = kset_create_and_add("llite", NULL, lustre_kobj);
	if (!llite_kset) {
		rc = -ENOMEM;
		goto out_debugfs;
	}

	cfs_get_random_bytes(seed, sizeof(seed));

	/* Nodes with small feet have little entropy. The NID for this
	 * node gives the most entropy in the low bits
	 */
	for (i = 0;; i++) {
		if (LNetGetId(i, &lnet_id) == -ENOENT)
			break;

		if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND)
			seed[0] ^= LNET_NIDADDR(lnet_id.nid);
	}

	ktime_get_ts64(&ts);
	cfs_srand(ts.tv_sec ^ seed[0], ts.tv_nsec ^ seed[1]);

	rc = vvp_global_init();
	if (rc != 0)
		goto out_sysfs;

	cl_inode_fini_env = cl_env_alloc(&cl_inode_fini_refcheck,
					 LCT_REMEMBER | LCT_NOREF);
	if (IS_ERR(cl_inode_fini_env)) {
		rc = PTR_ERR(cl_inode_fini_env);
		goto out_vvp;
	}

	cl_inode_fini_env->le_ctx.lc_cookie = 0x4;

	rc = ll_xattr_init();
	if (rc != 0)
		goto out_inode_fini_env;

	lustre_register_client_fill_super(ll_fill_super);
	lustre_register_kill_super_cb(ll_kill_super);
	lustre_register_client_process_config(ll_process_config);

	return 0;

out_inode_fini_env:
	cl_env_put(cl_inode_fini_env, &cl_inode_fini_refcheck);
out_vvp:
	vvp_global_fini();
out_sysfs:
	kset_unregister(llite_kset);
out_debugfs:
	debugfs_remove(llite_root);
out_cache:
	kmem_cache_destroy(ll_inode_cachep);
	kmem_cache_destroy(ll_file_data_slab);
	return rc;
}
コード例 #19
0
ファイル: visdn_main.c プロジェクト: perasmo/vstuff
static int __init visdn_init_module(void)
{
    int err;

    visdn_msg(KERN_INFO, "loading\n");

    visdn_kset = kset_create_and_add("visdn", NULL, NULL);
    if (!visdn_kset) {
        err = -ENOMEM;
        goto err_kset_register;
    }

    err = alloc_chrdev_region(&visdn_first_dev, 0, 2, visdn_MODULE_NAME);
    if (err < 0)
        goto err_alloc_chrdev_region;

    visdn_system_device.bus = NULL;
    visdn_system_device.parent = NULL;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
    visdn_system_device.driver_data = NULL;
#else
    dev_set_drvdata(&visdn_system_device,NULL);
#endif
    visdn_system_device.release = visdn_system_device_release;

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
    snprintf(visdn_system_device.bus_id,
             sizeof(visdn_system_device.bus_id),
             "visdn-system");
#else
    dev_set_name(&visdn_system_device,"visdn-system");
#endif

    err = device_register(&visdn_system_device);
    if (err < 0)
        goto err_system_device_register;

    err = class_register(&visdn_system_class);
    if (err < 0)
        goto err_class_register;

    err = visdn_port_modinit();
    if (err < 0)
        goto err_port_modinit;

    return 0;

    visdn_port_modexit();
err_port_modinit:
    class_unregister(&visdn_system_class);
err_class_register:
    device_unregister(&visdn_system_device);
err_system_device_register:
    unregister_chrdev_region(visdn_first_dev, 2);
err_alloc_chrdev_region:
    kset_unregister(visdn_kset);
    visdn_kset = NULL;
err_kset_register:

    return err;
}
コード例 #20
0
ファイル: super25.c プロジェクト: the-snowwhite/linux-socfpga
static int __init lustre_init(void)
{
	int rc;

	BUILD_BUG_ON(sizeof(LUSTRE_VOLATILE_HDR) !=
		     LUSTRE_VOLATILE_HDR_LEN + 1);

	/* print an address of _any_ initialized kernel symbol from this
	 * module, to allow debugging with gdb that doesn't support data
	 * symbols from modules.
	 */
	CDEBUG(D_INFO, "Lustre client module (%p).\n",
	       &lustre_super_operations);

	rc = -ENOMEM;
	ll_inode_cachep = kmem_cache_create("lustre_inode_cache",
					    sizeof(struct ll_inode_info), 0,
					    SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT,
					    NULL);
	if (!ll_inode_cachep)
		goto out_cache;

	ll_file_data_slab = kmem_cache_create("ll_file_data",
					      sizeof(struct ll_file_data), 0,
					      SLAB_HWCACHE_ALIGN, NULL);
	if (!ll_file_data_slab)
		goto out_cache;

	llite_root = debugfs_create_dir("llite", debugfs_lustre_root);
	if (IS_ERR_OR_NULL(llite_root)) {
		rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM;
		llite_root = NULL;
		goto out_cache;
	}

	llite_kset = kset_create_and_add("llite", NULL, lustre_kobj);
	if (!llite_kset) {
		rc = -ENOMEM;
		goto out_debugfs;
	}

	rc = vvp_global_init();
	if (rc != 0)
		goto out_sysfs;

	cl_inode_fini_env = cl_env_alloc(&cl_inode_fini_refcheck,
					 LCT_REMEMBER | LCT_NOREF);
	if (IS_ERR(cl_inode_fini_env)) {
		rc = PTR_ERR(cl_inode_fini_env);
		goto out_vvp;
	}

	cl_inode_fini_env->le_ctx.lc_cookie = 0x4;

	rc = ll_xattr_init();
	if (rc != 0)
		goto out_inode_fini_env;

	lustre_register_super_ops(THIS_MODULE, ll_fill_super, ll_kill_super);
	lustre_register_client_process_config(ll_process_config);

	return 0;

out_inode_fini_env:
	cl_env_put(cl_inode_fini_env, &cl_inode_fini_refcheck);
out_vvp:
	vvp_global_fini();
out_sysfs:
	kset_unregister(llite_kset);
out_debugfs:
	debugfs_remove(llite_root);
out_cache:
	kmem_cache_destroy(ll_inode_cachep);
	kmem_cache_destroy(ll_file_data_slab);
	return rc;
}