Lines Matching refs:ret

220 	int ret;
222 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_CTRL1);
223 if (ret < 0) {
225 return ret;
229 ret &= ~KXCJK1013_REG_CTRL1_BIT_PC1;
231 ret |= KXCJK1013_REG_CTRL1_BIT_PC1;
233 ret = i2c_smbus_write_byte_data(data->client,
234 KXCJK1013_REG_CTRL1, ret);
235 if (ret < 0) {
237 return ret;
246 int ret;
248 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_CTRL1);
249 if (ret < 0) {
251 return ret;
254 if (ret & KXCJK1013_REG_CTRL1_BIT_PC1)
264 int ret;
266 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_CTRL1);
267 if (ret < 0) {
269 return ret;
272 ret &= ~(KXCJK1013_REG_CTRL1_BIT_GSEL0 |
274 ret |= (KXCJK1013_scale_table[range_index].gsel_0 << 3);
275 ret |= (KXCJK1013_scale_table[range_index].gsel_1 << 4);
277 ret = i2c_smbus_write_byte_data(data->client,
279 ret);
280 if (ret < 0) {
282 return ret;
292 int ret;
294 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_WHO_AM_I);
295 if (ret < 0) {
297 return ret;
300 dev_dbg(&data->client->dev, "KXCJK1013 Chip Id %x\n", ret);
302 ret = kxcjk1013_set_mode(data, STANDBY);
303 if (ret < 0)
304 return ret;
306 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_CTRL1);
307 if (ret < 0) {
309 return ret;
313 ret |= KXCJK1013_REG_CTRL1_BIT_RES;
315 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_CTRL1,
316 ret);
317 if (ret < 0) {
319 return ret;
323 ret = kxcjk1013_set_range(data, KXCJK1013_RANGE_4G);
324 if (ret < 0)
325 return ret;
327 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_DATA_CTRL);
328 if (ret < 0) {
330 return ret;
333 data->odr_bits = ret;
336 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_INT_CTRL1);
337 if (ret < 0) {
339 return ret;
343 ret |= KXCJK1013_REG_INT_REG1_BIT_IEA;
345 ret &= ~KXCJK1013_REG_INT_REG1_BIT_IEA;
347 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_INT_CTRL1,
348 ret);
349 if (ret < 0) {
351 return ret;
354 ret = kxcjk1013_set_mode(data, OPERATION);
355 if (ret < 0)
356 return ret;
380 int ret;
383 ret = pm_runtime_get_sync(&data->client->dev);
386 ret = pm_runtime_put_autosuspend(&data->client->dev);
388 if (ret < 0) {
391 return ret;
399 int ret;
401 ret = i2c_smbus_write_byte_data(data->client,
404 if (ret < 0) {
407 return ret;
410 ret = i2c_smbus_write_byte_data(data->client,
413 if (ret < 0) {
415 return ret;
424 int ret;
427 ret = kxcjk1013_get_mode(data, &store_mode);
428 if (ret < 0)
429 return ret;
432 ret = kxcjk1013_set_mode(data, STANDBY);
433 if (ret < 0)
434 return ret;
436 ret = kxcjk1013_chip_update_thresholds(data);
437 if (ret < 0)
438 return ret;
440 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_INT_CTRL1);
441 if (ret < 0) {
443 return ret;
447 ret |= KXCJK1013_REG_INT_REG1_BIT_IEN;
449 ret &= ~KXCJK1013_REG_INT_REG1_BIT_IEN;
451 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_INT_CTRL1,
452 ret);
453 if (ret < 0) {
455 return ret;
458 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_CTRL1);
459 if (ret < 0) {
461 return ret;
465 ret |= KXCJK1013_REG_CTRL1_BIT_WUFE;
467 ret &= ~KXCJK1013_REG_CTRL1_BIT_WUFE;
469 ret = i2c_smbus_write_byte_data(data->client,
470 KXCJK1013_REG_CTRL1, ret);
471 if (ret < 0) {
473 return ret;
477 ret = kxcjk1013_set_mode(data, OPERATION);
478 if (ret < 0)
479 return ret;
488 int ret;
491 ret = kxcjk1013_get_mode(data, &store_mode);
492 if (ret < 0)
493 return ret;
496 ret = kxcjk1013_set_mode(data, STANDBY);
497 if (ret < 0)
498 return ret;
500 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_INT_CTRL1);
501 if (ret < 0) {
503 return ret;
507 ret |= KXCJK1013_REG_INT_REG1_BIT_IEN;
509 ret &= ~KXCJK1013_REG_INT_REG1_BIT_IEN;
511 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_INT_CTRL1,
512 ret);
513 if (ret < 0) {
515 return ret;
518 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_CTRL1);
519 if (ret < 0) {
521 return ret;
525 ret |= KXCJK1013_REG_CTRL1_BIT_DRDY;
527 ret &= ~KXCJK1013_REG_CTRL1_BIT_DRDY;
529 ret = i2c_smbus_write_byte_data(data->client,
530 KXCJK1013_REG_CTRL1, ret);
531 if (ret < 0) {
533 return ret;
537 ret = kxcjk1013_set_mode(data, OPERATION);
538 if (ret < 0)
539 return ret;
575 int ret;
579 ret = kxcjk1013_get_mode(data, &store_mode);
580 if (ret < 0)
581 return ret;
588 ret = kxcjk1013_set_mode(data, STANDBY);
589 if (ret < 0)
590 return ret;
592 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_DATA_CTRL,
594 if (ret < 0) {
596 return ret;
605 ret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_CTRL2,
607 if (ret < 0) {
609 return ret;
613 ret = kxcjk1013_set_mode(data, OPERATION);
614 if (ret < 0)
615 return ret;
639 int ret;
641 ret = i2c_smbus_read_word_data(data->client, reg);
642 if (ret < 0) {
645 return ret;
648 return ret;
653 int ret, i;
660 ret = kxcjk1013_get_mode(data, &store_mode);
661 if (ret < 0)
662 return ret;
664 ret = kxcjk1013_set_mode(data, STANDBY);
665 if (ret < 0)
666 return ret;
668 ret = kxcjk1013_set_range(data, i);
669 if (ret < 0)
670 return ret;
673 ret = kxcjk1013_set_mode(data, OPERATION);
674 if (ret)
675 return ret;
690 int ret;
696 ret = -EBUSY;
698 ret = kxcjk1013_set_power_state(data, true);
699 if (ret < 0) {
701 return ret;
703 ret = kxcjk1013_get_acc_reg(data, chan->scan_index);
704 if (ret < 0) {
707 return ret;
709 *val = sign_extend32(ret >> 4, 11);
710 ret = kxcjk1013_set_power_state(data, false);
714 if (ret < 0)
715 return ret;
726 ret = kxcjk1013_get_odr(data, val, val2);
728 return ret;
740 int ret;
745 ret = kxcjk1013_set_odr(data, val, val2);
753 ret = kxcjk1013_set_scale(data, val2);
757 ret = -EINVAL;
760 return ret;
831 int ret;
853 ret = kxcjk1013_set_power_state(data, state);
854 if (ret < 0) {
856 return ret;
859 ret = kxcjk1013_setup_any_motion_interrupt(data, state);
860 if (ret < 0) {
862 return ret;
948 int bit, ret, i = 0;
954 ret = kxcjk1013_get_acc_reg(data, bit);
955 if (ret < 0) {
959 data->buffer[i++] = ret;
975 int ret;
977 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_INT_REL);
978 if (ret < 0) {
980 return ret;
991 int ret;
1001 ret = kxcjk1013_set_power_state(data, state);
1002 if (ret < 0) {
1004 return ret;
1007 ret = kxcjk1013_setup_any_motion_interrupt(data, state);
1009 ret = kxcjk1013_setup_new_data_interrupt(data, state);
1010 if (ret < 0) {
1012 return ret;
1034 int ret;
1036 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_INT_SRC1);
1037 if (ret < 0) {
1042 if (ret & 0x02) {
1043 ret = i2c_smbus_read_byte_data(data->client,
1045 if (ret < 0) {
1051 if (ret & KXCJK1013_REG_INT_SRC2_BIT_XN)
1059 if (ret & KXCJK1013_REG_INT_SRC2_BIT_XP)
1069 if (ret & KXCJK1013_REG_INT_SRC2_BIT_YN)
1077 if (ret & KXCJK1013_REG_INT_SRC2_BIT_YP)
1086 if (ret & KXCJK1013_REG_INT_SRC2_BIT_ZN)
1094 if (ret & KXCJK1013_REG_INT_SRC2_BIT_ZP)
1108 ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_INT_REL);
1109 if (ret < 0)
1150 int ret;
1164 ret = gpiod_direction_input(gpio);
1165 if (ret)
1166 return ret;
1168 ret = gpiod_to_irq(gpio);
1170 dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
1172 return ret;
1182 int ret;
1207 ret = kxcjk1013_chip_init(data);
1208 if (ret < 0)
1209 return ret;
1224 ret = devm_request_threaded_irq(&client->dev, client->irq,
1230 if (ret)
1231 return ret;
1252 ret = iio_trigger_register(data->dready_trig);
1253 if (ret)
1254 return ret;
1259 ret = iio_trigger_register(data->motion_trig);
1260 if (ret) {
1265 ret = iio_triggered_buffer_setup(indio_dev,
1269 if (ret < 0) {
1276 ret = iio_device_register(indio_dev);
1277 if (ret < 0) {
1282 ret = pm_runtime_set_active(&client->dev);
1283 if (ret)
1304 return ret;
1336 int ret;
1339 ret = kxcjk1013_set_mode(data, STANDBY);
1342 return ret;
1349 int ret = 0;
1355 ret = kxcjk1013_set_mode(data, OPERATION);
1358 return ret;
1375 int ret;
1378 ret = kxcjk1013_set_mode(data, OPERATION);
1379 if (ret < 0)
1380 return ret;