From patchwork Wed Jun 29 08:24:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 927582 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 p5T8NtFe010922 for ; Wed, 29 Jun 2011 08:27:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753824Ab1F2IYX (ORCPT ); Wed, 29 Jun 2011 04:24:23 -0400 Received: from mga11.intel.com ([192.55.52.93]:49519 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753750Ab1F2IYV (ORCPT ); Wed, 29 Jun 2011 04:24:21 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 29 Jun 2011 01:24:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.65,442,1304319600"; d="scan'208";a="24178570" Received: from lantianyu-ws.sh.intel.com (HELO localhost) ([10.239.35.77]) by fmsmga001.fm.intel.com with ESMTP; 29 Jun 2011 01:24:19 -0700 From: Lan Tianyu To: lenb@kernel.org Cc: linux-acpi@vger.kernel.org, tianyu.lan@intel.com, rui.zhang@intel.com, stable@kernel.org Subject: [PATCH 5/6] ACPI / Battery: Add the check before refresh sysfs in the battery_notify() Date: Wed, 29 Jun 2011 16:24:34 +0800 Message-Id: <1309335874-26588-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]); Wed, 29 Jun 2011 08:27:35 +0000 (UTC) In the commit 25be5821, add the refresh sysfs when system resumes from suspend. But it didn't check that the battery exists. This will cause battery sysfs 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 cc35bdc..cb4a554 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; }