Re: [PATCH leds v5 02/12] leds: turris-omnia: Use command execution functions from the MCU driver

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

 



On Mon, Nov 04, 2024 at 04:51:24PM +0200, Andy Shevchenko wrote:
> On Mon, Nov 04, 2024 at 03:19:14PM +0100, Marek Behún wrote:
> > Use the MCU command execution functions from the MCU driver instead of
> > the ad-hoc implementation in the LED driver. This allows as to drop the
> > LED driver implementation, which is a duplicate.
> 
> ...
> 
> > +static int omnia_match_mcu_client(struct device *dev, void *data)
> > +{
> > +	struct i2c_client *client;
> > +
> > +	client = i2c_verify_client(dev);
> > +	if (!client)
> > +		return 0;
> > +
> > +	return client->addr == OMNIA_MCU_I2C_ADDR;
> > +}
> > +
> > +static int omnia_find_mcu_and_get_features(struct device *dev)
> > +{
> > +	struct device *mcu_dev;
> > +	int ret;
> > +
> > +	mcu_dev = device_find_child(dev->parent, NULL, omnia_match_mcu_client);
> > +	if (!mcu_dev)
> > +		return -ENODEV;
> > +
> > +	ret = omnia_mcu_get_features(i2c_verify_client(mcu_dev));
> > +
> > +	put_device(mcu_dev);
> > +
> > +	return ret;
> >  }
> 
> I'm wondering why the MCU driver (and node) is not represented as syscon
> (with some regmap beneath it).
> 
> In such a case it would be something like
> 
>   foo = syscon_regmap_lookup_by_compatible();
> 
> here instead of all these dances.

Hi Andy,

the MCU interface is command-reply oriented. It is incompatible with
regmap. I investigated this back in 2019 and explained to Jacek why it
is not possible, but can't find the e-mail on mailing lists, so I am
attaching it.

So regmap is most probably not possible, unless things changed.

It is possible to add MCU node to the DT binding and find the device
that way. But if the device-tree does not contain the MCU node, the
driver would still have to fall back to this dance, for backwards
compatibility. Otherwise it would not be able to determine whether gamma
correction is supported with old device tree, as it does currently.

I guess I could break backwards compatibility with old device tree with
this small feature. I don't think there are any users that don't use
TurrisOS, do upgrade the kernel, but don't upgrade the device-tree...

Marek




[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