Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755263AbbDNNea (ORCPT ); Tue, 14 Apr 2015 09:34:30 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:34061 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753525AbbDNNeV (ORCPT ); Tue, 14 Apr 2015 09:34:21 -0400 From: Krzysztof Kozlowski To: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , linux-pm@vger.kernel.org Cc: Linus Torvalds , Krzysztof Kozlowski Subject: [PATCH] ACPI / battery: Fix doubly added battery on system suspend Date: Tue, 14 Apr 2015 22:24:13 +0900 Message-Id: <1429017853-3520-1-git-send-email-k.kozlowski.k@gmail.com> X-Mailer: git-send-email 2.1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3734 Lines: 75 The commit 297d716f6260 ("power_supply: Change ownership from driver to core") inverted the logic in battery_notify(). As an effect already present battery was re-added on each system suspend or hibernation. Dmesg: [ 107.999370] WARNING: CPU: 0 PID: 303 at ../fs/sysfs/dir.c:31 sysfs_warn_dup+0x68/0x80() [ 107.999374] sysfs: cannot create duplicate filename '/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0' [ 107.999418] CPU: 0 PID: 303 Comm: rtcwake Not tainted 4.0.0-ARCH-02621-g07e6253af953 #48 [ 107.999421] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 107.999425] 0000000000000000 000000008600f41a ffff88001cf3f9f8 ffffffff8156c77d [ 107.999430] 0000000000000000 ffff88001cf3fa50 ffff88001cf3fa38 ffffffff81074cea [ 107.999434] 000029b71cf3fa38 ffff88001e387000 ffff88001cc3bfb8 ffff88001ce1e258 [ 107.999439] Call Trace: [ 107.999446] [] dump_stack+0x4c/0x6e [ 107.999453] [] warn_slowpath_common+0x8a/0xc0 [ 107.999458] [] warn_slowpath_fmt+0x55/0x70 [ 107.999464] [] ? kernfs_path+0x48/0x60 [ 107.999468] [] sysfs_warn_dup+0x68/0x80 [ 107.999472] [] sysfs_create_dir_ns+0x8d/0xa0 [ 107.999478] [] kobject_add_internal+0xb6/0x370 [ 107.999483] [] kobject_add+0x6f/0xd0 [ 107.999489] [] device_add+0x120/0x6c0 [ 107.999494] [] ? dev_set_name+0x50/0x70 [ 107.999500] [] __power_supply_register+0x145/0x290 [ 107.999506] [] ? extract_package+0x73/0xc5 [battery] [ 107.999511] [] power_supply_register_no_ws+0x10/0x20 [ 107.999517] [] sysfs_add_battery+0x84/0xc5 [battery] [ 107.999522] [] battery_notify+0x45/0x6b [battery] [ 107.999527] [] notifier_call_chain+0x4f/0x80 [ 107.999532] [] __blocking_notifier_call_chain+0x4b/0x70 [ 107.999537] [] blocking_notifier_call_chain+0x16/0x20 [ 107.999543] [] pm_notifier_call_chain+0x1a/0x40 [ 107.999548] [] pm_suspend+0x3ed/0x4e0 [ 107.999552] [] state_store+0xa7/0xb0 [ 107.999557] [] kobj_attr_store+0xf/0x20 [ 107.999561] [] sysfs_kf_write+0x3a/0x50 [ 107.999565] [] kernfs_fop_write+0x127/0x180 [ 107.999571] [] vfs_write+0xb7/0x200 [ 107.999576] [] SyS_write+0x59/0xd0 [ 107.999581] [] system_call_fastpath+0x12/0x71 [ 107.999586] ---[ end trace 3977e3a58591fca2 ]--- Signed-off-by: Krzysztof Kozlowski Reported-by: Linus Torvalds --- This fixes commit 297d716f6260 which was recently pulled from battery tree: https://lkml.org/lkml/2015/4/13/396. --- drivers/acpi/battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index fdc16ce9d272..672263a3832c 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -1106,7 +1106,7 @@ static int battery_notify(struct notifier_block *nb, if (!acpi_battery_present(battery)) return 0; - if (battery->bat) { + if (!battery->bat) { result = acpi_battery_get_info(battery); if (result) return result; -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/