From patchwork Thu Sep 13 07:40:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lu X-Patchwork-Id: 183530 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 C29512C00B3 for ; Thu, 13 Sep 2012 17:41:18 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753420Ab2IMHlQ (ORCPT ); Thu, 13 Sep 2012 03:41:16 -0400 Received: from mga14.intel.com ([143.182.124.37]:55472 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752289Ab2IMHlN (ORCPT ); Thu, 13 Sep 2012 03:41:13 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 13 Sep 2012 00:41:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,416,1344236400"; d="scan'208";a="192194088" Received: from mint-spring.sh.intel.com ([10.239.36.120]) by azsmga001.ch.intel.com with ESMTP; 13 Sep 2012 00:41:10 -0700 From: Aaron Lu To: Alan Stern , Jeff Garzik , James Bottomley Cc: Aaron Lu , Jack Wang , Shane Huang , Oliver Neukum , linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, Aaron Lu Subject: [PATCH 2/2] libata: acpi: set can_power_off for both ODD and HDD Date: Thu, 13 Sep 2012 15:40:49 +0800 Message-Id: <1347522049-1836-3-git-send-email-aaron.lu@intel.com> X-Mailer: git-send-email 1.7.12.21.g871e293 In-Reply-To: <1347522049-1836-1-git-send-email-aaron.lu@intel.com> References: <1347522049-1836-1-git-send-email-aaron.lu@intel.com> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org Hard disk may also be runtime powered off, so set can_power_off flag for it too if condition satisfies so that the may_power_off sysfs file will be created for it to give user a chance to disable runtime power off. 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 24347e0..443c3f2 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -1015,7 +1015,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); @@ -1036,7 +1036,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); @@ -1140,14 +1140,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; }