[v1,0/2] Update APDS990x ALS to support device trees

Message ID 20230731110239.107086-1-clamor95@gmail.com
Headers
Series Update APDS990x ALS to support device trees |

Message

Svyatoslav Ryhel July 31, 2023, 11:02 a.m. UTC
  This patchset is the successor of a wider patch called
'Update APDS990x ALS to support IIO'. I have decided to divide it into
two separate patches to ease review and submitting. All suggestions
from the previous patchset were applied.

This part is dedicated to including device tree support into APDS990x.
APDS990x is a combined ambient light and proximity sensor. ALS and
proximity functionality are highly connected. From mandatory properties
required by device (apart of compatible and address on i2c line) are
two supplies, interrupt, pdrive (LED drive current) and ppcount (the
number of IR calibration pulses).

These patches are oriented ONLY on bringing support of device tree into
driver, pdrive and ppcount are mandatory and datasheet nor driver does
not provide any reference values.

Namings and compatible properties derive from the original driver name.

Svyatoslav Ryhel (2):
  dt-bindings: iio: light: add apds990x binding
  misc: adps990x: convert to OF

 .../bindings/iio/light/avago,apds990x.yaml    | 87 +++++++++++++++++++
 drivers/misc/apds990x.c                       | 55 ++++++++++--
 2 files changed, 135 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/light/avago,apds990x.yaml
  

Comments

Arnd Bergmann July 31, 2023, 1:18 p.m. UTC | #1
On Mon, Jul 31, 2023, at 13:02, Svyatoslav Ryhel wrote:
> Add ability to use device tree bindings keeping existing setup.

I see that there are no more in-tree users of the old
apds990x_platform_data, so I think it would be best to completely
remove that codepath and merge that structure into struct
apds990x_chip, to simplify the probing and avoid the extra
allocation.

   Arnd
  
Svyatoslav Ryhel July 31, 2023, 2:58 p.m. UTC | #2
31 липня 2023 р. 16:18:16 GMT+03:00, Arnd Bergmann <arnd@arndb.de> написав(-ла):
>On Mon, Jul 31, 2023, at 13:02, Svyatoslav Ryhel wrote:
>> Add ability to use device tree bindings keeping existing setup.
>
>I see that there are no more in-tree users of the old
>apds990x_platform_data, so I think it would be best to completely
>remove that codepath and merge that structure into struct
>apds990x_chip, to simplify the probing and avoid the extra
>allocation.

Thank you very much for your review, but is it mandatory to drop pdata in this particular patch set? To be honest this driver needs serious upgrades and refactoring, and I have no dedication to invest my time into refactoring it, moreover, I am not a maintainer of this driver, nor a full time kernel maintainer of any kind. I am doing what I am doing only because one of my devices uses this als but it is not something crucial.

Best regards,
Svyatoslav R.

>   Arnd
  
Arnd Bergmann July 31, 2023, 3:38 p.m. UTC | #3
On Mon, Jul 31, 2023, at 16:58, Svyatoslav Ryhel wrote:
> 31 липня 2023 р. 16:18:16 GMT+03:00, Arnd Bergmann <arnd@arndb.de> написав(-ла):
>>On Mon, Jul 31, 2023, at 13:02, Svyatoslav Ryhel wrote:
>>> Add ability to use device tree bindings keeping existing setup.
>>
>>I see that there are no more in-tree users of the old
>>apds990x_platform_data, so I think it would be best to completely
>>remove that codepath and merge that structure into struct
>>apds990x_chip, to simplify the probing and avoid the extra
>>allocation.
>
> Thank you very much for your review, but is it mandatory to drop pdata 
> in this particular patch set? To be honest this driver needs serious 
> upgrades and refactoring, and I have no dedication to invest my time 
> into refactoring it, moreover, I am not a maintainer of this driver, 
> nor a full time kernel maintainer of any kind. I am doing what I am 
> doing only because one of my devices uses this als but it is not 
> something crucial.

We have a lot of drivers that are lacking the cleanup I'm asking
for, so I don't think I'd mandate it at this point, but I don't
actually expect the patch to be any more complicated in the end,
so just try it out.

I think at the minimum, please remove the include/platform_data
header and move the contents into the driver itself, I'd be fine
with that. If you can easily do further cleanup by dropping
the separate allocation and folding the apds990x_fw_probe()
function back into apds990x_probe(), please do that, just stop
at the point where you feel it gets too complicated.

    Arnd
  
Jonathan Cameron Aug. 1, 2023, 6:10 p.m. UTC | #4
On Mon, 31 Jul 2023 17:38:59 +0200
"Arnd Bergmann" <arnd@arndb.de> wrote:

