From: Andrew Morton <akpm@linux-foundation.org>
To: jg1.han@samsung.com
Cc: linux-kernel@vger.kernel.org, tj@kernel.org
Subject: Re: [PATCH 1/2] backlight: add devm_backlight_device_{register,unregister}()
Date: Fri, 24 May 2013 13:27:51 -0700 [thread overview]
Message-ID: <20130524132751.8bbcf26cb02c78ad9a8b7d80@linux-foundation.org> (raw)
In-Reply-To: <20226221.131531368682106551.JavaMail.weblogic@epml12>
On Thu, 16 May 2013 05:28:26 +0000 (GMT) Jingoo Han <jg1.han@samsung.com> wrote:
> These functions allow the driver core to automatically clean up any
> allocation made by backlight drivers. Thus it simplifies the error
> paths.
>
> ...
>
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -370,6 +370,81 @@ void backlight_device_unregister(struct backlight_device *bd)
> }
> EXPORT_SYMBOL(backlight_device_unregister);
>
> +static void devm_backlight_device_release(struct device *dev, void *res)
> +{
> + struct backlight_device *backlight = *(struct backlight_device **)res;
> +
> + backlight_device_unregister(backlight);
> +}
>
> ...
>
> +struct backlight_device *devm_backlight_device_register(struct device *dev,
> + const char *name, struct device *parent, void *devdata,
> + const struct backlight_ops *ops,
> + const struct backlight_properties *props)
> +{
> + struct backlight_device **ptr, *backlight;
> +
> + ptr = devres_alloc(devm_backlight_device_release, sizeof(*ptr),
> + GFP_KERNEL);
Well this is an awkward-looking thing. We allocate a silly little 4-
or 8-byte object just to track the backlight_device* via the devres
system.
I assume this was done so that devres could be used as a wrapper around
the existing code?
Really it would be better if things like backlight_device_register()
were themselves directly converted to use devm_foo(), yes?
prev parent reply other threads:[~2013-05-24 20:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-16 5:28 Jingoo Han
2013-05-24 20:27 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130524132751.8bbcf26cb02c78ad9a8b7d80@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=jg1.han@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®