Re: [PATCH v4 3/3] iio: light: Add support for ltrf216a sensor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 13/05/22 06:00, Dmitry Osipenko wrote:
11.05.2022 12:40, Shreeya Patel пишет:
+static int ltrf216a_set_int_time(struct ltrf216a_data *data, int itime)
+{
+	int i, ret, index = -1;
+	u8 reg_val;
+
+	for (i = 0; i < ARRAY_SIZE(ltrf216a_int_time_available); i++) {
+		if (ltrf216a_int_time_available[i][1] == itime) {
+			index = i;
+			break;
+		}
+	}
+
+	if (index < 0)
+		return -EINVAL;
+
+	reg_val = ltrf216a_int_time_reg[index][1];
+	data->int_time_fac = ltrf216a_int_time_reg[index][0];
+
+	ret = i2c_smbus_write_byte_data(data->client, LTRF216A_ALS_MEAS_RES, reg_val);
+	if (ret < 0)
+		return ret;
Should the data->int_time_fac be updated only if I2C write was successful?

Yes, thanks for pointing it out. It should be updated only if write is successful.

I'm not sure what reading of LTRF216A_CLEAR_DATA reg does, but if it
clears the measured data, then shouldn't the data be cleared after
changing the config?

LTRF216A_CLEAR_DATA isn't used for clearing the measured data. Name is a
bit confusing and even I assumed it is being used for clearing the data. But from the datasheet, it seems that clear data registers provides light intensity data related to infrared
and ultravoilet.
We are currently not using this anywhere in the driver so we could remove the cleardata readings
for now.


Thanks,
Shreeya Patel
+	data->int_time = itime;
+
+	return 0;
+}




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux