From patchwork Sun Aug 2 15:58:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Jenkins X-Patchwork-Id: 38770 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n72FnJdv005313 for ; Sun, 2 Aug 2009 15:58:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752967AbZHBP6m (ORCPT ); Sun, 2 Aug 2009 11:58:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752983AbZHBP6m (ORCPT ); Sun, 2 Aug 2009 11:58:42 -0400 Received: from mail-ew0-f214.google.com ([209.85.219.214]:40106 "EHLO mail-ew0-f214.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752921AbZHBP6l (ORCPT ); Sun, 2 Aug 2009 11:58:41 -0400 Received: by ewy10 with SMTP id 10so2536542ewy.37 for ; Sun, 02 Aug 2009 08:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:content-type :content-transfer-encoding; bh=5hxu7d2JmAT0HLoOVZXBdFQBdunwAOJVWzyi3va7X7Q=; b=XYtlGvZLMPZJ9t7QyzyoJ2fke32JBSITbdSK4rcWFO96nQQSJfSoPDvNkflJ0k1J3C CamT90El2mTZodKCgtV+R1E7qWVBieo6HXyEJLVJg71gFSAcvP1VzkmPkOF0u3QV7LDd k4J/6HdS4rVHlzfeZIZqGwAnJS0IFbgRKIvQs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; b=O9qeZOe90pJ5+chz8o+gS6HGC5E73YD2gJWGLUAd+im2l+wS55j2IpFbs5RwwEhY0C 7nNRWQxuj8HhFr1Z5UfpJXkNkIFXwmc0GgYrtwp+Ar5twDoVsI+kj5NIGbJ1bjTC3VQ2 cL0WERDFGHWE+f+eL7gswj3KwO5LCMOu3TueM= Received: by 10.210.128.1 with SMTP id a1mr772790ebd.22.1249228721578; Sun, 02 Aug 2009 08:58:41 -0700 (PDT) Received: from ?192.168.0.2? ([86.53.68.233]) by mx.google.com with ESMTPS id 10sm8956147eyd.32.2009.08.02.08.58.40 (version=SSLv3 cipher=RC4-MD5); Sun, 02 Aug 2009 08:58:40 -0700 (PDT) Message-ID: <4A75B7AF.1080206@tuffmail.co.uk> Date: Sun, 02 Aug 2009 16:58:39 +0100 From: Alan Jenkins User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: Corentin Chary CC: acpi4asus-user@lists.sourceforge.net, linux-acpi@vger.kernel.org Subject: [PATCH 8/8] eeepc-laptop: switch to dev_pm_ops Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org This also involves switching the resume handler from the acpi device to the platform device. Using the more fine grained handlers allows two improvements: 1. We only need to recheck rfkill state after resume from hibernation. 2. The wireless LED workaround accounts for up to 1.1s out of 1.7s resuming devices (when wireless is enabled). We can limit the workaround to thaw(), so that it only delays suspend to disk. The workaround is only likely to help when hibernation is aborted. Suspend to ram cannot be aborted by the user. Device suspend errors may well happen before eeepc-laptop would even be frozen. Suspend errors which happen after that could be pretty funky anyway. Signed-off-by: Alan Jenkins --- drivers/platform/x86/eeepc-laptop.c | 25 +++++++++++++++++++------ 1 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index df68ae6..1c94860 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c @@ -150,10 +150,19 @@ struct eeepc_hotk { static struct eeepc_hotk *ehotk; /* Platform device/driver */ +static int eeepc_hotk_thaw(struct device *device); +static int eeepc_hotk_restore(struct device *device); + +static struct dev_pm_ops eeepc_pm_ops = { + .thaw = eeepc_hotk_thaw, + .restore = eeepc_hotk_restore, +}; + static struct platform_driver platform_driver = { .driver = { .name = EEEPC_HOTK_FILE, .owner = THIS_MODULE, + .pm = &eeepc_pm_ops, } }; @@ -192,7 +201,6 @@ static struct key_entry eeepc_keymap[] = { */ static int eeepc_hotk_add(struct acpi_device *device); static int eeepc_hotk_remove(struct acpi_device *device, int type); -static int eeepc_hotk_resume(struct acpi_device *device); static void eeepc_hotk_notify(struct acpi_device *device, u32 event); static const struct acpi_device_id eeepc_device_ids[] = { @@ -209,7 +217,6 @@ static struct acpi_driver eeepc_hotk_driver = { .ops = { .add = eeepc_hotk_add, .remove = eeepc_hotk_remove, - .resume = eeepc_hotk_resume, .notify = eeepc_hotk_notify, }, }; @@ -821,7 +828,7 @@ error_slot: return ret; } -static int eeepc_hotk_resume(struct acpi_device *device) +static int eeepc_hotk_thaw(struct device *device) { if (ehotk->wlan_rfkill) { bool wlan; @@ -829,14 +836,20 @@ static int eeepc_hotk_resume(struct acpi_device *device) /* * Work around bios bug - acpi _PTS turns off the wireless led * during suspend. Normally it restores it on resume, but - * we should kick it ourselves in case suspend is aborted. + * we should kick it ourselves in case hibernation is aborted. */ wlan = get_acpi(CM_ASL_WLAN); set_acpi(CM_ASL_WLAN, wlan); + } + + return 0; +} - /* Refresh both rfkill state and pci hotplug */ +static int eeepc_hotk_restore(struct device *device) +{ + /* Refresh both wlan rfkill state and pci hotplug */ + if (ehotk->wlan_rfkill) eeepc_rfkill_hotplug(); - } if (ehotk->bluetooth_rfkill) rfkill_set_sw_state(ehotk->bluetooth_rfkill,