Re: [PATCH 2/2] iio: light: Add support for APDS9306 Light Sensor

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

 



On 10/10/23 20:15, Matti Vaittinen wrote:


To my eyes this driver looks nice. Just spotted two minor things.


Thanks Matti. Nice is one nice thing I heard after some time!

+    gain_new_closest = iio_find_closest_gain_low(&data->gts, gain_new, &ok);
+    if (gain_new_closest < 0) {
+        gain_new_closest = iio_gts_get_min_gain(&data->gts);
+        if (gain_new_closest < 0)
+            return gain_new_closest < 0;

Returning the truth value on purpose? :)

Nope, it's a bug. I'll fix it.

+static int get_device_id_lux_per_count(struct apds9306_data *data)
+{
+    int ret, part_id;
+
+    ret = regmap_read(data->regmap, APDS9306_PART_ID, &part_id);
+    if (ret)
+        return ret;
+
+    if (part_id == apds9306_part_id_nlux_per_count[0].part_id)
+        data->nlux_per_count =
+            apds9306_part_id_nlux_per_count[0].nlux_per_count;
+    else if (part_id == apds9306_part_id_nlux_per_count[1].part_id)
+        data->nlux_per_count =
+            apds9306_part_id_nlux_per_count[1].nlux_per_count;
+    else
+        return -ENXIO;

I think we should be able to differentiate between the IC variants by DT compatible. (Commented that on bindings patch). Not sure if we need to support cases where the sensor is instantiated without device-tree. I am not super happy when code requires the part-id to be known if we have separate compatibles for variants. Can we in dt-case just print a warning if the part-ID is not what we expect - and proceed assuming the nlux_per_count based on the DT information? (Sometimes we see new variants with same part-IDs - or many part-IDs with no SW changes needed. Hence maintaining the part-ID lists may be tedious). This is just some pondering though, no strong requirements from my side

Yes, I agree with you. The purpose of DT is to provide proper hardware descriptions.
I will throw a warning as well as implement a compatibility match.

Regards,
Subhajit Ghosh





[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