static int yas_acc_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
    struct yas_acc_private_data *data;
    int err;

    /* Setup private data */
    data = kzalloc(sizeof(struct yas_acc_private_data), GFP_KERNEL);
    if (!data) {
        err = -ENOMEM;
        goto ERR1;
    }
    yas_acc_set_data(data);

    mutex_init(&data->driver_mutex);
    mutex_init(&data->data_mutex);

    /* Setup i2c client */
    if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
        err = -ENODEV;
        goto ERR2;
    }
    i2c_set_clientdata(client, data);
    data->client = client;

    /* Setup accelerometer core driver */
    err = yas_acc_core_driver_init(data);
    if (err < 0) {
        goto ERR2;
    }

    /* Setup driver interface */
    INIT_DELAYED_WORK(&data->work, yas_acc_work_func);

    /* Setup input device interface */
    err = yas_acc_input_init(data);
    if (err < 0) {
        goto ERR3;
    }

    /* Setup sysfs */
    err = sysfs_create_group(&data->input->dev.kobj, &yas_acc_attribute_group);
    if (err < 0) {
        goto ERR4;
    }

    return 0;

 ERR4:
    yas_acc_input_fini(data);
 ERR3:
    yas_acc_core_driver_fini(data);
 ERR2:
    kfree(data);
 ERR1:
    return err;
}
Esempio n. 2
0
//static int yas_acc_probe(struct i2c_client *client, const struct i2c_device_id *id)
static int bma222_init_proc()
{
    struct yas_acc_private_data *data;
    int err;
     printk(KERN_ERR "bma222_init_proc +\n");
    /* Setup private data */
    data = kzalloc(sizeof(struct yas_acc_private_data), GFP_KERNEL);
    if (!data) {
        err = -ENOMEM;
        goto ERR1;
    }
    yas_acc_set_data(data);

    mutex_init(&data->driver_mutex);
    mutex_init(&data->data_mutex);

    data->client = omap_gpio_i2c_init(OMAP_GPIO_SENSOR_SDA, OMAP_GPIO_SENSOR_SCL, 0x08, 200);
	
/*
    // Setup i2c client
    if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
        err = -ENODEV;
        goto ERR2;
    }
    i2c_set_clientdata(client, data);
    data->client = client;
*/
    /* Setup accelerometer core driver */
    err = yas_acc_core_driver_init(data);
    if (err < 0) {
        goto ERR2;
    }

    /* Setup driver interface */
    INIT_DELAYED_WORK(&data->work, yas_acc_work_func);

    /* Setup input device interface */
    err = yas_acc_input_init(data);
    if (err < 0) {
        goto ERR3;
    }

    /* Setup sysfs */
    err = sysfs_create_group(&data->input->dev.kobj, &yas_acc_attribute_group);
    if (err < 0) {
        goto ERR4;
    }

    err = sensors_register(accel_sensor_device, NULL, accel_sensor_attrs, "accelerometer_sensor");
    if(err) {
    	printk(KERN_ERR "%s: cound not register accelerometer sensor device(%d).\n", __func__, err);
    }
	
#if defined(CONFIG_HAS_EARLYSUSPEND)
    data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
    data->early_suspend.suspend = (void *)bma222_early_suspend;
    data->early_suspend.resume  = (void *)bma222_early_resume;
    register_early_suspend(&data->early_suspend);
#endif	

	printk(KERN_ERR "bma222_init_proc -\n");


    return 0;

 ERR4:
    yas_acc_input_fini(data);
 ERR3:
    yas_acc_core_driver_fini(data);
 ERR2:
    kfree(data);
 ERR1:
    return err;
}
static int yas_acc_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
    struct yas_acc_private_data *data;
    int err;
#ifdef WILLOW_SENSOR_REGULATOR_CONTROL
    int ret;
#endif
    /* Setup private data */
    data = kzalloc(sizeof(struct yas_acc_private_data), GFP_KERNEL);
    if (!data) {
        err = -ENOMEM;
        goto ERR1;
    }
    yas_acc_set_data(data);

