isl29501 197 drivers/iio/proximity/isl29501.c static int isl29501_register_read(struct isl29501_private *isl29501, isl29501 205 drivers/iio/proximity/isl29501.c mutex_lock(&isl29501->lock); isl29501 207 drivers/iio/proximity/isl29501.c ret = i2c_smbus_read_byte_data(isl29501->client, reg->msb); isl29501 214 drivers/iio/proximity/isl29501.c ret = i2c_smbus_read_byte_data(isl29501->client, reg->lsb); isl29501 219 drivers/iio/proximity/isl29501.c mutex_unlock(&isl29501->lock); isl29501 225 drivers/iio/proximity/isl29501.c mutex_unlock(&isl29501->lock); isl29501 230 drivers/iio/proximity/isl29501.c static u32 isl29501_register_write(struct isl29501_private *isl29501, isl29501 243 drivers/iio/proximity/isl29501.c mutex_lock(&isl29501->lock); isl29501 245 drivers/iio/proximity/isl29501.c ret = i2c_smbus_write_byte_data(isl29501->client, isl29501 251 drivers/iio/proximity/isl29501.c ret = i2c_smbus_write_byte_data(isl29501->client, reg->lsb, value); isl29501 254 drivers/iio/proximity/isl29501.c mutex_unlock(&isl29501->lock); isl29501 263 drivers/iio/proximity/isl29501.c struct isl29501_private *isl29501 = iio_priv(indio_dev); isl29501 271 drivers/iio/proximity/isl29501.c ret = isl29501_register_read(isl29501, reg, &gain); isl29501 281 drivers/iio/proximity/isl29501.c ret = isl29501_register_read(isl29501, REG_PHASE_EXP, &exp); isl29501 285 drivers/iio/proximity/isl29501.c ret = isl29501_register_read(isl29501, reg, &coeff); isl29501 298 drivers/iio/proximity/isl29501.c static int isl29501_set_shadow_coeff(struct isl29501_private *isl29501, isl29501 320 drivers/iio/proximity/isl29501.c isl29501->shadow_coeffs[coeff] = val; isl29501 325 drivers/iio/proximity/isl29501.c static int isl29501_write_coeff(struct isl29501_private *isl29501, isl29501 348 drivers/iio/proximity/isl29501.c return isl29501_register_write(isl29501, reg, val); isl29501 385 drivers/iio/proximity/isl29501.c struct isl29501_private *isl29501 = iio_priv(indio_dev); isl29501 401 drivers/iio/proximity/isl29501.c ret = isl29501_register_write(isl29501, reg, val); isl29501 415 drivers/iio/proximity/isl29501.c ret = isl29501_set_shadow_coeff(isl29501, reg, val); isl29501 427 drivers/iio/proximity/isl29501.c corr = isl29501->shadow_coeffs[i]; isl29501 431 drivers/iio/proximity/isl29501.c dev_dbg(&isl29501->client->dev, isl29501 446 drivers/iio/proximity/isl29501.c corr = isl29501->shadow_coeffs[i]; isl29501 452 drivers/iio/proximity/isl29501.c ret = isl29501_write_coeff(isl29501, i, mantissa); isl29501 457 drivers/iio/proximity/isl29501.c ret = isl29501_register_write(isl29501, REG_PHASE_EXP, max_exp); isl29501 539 drivers/iio/proximity/isl29501.c static int isl29501_reset_registers(struct isl29501_private *isl29501) isl29501 543 drivers/iio/proximity/isl29501.c ret = i2c_smbus_write_byte_data(isl29501->client, isl29501 547 drivers/iio/proximity/isl29501.c dev_err(&isl29501->client->dev, isl29501 552 drivers/iio/proximity/isl29501.c ret = i2c_smbus_write_byte_data(isl29501->client, isl29501 556 drivers/iio/proximity/isl29501.c dev_err(&isl29501->client->dev, isl29501 562 drivers/iio/proximity/isl29501.c static int isl29501_begin_acquisition(struct isl29501_private *isl29501) isl29501 566 drivers/iio/proximity/isl29501.c ret = i2c_smbus_write_byte_data(isl29501->client, isl29501 570 drivers/iio/proximity/isl29501.c dev_err(&isl29501->client->dev, isl29501 612 drivers/iio/proximity/isl29501.c static int isl29501_get_raw(struct isl29501_private *isl29501, isl29501 620 drivers/iio/proximity/isl29501.c ret = isl29501_register_read(isl29501, REG_DISTANCE, raw); isl29501 626 drivers/iio/proximity/isl29501.c ret = isl29501_register_read(isl29501, isl29501 634 drivers/iio/proximity/isl29501.c ret = isl29501_register_read(isl29501, REG_PHASE, raw); isl29501 640 drivers/iio/proximity/isl29501.c ret = isl29501_register_read(isl29501, REG_EMITTER_DAC, raw); isl29501 646 drivers/iio/proximity/isl29501.c ret = isl29501_register_read(isl29501, REG_TEMPERATURE, raw); isl29501 656 drivers/iio/proximity/isl29501.c static int isl29501_get_scale(struct isl29501_private *isl29501, isl29501 683 drivers/iio/proximity/isl29501.c ret = isl29501_register_read(isl29501, isl29501 713 drivers/iio/proximity/isl29501.c static int isl29501_get_calibbias(struct isl29501_private *isl29501, isl29501 719 drivers/iio/proximity/isl29501.c return isl29501_register_read(isl29501, isl29501 723 drivers/iio/proximity/isl29501.c return isl29501_register_read(isl29501, isl29501 731 drivers/iio/proximity/isl29501.c static int isl29501_get_inttime(struct isl29501_private *isl29501, isl29501 737 drivers/iio/proximity/isl29501.c ret = isl29501_register_read(isl29501, REG_INT_TIME, &inttime); isl29501 750 drivers/iio/proximity/isl29501.c static int isl29501_get_freq(struct isl29501_private *isl29501, isl29501 758 drivers/iio/proximity/isl29501.c ret = isl29501_register_read(isl29501, REG_SAMPLE_TIME, &sample_time); isl29501 778 drivers/iio/proximity/isl29501.c struct isl29501_private *isl29501 = iio_priv(indio_dev); isl29501 782 drivers/iio/proximity/isl29501.c return isl29501_get_raw(isl29501, chan, val); isl29501 784 drivers/iio/proximity/isl29501.c return isl29501_get_scale(isl29501, chan, val, val2); isl29501 786 drivers/iio/proximity/isl29501.c return isl29501_get_inttime(isl29501, val, val2); isl29501 788 drivers/iio/proximity/isl29501.c return isl29501_get_freq(isl29501, val, val2); isl29501 790 drivers/iio/proximity/isl29501.c return isl29501_get_calibbias(isl29501, chan, val); isl29501 796 drivers/iio/proximity/isl29501.c static int isl29501_set_raw(struct isl29501_private *isl29501, isl29501 802 drivers/iio/proximity/isl29501.c return isl29501_register_write(isl29501, REG_EMITTER_DAC, raw); isl29501 808 drivers/iio/proximity/isl29501.c static int isl29501_set_inttime(struct isl29501_private *isl29501, isl29501 816 drivers/iio/proximity/isl29501.c return isl29501_register_write(isl29501, isl29501 825 drivers/iio/proximity/isl29501.c static int isl29501_set_scale(struct isl29501_private *isl29501, isl29501 837 drivers/iio/proximity/isl29501.c return isl29501_register_write(isl29501, isl29501 846 drivers/iio/proximity/isl29501.c static int isl29501_set_calibbias(struct isl29501_private *isl29501, isl29501 852 drivers/iio/proximity/isl29501.c return isl29501_register_write(isl29501, isl29501 856 drivers/iio/proximity/isl29501.c return isl29501_register_write(isl29501, isl29501 864 drivers/iio/proximity/isl29501.c static int isl29501_set_freq(struct isl29501_private *isl29501, isl29501 880 drivers/iio/proximity/isl29501.c return isl29501_register_write(isl29501, REG_SAMPLE_TIME, sample_time); isl29501 887 drivers/iio/proximity/isl29501.c struct isl29501_private *isl29501 = iio_priv(indio_dev); isl29501 891 drivers/iio/proximity/isl29501.c return isl29501_set_raw(isl29501, chan, val); isl29501 893 drivers/iio/proximity/isl29501.c return isl29501_set_inttime(isl29501, val, val2); isl29501 895 drivers/iio/proximity/isl29501.c return isl29501_set_freq(isl29501, val, val2); isl29501 897 drivers/iio/proximity/isl29501.c return isl29501_set_scale(isl29501, chan, val, val2); isl29501 899 drivers/iio/proximity/isl29501.c return isl29501_set_calibbias(isl29501, chan, val); isl29501 911 drivers/iio/proximity/isl29501.c static int isl29501_init_chip(struct isl29501_private *isl29501) isl29501 915 drivers/iio/proximity/isl29501.c ret = i2c_smbus_read_byte_data(isl29501->client, ISL29501_DEVICE_ID); isl29501 917 drivers/iio/proximity/isl29501.c dev_err(&isl29501->client->dev, "Error reading device id\n"); isl29501 922 drivers/iio/proximity/isl29501.c dev_err(&isl29501->client->dev, isl29501 928 drivers/iio/proximity/isl29501.c ret = isl29501_reset_registers(isl29501); isl29501 932 drivers/iio/proximity/isl29501.c return isl29501_begin_acquisition(isl29501); isl29501 939 drivers/iio/proximity/isl29501.c struct isl29501_private *isl29501 = iio_priv(indio_dev); isl29501 944 drivers/iio/proximity/isl29501.c isl29501_register_read(isl29501, REG_DISTANCE, buffer); isl29501 956 drivers/iio/proximity/isl29501.c struct isl29501_private *isl29501; isl29501 959 drivers/iio/proximity/isl29501.c indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*isl29501)); isl29501 963 drivers/iio/proximity/isl29501.c isl29501 = iio_priv(indio_dev); isl29501 966 drivers/iio/proximity/isl29501.c isl29501->client = client; isl29501 968 drivers/iio/proximity/isl29501.c mutex_init(&isl29501->lock); isl29501 970 drivers/iio/proximity/isl29501.c ret = isl29501_init_chip(isl29501);