Пример #1
0
/*
 * initialise the fs caching module
 */
static int __init fscache_init(void)
{
	int ret;

	ret = slow_work_register_user(THIS_MODULE);
	if (ret < 0)
		goto error_slow_work;

	ret = fscache_proc_init();
	if (ret < 0)
		goto error_proc;

	fscache_cookie_jar = kmem_cache_create("fscache_cookie_jar",
					       sizeof(struct fscache_cookie),
					       0,
					       0,
					       fscache_cookie_init_once);
	if (!fscache_cookie_jar) {
		printk(KERN_NOTICE
		       "FS-Cache: Failed to allocate a cookie jar\n");
		ret = -ENOMEM;
		goto error_cookie_jar;
	}

	fscache_root = kobject_create_and_add("fscache", kernel_kobj);
	if (!fscache_root)
		goto error_kobj;

	printk(KERN_NOTICE "FS-Cache: Loaded\n");
	return 0;

error_kobj:
	kmem_cache_destroy(fscache_cookie_jar);
error_cookie_jar:
	fscache_proc_cleanup();
error_proc:
	slow_work_unregister_user(THIS_MODULE);
error_slow_work:
	return ret;
}
Пример #2
0
int logger_mode_init(void)
{
	int logger_mode_retval;

        logger_mode_kobj = kobject_create_and_add("logger_mode", kernel_kobj);

        if (!logger_mode_kobj) {
                return -ENOMEM;
        }

        logger_mode_retval = sysfs_create_group(logger_mode_kobj, &logger_mode_attr_group);

        if (logger_mode_retval)
	{
			kobject_put(logger_mode_kobj);
	}

	// initialize logger mode to 0 (disabled) as default
	logger_mode = 0;

        return (logger_mode_retval);
}
Пример #3
0
int printk_mode_init(void)
{
	int printk_mode_retval;

        printk_mode_kobj = kobject_create_and_add("printk_mode", kernel_kobj);

        if (!printk_mode_kobj) {
                return -ENOMEM;
        }

        printk_mode_retval = sysfs_create_group(printk_mode_kobj, &printk_mode_attr_group);

        if (printk_mode_retval)
	{
			kobject_put(printk_mode_kobj);
	}

	// initialize printk mode to 1 (enabled) as default
	printk_mode = 1;

        return (printk_mode_retval);
}
/**
 * tp_get_touch_screen_obj - it is a common function,tp can call it to creat /sys/touch_screen file node
 *
 * @no input value
 *
 * This function is tp call it to creat /sys/touch_screen file node.
 *
 * The kobject of touch_screen_kobject_ts will be returned,notice it is static.
 */
struct kobject* tp_get_touch_screen_obj(void)
{
	if( NULL == touch_screen_kobject_ts )
	{
		touch_screen_kobject_ts = kobject_create_and_add("touch_screen", NULL);
		if (!touch_screen_kobject_ts)
		{
			tp_log_err("%s: create touch_screen kobjetct error!\n", __func__);
			return NULL;
		}
		else
		{
			tp_log_debug("%s: create sys/touch_screen successful!\n", __func__);
		}
	}
	else
	{
		tp_log_debug("%s: sys/touch_screen already exist!\n", __func__);
	}

	return touch_screen_kobject_ts;
}
/**
 * tp_get_virtual_key_obj - it is a common function,tp can call it to creat virtual_key file node in /sys/
 *
 * @no input value
 *
 * This function is tp call it to creat virtual_key file node in /sys/
 *
 * The kobject of virtual_key_kobject_ts will be returned
 */
struct kobject* tp_get_virtual_key_obj(char *name)
{
	if( NULL == virtual_key_kobject_ts )
	{
		virtual_key_kobject_ts = kobject_create_and_add(name, NULL);
		if (!virtual_key_kobject_ts)
		{
			tp_log_err("%s: create virtual_key kobjetct error!\n", __func__);
			return NULL;
		}
		else
		{
			tp_log_debug("%s: create virtual_key successful!\n", __func__);
		}
	}
	else
	{
		tp_log_debug("%s: virtual_key already exist!\n", __func__);
	}

