From patchwork Wed Jul 7 01:11:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 110565 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o671ATcR011098 for ; Wed, 7 Jul 2010 01:10:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754553Ab0GGBKZ (ORCPT ); Tue, 6 Jul 2010 21:10:25 -0400 Received: from mga02.intel.com ([134.134.136.20]:35901 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754506Ab0GGBKY (ORCPT ); Tue, 6 Jul 2010 21:10:24 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 06 Jul 2010 18:09:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.53,549,1272870000"; d="scan'208";a="533101984" Received: from rzhang1-desktop.sh.intel.com (HELO [10.239.36.208]) ([10.239.36.208]) by orsmga002.jf.intel.com with ESMTP; 06 Jul 2010 18:11:00 -0700 Subject: [PATCH] ACPI battery: don't invoke power_supply_changed twice when battery is hot-added From: Zhang Rui To: "Brown, Len" Cc: "linux-acpi@vger.kernel.org" , Alexey Starikovskiy , "Zhang, Rui" Date: Wed, 07 Jul 2010 09:11:57 +0800 Message-ID: <1278465117.4537.7520.camel@rzhang1-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 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.3 (demeter.kernel.org [140.211.167.41]); Wed, 07 Jul 2010 01:10:29 +0000 (UTC) Index: linux-2.6-clean/drivers/acpi/battery.c =================================================================== --- linux-2.6-clean.orig/drivers/acpi/battery.c +++ linux-2.6-clean/drivers/acpi/battery.c @@ -868,9 +868,15 @@ static void acpi_battery_remove_fs(struc static void acpi_battery_notify(struct acpi_device *device, u32 event) { struct acpi_battery *battery = acpi_driver_data(device); +#ifdef CONFIG_ACPI_SYSFS_POWER + struct device *old; +#endif if (!battery) return; +#ifdef CONFIG_ACPI_SYSFS_POWER + old = battery->bat.dev; +#endif acpi_battery_update(battery); acpi_bus_generate_proc_event(device, event, acpi_battery_present(battery)); @@ -879,7 +885,7 @@ static void acpi_battery_notify(struct a acpi_battery_present(battery)); #ifdef CONFIG_ACPI_SYSFS_POWER /* acpi_battery_update could remove power_supply object */ - if (battery->bat.dev) + if (old && battery->bat.dev) power_supply_changed(&battery->bat); #endif }