lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Fri, 24 May 2013 13:27:51 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	jg1.han@...sung.com
Cc:	linux-kernel@...r.kernel.org, tj@...nel.org
Subject: Re: [PATCH 1/2] backlight: add
 devm_backlight_device_{register,unregister}()

On Thu, 16 May 2013 05:28:26 +0000 (GMT) Jingoo Han <jg1.han@...sung.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?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