> On Mon, Jul 31, 2023, at 16:58, Svyatoslav Ryhel wrote:
> > 31 липня 2023 р. 16:18:16 GMT+03:00, Arnd Bergmann <arnd@arndb.de> написав(-ла):  
> >>On Mon, Jul 31, 2023, at 13:02, Svyatoslav Ryhel wrote:  
> >>> Add ability to use device tree bindings keeping existing setup.  
> >>
> >>I see that there are no more in-tree users of the old
> >>apds990x_platform_data, so I think it would be best to completely
> >>remove that codepath and merge that structure into struct
> >>apds990x_chip, to simplify the probing and avoid the extra
> >>allocation.  
> >
> > Thank you very much for your review, but is it mandatory to drop pdata 
> > in this particular patch set? To be honest this driver needs serious 
> > upgrades and refactoring, and I have no dedication to invest my time 
> > into refactoring it, moreover, I am not a maintainer of this driver, 
> > nor a full time kernel maintainer of any kind. I am doing what I am 
> > doing only because one of my devices uses this als but it is not 
> > something crucial.  
> 
> We have a lot of drivers that are lacking the cleanup I'm asking
> for, so I don't think I'd mandate it at this point, but I don't
> actually expect the patch to be any more complicated in the end,
> so just try it out.
> 
> I think at the minimum, please remove the include/platform_data
> header and move the contents into the driver itself, I'd be fine
> with that. If you can easily do further cleanup by dropping
> the separate allocation and folding the apds990x_fw_probe()
> function back into apds990x_probe(), please do that, just stop
> at the point where you feel it gets too complicated.
> 

It's a long shot, but this looks pretty close in register map to
the apds9960 in IIO.

Maybe try adding the ID to that driver and cross your fingers?

There is some stuff going on around the register address / commands
that I haven't figured out but it looks similar for the byte access
path and that may be all the IIO driver is using.

If you are fine testing, it's possible someone else might do the
leg work (if me I'll emulate just enough to convince myself I didn't
break it too badly). Won't be high on my list, but maybe I'll get
a boring wet weekend sometime...

Jonathan

>     Arnd
  
Svyatoslav Ryhel Aug. 1, 2023, 6:13 p.m. UTC | #5
1 серпня 2023 р. 21:10:26 GMT+03:00, Jonathan Cameron <jic23@kernel.org> написав(-ла):
>On Mon, 31 Jul 2023 17:38:59 +0200
>"Arnd Bergmann" <arnd@arndb.de> wrote:
>
>> On Mon, Jul 31, 2023, at 16:58, Svyatoslav Ryhel wrote:
>> > 31 липня 2023 р. 16:18:16 GMT+03:00, Arnd Bergmann <arnd@arndb.de> написав(-ла):  
>> >>On Mon, Jul 31, 2023, at 13:02, Svyatoslav Ryhel wrote:  
>> >>> Add ability to use device tree bindings keeping existing setup.  
>> >>
>> >>I see that there are no more in-tree users of the old
>> >>apds990x_platform_data, so I think it would be best to completely
>> >>remove that codepath and merge that structure into struct
>> >>apds990x_chip, to simplify the probing and avoid the extra
>> >>allocation.  
>> >
>> > Thank you very much for your review, but is it mandatory to drop pdata 
>> > in this particular patch set? To be honest this driver needs serious 
>> > upgrades and refactoring, and I have no dedication to invest my time 
>> > into refactoring it, moreover, I am not a maintainer of this driver, 
>> > nor a full time kernel maintainer of any kind. I am doing what I am 
>> > doing only because one of my devices uses this als but it is not 
>> > something crucial.  
>> 
>> We have a lot of drivers that are lacking the cleanup I'm asking
>> for, so I don't think I'd mandate it at this point, but I don't
>> actually expect the patch to be any more complicated in the end,
>> so just try it out.
>> 
>> I think at the minimum, please remove the include/platform_data
>> header and move the contents into the driver itself, I'd be fine
>> with that. If you can easily do further cleanup by dropping
>> the separate allocation and folding the apds990x_fw_probe()
>> function back into apds990x_probe(), please do that, just stop
>> at the point where you feel it gets too complicated.
>> 
>
>It's a long shot, but this looks pretty close in register map to
>the apds9960 in IIO.
>
>Maybe try adding the ID to that driver and cross your fingers?

If you pay me for a broken phone or repair if smth goes wrong, sure, why not.

>There is some stuff going on around the register address / commands
>that I haven't figured out but it looks similar for the byte access
>path and that may be all the IIO driver is using.
>
>If you are fine testing, it's possible someone else might do the
>leg work (if me I'll emulate just enough to convince myself I didn't
>break it too badly). Won't be high on my list, but maybe I'll get
>a boring wet weekend sometime...
>
>Jonathan
>
>>     Arnd
>