Skip to content

Commit 857dcab

Browse files
Joseph WuJoseph Wu
Joseph Wu
authored and
Joseph Wu
committed
Revert "Sensors: Checking compass compensation from factory calibrated gain."
This reverts commit a113725.
1 parent 72437e9 commit 857dcab

File tree

3 files changed

+0
-162
lines changed

3 files changed

+0
-162
lines changed

drivers/staging/iio/magnetometer/inv_compass/inv_ami306_core.c

-59
Original file line numberDiff line numberDiff line change
@@ -373,55 +373,6 @@ static ssize_t ami306_rate_show(struct device *dev,
373373
return sprintf(buf, "%d\n", 1000 / st->delay);
374374
}
375375

376-
static ssize_t compass_cali_test(struct device *dev,
377-
struct device_attribute *devattr, char *buf)
378-
{
379-
struct iio_dev *indio_dev = dev_get_drvdata(dev);
380-
struct inv_ami306_state_s *st = iio_priv(indio_dev);
381-
int bufcnt = 0;
382-
int ii = 0;
383-
int val = 0;
384-
char tmpbuf[100];
385-
386-
/* Check if compass calibration file exist */
387-
if (!st->data_chk.fexist)
388-
bufcnt += sprintf(tmpbuf,
389-
"\nE-compass calibration file EXIST.\n\n");
390-
else
391-
bufcnt += sprintf(tmpbuf,
392-
"\nE-compass calibration file DO NOT EXIST.\n\n");
393-
394-
strncat(buf, tmpbuf, strlen(tmpbuf));
395-
396-
/* Check if raw data match the gain from calibration file */
397-
for (ii = 0; ii < 3; ii++) {
398-
val = (short)(st->data_chk.ori[ii] *
399-
st->data_chk.gain[ii] / 100);
400-
401-
if (val == st->data_chk.post[ii])
402-
bufcnt += sprintf(tmpbuf,
403-
"[axis-%d] Compensation is matched to the gain.\n",
404-
ii);
405-
else
406-
bufcnt += sprintf(tmpbuf,
407-
"[axis-%d] Compensation FAIL. %d != %d",
408-
ii, val, st->data_chk.post[ii]);
409-
410-
strncat(buf, tmpbuf, strlen(tmpbuf));
411-
}
412-
413-
bufcnt += sprintf(tmpbuf,
414-
"gain: %d, %d, %d\nori:(%d, %d, %d); post:(%d, %d, %d)\n",
415-
st->data_chk.gain[0], st->data_chk.gain[1],
416-
st->data_chk.gain[2], st->data_chk.ori[0],
417-
st->data_chk.ori[1], st->data_chk.ori[2],
418-
st->data_chk.post[0], st->data_chk.post[1],
419-
st->data_chk.post[2]);
420-
421-
strncat(buf, tmpbuf, strlen(tmpbuf));
422-
423-
return bufcnt;
424-
}
425376

