From patchwork Fri Nov 15 11:40:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 3187801 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 04BB19F39E for ; Fri, 15 Nov 2013 11:41:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4461320984 for ; Fri, 15 Nov 2013 11:41:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E20C32096B for ; Fri, 15 Nov 2013 11:41:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754914Ab3KOLk6 (ORCPT ); Fri, 15 Nov 2013 06:40:58 -0500 Received: from mail-la0-f53.google.com ([209.85.215.53]:49285 "EHLO mail-la0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753815Ab3KOLkv (ORCPT ); Fri, 15 Nov 2013 06:40:51 -0500 Received: by mail-la0-f53.google.com with SMTP id ea20so2621785lab.26 for ; Fri, 15 Nov 2013 03:40:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=qvk2nhnEDgnnoaMDP/AIFT+/FybcBWFOBXWxjpYKDx4=; b=BLIBJu0yzwyPNJA8C3gH0R7VzFgaE3ktvxgVIwZXvQZ6NzmKMCSvLGyw3CHbEFoy6C 4TwPtmmwh19/j5+p0dl2nkppBQ12Y46ERLlb4zNWowQSFnFVkrPzBypBLuG97T0Nm35V SWWEBEEcrBR1/h8k8TFA8iW1rwqZUXpNF0V4au3P0gCdsyEuS7aB6/qsTs6gGaXgsgrF WrPfaWK+XiPDPmHenwuTko8YMhglLPCQzWVOjnUi3QEQzF8Ei+wLrFTO6XjX7TqqrgGs /dO6Nx+DyNlBp3IL+4/h4hB/gbJo9kS3Rm+LewciZqQFC7Tp9ozPanmRAxdcPNakUrr/ iZvg== X-Gm-Message-State: ALoCoQln5WBy0ko3ktXke1wztV8PRtEMSFWMeVFzeaAHb6fG9P4Nb09twLPbinAqto3BKs9S7Aor X-Received: by 10.112.13.72 with SMTP id f8mr1023959lbc.40.1384515649998; Fri, 15 Nov 2013 03:40:49 -0800 (PST) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id l10sm1875552lbh.13.2013.11.15.03.40.48 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Nov 2013 03:40:49 -0800 (PST) From: Ulf Hansson To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , linux-pm@vger.kernel.org Cc: Greg Kroah-Hartman , linux-pci@vger.kernel.org, linux-usb@vger.kernel.org, Ulf Hansson , Kevin Hilman , Alan Stern Subject: [PATCH 1/2] PM / Runtime: Fix error path for prepare Date: Fri, 15 Nov 2013 12:40:44 +0100 Message-Id: <1384515645-8696-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a device prepare callback for some reason would fail, the PM core prevented the device from going inactive forever. In this case, to reverse the pm_runtime_get_noresume() we invokes the asyncronous pm_runtime_put(), thus restoring the usage count. Cc: Kevin Hilman Cc: Alan Stern Signed-off-by: Ulf Hansson --- drivers/base/power/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index ee039af..2a1b06a 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1350,6 +1350,9 @@ static int device_prepare(struct device *dev, pm_message_t state) device_unlock(dev); + if (error) + pm_runtime_put(dev); + return error; }