[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <hinocg3itjqizbmzgaxv6cfnhtus6wbykouiy6pa27cxnjjuuk@l5ppwh7md6ul>
Date: Thu, 20 Mar 2025 08:50:00 +0100
From: Uwe Kleine-König <ukleinek@...nel.org>
To: Andy Shevchenko <andriy.shevchenko@...el.com>,
mathieu.dubois-briand@...tlin.com
Cc: Lee Jones <lee@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Kamel Bouhara <kamel.bouhara@...tlin.com>, Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>, Dmitry Torokhov <dmitry.torokhov@...il.com>,
Michael Walle <mwalle@...nel.org>, Mark Brown <broonie@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>, "Rafael J. Wysocki" <rafael@...nel.org>,
Danilo Krummrich <dakr@...nel.org>, devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-gpio@...r.kernel.org, linux-input@...r.kernel.org, linux-pwm@...r.kernel.org,
Grégory Clement <gregory.clement@...tlin.com>, Thomas Petazzoni <thomas.petazzoni@...tlin.com>
Subject: Re: [PATCH v5 04/11] pwm: max7360: Add MAX7360 PWM support
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@...tlin.com wrote:
> > +static int max7360_pwm_round_waveform_tohw(struct pwm_chip *chip,
> > + struct pwm_device *pwm,
> > + const struct pwm_waveform *wf,
> > + void *_wfhw)
>
> I would expect other way around, i.e. naming with leading underscore(s) to be
> private / local. Ditto for all similar cases.
I guess that one of the other waveform drivers is the source of that. I
chose to name the void pointer with the underscore because I consider
that the strange one that has the void* type for technical reasons.
That's obviously subjective, but I'm happy with that choice.
> > +static int max7360_pwm_probe(struct platform_device *pdev)
> > +{
> > + struct device *dev = &pdev->dev;
> > + struct pwm_chip *chip;
> > + struct regmap *regmap;
> > + int ret;
> > +
> > + if (!dev->parent)
> > + return dev_err_probe(dev, -ENODEV, "no parent device\n");
>
> Why? Code most likely will fail on the regmap retrieval. Just do that first.
>
> > + 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().
Best regards
Uwe
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists