From patchwork Tue Jul 24 09:37:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: aaron lu X-Patchwork-Id: 1230831 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 64C0140071 for ; Tue, 24 Jul 2012 09:39:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753476Ab2GXJjw (ORCPT ); Tue, 24 Jul 2012 05:39:52 -0400 Received: from va3ehsobe003.messaging.microsoft.com ([216.32.180.13]:19972 "EHLO va3outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753402Ab2GXJju (ORCPT ); Tue, 24 Jul 2012 05:39:50 -0400 Received: from mail48-va3-R.bigfish.com (10.7.14.246) by VA3EHSOBE002.bigfish.com (10.7.40.22) with Microsoft SMTP Server id 14.1.225.23; Tue, 24 Jul 2012 09:39:50 +0000 Received: from mail48-va3 (localhost [127.0.0.1]) by mail48-va3-R.bigfish.com (Postfix) with ESMTP id 0FC562400AD; Tue, 24 Jul 2012 09:39:50 +0000 (UTC) X-Forefront-Antispam-Report: CIP:163.181.249.109; KIP:(null); UIP:(null); IPV:NLI; H:ausb3twp02.amd.com; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VPS0(zzzz1202hzz8275bhz2dh668h839hd24he5bhf0ah107ah) Received: from mail48-va3 (localhost.localdomain [127.0.0.1]) by mail48-va3 (MessageSwitch) id 1343122788511155_27102; Tue, 24 Jul 2012 09:39:48 +0000 (UTC) Received: from VA3EHSMHS021.bigfish.com (unknown [10.7.14.244]) by mail48-va3.bigfish.com (Postfix) with ESMTP id 6E7A72A004B; Tue, 24 Jul 2012 09:39:48 +0000 (UTC) Received: from ausb3twp02.amd.com (163.181.249.109) by VA3EHSMHS021.bigfish.com (10.7.99.31) with Microsoft SMTP Server id 14.1.225.23; Tue, 24 Jul 2012 09:39:48 +0000 X-WSS-ID: 0M7NS69-02-1NS-02 X-M-MSG: Received: from sausexedgep02.amd.com (sausexedgep02-ext.amd.com [163.181.249.73]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ausb3twp02.amd.com (Axway MailGate 3.8.1) with ESMTP id 238D8FCC00B; Tue, 24 Jul 2012 04:39:45 -0500 (CDT) Received: from sausexhtp02.amd.com (163.181.3.152) by sausexedgep02.amd.com (163.181.36.59) with Microsoft SMTP Server (TLS) id 8.3.192.1; Tue, 24 Jul 2012 04:39:53 -0500 Received: from sausexmb1.amd.com (163.181.3.156) by sausexhtp02.amd.com (163.181.3.152) with Microsoft SMTP Server id 8.3.213.0; Tue, 24 Jul 2012 04:39:45 -0500 Received: from storexbh1.amd.com ([10.1.1.17]) by sausexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 24 Jul 2012 04:39:45 -0500 Received: from sshaexmb1.amd.com ([10.237.2.11]) by storexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 24 Jul 2012 05:39:44 -0400 Received: from srdclcs1.amd.com ([10.237.73.42]) by sshaexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 24 Jul 2012 17:39:30 +0800 From: Aaron Lu To: Jeff Garzik , Alan Stern , Lin Ming , James Bottomley , Jeff Wu CC: , , , , Aaron Lu , Aaron Lu Subject: [PATCH v2 1/7] scsi: sr: fix for sr suspend and resume Date: Tue, 24 Jul 2012 17:37:39 +0800 Message-ID: <1343122665-18711-2-git-send-email-aaron.lu@amd.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1343122665-18711-1-git-send-email-aaron.lu@amd.com> References: <1343122665-18711-1-git-send-email-aaron.lu@amd.com> X-OriginalArrivalTime: 24 Jul 2012 09:39:30.0601 (UTC) FILETIME=[398EE990:01CD6980] MIME-Version: 1.0 X-OriginatorOrg: amd.com Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In sr_suspend, we do not need to do anything if it is not a runtime pm request, so just return by checking the PM_IS_AUTO macro. And in sr_resume, only reset the suspend_count back to 1 if the ODD is waken up by the user, or the usage count of the scsi device will not balance. Signed-off-by: Aaron Lu --- V2: Use PMSG_IS_AUTO as suggested by Alan Stern. drivers/scsi/sr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 3da0879..225848c 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -178,8 +178,8 @@ static int sr_suspend(struct device *dev, pm_message_t msg) struct scsi_sense_hdr sshdr; struct scsi_cd *cd = dev_get_drvdata(dev); - /* no action for system suspend */ - if (msg.event == PM_EVENT_SUSPEND) + /* no action for system pm operations */ + if (!PMSG_IS_AUTO(msg)) return 0; /* do another TUR to see if the ODD is still ready to be powered off */ @@ -217,9 +217,9 @@ static int sr_resume(struct device *dev) cd->device->wakeup_by_user = 0; if (!(cd->cdi.mask & CDC_CLOSE_TRAY)) sr_tray_move(&cd->cdi, 1); - } - atomic_set(&cd->suspend_count, 1); + atomic_set(&cd->suspend_count, 1); + } return 0; }