From patchwork Mon Jul 23 06:49:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lu X-Patchwork-Id: 172554 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 33D5A2C035E for ; Mon, 23 Jul 2012 16:52:17 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753703Ab2GWGvV (ORCPT ); Mon, 23 Jul 2012 02:51:21 -0400 Received: from va3ehsobe004.messaging.microsoft.com ([216.32.180.14]:21485 "EHLO va3outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753289Ab2GWGu7 (ORCPT ); Mon, 23 Jul 2012 02:50:59 -0400 Received: from mail260-va3-R.bigfish.com (10.7.14.248) by VA3EHSOBE007.bigfish.com (10.7.40.11) with Microsoft SMTP Server id 14.1.225.23; Mon, 23 Jul 2012 06:50:59 +0000 Received: from mail260-va3 (localhost [127.0.0.1]) by mail260-va3-R.bigfish.com (Postfix) with ESMTP id D4BD74011E; Mon, 23 Jul 2012 06:50:58 +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 mail260-va3 (localhost.localdomain [127.0.0.1]) by mail260-va3 (MessageSwitch) id 1343026256822136_24167; Mon, 23 Jul 2012 06:50:56 +0000 (UTC) Received: from VA3EHSMHS012.bigfish.com (unknown [10.7.14.242]) by mail260-va3.bigfish.com (Postfix) with ESMTP id C58675C0043; Mon, 23 Jul 2012 06:50:56 +0000 (UTC) Received: from ausb3twp02.amd.com (163.181.249.109) by VA3EHSMHS012.bigfish.com (10.7.99.22) with Microsoft SMTP Server id 14.1.225.23; Mon, 23 Jul 2012 06:50:56 +0000 X-WSS-ID: 0M7LPOU-02-5HU-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 29FF0C8143; Mon, 23 Jul 2012 01:50:54 -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; Mon, 23 Jul 2012 01:50:58 -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; Mon, 23 Jul 2012 01:50:54 -0500 Received: from storexbh1.amd.com ([10.1.1.17]) by sausexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 23 Jul 2012 01:50:54 -0500 Received: from sshaexmb1.amd.com ([10.237.2.11]) by storexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 23 Jul 2012 02:50:52 -0400 Received: from srdclcs1.amd.com ([10.237.73.42]) by sshaexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 23 Jul 2012 14:50:37 +0800 From: Aaron Lu To: Jeff Garzik , Alan Stern , Lin Ming CC: , , , , Aaron Lu , Aaron Lu Subject: [PATCH 1/5] scsi: sr: fix for sr suspend and resume Date: Mon, 23 Jul 2012 14:49:36 +0800 Message-ID: <1343026180-22236-2-git-send-email-aaron.lu@amd.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1343026180-22236-1-git-send-email-aaron.lu@amd.com> References: <1343026180-22236-1-git-send-email-aaron.lu@amd.com> X-OriginalArrivalTime: 23 Jul 2012 06:50:37.0404 (UTC) FILETIME=[774A01C0:01CD689F] MIME-Version: 1.0 X-OriginatorOrg: amd.com Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@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_EVENT_AUTO flag. 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 --- 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..5f4d19a 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 (!(msg.event & PM_EVENT_AUTO)) 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; }