public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: USB development list <linux-usb-devel@lists.sourceforge.net>,
	LKML <linux-kernel@vger.kernel.org>, Pavel Machek <pavel@ucw.cz>,
	pm list <linux-pm@lists.linux-foundation.org>
Subject: Re: [RFC][PATCH -mm 1/7] PM: Remove pm_parent from struct dev_pm_info
Date: Mon, 11 Jun 2007 20:52:32 +0200	[thread overview]
Message-ID: <200706112052.32872.rjw@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0706111147160.2611-100000@iolanthe.rowland.org>

On Monday, 11 June 2007 17:59, Alan Stern wrote:
> On Mon, 11 Jun 2007, Rafael J. Wysocki wrote:
> 
> > From: Rafael J. Wysocki <rjw@sisk.pl>
> > 
> > The pm_parent member of struct dev_pm_info (defined in include/linux/pm.h) is
> > only used to check if the device's parent is in the right state while the
> > device is being suspended or resumed.  However, this can be done just as well
> > with the help of the parent pointer in struct device, so pm_parent can be
> > removed along with some code that handles it.
> 
> > @@ -61,21 +40,26 @@ int device_pm_add(struct device * dev)
> >  		 kobject_name(&dev->kobj));
> >  	mutex_lock(&dpm_list_mtx);
> >  	list_add_tail(&dev->power.entry, &dpm_active);
> > -	device_pm_set_parent(dev, dev->parent);
> > -	if ((error = dpm_sysfs_add(dev)))
> > +	/*
> > +	 * The device's parent must not be released until the device itself is
> > +	 * removed from the dpm_active list.
> > +	 */
> > +	get_device(dev->parent);
> > +	error = dpm_sysfs_add(dev);
> > +	if (error)
> >  		list_del(&dev->power.entry);
> >  	mutex_unlock(&dpm_list_mtx);
> >  	return error;
> >  }
> 
> The error pathway here does an unbalanced get_device on dev->parent.
> 
> Anyway, I don't think you need to do this get_device at all (or the
> coresponding put in device_pm_remove).  As long as a device is
> registered it retains a reference to its parent, and unregistration
> always calls device_pm_remove.

Yes, I've just come to the same conclusion.  I'll remove the
get_device(dev->parent) and the correspondint put_device(dev->parent)
from device_pm_remove().

Greetings,
Rafael


-- 
"Premature optimization is the root of all evil." - Donald Knuth

  reply	other threads:[~2007-06-11 18:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200706111657.09038.rjw@sisk.pl>
2007-06-11 15:59 ` [RFC][PATCH -mm 1/7] PM: Remove pm_parent from struct dev_pm_info Alan Stern
2007-06-11 18:52   ` Rafael J. Wysocki [this message]
2007-06-11 19:55     ` Rafael J. Wysocki
     [not found] <200706111655.50022.rjw@sisk.pl>
2007-06-11 14:57 ` Rafael J. Wysocki

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=200706112052.32872.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=pavel@ucw.cz \
    --cc=stern@rowland.harvard.edu \
    /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