From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: Re: [PATCH 1/6] PM: Introduce PM links framework Date: Fri, 28 Aug 2009 21:11:19 +0200 Message-ID: <200908282111.19925.rjw@sisk.pl> References: Mime-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Alan Stern Cc: linux-pm , LKML , Len Brown , Pavel Machek , ACPI Devel Maling List , Arjan van de Ven , Zhang Rui , Dmitry Torokhov , Linux PCI List-Id: linux-acpi@vger.kernel.org On Friday 28 August 2009, Alan Stern wrote: > On Wed, 26 Aug 2009, Rafael J. Wysocki wrote: > > > From: Rafael J. Wysocki > > > > Introduce a framework for representing off-tree PM dependencies > > between devices. > > > > There are PM dependencies between devices that are not reflected by > > the structure of the device tree. In other words, as far as PM is > > concerned, a device may depend on some other devices which are not > > its children and none of which is its parent. > > > > Every such dependency involves two devices, one of which is a > > "master" and the other of which is a "slave", meaning that the > > "slave" have to be suspended before the "master" and cannot be > > woken up before it. Thus every device can be given two lists of > > "dependency objects", one for the dependencies where the device is > > the "master" and the other for the dependencies where the device is > > the "slave". Then, each "dependency object" can be represented as > > > > Index: linux-2.6/drivers/base/power/common.c > > =================================================================== > > --- /dev/null > > +++ linux-2.6/drivers/base/power/common.c > > > +/** > > + * device_for_each_master - Execute given function for each master of a device. > > + * @slave: Device whose masters to execute the function for. > > + * @data: Data pointer to pass to the function. > > + * @fn: Function to execute for each master of @slave. > > + * > > + * The function is executed for the parent of the device, if there is one, and > > + * for each device connected to it via a pm_link object where @slave is the > > + * "slave". > > + */ > > +int device_for_each_master(struct device *slave, void *data, > > + int (*fn)(struct device *dev, void *data)) > > +{ > > + struct pm_link *link; > > + int idx; > > + int error = 0; > > + > > + if (slave->parent) { > > + error = fn(slave->parent, data); > > + if (error) > > + return error; > > + } > > + > > + idx = srcu_read_lock(&pm_link_ss); > > + > > + list_for_each_entry(link, &slave->power.slave_links, slave_hook) { > > This needs to use list_for_each_entry_rcu. Likewise in > device_for_each_slave(). OK, I wasn't sure about that. Thanks, Rafael