From patchwork Tue Mar 22 20:19:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: kyle mcmartin X-Patchwork-Id: 653411 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2MKJxmT025765 for ; Tue, 22 Mar 2011 20:19:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932083Ab1CVUT7 (ORCPT ); Tue, 22 Mar 2011 16:19:59 -0400 Received: from bombadil.infradead.org ([18.85.46.34]:33500 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932077Ab1CVUT6 (ORCPT ); Tue, 22 Mar 2011 16:19:58 -0400 Received: from kyle by bombadil.infradead.org with local (Exim 4.72 #1 (Red Hat Linux)) id 1Q283T-0003fU-1P; Tue, 22 Mar 2011 20:19:51 +0000 Date: Tue, 22 Mar 2011 16:19:50 -0400 From: Kyle McMartin To: rjw@sisk.pl Cc: mjg@redhat.com, len.brown@intel.com, torvalds@linux-foundation.org, linux-acpi@vger.kernel.org Subject: [PATCH] acpi_battery: fribble sysfs files from a resume notifier Message-ID: <20110322201950.GC11925@bombadil.infradead.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 22 Mar 2011 20:19:59 +0000 (UTC) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index ac1a599..fcc13ac 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef CONFIG_ACPI_PROCFS_POWER #include @@ -102,6 +103,7 @@ struct acpi_battery { struct mutex lock; struct power_supply bat; struct acpi_device *device; + struct notifier_block pm_nb; unsigned long update_time; int rate_now; int capacity_now; @@ -940,6 +942,21 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event) power_supply_changed(&battery->bat); } +static int battery_notify(struct notifier_block *nb, + unsigned long mode, void *_unused) +{ + struct acpi_battery *battery = container_of(nb, struct acpi_battery, + pm_nb); + switch (mode) { + case PM_POST_SUSPEND: + sysfs_remove_battery(battery); + sysfs_add_battery(battery); + break; + } + + return 0; +} + static int acpi_battery_add(struct acpi_device *device) { int result = 0; @@ -972,6 +989,10 @@ static int acpi_battery_add(struct acpi_device *device) #endif kfree(battery); } + + battery->pm_nb.notifier_call = battery_notify; + register_pm_notifier(&battery->pm_nb); + return result; } @@ -982,6 +1003,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type) if (!device || !acpi_driver_data(device)) return -EINVAL; battery = acpi_driver_data(device); + unregister_pm_notifier(&battery->pm_nb); #ifdef CONFIG_ACPI_PROCFS_POWER acpi_battery_remove_fs(device); #endif