public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Samsung backlight driver
Date: Fri, 14 Aug 2009 15:18:30 -0700	[thread overview]
Message-ID: <20090814221830.GA13114@kroah.com> (raw)
In-Reply-To: <20090814222533.26D94526EC9@mailhub.coreip.homeip.net>

On Fri, Aug 14, 2009 at 02:54:40PM -0700, Dmitry Torokhov wrote:
> Hi Greg,
> 
> On Fri, Aug 14, 2009 at 12:48:15PM -0700, Greg KH wrote:
> > +
> > +static int update_status(struct backlight_device *bd)
> > +{
> > +	if (!pci_device)
> > +		return -ENODEV;
> > +	if (!backlight_device)
> 
> How is this possible?

It's probably not, I was just being paranoid.  You're right, I can drop
all of these checks and rework the find logic a bit.

> > +		return -ENODEV;
> > +
> > +	current_brightness = bd->props.brightness;
> > +	set_brightness();
> > +	return 0;
> > +}
> > +
> > +static struct backlight_ops backlight_ops = {
> > +	.get_brightness	= get_brightness,
> > +	.update_status	= update_status,
> > +};
> > +
> > +static int find_video_card(void)
> > +{
> > +	struct pci_dev *dev = NULL;
> > +
> > +	while ((dev = pci_get_device(0x8086, 0x27ae, dev)) != NULL) {
> > +		/* Found one, so let's save it off */
> > +		if (!pci_device)
> > +			pci_device = pci_dev_get(dev);
> 
> If you need to iterate all matching devices you need to save them all or
> release references to "extras" right here... Or, better yet, just break
> after you find the first one.

It's a trivially small loop, this way I get the "hm, do I need to drop
the reference or not" logic correct :)

> > +	}
> > +
> > +	if (!pci_device)
> > +		return 0;
> 
> Why not -ENODEV? What is the point of having this driver loaded if the
> device is not available? Then you could drop all silly "if (!pci_device)"
> checks.

Ah, you are right, thanks, I'll go fix that.

thanks for the review, I appreciate it.

greg k-h

  reply	other threads:[~2009-08-14 22:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-14 19:48 [PATCH] Samsung backlight driver Greg KH
2009-08-14 21:43 ` [PATCH] samsung-backlight: Added support for Samsung NC10 laptop Greg KH
2009-08-14 21:54 ` [PATCH] Samsung backlight driver Dmitry Torokhov
2009-08-14 22:18   ` Greg KH [this message]
2009-08-14 22:48   ` Greg KH
2009-08-15  7:15     ` Dmitry Torokhov
2009-08-16 22:04       ` Greg KH

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=20090814221830.GA13114@kroah.com \
    --to=greg@kroah.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-kernel@vger.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