#ifdef WILLOW_SENSOR_REGULATOR_CONTROL
    data->regulator = regulator_get(&client->dev, "vdd_sensor");
    if(IS_ERR(data->regulator)) {
        printk(KERN_ERR "[accelerometer] failed to get regulator\n");
        err = -EINVAL;
        goto regulator_err;
    }

    ret = regulator_enable(data->regulator);
    if(ret<0) {
        printk(KERN_ERR "[accelerometer] failed to enable regulator\n");
        err = -EINVAL;
        goto regulator_err;
    }

    mdelay(3);
#endif

    mutex_init(&data->driver_mutex);
    mutex_init(&data->data_mutex);

    /* Setup i2c client */
    if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
        err = -ENODEV;
        goto ERR2;
    }
    i2c_set_clientdata(client, data);
    data->client = client;

    /* Setup accelerometer core driver */
    err = yas_acc_core_driver_init(data);
    if (err < 0) {
        goto ERR2;
    }

    /* Setup driver interface */
    INIT_DELAYED_WORK(&data->work, yas_acc_work_func);

    /* Setup input device interface */
    err = yas_acc_input_init(data);
    if (err < 0) {
        goto ERR3;
    }

#ifdef CONFIG_HAS_EARLYSUSPEND
    data->early_suspend.suspend = yas_acc_early_suspend;
    data->early_suspend.resume = yas_acc_late_resume;
    data->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
    register_early_suspend(&data->early_suspend);
#endif

    /* Setup sysfs */
    err = sysfs_create_group(&data->input->dev.kobj, &yas_acc_attribute_group);
    if (err < 0) {
        goto ERR4;
    }

    return 0;

 ERR4:
#ifdef CONIFG_HAS_EARLYSUSPEND
    unregister_early_suspend(&data->early_suspend);
#endif
    yas_acc_input_fini(data);
 ERR3:
    yas_acc_core_driver_fini(data);
#ifdef WILLOW_SENSOR_REGULATOR_CONTROL
 regulator_err:
    regulator_disable(data->regulator);
    regulator_put(data->regulator);
#endif
 ERR2:
    kfree(data);
 ERR1:
    return err;
}
Esempio n. 4
0
static int yas_acc_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
    struct yas_acc_private_data *data;
    int err;
	dbg_func_in();
    /* Setup private data */
    data = kzalloc(sizeof(struct yas_acc_private_data), GFP_KERNEL);
    if (!data) {
        err = -ENOMEM;
        goto ERR1;
    }
    yas_acc_set_data(data);

#ifndef PANTECH_AVOID_DEADLOCK
    mutex_init(&data->driver_mutex);
    mutex_init(&data->data_mutex);
#endif

    /* Setup i2c client */
    if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
        err = -ENODEV;
        goto ERR2;
    }
    i2c_set_clientdata(client, data);
    data->client = client;

    /* Setup accelerometer core driver */
    err = yas_acc_core_driver_init(data);
    if (err < 0) {
        goto ERR2;
    }

    /* Setup driver interface */
    INIT_DELAYED_WORK(&data->work, yas_acc_work_func);

    /* Setup input device interface */
    err = yas_acc_input_init(data);
    if (err < 0) {
        goto ERR3;
    }

    /* Setup sysfs */
    err = sysfs_create_group(&data->input->dev.kobj, &yas_acc_attribute_group);
    if (err < 0) {
        goto ERR4;
    }
	g_acc = 1;
	dbg_func_out();
#ifdef POWER_ON_OFF
	dbg("acc probe start\n");
	geomagnetic_set_power(0);
	dbg("end\n");
#endif
    return 0;

 ERR4:
    yas_acc_input_fini(data);
 ERR3:
    yas_acc_core_driver_fini(data);
 ERR2:
    kfree(data);
 ERR1:
    return err;
}