Re: [PATCH v2 2/6] platform/x86: dell-smo8800: Move instantiation of lis3lv02d i2c_client from i2c-i801 to dell-smo8800

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

 



On Tue, Feb 27, 2024 at 11:50 PM Pali Rohár <pali@xxxxxxxxxx> wrote:
> On Tuesday 27 February 2024 23:19:19 Andy Shevchenko wrote:
> > On Tue, Feb 27, 2024 at 11:04 PM Pali Rohár <pali@xxxxxxxxxx> wrote:

...

> > I'm wondering why we need all this. We have notifiers when a device is
> > added / removed. We can provide a board_info for the device and attach
> > it to the proper adapter, no?
>
> I do not know how flexible are notifiers. Can notifier call our callback
> when new "struct i2c_adapter *adapter" was instanced?

You can follow notifications of *an* I2C adapter being added /
removed. With that, you can filter which one is that. Based on that
you may attach a saved (at __init as you talked about in the reply to
Hans) board_info with all necessary information.

Something like this (combined)
https://elixir.bootlin.com/linux/latest/source/drivers/ptp/ptp_ocp.c#L4515
https://elixir.bootlin.com/linux/latest/source/drivers/input/mouse/psmouse-smbus.c#L194

> > > With this simple change all dell smo8800 code would be in its subdir
> > > drivers/platform/x86/dell/ and i2c-i801.c would get rid of smo code.
> > >
> > > This approach does not change any functionality, so should be absolutely
> > > safe.
> > >
> > > Future changes will be done only in drivers/platform/x86/dell/ subdir,
> > > touching i801 would not be needed at all.
> >
> > Still these exported functions are not the best solution we can do,
> > right? We should be able to decouple them without need for the custom
> > APIs.
>
> Well, what I described here is a simple change which get rid of the one
> problem: i2c-i801.c contains SMO88xx related code and changing SMO88xx
> logic (like adding a new device id) requires touching unrelated
> i2c-i801.c source file.

`get rid of one problem` --> `replace one by another (but maybe less
critical, dunno) problem`. The new one is the spread of custom APIs
for a single user, which also requires an additional, shared header
file and all hell with the Kconfig dependencies.

> I like small changes which can be easily reviewed and address one
> problem. Step by step. That is why I proposed it here.
>
> For decoupling it is needed to get newly instanced adapter (if the
> mentioned notifier is able to tell this information) and also it is
> needed to check if the adapter is the i801.

Yes.


-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux