Esempio n. 1
0
static int gyro_probe(struct platform_device *pdev)
{

    int err;
    GYRO_LOG("+++++++++++++gyro_probe!!\n");

    gyro_context_obj = gyro_context_alloc_object();
    if (!gyro_context_obj)
    {
        err = -ENOMEM;
        GYRO_ERR("unable to allocate devobj!\n");
        goto exit_alloc_data_failed;
    }

    //init real gyroeleration driver
    err = gyro_real_driver_init();
    if(err)
    {
        GYRO_ERR("gyro real driver init fail\n");
        goto real_driver_init_fail;
    }

    //init input dev
    err = gyro_input_init(gyro_context_obj);
    if(err)
    {
        GYRO_ERR("unable to register gyro input device!\n");
        goto exit_alloc_input_dev_failed;
    }

        atomic_set(&(gyro_context_obj->early_suspend), 0);
    gyro_context_obj->early_drv.level    = EARLY_SUSPEND_LEVEL_STOP_DRAWING - 1,
    gyro_context_obj->early_drv.suspend  = gyro_early_suspend,
    gyro_context_obj->early_drv.resume   = gyro_late_resume,
    register_early_suspend(&gyro_context_obj->early_drv);

    GYRO_LOG("----gyro_probe OK !!\n");
    return 0;

    //exit_hwmsen_create_attr_failed:
    //exit_misc_register_failed:

    //exit_err_sysfs:

    if (err)
    {
       GYRO_ERR("sysfs node creation error \n");
       gyro_input_destroy(gyro_context_obj);
    }

    real_driver_init_fail:
    exit_alloc_input_dev_failed:
    kfree(gyro_context_obj);

    exit_alloc_data_failed:


    GYRO_LOG("----gyro_probe fail !!!\n");
    return err;
}
static int gyro_probe(void)
{

	int err;

	GYRO_LOG("+++++++++++++gyro_probe!!\n");

	gyro_context_obj = gyro_context_alloc_object();
	if (!gyro_context_obj) {
		err = -ENOMEM;
		GYRO_ERR("unable to allocate devobj!\n");
		goto exit_alloc_data_failed;
	}

	/* init real gyroeleration driver */
	err = gyro_real_driver_init(pltfm_dev);
	if (err) {
		GYRO_ERR("gyro real driver init fail\n");
		goto real_driver_init_fail;
	}

	err = gyro_factory_device_init();
	if (err)
		GYRO_ERR("gyro_factory_device_init fail\n");

	/* init input dev */
	err = gyro_input_init(gyro_context_obj);
	if (err) {
		GYRO_ERR("unable to register gyro input device!\n");
		goto exit_alloc_input_dev_failed;
	}

	GYRO_LOG("----gyro_probe OK !!\n");
	return 0;

	if (err) {
		GYRO_ERR("sysfs node creation error\n");
		gyro_input_destroy(gyro_context_obj);
	}

real_driver_init_fail:
exit_alloc_input_dev_failed:
	kfree(gyro_context_obj);

exit_alloc_data_failed:
	GYRO_ERR("----gyro_probe fail !!!\n");
	return err;
}