Lines Matching refs:lv0104cs

160 static int lv0104cs_get_lux(struct lv0104cs_private *lv0104cs,  in lv0104cs_get_lux()  argument
167 regval |= lv0104cs_scales[lv0104cs->scale].regval; in lv0104cs_get_lux()
168 regval |= lv0104cs_int_times[lv0104cs->int_time].regval; in lv0104cs_get_lux()
169 ret = lv0104cs_write_reg(lv0104cs->client, regval); in lv0104cs_get_lux()
174 switch (lv0104cs->int_time) { in lv0104cs_get_lux()
191 ret = lv0104cs_read_adc(lv0104cs->client, &adc_output); in lv0104cs_get_lux()
195 ret = lv0104cs_write_reg(lv0104cs->client, LV0104CS_REGVAL_SLEEP); in lv0104cs_get_lux()
200 switch (lv0104cs->scale) { in lv0104cs_get_lux()
230 struct lv0104cs_private *lv0104cs = iio_priv(indio_dev); in lv0104cs_read_raw() local
236 mutex_lock(&lv0104cs->lock); in lv0104cs_read_raw()
240 ret = lv0104cs_get_lux(lv0104cs, val, val2); in lv0104cs_read_raw()
247 *val = lv0104cs_calibscales[lv0104cs->calibscale].val; in lv0104cs_read_raw()
248 *val2 = lv0104cs_calibscales[lv0104cs->calibscale].val2; in lv0104cs_read_raw()
253 *val = lv0104cs_scales[lv0104cs->scale].val; in lv0104cs_read_raw()
254 *val2 = lv0104cs_scales[lv0104cs->scale].val2; in lv0104cs_read_raw()
259 *val = lv0104cs_int_times[lv0104cs->int_time].val; in lv0104cs_read_raw()
260 *val2 = lv0104cs_int_times[lv0104cs->int_time].val2; in lv0104cs_read_raw()
269 mutex_unlock(&lv0104cs->lock); in lv0104cs_read_raw()
274 static int lv0104cs_set_calibscale(struct lv0104cs_private *lv0104cs, in lv0104cs_set_calibscale() argument
305 mutex_lock(&lv0104cs->lock); in lv0104cs_set_calibscale()
308 ret = lv0104cs_write_reg(lv0104cs->client, in lv0104cs_set_calibscale()
313 lv0104cs->calibscale = index; in lv0104cs_set_calibscale()
316 mutex_unlock(&lv0104cs->lock); in lv0104cs_set_calibscale()
321 static int lv0104cs_set_scale(struct lv0104cs_private *lv0104cs, in lv0104cs_set_scale() argument
338 mutex_lock(&lv0104cs->lock); in lv0104cs_set_scale()
339 lv0104cs->scale = i; in lv0104cs_set_scale()
340 mutex_unlock(&lv0104cs->lock); in lv0104cs_set_scale()
345 static int lv0104cs_set_int_time(struct lv0104cs_private *lv0104cs, in lv0104cs_set_int_time() argument
362 mutex_lock(&lv0104cs->lock); in lv0104cs_set_int_time()
363 lv0104cs->int_time = i; in lv0104cs_set_int_time()
364 mutex_unlock(&lv0104cs->lock); in lv0104cs_set_int_time()
373 struct lv0104cs_private *lv0104cs = iio_priv(indio_dev); in lv0104cs_write_raw() local
380 return lv0104cs_set_calibscale(lv0104cs, val, val2); in lv0104cs_write_raw()
383 return lv0104cs_set_scale(lv0104cs, val, val2); in lv0104cs_write_raw()
386 return lv0104cs_set_int_time(lv0104cs, val, val2); in lv0104cs_write_raw()
480 struct lv0104cs_private *lv0104cs; in lv0104cs_probe() local
483 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*lv0104cs)); in lv0104cs_probe()
487 lv0104cs = iio_priv(indio_dev); in lv0104cs_probe()
489 i2c_set_clientdata(client, lv0104cs); in lv0104cs_probe()
490 lv0104cs->client = client; in lv0104cs_probe()
492 mutex_init(&lv0104cs->lock); in lv0104cs_probe()
494 lv0104cs->calibscale = LV0104CS_CALIBSCALE_UNITY; in lv0104cs_probe()
495 lv0104cs->scale = LV0104CS_SCALE_1X; in lv0104cs_probe()
496 lv0104cs->int_time = LV0104CS_INTEG_200MS; in lv0104cs_probe()
498 ret = lv0104cs_write_reg(lv0104cs->client, in lv0104cs_probe()