|
|
|
@ -705,6 +705,23 @@ LSM303D::ioctl(struct file *filp, int cmd, unsigned long arg)
@@ -705,6 +705,23 @@ LSM303D::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|
|
|
|
else |
|
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
|
case ACCELIOCSSCALE: |
|
|
|
|
{ |
|
|
|
|
/* copy scale, but only if off by a few percent */ |
|
|
|
|
struct accel_scale *s = (struct accel_scale *) arg; |
|
|
|
|
float sum = s->x_scale + s->y_scale + s->z_scale; |
|
|
|
|
if (sum > 2.0f && sum < 4.0f) { |
|
|
|
|
memcpy(&_accel_scale, s, sizeof(_accel_scale)); |
|
|
|
|
return OK; |
|
|
|
|
} else { |
|
|
|
|
return -EINVAL; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case ACCELIOCGSCALE: |
|
|
|
|
/* copy scale out */ |
|
|
|
|
memcpy((struct accel_scale *) arg, &_accel_scale, sizeof(_accel_scale)); |
|
|
|
|
return OK; |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
/* give it to the superclass */ |
|
|
|
|