[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <D5272A7B-8943-4AB9-8705-1EC4E9891C1D@goldelico.com>
Date: Wed, 24 Nov 2021 22:28:43 +0100
From: "H. Nikolaus Schaller" <hns@...delico.com>
To: Paul Cercueil <paul@...pouillou.net>
Cc: Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
Geert Uytterhoeven <geert+renesas@...der.be>,
Kees Cook <keescook@...omium.org>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Miquel Raynal <miquel.raynal@...tlin.com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
Neil Armstrong <narmstrong@...libre.com>,
Robert Foss <robert.foss@...aro.org>,
Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
Jernej Skrabec <jernej.skrabec@...il.com>,
Ezequiel Garcia <ezequiel@...labora.com>,
Harry Wentland <harry.wentland@....com>,
Sam Ravnborg <sam@...nborg.org>,
Maxime Ripard <maxime@...no.tech>,
Hans Verkuil <hverkuil-cisco@...all.nl>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Paul Boddie <paul@...die.org.uk>, devicetree@...r.kernel.org,
linux-mips@...r.kernel.org, linux-kernel@...r.kernel.org,
letux-kernel@...nphoenux.org, Jonas Karlman <jonas@...boo.se>,
dri-devel@...ts.freedesktop.org
Subject: Re: [PATCH v8 4/8] drm/ingenic: Add dw-hdmi driver for jz4780
Hi Paul,
>>> You probably should disable the regulator (if not NULL) here.
>> Indeed. Would it be ok to make struct regulator *regulator static
>> or do we need dynamically allocated memory?
>
> static non-const is almost always a bad idea, so avoid it.
Well some years ago it was a perfectly simple solution that still works...
But I asked because I had a lot of doubt.
>
> You can either:
>
> - create a "ingenic_dw_hdmi" struct that will contain a pointer to dw_hdmi and a pointer to the regulator. Instanciate it in the probe with devm_kzalloc() and set the pointers, then set it as the driver data (platform_set_drvdata). In the remove function you can then obtain the pointer to your ingenic_dw_hdmi struct with platform_get_drvdata(), and you can remove the dw_hdmi and unregister the regulator.
>
> - register cleanup functions, using devm_add_action_or_reset(dev, f, priv). When it's time to cleanup, the kernel core will call f(priv) automatically. So you can add a small wrapper around dw_hdmi_remove() and another one around regulator_disable(), and those will be called automatically if your probe function fails, or when the driver is removed. Then you can completely remove the ".remove" callback. There are a few examples of these in the ingenic-drm-drv.c if you want to take a look.
The second one turned out to be cleaner to handle special cases like if there is no regulator. We just register the disabler only if there is a regulator and enable succeeds.
So v9 is coming now.
BR and thanks,
Nikolaus
Powered by blists - more mailing lists