From patchwork Tue Apr 14 13:24:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 6215921 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3F6F0BF4A7 for ; Tue, 14 Apr 2015 13:34:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48092202E9 for ; Tue, 14 Apr 2015 13:34:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77205202FE for ; Tue, 14 Apr 2015 13:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753636AbbDNNeW (ORCPT ); Tue, 14 Apr 2015 09:34:22 -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 Received: by pacyx8 with SMTP id yx8so12095251pac.1; Tue, 14 Apr 2015 06:34:21 -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; bh=flflKA20oghp5nx55Abuq760atpwOTke6H0xlBu/qJc=; b=dSbZ97k+gkoDxpLsiDF6gPrXqkSeL2ETfAX8w+3lYEwIinkEHVwvg85M+jnEHK6S8+ 6qQqCs/IlmZJl15GAN4oDlcqoLA4nCLmmIw39JeP2tBZRS6CabGQdfQujod9em7Jkone A9wHYVYYxqrklZGgZu6O9eg6atkCTFymgjftmT1gTjm3cXoF1BtBrDuT2fsUu42T6hEH 6gAEU1G+k99ZErKS9M6vr9vHX+zNJoIcj8nBQPK1iWxqjjCEVvNPKDYPSlYy6T7V7D9X H/3lv+daPYBIuJ6g75Vlt6jiF0BHZbGYCaUNKHD8Q9tgrocR+EsIynEVr0lrKQaK2vv8 bkGA== X-Received: by 10.66.222.41 with SMTP id qj9mr36819881pac.139.1429018460926; Tue, 14 Apr 2015 06:34:20 -0700 (PDT) Received: from localhost.localdomain ([175.195.192.239]) by mx.google.com with ESMTPSA id t5sm1143199pdn.58.2015.04.14.06.34.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Apr 2015 06:34:20 -0700 (PDT) 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-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-By: Sebastian Reichel Acked-by: Rafael J. Wysocki --- 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;