static int mma7660_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct mma7660_data *mma7660; int err; Xaverage = Yaverage = Zaverage = RawDataNum = 0; mma7660 = kzalloc(sizeof(struct mma7660_data), GFP_KERNEL); if (!mma7660) { rk28printk("[mma7660]:alloc data failed.\n"); err = -ENOMEM; goto exit_alloc_data_failed; } INIT_WORK(&mma7660->work, mma7660_work_func); INIT_DELAYED_WORK(&mma7660->delaywork, mma7660_delaywork_func); mma7660->client = client; //mma7660->swap_xy = i2c_set_clientdata(client, mma7660); this_client = client; err = mma7660_init_client(client); if (err < 0) { rk28printk(KERN_ERR "mma7660_probe: mma7660_init_client failed\n"); goto exit_request_gpio_irq_failed; } mma7660->input_dev = input_allocate_device(); if (!mma7660->input_dev) { err = -ENOMEM; rk28printk(KERN_ERR "mma7660_probe: Failed to allocate input device\n"); goto exit_input_allocate_device_failed; } set_bit(EV_ABS, mma7660->input_dev->evbit); /* x-axis acceleration */ input_set_abs_params(mma7660->input_dev, ABS_X, -1500, 1500, 0, 0); /* y-axis acceleration */ input_set_abs_params(mma7660->input_dev, ABS_Y, -1500, 1500, 0, 0); /* z-axis acceleration */ input_set_abs_params(mma7660->input_dev, ABS_Z, -1500, 1500, 0, 0); mma7660->input_dev->name = "gsensor"; mma7660->input_dev->dev.parent = &client->dev; err = input_register_device(mma7660->input_dev); if (err < 0) { rk28printk(KERN_ERR "mma7660_probe: Unable to register input device: %s\n", mma7660->input_dev->name); goto exit_input_register_device_failed; } mma7660_device.parent = &client->dev; err = misc_register(&mma7660_device); if (err < 0) { rk28printk(KERN_ERR "mma7660_probe: mmad_device register failed\n"); goto exit_misc_device_register_mma7660_device_failed; } err = gsensor_sysfs_init(); if (err < 0) { rk28printk(KERN_ERR "mma7660_probe: gsensor sysfs init failed\n"); goto exit_gsensor_sysfs_init_failed; } #ifdef CONFIG_HAS_EARLYSUSPEND mma7660_early_suspend.suspend = mma7660_suspend; mma7660_early_suspend.resume = mma7660_resume; mma7660_early_suspend.level = 0x2; register_early_suspend(&mma7660_early_suspend); #endif rk28printk(KERN_INFO "mma7660 probe ok\n"); mma7660->status = -1; #if 1 mma7660_start(client, MMA7660_RATE_32); #endif return 0; exit_gsensor_sysfs_init_failed: misc_deregister(&mma7660_device); exit_misc_device_register_mma7660_device_failed: input_unregister_device(mma7660->input_dev); exit_input_register_device_failed: input_free_device(mma7660->input_dev); exit_input_allocate_device_failed: free_irq(client->irq, mma7660); exit_request_gpio_irq_failed: kfree(mma7660); exit_alloc_data_failed: ; return err; }
static int __devinit mma7660_probe(struct i2c_client *client, const struct i2c_device_id *id) { //printk(KERN_INFO "Linda mma7660_probe start ! 111111111111111111111111111111111\n"); int result; //struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct input_dev *idev; struct i2c_adapter *adapter; mma7660_i2c_client = client; adapter = to_i2c_adapter(client->dev.parent); result = i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA); assert(result); /* Initialize the MMA7660 chip */ result = mma7660_init_client(client); //printk(KERN_INFO "Linda mma7660_init_client ! 111111111111111111111111111111111\n"); assert(result==0); result = sysfs_create_group(&client->dev.kobj, &mma7660_group); assert(result==0); hwmon_dev = hwmon_device_register(&client->dev); assert(!(IS_ERR(hwmon_dev))); dev_info(&client->dev, "build time %s %s\n", __DATE__, __TIME__); //printk(KERN_INFO "Linda test 111111111111111111111111111111111\n"); /*input poll device register */ mma7660_idev = input_allocate_polled_device(); if (!mma7660_idev) { dev_err(&client->dev, "alloc poll device failed!\n"); result = -ENOMEM; return result; } mma7660_idev->poll = mma7660_dev_poll; mma7660_idev->poll_interval = POLL_INTERVAL; mma7660_idev->poll_interval_max = POLL_INTERVAL_MAX; idev = mma7660_idev->input; idev->name = MMA7660_DRV_NAME; idev->id.bustype = BUS_I2C; idev->dev.parent = &client->dev; idev->evbit[0] = BIT_MASK(EV_ABS); input_set_abs_params(idev, ABS_X, -512, 512, INPUT_FUZZ, INPUT_FLAT); input_set_abs_params(idev, ABS_Y, -512, 512, INPUT_FUZZ, INPUT_FLAT); input_set_abs_params(idev, ABS_Z, -512, 512, INPUT_FUZZ, INPUT_FLAT); result = input_register_polled_device(mma7660_idev); if (result) { dev_err(&client->dev, "register poll device failed!\n"); return result; } ////////////////////////////// //a7660_enter_suspend(); ////////////////////////////// //Encryp_main(); //////////////////////// return result; }
static int __devinit mma7660_probe(struct i2c_client *client, const struct i2c_device_id *id) { int result; struct input_dev *idev; struct i2c_adapter *adapter; printk(KERN_INFO "mma7660 probe\n"); mma7660_i2c_client = client; adapter = to_i2c_adapter(client->dev.parent); result = i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA); assert(result); /* Initialize the MMA7660 chip */ result = mma7660_init_client(client); assert(result==0); hwmon_dev = hwmon_device_register(&client->dev); assert(!(IS_ERR(hwmon_dev))); dev_info(&client->dev, "build time %s %s\n", __DATE__, __TIME__); /*input poll device register */ mma7660_idev = input_allocate_polled_device(); if (!mma7660_idev) { dev_err(&client->dev, "alloc poll device failed!\n"); result = -ENOMEM; return result; } mma7660_idev->poll = mma7660_dev_poll; mma7660_idev->poll_interval = POLL_INTERVAL; mma7660_idev->poll_interval_max = POLL_INTERVAL_MAX; idev = mma7660_idev->input; idev->name = MMA7660_DRV_NAME; idev->id.bustype = BUS_I2C; idev->evbit[0] = BIT_MASK(EV_ABS); input_set_abs_params(idev, ABS_X, -512, 512, INPUT_FUZZ, INPUT_FLAT); input_set_abs_params(idev, ABS_Y, -512, 512, INPUT_FUZZ, INPUT_FLAT); input_set_abs_params(idev, ABS_Z, -512, 512, INPUT_FUZZ, INPUT_FLAT); result = input_register_polled_device(mma7660_idev); if (result) { dev_err(&client->dev, "register poll device failed!\n"); return result; } result = sysfs_create_group(&mma7660_idev->input->dev.kobj, &mma7660_attribute_group); //result = device_create_file(&mma7660_idev->input->dev, &dev_attr_enable); //result = device_create_file(&mma7660_idev->input->dev, &dev_attr_value); if(result) { dev_err(&client->dev, "create sys failed\n"); } #ifdef CONFIG_HAS_EARLYSUSPEND mma7660_data.early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; mma7660_data.early_suspend.suspend = mma7660_early_suspend; mma7660_data.early_suspend.resume = mma7660_late_resume; register_early_suspend(&mma7660_data.early_suspend); mma7660_data.suspend_indator = 0; #endif return result; }