Skip to content

Commit be49c69

Browse files
liuyx1314rkhuangtao
authored andcommitted
drivers: input: sensor: update for akmxxxx compass chips
Change-Id: Iba164016e01c7741d5cf99f207829e6654ab43ff Signed-off-by: Zorro Liu <lyx@rock-chips.com>
1 parent d362c39 commit be49c69

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

drivers/input/sensors/compass/ak09911.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ static int compass_akm_set_mode(struct i2c_client *client, char mode)
367367
case AK09911_MODE_FUSE_ACCESS:
368368
if(sensor->status_cur == SENSOR_OFF)
369369
{
370+
sensor->stop_work = 0;
371+
sensor->status_cur = SENSOR_ON;
372+
370373
if(sensor->pdata->irq_enable)
371374
{
372375
//DBG("%s:enable irq=%d\n",__func__,client->irq);
@@ -377,14 +380,14 @@ static int compass_akm_set_mode(struct i2c_client *client, char mode)
377380
schedule_delayed_work(&sensor->delaywork, msecs_to_jiffies(sensor->pdata->poll_delay_ms));
378381
}
379382

380-
sensor->status_cur = SENSOR_ON;
381383
}
382384

383385
break;
384386

385387
case AK09911_MODE_POWERDOWN:
386388
if(sensor->status_cur == SENSOR_ON)
387389
{
390+
sensor->stop_work = 1;
388391
if(sensor->pdata->irq_enable)
389392
{
390393
//DBG("%s:disable irq=%d\n",__func__,client->irq);

drivers/input/sensors/compass/ak8963.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ static int compass_akm_set_mode(struct i2c_client *client, char mode)
367367
case AK8963_MODE_FUSE_ACCESS:
368368
if(sensor->status_cur == SENSOR_OFF)
369369
{
370+
sensor->stop_work = 0;
371+
sensor->status_cur = SENSOR_ON;
372+
370373
if(sensor->pdata->irq_enable)
371374
{
372375
//DBG("%s:enable irq=%d\n",__func__,client->irq);
@@ -377,14 +380,14 @@ static int compass_akm_set_mode(struct i2c_client *client, char mode)
377380
schedule_delayed_work(&sensor->delaywork, msecs_to_jiffies(sensor->pdata->poll_delay_ms));
378381
}
379382

380-
sensor->status_cur = SENSOR_ON;
381383
}
382384

383385
break;
384386

385387
case AK8963_MODE_POWERDOWN:
386388
if(sensor->status_cur == SENSOR_ON)
387389
{
390+
sensor->stop_work = 1;
388391
if(sensor->pdata->irq_enable)
389392
{
390393
//DBG("%s:disable irq=%d\n",__func__,client->irq);

drivers/input/sensors/compass/ak8975.c

100755100644
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ static int compass_akm_set_mode(struct i2c_client *client, char mode)
339339
case AK8975_MODE_FUSE_ACCESS:
340340
if(sensor->status_cur == SENSOR_OFF)
341341
{
342+
sensor->stop_work = 0;
343+
sensor->status_cur = SENSOR_ON;
342344
if(sensor->pdata->irq_enable)
343345
{
344346
//DBG("%s:enable irq=%d\n",__func__,client->irq);
@@ -348,15 +350,14 @@ static int compass_akm_set_mode(struct i2c_client *client, char mode)
348350
{
349351
schedule_delayed_work(&sensor->delaywork, msecs_to_jiffies(sensor->pdata->poll_delay_ms));
350352
}
351-
352-
sensor->status_cur = SENSOR_ON;
353353
}
354354

355355
break;
356356

357357
case AK8975_MODE_POWERDOWN:
358358
if(sensor->status_cur == SENSOR_ON)
359359
{
360+
sensor->stop_work = 1;
360361
if(sensor->pdata->irq_enable)
361362
{
362363
//DBG("%s:disable irq=%d\n",__func__,client->irq);

drivers/input/sensors/sensor-dev.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ static long compass_dev_ioctl(struct file *file,
966966
unsigned int cmd, unsigned long arg)
967967
{
968968
struct sensor_private_data *sensor = g_sensor[SENSOR_TYPE_COMPASS];
969+
struct i2c_client *client = sensor->client;
969970
void __user *argp = (void __user *)arg;
970971
int result = 0;
971972
short flag;
@@ -1008,6 +1009,13 @@ static long compass_dev_ioctl(struct file *file,
10081009
break;
10091010
case ECS_IOCTL_APP_SET_DELAY:
10101011
sensor->flags.delay = flag;
1012+
mutex_lock(&sensor->operation_mutex);
1013+
result = sensor_reset_rate(client, flag);
1014+
if (result < 0) {
1015+
mutex_unlock(&sensor->operation_mutex);
1016+
return result;
1017+
}
1018+
mutex_unlock(&sensor->operation_mutex);
10111019
break;
10121020
case ECS_IOCTL_APP_GET_DELAY:
10131021
flag = sensor->flags.delay;

0 commit comments

Comments
 (0)