426377
static void ami306_work_func(struct work_struct *work)
427378
{
@@ -466,12 +417,10 @@ static const struct iio_chan_spec compass_channels[] = {
466417
static DEVICE_ATTR(compass_matrix, S_IRUGO, inv_compass_matrix_show, NULL);
467418
static DEVICE_ATTR(sampling_frequency, S_IRUGO | S_IWUSR, ami306_rate_show,
468419
ami306_rate_store);
469-
static DEVICE_ATTR(compass_cali_test, S_IRUGO, compass_cali_test, NULL);
470420

471421
static struct attribute *inv_ami306_attributes[] = {
472422
&dev_attr_compass_matrix.attr,
473423
&dev_attr_sampling_frequency.attr,
474-
&dev_attr_compass_cali_test.attr,
475424
NULL,
476425
};
477426
static const struct attribute_group inv_attribute_group = {
@@ -497,8 +446,6 @@ static int inv_ami306_probe(struct i2c_client *client,
497446
struct iio_dev *indio_dev;
498447
int result;
499448
char data;
500-
int ii;
501-
502449
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
503450
result = -ENODEV;
504451
goto out_no_free;
@@ -515,12 +462,6 @@ static int inv_ami306_probe(struct i2c_client *client,
515462
*(struct mpu_platform_data *)dev_get_platdata(&client->dev);
516463
st->delay = 10;
517464

518-
/* init for loading factory file*/
519-
st->data_chk.load_cali = false;
520-
st->data_chk.fexist = -1;
521-
for (ii = 0; ii < 3; ii++)
522-
st->data_chk.gain[ii] = 100;
523-
524465
/* Make state variables available to all _show and _store functions. */
525466
i2c_set_clientdata(client, indio_dev);
526467
result = i2c_read(st->i2c, REG_AMI_WIA, 1, &data);

drivers/staging/iio/magnetometer/inv_compass/inv_ami306_iio.h

-11
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,6 @@ struct ami_sensor_parametor {
7171
struct ami_interference m_interference;
7272
};
7373

74-
struct cali_data_check {
75-
short ori[3];
76-
short post[3];
77-
int gain[3];
78-
bool load_cali;
79-
bool fexist;
80-
bool status;
81-
};
82-
8374
/**
8475
* struct inv_ami306_state_s - Driver state variables.
8576
* @i2c: i2c client handle.
@@ -99,9 +90,7 @@ struct inv_ami306_state_s {
9990
char fine[3];
10091
short compass_data[3];
10192
s64 timestamp;
102-
struct cali_data_check data_chk;
10393
};
104-
10594
/* scan element definition */
10695
enum inv_mpu_scan {
10796
INV_AMI306_SCAN_MAGN_X,

drivers/staging/iio/magnetometer/inv_compass/inv_ami306_ring.c

-92
Original file line numberDiff line numberDiff line change
@@ -42,77 +42,7 @@
4242
#include "sysfs.h"
4343

4444
#include "inv_ami306_iio.h"
45-
enum Compass_cali_File {
46-
AMI30X = 0,
47-
AMI306,
48-
AMICaliMax
49-
};
50-
51-
#define AMI30X_CALIBRATION_PATH "/data/sensors/AMI304_Config.ini"
52-
#define AMI306_CALIBRATION_PATH "/data/sensors/AMI306_Config.ini"
53-
54-
/* function for loading compass calibration file. */
55-
static int access_cali_file(short *gain, int target)
56-
{
57-
char buf[256];
58-
int ret;
59-
struct file *fp = NULL;
60-
mm_segment_t oldfs;
61-
int data[23];
62-
int ii;
63-
64-
oldfs = get_fs();
65-
set_fs(get_ds());
66-
memset(buf, 0, sizeof(u8)*256);
67-
68-
if (target == AMI30X)
69-
fp = filp_open(AMI30X_CALIBRATION_PATH, O_RDONLY, 0);
70-
else if (target == AMI306)
71-
fp = filp_open(AMI306_CALIBRATION_PATH, O_RDONLY, 0);
72-
else
73-
goto LoadFileFail;
74-
75-
if (!IS_ERR(fp)) {
76-
77-
pr_info("ami306 open calibration file success\n");
78-
ret = fp->f_op->read(fp, buf, sizeof(buf), &fp->f_pos);
79-
pr_info("ami306 calibration content is :\n%s\n", buf);
80-
sscanf(buf, "%6d\n%6d %6d %6d\n"
81-
"%6d %6d %6d\n%6d %6d %6d\n"
82-
"%6d %6d %6d\n%6d %6d %6d\n"
83-
"%6d %6d %6d\n%6d %6d %6d\n%6d\n",
84-
&data[0],
85-
&data[1], &data[2], &data[3],
86-
&data[4], &data[5], &data[6],
87-
&data[7], &data[8], &data[9],
88-
&data[10], &data[11], &data[12],
89-
&data[13], &data[14], &data[15],
90-
&data[16], &data[17], &data[18],
91-
&data[19], &data[20], &data[21],
92-
&data[22]);
93-
94-
if ((data[19] > 150) || (data[19] < 50) ||
95-
(data[20] > 150) || (data[20] < 50) ||
96-
(data[21] > 150) || (data[21] < 50)) {
97-
for (ii = 0; ii < 3; ii++)
98-
gain[ii] = 100;
99-
} else{
100-
for (ii = 0; ii < 3; ii++)
101-
gain[ii] = data[ii + 19];
102-
}
103-
104-
pr_info("gain: %d %d %d\n", gain[0], gain[1], gain[2]);
105-
106-
return 0;
107-
} else{
108-
pr_info("Compass compensation: No target File. (%d)\n", target);
109-
set_fs(oldfs);
110-
return -1;
111-
}
11245

113-
LoadFileFail:
114-
return -1;
115-
}
11646
static int put_scan_to_buf(struct iio_dev *indio_dev, unsigned char *d,
11747
short *s, int scan_index) {
11848
struct iio_buffer *ring = indio_dev->buffer;
@@ -140,7 +70,6 @@ int inv_read_ami306_fifo(struct iio_dev *indio_dev)
14070
char b;
14171
char *tmp;
14272
s64 tmp_buf[2];
143-
int ii;
14473

14574
result = i2c_smbus_read_i2c_block_data(st->i2c, REG_AMI_STA1, 1, &b);
14675
if (result < 0)
@@ -151,27 +80,6 @@ int inv_read_ami306_fifo(struct iio_dev *indio_dev)
15180
pr_err("error reading raw\n");
15281
goto end_session;
15382
}
154-
155-
if (!st->data_chk.load_cali) {
156-
for (ii = 0; ii < AMICaliMax; ii++) {
157-
result =
158-
access_cali_file(st->data_chk.gain, ii);
159-
if (!result) {
160-
st->data_chk.fexist = 0;
161-
break;
162-
}
163-
}
164-
st->data_chk.load_cali = true;
165-
}
166-
167-
for (ii = 0; ii < 3; ii++) {
168-
st->data_chk.ori[ii] = st->compass_data[ii];
169-
st->compass_data[ii] =
170-
(short)((int)st->compass_data[ii] *
171-
st->data_chk.gain[ii] / 100);
172-
st->data_chk.post[ii] = st->compass_data[ii];
173-
}
174-
17583
tmp = (unsigned char *)tmp_buf;
17684
d_ind = put_scan_to_buf(indio_dev, tmp, st->compass_data,
17785
INV_AMI306_SCAN_MAGN_X);

0 commit comments

Comments
 (0)