From patchwork Tue Sep 4 14:24:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lu X-Patchwork-Id: 1402491 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 04E61DF280 for ; Tue, 4 Sep 2012 14:25:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932284Ab2IDOZr (ORCPT ); Tue, 4 Sep 2012 10:25:47 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:44458 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932262Ab2IDOZn (ORCPT ); Tue, 4 Sep 2012 10:25:43 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr13so9559178pbb.19 for ; Tue, 04 Sep 2012 07:25:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=N9VYHSfZV5D/YW3GBmEZmWjfDk0xDVKo3FLgFKZ6+rA=; b=pVFFK1wXjDJkviM3phX611FdZCwGvlGhxJezeyrcDOu6VqswZOqlUj9vK54hS/XvPA y0+tzltpH1CU2HE7Nj0XkZppKlizOtx88lcLxyKLAwbYxxFOGadiot436+FlFNm1KrYp 2nPd7Bx7By2TWzW36rTcUbZMiadclxwpyyYY9lb2ww15ndT+hE1xi7wSRfVzBwW7vpPE 8Vf265NFKNcm43e0UT3jQYTdWRf4J7eLNw7bnIO2dfCl+hewX3zJSk/FKaogsHDyPPUY WaOGMoU+CTZ5Gfq/F3aWHNUgaEFqtrQssgofrh1Op6pbaapTVIg+C5rTA068ybUC6ABE X8ag== Received: by 10.68.116.48 with SMTP id jt16mr46136868pbb.101.1346768743104; Tue, 04 Sep 2012 07:25:43 -0700 (PDT) Received: from localhost.localdomain.localdomain ([180.157.93.243]) by mx.google.com with ESMTPS id lb1sm12311440pbc.47.2012.09.04.07.25.37 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 04 Sep 2012 07:25:42 -0700 (PDT) From: Aaron Lu To: Alan Stern , James Bottomley , Jeff Garzik Cc: linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, Aaron Lu , Aaron Lu Subject: [PATCH v6 4/7] libata: acpi: set can_power_off for both ODD and HD Date: Tue, 4 Sep 2012 22:24:37 +0800 Message-Id: <1346768680-7287-5-git-send-email-aaron.lwe@gmail.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1346768680-7287-1-git-send-email-aaron.lwe@gmail.com> References: <1346768680-7287-1-git-send-email-aaron.lwe@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Aaron Lu Hard disk may also be runtime powered off, so set can_power_off flag for it too if condition satisfies. Signed-off-by: Aaron Lu Acked-by: Jeff Garzik --- drivers/ata/libata-acpi.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 64ba43d..6c8f89c 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -1005,7 +1005,7 @@ static void ata_acpi_add_pm_notifier(struct ata_device *dev) if (ACPI_FAILURE(status)) return; - if (dev->sdev->can_power_off) { + if (dev->class == ATA_DEV_ATAPI && dev->sdev->can_power_off) { acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, ata_acpi_wake_dev, dev); device_set_run_wake(&dev->sdev->sdev_gendev, true); @@ -1026,7 +1026,7 @@ static void ata_acpi_remove_pm_notifier(struct ata_device *dev) if (ACPI_FAILURE(status)) return; - if (dev->sdev->can_power_off) { + if (dev->class == ATA_DEV_ATAPI && dev->sdev->can_power_off) { device_set_run_wake(&dev->sdev->sdev_gendev, false); acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, ata_acpi_wake_dev); @@ -1130,14 +1130,23 @@ static int ata_acpi_bind_device(struct ata_port *ap, struct scsi_device *sdev, /* * If firmware has _PS3 or _PR3 for this device, - * and this ata ODD device support device attention, - * it means this device can be powered off + * it means this device can be powered off runtime */ states = acpi_dev->power.states; - if ((states[ACPI_STATE_D3_HOT].flags.valid || - states[ACPI_STATE_D3_COLD].flags.explicit_set) && - ata_dev->flags & ATA_DFLAG_DA) - sdev->can_power_off = 1; + if (states[ACPI_STATE_D3_HOT].flags.valid || + states[ACPI_STATE_D3_COLD].flags.explicit_set) { + /* + * For ODD, it needs to support device attention or + * it can't be powered up back by user + */ + if (ata_dev->class == ATA_DEV_ATAPI && + ata_dev->flags & ATA_DFLAG_DA) + sdev->can_power_off = 1; + + /* No requirement for hard disk */ + if (ata_dev->class == ATA_DEV_ATA) + sdev->can_power_off = 1; + } return 0; }