From patchwork Thu Jun 30 03:33:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 931522 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5U3XY6h017354 for ; Thu, 30 Jun 2011 03:33:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757604Ab1F3Ddn (ORCPT ); Wed, 29 Jun 2011 23:33:43 -0400 Received: from mga09.intel.com ([134.134.136.24]:26833 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753782Ab1F3Ddm (ORCPT ); Wed, 29 Jun 2011 23:33:42 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 29 Jun 2011 20:33:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.65,447,1304319600"; d="scan'208";a="19947444" Received: from lantianyu-ws.sh.intel.com (HELO localhost) ([10.239.35.77]) by orsmga002.jf.intel.com with ESMTP; 29 Jun 2011 20:33:40 -0700 From: Lan Tianyu To: lenb@kernel.org Cc: linux-acpi@vger.kernel.org, tianyu.lan@intel.com, rui.zhang@intel.com Subject: [v2 5/6] ACPI / Battery: Add the check before refresh sysfs in the battery_notify() Date: Thu, 30 Jun 2011 11:33:58 +0800 Message-Id: <1309404838-15854-1-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.7.6.rc2.8.g28eb 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]); Thu, 30 Jun 2011 03:33:43 +0000 (UTC) In the commit 25be5821, add the refresh sysfs when system resumes from suspending. But it didn't check that the battery exists. This will cause battery sysfs files added when the battery doesn't exist. This patch add the check before refreshing. https://bugzilla.kernel.org/show_bug.cgi?id=35642 Signed-off-by: Lan Tianyu --- drivers/acpi/battery.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 2fe7cfd..4ba339d 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -949,8 +949,10 @@ static int battery_notify(struct notifier_block *nb, switch (mode) { case PM_POST_HIBERNATION: case PM_POST_SUSPEND: - sysfs_remove_battery(battery); - sysfs_add_battery(battery); + if (battery->bat.dev) { + sysfs_remove_battery(battery); + sysfs_add_battery(battery); + } break; }