|
@@ -308,31 +308,31 @@ static int mmc35240_read_measurement(struct mmc35240_data *data, __le16 buf[3])
|
|
static int mmc35240_raw_to_mgauss(struct mmc35240_data *data, int index,
|
|
static int mmc35240_raw_to_mgauss(struct mmc35240_data *data, int index,
|
|
__le16 buf[], int *val)
|
|
__le16 buf[], int *val)
|
|
{
|
|
{
|
|
- int raw_x, raw_y, raw_z;
|
|
|
|
- int sens_x, sens_y, sens_z;
|
|
|
|
|
|
+ int raw[3];
|
|
|
|
+ int sens[3];
|
|
int nfo;
|
|
int nfo;
|
|
|
|
|
|
- raw_x = le16_to_cpu(buf[AXIS_X]);
|
|
|
|
- raw_y = le16_to_cpu(buf[AXIS_Y]);
|
|
|
|
- raw_z = le16_to_cpu(buf[AXIS_Z]);
|
|
|
|
|
|
+ raw[AXIS_X] = le16_to_cpu(buf[AXIS_X]);
|
|
|
|
+ raw[AXIS_Y] = le16_to_cpu(buf[AXIS_Y]);
|
|
|
|
+ raw[AXIS_Z] = le16_to_cpu(buf[AXIS_Z]);
|
|
|
|
|
|
- sens_x = mmc35240_props_table[data->res].sens[AXIS_X];
|
|
|
|
- sens_y = mmc35240_props_table[data->res].sens[AXIS_Y];
|
|
|
|
- sens_z = mmc35240_props_table[data->res].sens[AXIS_Z];
|
|
|
|
|
|
+ sens[AXIS_X] = mmc35240_props_table[data->res].sens[AXIS_X];
|
|
|
|
+ sens[AXIS_Y] = mmc35240_props_table[data->res].sens[AXIS_Y];
|
|
|
|
+ sens[AXIS_Z] = mmc35240_props_table[data->res].sens[AXIS_Z];
|
|
|
|
|
|
nfo = mmc35240_props_table[data->res].nfo;
|
|
nfo = mmc35240_props_table[data->res].nfo;
|
|
|
|
|
|
switch (index) {
|
|
switch (index) {
|
|
case AXIS_X:
|
|
case AXIS_X:
|
|
- *val = (raw_x - nfo) * 1000 / sens_x;
|
|
|
|
|
|
+ *val = (raw[AXIS_X] - nfo) * 1000 / sens[AXIS_X];
|
|
break;
|
|
break;
|
|
case AXIS_Y:
|
|
case AXIS_Y:
|
|
- *val = (raw_y - nfo) * 1000 / sens_y -
|
|
|
|
- (raw_z - nfo) * 1000 / sens_z;
|
|
|
|
|
|
+ *val = (raw[AXIS_Y] - nfo) * 1000 / sens[AXIS_Y] -
|
|
|
|
+ (raw[AXIS_Z] - nfo) * 1000 / sens[AXIS_Z];
|
|
break;
|
|
break;
|
|
case AXIS_Z:
|
|
case AXIS_Z:
|
|
- *val = (raw_y - nfo) * 1000 / sens_y +
|
|
|
|
- (raw_z - nfo) * 1000 / sens_z;
|
|
|
|
|
|
+ *val = (raw[AXIS_Y] - nfo) * 1000 / sens[AXIS_Y] +
|
|
|
|
+ (raw[AXIS_Z] - nfo) * 1000 / sens[AXIS_Z];
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
return -EINVAL;
|
|
return -EINVAL;
|