	return virtual_key_kobject_ts;
}
Пример #6
0
static int charger_control_probe(void)
{
	int sysfs_result;
	printk(KERN_DEBUG "[%s]\n",__func__);

	charger_control_kobj = kobject_create_and_add("thundercharge_control", kernel_kobj);

	if (!charger_control_kobj) {
		pr_err("%s Interface create failed!\n",
			__FUNCTION__);
		return -ENOMEM;
        }

	sysfs_result = sysfs_create_group(charger_control_kobj,
			&chgr_control_attr_group);

	if (sysfs_result) {
		pr_info("%s sysfs create failed!\n", __FUNCTION__);
		kobject_put(charger_control_kobj);
	}
	return sysfs_result;
}
Пример #7
0
static int imx219_sysfs_init(void)
{
	int ret ;
	pr_info("%s: imx219:kobject creat and add\n", __func__);

	android_imx219 = kobject_create_and_add("android_camera", NULL);
	if (android_imx219 == NULL) {
		pr_info("imx219_sysfs_init: subsystem_register " \
		"failed\n");
		ret = -ENOMEM;
		return ret ;
	}
	pr_info("imx219:sysfs_create_file\n");
	ret = sysfs_create_file(android_imx219, &dev_attr_sensor.attr);
	if (ret) {
		pr_info("imx219_sysfs_init: sysfs_create_file " \
		"failed\n");
		kobject_del(android_imx219);
	}

	return 0 ;
}
Пример #8
0
int ntrig_dispathcer_sysfs_init(void)
{
	int retval;

	ntrig_dbg( "inside %s\n", __FUNCTION__);

	dispatcher_kobj = kobject_create_and_add("ntrig", NULL);
	if (!dispatcher_kobj) {
		ntrig_dbg( "inside %s\n failed to create dispatcher_kobj", __FUNCTION__);
		return -ENOMEM;
	}
	/* Create the files associated with this kobject */
	retval = sysfs_create_group(dispatcher_kobj, &attr_group);
	if (retval) {
		ntrig_dbg( "inside %s\n failed to create sysfs_group", __FUNCTION__);
		kobject_put(dispatcher_kobj);
	}

#ifdef VIRTUAL_KEYS_SUPPORTED
	ntrig_create_virtualkeys_file();
#endif

	ntrig_dbg("ntrig-dispatcher-sysfs inside %s \n", __FUNCTION__);

	if(setup_config_dispatcher(&read_config_dispatcher, &write_config_dispatcher)){
		ntrig_dbg("ntrig-dispatcher-sysfs inside %s cannot setup_get_bus_interface\n", __FUNCTION__);
	}
	if(setup_config_sensor(&read_config_sensor, &write_config_sensor)){
		ntrig_dbg("ntrig-dispatcher-sysfs inside %s cannot setup_config_sensor\n", __FUNCTION__);
	}
	if(setup_get_bus_interface(&read_get_bus_interface, &write_get_bus_interface)){
		ntrig_dbg("ntrig-dispatcher-sysfs inside %s cannot setup_get_bus_interface\n", __FUNCTION__);
	}
	if(setup_config_counters(&read_get_counters, &write_reset_counters)){
		ntrig_dbg("ntrig-dispatcher-sysfs inside %s cannot setup_get_counters\n", __FUNCTION__);
	}
	
	return retval;
}
Пример #9
0
static int __init mntest_init(void)
{
	int ret;

#ifdef SYSFS_ATTR_CREATE
	/*
	 * Create a simple kobject with the name of "mntest",
	 * located under /sys/kernel/
	 **/
	mntest_kobj = kobject_create_and_add("mntest", kernel_kobj);
	if (!mntest_kobj)
		return -ENOMEM;

	ret = sysfs_create_file(mntest_kobj, &test_value_attribute);
	if (ret)
		kobject_put(mntest_kobj);
#endif

	printk("%s:%d\n", __func__, __LINE__);

	return ret;
}
Пример #10
0
static int add_sysfs_objects(struct sleep_data *sleep_info)
{
	int err = 0;

	atomic_set(&sleep_info->timer_expired, 0);
	atomic_set(&sleep_info->timer_val_ms, INT_MAX);

	sleep_info->attr_group = &sleep_info_attr_group;

	sleep_info->kobj = kobject_create_and_add("sleep-stats",
			&get_cpu_device(0)->kobj);
	if (!sleep_info->kobj)
		return -ENOMEM;

	err = sysfs_create_group(sleep_info->kobj, sleep_info->attr_group);
	if (err)
		kobject_put(sleep_info->kobj);
	else
		kobject_uevent(sleep_info->kobj, KOBJ_ADD);

	return err;
}
Пример #11
0
static int __init pm_init(void)
{
	int error = pm_start_workqueue();
#ifdef CONFIG_PERFLOCK
	int i;
	static char ceil_buf[PERF_LOCK_INVALID][38];
	static char perf_buf[PERF_LOCK_INVALID][24];
#endif
	if (error)
		return error;
	hibernate_image_size_init();
	hibernate_reserved_size_init();

	touch_evt_timer_val = ktime_set(2, 0);
	hrtimer_init(&tc_ev_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	tc_ev_timer.function = &tc_ev_stop;
	tc_ev_processed = 1;

	power_kobj = kobject_create_and_add("power", NULL);
#ifdef CONFIG_PERFLOCK
	perf_lock_init(&user_cpu_perf_lock, TYPE_PERF_LOCK, PERF_LOCK_HIGHEST, "User CPU Highest Perflock"); 
	perf_lock_init(&user_cpu_ceiling_lock, TYPE_CPUFREQ_CEILING, PERF_LOCK_HIGH, "User CPU High cpufreq_ceiling lock"); 
	for (i = PERF_LOCK_LOWEST; i < PERF_LOCK_INVALID; i++) {
		snprintf(perf_buf[i], 23, "User Perflock level(%d)", i);
		perf_buf[i][23] = '\0';
		perf_lock_init(&user_perf_lock[i], TYPE_PERF_LOCK, i, perf_buf[i]);

		snprintf(ceil_buf[i], 37, "User cpufreq_ceiling lock level(%d)", i);
		ceil_buf[i][37] = '\0';
		perf_lock_init(&user_ceiling_lock[i], TYPE_CPUFREQ_CEILING, i, ceil_buf[i]);
	}
#endif
	if (!power_kobj)
		return -ENOMEM;
	error = sysfs_create_group(power_kobj, &attr_group);
	if (error)
		return error;
	return pm_autosleep_init();
}
static int __init sysfscluster_init(void)
{
	int e;

	TRACE_CLUSTER(("+sysfscluster_init\n"));

	if (!cluster_switch_supported()) {
		pr_info("%s: Cluster switch disabled\n", __func__);
		return 0;
	}

	spin_lock_init(&cluster_lock);
	cluster_kobj = kobject_create_and_add("cluster", kernel_kobj);

	CREATE_FILE(active);
	CREATE_FILE(immediate);
	CREATE_FILE(force);
	CREATE_FILE(wake_ms);
#if defined(CONFIG_PM_SLEEP) && SYSFS_CLUSTER_POWER_MODE
	CREATE_FILE(powermode);
#endif
#ifdef CONFIG_ARCH_TEGRA_HAS_SYMMETRIC_CPU_PWR_GATE
	CREATE_FILE(powergate);
#endif
#if DEBUG_CLUSTER_SWITCH
	CREATE_FILE(debug);
#endif

	spin_lock(&cluster_lock);
	if (is_lp_cluster())
		flags |= TEGRA_POWER_CLUSTER_LP;
	else
		flags |= TEGRA_POWER_CLUSTER_G;
	spin_unlock(&cluster_lock);

fail:
	TRACE_CLUSTER(("-sysfscluster_init\n"));
	return e;
}
Пример #13
0
static int __init enhance_init(void)
{
	int retval;
	int attr_count = 0;

	enhance__kobj = kobject_create_and_add("lcd_enhance", kernel_kobj);

	if (!enhance__kobj)
		return -ENOMEM;

	/* Create the files associated with this kobject */
	for (attr_count = 0; attr_count < ARRAY_SIZE(attrs); attr_count++) {
		
		if(!zte_enhance_val.en_colortmp && (attr_count == 1))
			continue;
	
		retval = sysfs_create_file(enhance__kobj, &attrs[attr_count].attr);
		if (retval < 0) {
			pr_err("%s: Failed to create sysfs attributes\n", __func__);
			goto err_sys;
		}
	}
	
	pr_info("lcd: %s Done.\n",__func__);

	return retval;
	
err_sys:
	for (attr_count--; attr_count >= 0; attr_count--) {
		sysfs_remove_file(enhance__kobj, &attrs[attr_count].attr);
	}
	
	kobject_put(enhance__kobj);
	
	pr_info("lcd: %s init ERR.\n",__func__);

	return retval;
}
int init_module(void)
{
	int ret;

	ProcBuffer = vmalloc(sizeof(char)*MAXDATASIZE);
	if(ProcBuffer == NULL) {
		return -ENOMEM;
	}
	memset(ProcBuffer,0,sizeof(char)*MAXDATASIZE);
	WritingLength = 0;

	/* Procfs setting */
/*
	if( (proc_mtd = create_proc_entry("htc_monitor", 0444, NULL)) ) {
		proc_mtd->proc_fops = &log_proc_ops;
	}
*/
	proc_mtd = proc_create_data("htc_monitor", 0444, NULL, &log_proc_ops, NULL);
	if (proc_mtd == NULL) {
		pr_info("proc_create_data is null\n");
	}

	/* Attribute file setting */
	htc_monitor_status_obj = kobject_create_and_add("htc_monitor_status", NULL);
	if (htc_monitor_status_obj == NULL) {
		pr_info("kobject_create_and_add: htc_monitor_status failed\n");
                return -EFAULT;
	}

	ret = sysfs_create_file(htc_monitor_status_obj,
             &dev_attr_htc_monitor_param.attr);
        if (ret) {
                pr_info("sysfs_create_file: dev_attr_htc_monitor_param failed\n");
                return -EFAULT;
        }

	return 0;
}
int __init shuttle_usb_register_devices(void)
{
#ifdef CONFIG_USB_SUPPORT
	int ret;
	
	tegra_ehci1_device.dev.platform_data = &tegra_ehci_pdata[0];
	tegra_ehci3_device.dev.platform_data = &tegra_ehci_pdata[1];
#ifdef CONFIG_USB_TEGRA_OTG
	tegra_otg_device.dev.platform_data = &tegra_otg_pdata;
#endif

	/* If in host mode, set VBUS to 1 */
	gpio_request(SHUTTLE_USB0_VBUS, "USB0 VBUS"); /* VBUS switch, perhaps ? -- Tied to what? -- should require +5v ... */
	
	/* 0 = Gadget */
	gpio_direction_output(SHUTTLE_USB0_VBUS, 0 ); /* Gadget */
	
	ret = platform_add_devices(shuttle_usb_devices, ARRAY_SIZE(shuttle_usb_devices));
	if (ret)
		return ret;

	/* Enable gadget mode by default */
	tegra_set_gadget_mode();
		
	/* Register a sysfs interface to let user switch modes */
	usb_kobj = kobject_create_and_add("usbbus", NULL);
	if (!usb_kobj) {
		pr_err("Unable to register USB mode switch");
		return 0;	
	}
	
	
	/* Attach an attribute to the already registered usbbus to let the user switch usb modes */
	return sysfs_create_group(usb_kobj, &usb_attr_group); 
#else
	return 0;
#endif	
}
static int create_test_nodes(int size, struct kobject *parent_kobj)
{
    int i, j;
    int retval = 0;
    char *name;
    //struct attribute *temp_attr;
    //char test_mode[][DEVNAME_SIZE] = {"DATA_READ", "DATA_WRITE", "CMD"};
    //int test_mode_count = sizeof(test_mode)/sizeof(test_mode[0]);
    
    test_attrs = kzalloc(TEST_MODE_COUNT * size * sizeof(struct attribute*), GFP_KERNEL);
    test_kattr = kzalloc(TEST_MODE_COUNT * size * sizeof(struct kobj_attribute*), GFP_KERNEL);
    
    tmode_kobj = kzalloc(size * sizeof(struct kobject*), GFP_KERNEL);
    for(i=0; i<size; i++){
        name = kzalloc(DEVNAME_SIZE, GFP_KERNEL);
        sprintf(name, "%d", i);
        tmode_kobj[i] = kobject_create_and_add(name, parent_kobj);
        if (tmode_kobj[i] == NULL)
            return -ENOMEM;
        for(j=0; j<TEST_MODE_COUNT; j++){    
            test_attrs[i*TEST_MODE_COUNT+j] = kzalloc(sizeof(struct attribute), GFP_KERNEL);
            test_kattr[i*TEST_MODE_COUNT+j] = kzalloc(sizeof(struct kobj_attribute), GFP_KERNEL);
            name = kzalloc(DEVNAME_SIZE, GFP_KERNEL);
            sprintf(name, "%s", test_mode[j]);
            test_attrs[i*TEST_MODE_COUNT+j]->name = name;
            test_attrs[i*TEST_MODE_COUNT+j]->mode = 0777;
            test_kattr[i*TEST_MODE_COUNT+j]->attr = *test_attrs[i*TEST_MODE_COUNT+j];//*temp_attr;
            test_kattr[i*TEST_MODE_COUNT+j]->show = test_show;
            test_kattr[i*TEST_MODE_COUNT+j]->store = test_store;
            //test_attrs[i*TEST_MODE_COUNT+j] = &test_kattr[i*TEST_MODE_COUNT+j]->attr;
            retval = sysfs_create_file(tmode_kobj[i], &test_kattr[i*TEST_MODE_COUNT+j]->attr);
            if (retval)
                kobject_put(tmode_kobj[i]);
            
        }
    }
    return 0;
}
Пример #17
0
//#ifdef CONFIG_AMAZON_POWER_DEBUG
//extern int init_wakeup_monitor(struct kobject*);
//#endif
static int __init pm_init(void)
{
	int error = pm_start_workqueue();
	if (error)
		return error;

	hibernate_image_size_init();
	hibernate_reserved_size_init();

	touch_evt_timer_val = ktime_set(2, 0);
	hrtimer_init(&tc_ev_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	tc_ev_timer.function = &tc_ev_stop;
	tc_ev_processed = 1;

	power_kobj = kobject_create_and_add("power", NULL);
	if (!power_kobj)
		return -ENOMEM;
	error = sysfs_create_group(power_kobj, &attr_group);
	if (error)
		return error;

	return pm_autosleep_init();
}
Пример #18
0
static int ts_key_report_init(void)
{
	int ret;

	pr_info("%s called!\n", __func__);
	virtual_key_kobj = kobject_get(android_touch_kobj);
	if (virtual_key_kobj == NULL) {
		virtual_key_kobj = kobject_create_and_add("board_properties", NULL);
		if (virtual_key_kobj == NULL) {
			pr_info(KERN_ERR "%s: subsystem_register failed\n", __func__);
			ret = -ENOMEM;
			return ret;
		}
	}
 
	ret = sysfs_create_file(virtual_key_kobj, &dev_attr_virtualkeys.attr);
	if (ret) {
		pr_info(KERN_ERR "%s: sysfs_create_file failed\n", __func__);
		return ret;
	}
 
	return 0;
}
static int fluid_board_props_init(void)
{
	int rc;
	struct kobject *properties_kobj;

	properties_kobj = kobject_create_and_add("board_properties", NULL);
	if (!properties_kobj) {
		rc = -ENOMEM;
		goto err_kobj_create;
	}

	rc = sysfs_create_group(properties_kobj, &fluid_properties_attr_group);
	if (rc)
		goto err_sysfs_create;

	return 0;

err_sysfs_create:
	kobject_put(properties_kobj);
err_kobj_create:
	pr_err("failed to create board_properties\n");
	return rc;
}
Пример #20
0
static int __init sysfs_lkm_sysfs_init(void)
{
	int ret;

	pr_debug("%s: Init\n", DRV_NAME);

	sysfs_lkm_kobject = kobject_create_and_add(SYSFS_NAME, kernel_kobj);
	if (!sysfs_lkm_kobject) {
		pr_debug("Failed to create kobject for %s\n", SYSFS_NAME);
		return -ENOMEM;
	}

	/* Files go online as soon they are created */
	init_rwsem(&rw_sem);

	ret = sysfs_create_group(sysfs_lkm_kobject, &attr_group);
	if (ret) {
		kobject_put(sysfs_lkm_kobject);
		return ret;
	}

	return 0;
}
Пример #21
0
static int __init compbench_init(void)
{
    int retval;

    cb_kobj = kobject_create_and_add("compbench", kernel_kobj);
    if (!cb_kobj)
        return -ENOMEM;

    retval = sysfs_create_group(cb_kobj, &attr_group);
    if (retval)
        goto err;

    retval = sysfs_create_bin_file(cb_kobj, &bin_attr_in);
    if (retval)
        goto err;

    goto success;

    err:
    kobject_put(cb_kobj);
    success:
    return retval;
}
Пример #22
0
static int __init gpu_control_init(void)
{
	int ret;

	register_early_suspend(&gpu_control_suspend_handler);
	
	gpu_control_kobj = kobject_create_and_add("gpu_control", kernel_kobj);
	if (!gpu_control_kobj) {
		pr_err("%s gpu_control kobject create failed!\n", __FUNCTION__);
		return -ENOMEM;
        }
	
	ret = sysfs_create_group(gpu_control_kobj,
			&gpu_control_group);

        if (ret) {
		pr_info("%s gpu_control sysfs create failed!\n", __FUNCTION__);
		kobject_put(gpu_control_kobj);
	}

    init_gpu_proc_fs();
	return ret;
}
static int vibr_level_control_init(void)
{
	int sysfs_result;
	printk(KERN_DEBUG "[%s]\n",__func__);

	vibr_level_control_kobj =
		kobject_create_and_add("thunderquake_engine", kernel_kobj);

	if (!vibr_level_control_kobj) {
		pr_err("%s Interface create failed!\n",
			__FUNCTION__);
		return -ENOMEM;
        }

	sysfs_result = sysfs_create_group(vibr_level_control_kobj,
			&vibr_level_control_attr_group);

	if (sysfs_result) {
		pr_info("%s sysfs create failed!\n", __FUNCTION__);
		kobject_put(vibr_level_control_kobj);
	}
	return sysfs_result;
}
static int cap_ts_vkeys_init(void)
{
	int rc,i;
	struct kobject * cap_ts_properties_kobj=NULL;

	cap_ts_properties_kobj = kobject_create_and_add("board_properties", NULL);
	if (cap_ts_properties_kobj == NULL) {
		printk("%s: subsystem_register failed\n", __func__);
		rc = -ENOMEM;
		return rc;
	}
	android_touch_kobj = cap_ts_properties_kobj;

	for ( i=0; i < ARRAY_SIZE(cap_ts_device_attr); i++ ){
		rc = sysfs_create_file(cap_ts_properties_kobj, &cap_ts_device_attr[i].attr);
		if (rc) {
			printk("%s: sysfs_create_file failed\n", __func__);
			return rc;
		}
	}

	return 0;
}
/* Initializes the sysfs parameter
 * registers the pm_event notifier
 */
int __init wakeup_reason_init(void)
{
	int retval;
	spin_lock_init(&resume_reason_lock);
	retval = register_pm_notifier(&wakeup_reason_pm_notifier_block);
	if (retval)
		printk(KERN_WARNING "[%s] failed to register PM notifier %d\n",
				__func__, retval);

	wakeup_reason = kobject_create_and_add("wakeup_reasons", kernel_kobj);
	if (!wakeup_reason) {
		printk(KERN_WARNING "[%s] failed to create a sysfs kobject\n",
				__func__);
		return 1;
	}
	retval = sysfs_create_group(wakeup_reason, &attr_group);
	if (retval) {
		kobject_put(wakeup_reason);
		printk(KERN_WARNING "[%s] failed to create a sysfs group %d\n",
				__func__, retval);
	}
	return 0;
}
Пример #26
0
void __init acer_ts_init(void)
{
	int ret = 0;
	struct kobject *properties_kobj;
	acer_smem_flag_t *acer_smem_flag;

	acer_smem_flag = (acer_smem_flag_t *)(smem_alloc(SMEM_ID_VENDOR0, sizeof(acer_smem_flag_t)));
	if (acer_smem_flag != NULL && acer_smem_flag->acer_hw_version < ACER_HW_VERSION_PVT)
		a4_ts_board_info[0].irq = MSM_GPIO_TO_INT(A4_GPIO_CYP_TP_IRQ1);
	else
		a4_ts_board_info[0].irq = MSM_GPIO_TO_INT(A4_GPIO_CYP_TP_IRQ2);

	i2c_register_board_info(0, a4_ts_board_info,
			ARRAY_SIZE(a4_ts_board_info));

	properties_kobj = kobject_create_and_add("board_properties", NULL);
	if (properties_kobj)
		ret = sysfs_create_group(properties_kobj,
				&a4_properties_attr_group);

	if (!properties_kobj || ret)
		pr_err("failed to create board_properties\n");
}
Пример #27
0
static int __init pnpmgr_init(void)
{
	int ret;

	init_timer(&app_timer);
	app_timer.function = app_timeout_handler;

	pnpmgr_kobj = kobject_create_and_add("pnpmgr", power_kobj);

	if (!pnpmgr_kobj) {
		pr_err("%s: Can not allocate enough memory for pnpmgr.\n", __func__);
		return -ENOMEM;
	}

	cpufreq_kobj = kobject_create_and_add("cpufreq", pnpmgr_kobj);
	hotplug_kobj = kobject_create_and_add("hotplug", pnpmgr_kobj);
	thermal_kobj = kobject_create_and_add("thermal", pnpmgr_kobj);
	apps_kobj = kobject_create_and_add("apps", pnpmgr_kobj);
	battery_kobj = kobject_create_and_add("battery", pnpmgr_kobj);
	adaptive_policy_kobj = kobject_create_and_add("adaptive_policy", power_kobj);

	if (!cpufreq_kobj || !hotplug_kobj || !thermal_kobj || !apps_kobj || !battery_kobj || !adaptive_policy_kobj) {
		pr_err("%s: Can not allocate enough memory.\n", __func__);
		return -ENOMEM;
	}

	ret = sysfs_create_group(cpufreq_kobj, &cpufreq_attr_group);
	ret |= sysfs_create_group(hotplug_kobj, &hotplug_attr_group);
	ret |= sysfs_create_group(thermal_kobj, &thermal_attr_group);
	ret |= sysfs_create_group(apps_kobj, &apps_attr_group);
	ret |= sysfs_create_group(battery_kobj, &battery_attr_group);
	ret |= sysfs_create_group(adaptive_policy_kobj, &adaptive_attr_group);

	if (ret) {
		pr_err("%s: sysfs_create_group failed\n", __func__);
		return ret;
	}

	return 0;
}
static int hall_cover_sysfs_init(void)
{
	int ret = 0;
	android_cover_kobj = kobject_create_and_add("android_cover", NULL);
	if (android_cover_kobj == NULL) {
		HL_ERR("%s:subsystem_register_failed", __func__);
		ret = -ENOMEM;
		return ret;
	}

	ret = sysfs_create_file(android_cover_kobj, &dev_attr_debug_level.attr);
	if (ret) {
		HL_ERR("%s: sysfs_create_file debug_level failed\n", __func__);
		return ret;
	}
	ret = sysfs_create_file(android_cover_kobj, &dev_attr_read_att.attr);
	if (ret) {
		HL_ERR("%s: sysfs_create_file read_att failed\n", __func__);
		return ret;
	}
	HL_LOG("attribute file register Done");
	return 0;
}
Пример #29
0
static int __init edac_init_mce_inject(void)
{
	struct sysdev_class *edac_class = NULL;
	int i, err = 0;

	edac_class = edac_get_sysfs_class();
	if (!edac_class)
		return -EINVAL;

	mce_kobj = kobject_create_and_add("mce", &edac_class->kset.kobj);
	if (!mce_kobj) {
		printk(KERN_ERR "Error creating a mce kset.\n");
		err = -ENOMEM;
		goto err_mce_kobj;
	}

	for (i = 0; i < ARRAY_SIZE(sysfs_attrs); i++) {
		err = sysfs_create_file(mce_kobj, &sysfs_attrs[i]->attr);
		if (err) {
			printk(KERN_ERR "Error creating %s in sysfs.\n",
					sysfs_attrs[i]->attr.name);
			goto err_sysfs_create;
		}
	}
	return 0;

err_sysfs_create:
	while (--i >= 0)
		sysfs_remove_file(mce_kobj, &sysfs_attrs[i]->attr);

	kobject_del(mce_kobj);

err_mce_kobj:
	edac_put_sysfs_class();

	return err;
}