summaryrefslogtreecommitdiff
path: root/driver/als_si114x.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-08-25 18:22:24 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-08-29 00:04:15 -0700
commit7a2299163b7769b546db53c0dd225eee9e0a0df1 (patch)
tree6fed3596ec94354b08d85ce2b65621aedd2794e2 /driver/als_si114x.c
parent252dce9bd3d70b09e33aba17580ad11d1203ee73 (diff)
downloadchrome-ec-7a2299163b7769b546db53c0dd225eee9e0a0df1.tar.gz
driver: change get_ interface.
Simplify sensor get_data_rate, get_range and get_resolution. Error code was not checked and these functions as currently implemented have no reason to fail. BRANCH=ryu,samus,cyan,strago BUG=chromium:513458 TEST=Check on ryu, compile Change-Id: I40dca41cee29a19f65b2f84d434b4c19eb6cbf3c Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/295635 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Diffstat (limited to 'driver/als_si114x.c')
-rw-r--r--driver/als_si114x.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/driver/als_si114x.c b/driver/als_si114x.c
index 6441873ed7..c7a3d0374a 100644
--- a/driver/als_si114x.c
+++ b/driver/als_si114x.c
@@ -391,8 +391,7 @@ static int set_resolution(const struct motion_sensor_t *s,
return ret;
}
-static int get_resolution(const struct motion_sensor_t *s,
- int *res)
+static int get_resolution(const struct motion_sensor_t *s)
{
int ret, reg, val;
if (s->type == MOTIONSENSE_TYPE_PROX)
@@ -404,10 +403,9 @@ static int get_resolution(const struct motion_sensor_t *s,
val = 0;
ret = si114x_param_op(s, SI114X_CMD_PARAM_QUERY, reg, &val);
if (ret != EC_SUCCESS)
- return ret;
+ return -1;
- *res = val & 0x07;
- return EC_SUCCESS;
+ return val & 0x07;
}
static int set_range(const struct motion_sensor_t *s,
@@ -420,21 +418,17 @@ static int set_range(const struct motion_sensor_t *s,
return EC_SUCCESS;
}
-static int get_range(const struct motion_sensor_t *s,
- int *range)
+static int get_range(const struct motion_sensor_t *s)
{
struct si114x_typed_data_t *data = SI114X_GET_TYPED_DATA(s);
- *range = (data->scale << 16) | (data->uscale);
- return EC_SUCCESS;
+ return (data->scale << 16) | (data->uscale);
}
-static int get_data_rate(const struct motion_sensor_t *s,
- int *rate)
+static int get_data_rate(const struct motion_sensor_t *s)
{
/* Sensor in forced mode, rate is used by motion_sense */
struct si114x_typed_data_t *data = SI114X_GET_TYPED_DATA(s);
- *rate = data->rate;
- return EC_SUCCESS;
+ return data->rate;
}
static int set_data_rate(const struct motion_sensor_t *s,
@@ -501,7 +495,7 @@ static int init(const struct motion_sensor_t *s)
set_resolution(s, resol, 0);
CPRINTF("[%T %s: MS Done Init type:0x%X range:%d]\n",
- s->name, s->type, s->runtime_config.range);
+ s->name, s->type, get_range(s));
return EC_SUCCESS;
}