public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: David Herrmann <dh.herrmann@gmail.com>
Cc: "dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Matthew Garrett <matthew.garrett@nebula.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Bryan Wu <cooloney@gmail.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Lee Jones <lee.jones@linaro.org>
Subject: Re: [PATCH RFC 3/4] backlight: add kernel-internal backlight API
Date: Thu, 11 Sep 2014 13:21:34 +0200	[thread overview]
Message-ID: <20140911112133.GC552@ulmo> (raw)
In-Reply-To: <CANq1E4S=0EHyLh6M_pA94QNgMzzj5NXpd6p7OMDTaQSW+Qd_bQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2490 bytes --]

On Thu, Sep 11, 2014 at 01:14:31PM +0200, David Herrmann wrote:
> Hi
> 
> On Thu, Sep 11, 2014 at 1:10 PM, Thierry Reding
> <thierry.reding@gmail.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.

Fair enough, this can be cleaned up in separate patches.

> >> 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.

That looks somewhat odd to me. Wouldn't priv->backlight typically go
away after the unref anyway (presumably because priv is going to get
freed soon after)?

But I have no strong objections to returning NULL from _unref(), if code
doesn't need it it can always choose not to use the return value.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2014-09-11 11:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10 15:54 [PATCH RFC 0/4] Linking DRM Connectors to Backlight Devices David Herrmann
2014-09-10 15:54 ` [PATCH RFC 1/4] backlight: use static initializers David Herrmann
2014-09-11  8:59   ` Jani Nikula
2014-09-10 15:54 ` [PATCH RFC 2/4] backlight: use spin-lock to protect device list David Herrmann
2014-09-11  9:00   ` Jani Nikula
2014-09-10 15:54 ` [PATCH RFC 3/4] backlight: add kernel-internal backlight API David Herrmann
2014-09-11 11:10   ` Thierry Reding
2014-09-11 11:14     ` David Herrmann
2014-09-11 11:21       ` Thierry Reding [this message]
2014-09-10 15:54 ` [PATCH RFC 4/4] drm: link connectors to backlight devices David Herrmann
2014-09-11  6:48   ` Daniel Vetter
2014-09-11 12:22     ` David Herrmann
2014-09-11 13:06       ` Daniel Vetter
2014-09-11 16:07         ` David Herrmann
2014-09-11 12:46     ` Jani Nikula
2014-09-10 20:40 ` [PATCH RFC 0/4] Linking DRM Connectors to Backlight Devices Matthew Garrett
2014-09-11 12:48   ` David Herrmann

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=20140911112133.GC552@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=cooloney@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dh.herrmann@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.garrett@nebula.com \
    /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