input: gsensor: mma8452: initialize data early

fix this bug:
Unable to handle kernel NULL pointer dereference at virtual address 00000000
PC is at __mutex_lock_slowpath+0x4c/0x154
LR is at mma8452_get_data+0x1fc/0x238
[<c07e4f2c>] (__mutex_lock_slowpath+0x4c/0x154) from [<c066d9c4>] (mma8452_get_data+0x1fc/0x238)
[<c066d9c4>] (mma8452_get_data+0x1fc/0x238) from [<c066da10>] (mma8452_delaywork_func+0x10/0x30)
[<c066da10>] (mma8452_delaywork_func+0x10/0x30) from [<c0466600>] (process_one_work+0x258/0x3ac)
[<c0466600>] (process_one_work+0x258/0x3ac) from [<c0468f60>] (worker_thread+0x238/0x440)
[<c0468f60>] (worker_thread+0x238/0x440) from [<c046c9ac>] (kthread+0x80/0x88)
[<c046c9ac>] (kthread+0x80/0x88) from [<c0433190>] (kernel_thread_exit+0x0/0x8)
This commit is contained in:
黄涛
2011-11-09 09:44:26 +08:00
parent 686b79c488
commit acd77ec58b

View File

@@ -724,6 +724,17 @@ static int mma8452_probe(struct i2c_client *client, const struct i2c_device_id
INIT_WORK(&mma8452->work, mma8452_work_func);
INIT_DELAYED_WORK(&mma8452->delaywork, mma8452_delaywork_func);
memset(&(mma8452->sense_data), 0, sizeof(struct mma8452_axis) );
mutex_init(&(mma8452->sense_data_mutex) );
atomic_set(&(mma8452->data_ready), 0);
init_waitqueue_head(&(mma8452->data_ready_wq) );
mma8452->start_count = 0;
mutex_init(&(mma8452->operation_mutex) );
mma8452->status = MMA8452_CLOSE;
mma8452->client = client;
i2c_set_clientdata(client, mma8452);
@@ -794,17 +805,6 @@ static int mma8452_probe(struct i2c_client *client, const struct i2c_device_id
#endif
printk(KERN_INFO "mma8452 probe ok\n");
memset(&(mma8452->sense_data), 0, sizeof(struct mma8452_axis) );
mutex_init(&(mma8452->sense_data_mutex) );
atomic_set(&(mma8452->data_ready), 0);
init_waitqueue_head(&(mma8452->data_ready_wq) );
mma8452->start_count = 0;
mutex_init(&(mma8452->operation_mutex) );
// mma8452->status = -1;
mma8452->status = MMA8452_CLOSE;
#if 0
// mma8452_start_test(this_client);
mma8452_start(client, MMA8452_RATE_12P5);