From patchwork Thu Mar 15 09:58:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 7308 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 1C11023E16 for ; Thu, 15 Mar 2012 09:58:41 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id AF3EEA180D9 for ; Thu, 15 Mar 2012 09:58:40 +0000 (UTC) Received: by iage36 with SMTP id e36so4941175iag.11 for ; Thu, 15 Mar 2012 02:58:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=AJplaQsQqyDnlIJPQn4xRJvUUw5lr145IHGj+S5BuAQ=; b=cxY7N/McC1wJ0v5+sGB/6MiymRvN+RLvchCSlTXQ1tgJx6sAFL6F35dfP6LODkeR+3 fsJm4ZZl7EB1gg4715fPwoZug3TrcTSug6uB4KuILKQeyp75moLA66Rouilt5cmMRe3D i/X0DSCQLzRaIsmRv6BUkeTbpFkCrREjA0AXnTrhvaeDz1t6tUtSj6ht+U7LqzEVMRs7 STf9xGH0kR8TSFL/ew/I4qad/HdI5CehFUTYHk/yOPFErAisSxXDSEhoeybKFmWSGX6t ROmh58qzBInR2P92DqGNEPZSrTfgPjwyy0CsxL2WXDNi9+23qB5zLonihyvVrqhNcw7H dAeA== Received: by 10.42.147.199 with SMTP id o7mr6713189icv.50.1331805520053; Thu, 15 Mar 2012 02:58:40 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.53.18 with SMTP id k18csp31468ibg; Thu, 15 Mar 2012 02:58:39 -0700 (PDT) Received: by 10.213.4.205 with SMTP id 13mr442375ebs.89.1331805518516; Thu, 15 Mar 2012 02:58:38 -0700 (PDT) Received: from eu1sys200aog104.obsmtp.com (eu1sys200aog104.obsmtp.com. [207.126.144.117]) by mx.google.com with SMTP id a45si374786eeg.54.2012.03.15.02.58.35 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Mar 2012 02:58:38 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.117 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.117; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.117 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob104.postini.com ([207.126.147.11]) with SMTP ID DSNKT2G9S+guBiaecTODwBsodQt5EQXqSbaZ@postini.com; Thu, 15 Mar 2012 09:58:38 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 671D7B1; Thu, 15 Mar 2012 09:58:21 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 80DD449; Thu, 15 Mar 2012 08:19:24 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id A984124C075; Thu, 15 Mar 2012 10:58:27 +0100 (CET) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 15 Mar 2012 10:58:32 +0100 From: Linus Walleij To: , Greg Kroah-Hartman Cc: Rabin Vincent , Linus Walleij Subject: [PATCH] driver core: always handle dpm_order Date: Thu, 15 Mar 2012 10:58:18 +0100 Message-ID: <1331805498-12903-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.9.2 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlpW0o5BPK//KutAK3u94iyO2Zjww+roX+dK1skP1co+jmhfIpp01yth8W6BT8AH39kJ/FK From: Rabin Vincent If !dev->class, device_move() does not respect the dpm_order. Fix it to do so. Signed-off-by: Rabin Vincent Reviewed-by: Srinidhi Kasagar [Fixed a small dangling label compile warning] Signed-off-by: Linus Walleij --- drivers/base/core.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 74dda4f..be07591 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1746,25 +1746,25 @@ int device_move(struct device *dev, struct device *new_parent, set_dev_node(dev, dev_to_node(new_parent)); } - if (!dev->class) - goto out_put; - error = device_move_class_links(dev, old_parent, new_parent); - if (error) { - /* We ignore errors on cleanup since we're hosed anyway... */ - device_move_class_links(dev, new_parent, old_parent); - if (!kobject_move(&dev->kobj, &old_parent->kobj)) { - if (new_parent) - klist_remove(&dev->p->knode_parent); - dev->parent = old_parent; - if (old_parent) { - klist_add_tail(&dev->p->knode_parent, - &old_parent->p->klist_children); - set_dev_node(dev, dev_to_node(old_parent)); + if (dev->class) { + error = device_move_class_links(dev, old_parent, new_parent); + if (error) { + /* We ignore errors on cleanup since we're hosed anyway... */ + device_move_class_links(dev, new_parent, old_parent); + if (!kobject_move(&dev->kobj, &old_parent->kobj)) { + if (new_parent) + klist_remove(&dev->p->knode_parent); + dev->parent = old_parent; + if (old_parent) { + klist_add_tail(&dev->p->knode_parent, + &old_parent->p->klist_children); + set_dev_node(dev, dev_to_node(old_parent)); + } } + cleanup_glue_dir(dev, new_parent_kobj); + put_device(new_parent); + goto out; } - cleanup_glue_dir(dev, new_parent_kobj); - put_device(new_parent); - goto out; } switch (dpm_order) { case DPM_ORDER_NONE: @@ -1779,7 +1779,7 @@ int device_move(struct device *dev, struct device *new_parent, device_pm_move_last(dev); break; } -out_put: + put_device(old_parent); out: device_pm_unlock();