Re: [PATCH v5 04/11] pwm: max7360: Add MAX7360 PWM support
From: Andy Shevchenko
Date: Thu Mar 20 2025 - 06:48:44 EST
On Thu, Mar 20, 2025 at 08:50:00AM +0100, Uwe Kleine-König wrote:
> On Wed, Mar 19, 2025 at 01:18:50PM +0200, Andy Shevchenko wrote:
> > On Tue, Mar 18, 2025 at 05:26:20PM +0100, mathieu.dubois-briand@xxxxxxxxxxx wrote:
...
> > > + chip = devm_pwmchip_alloc(dev->parent, MAX7360_NUM_PWMS, 0);
> >
> > This is quite worrying. The devm_ to parent makes a lot of assumptions that may
> > not be realised. If you really need this, it has to have a very good comment
> > explaining why and object lifetimes.
>
> Pretty sure this is broken. This results for example in the device link
> being created on the parent. So if the pwm devices goes away a consumer
> might not notice (at least in the usual way). I guess this was done to
> ensure that #pwm-cells is parsed from the right dt node? If so, that
> needs a different adaption. That will probably involve calling
> device_set_of_node_from_dev().
It's an MFD based driver, and MFD core cares about propagating fwnode by
default. I believe it should just work if we drop that '->parent' part.
--
With Best Regards,
Andy Shevchenko