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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANq1E4S=0EHyLh6M_pA94QNgMzzj5NXpd6p7OMDTaQSW+Qd_bQ@mail.gmail.com>
Date:	Thu, 11 Sep 2014 13:14:31 +0200
From:	David Herrmann <dh.herrmann@...il.com>
To:	Thierry Reding <thierry.reding@...il.com>
Cc:	"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
	Matthew Garrett <matthew.garrett@...ula.com>,
	Daniel Vetter <daniel.vetter@...ll.ch>,
	Bryan Wu <cooloney@...il.com>,
	linux-kernel <linux-kernel@...r.kernel.org>,
	Lee Jones <lee.jones@...aro.org>
Subject: Re: [PATCH RFC 3/4] backlight: add kernel-internal backlight API

Hi

On Thu, Sep 11, 2014 at 1:10 PM, Thierry Reding
<thierry.reding@...il.com> wrote:
> On Wed, Sep 10, 2014 at 05:54:22PM +0200, David Herrmann wrote:
> [...]
>> +void backlight_set_brightness(struct backlight_device *bd, unsigned int value,
>> +                           enum backlight_update_reason reason)
>> +{
>> +     mutex_lock(&bd->ops_lock);
>> +     if (bd->ops) {
>> +             value = clamp(value, 0U, (unsigned)bd->props.max_brightness);
>
> max_brightness should really be unsigned to begin with...
>
>> +             pr_debug("set brightness to %u\n", value);
>
> dev_dbg(&bd->dev, ...)?

I agree with both comments, but I tried to be consistent with what
brightness_store() does.

>> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
>> index adb14a8..bcc0dec 100644
>> --- a/include/linux/backlight.h
>> +++ b/include/linux/backlight.h
>> @@ -141,6 +141,22 @@ extern bool backlight_device_registered(enum backlight_type type);
>>  extern int backlight_register_notifier(struct notifier_block *nb);
>>  extern int backlight_unregister_notifier(struct notifier_block *nb);
>>
>> +struct backlight_device *backlight_device_lookup(const char *name);
>> +void backlight_set_brightness(struct backlight_device *bd, unsigned int value,
>> +                           enum backlight_update_reason reason);
>> +
>> +static inline void backlight_device_ref(struct backlight_device *bd)
>> +{
>> +     if (bd)
>> +             get_device(&bd->dev);
>> +}
>
> Perhaps for consistency with get_device() this should return bd? That
> way you can chain things like so:
>
>         priv->backlight = backlight_device_ref(bd);

Makes sense, will change it. Same is actually true for _unref(), which
should return NULL unconditionally. This way, you can use:
  priv->backlight = backlight_device_unref(priv->backlight);
to release a reference and reset the pointer at the same time.

Thanks
David
--
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