From patchwork Fri Feb 7 19:28:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mezin X-Patchwork-Id: 3607391 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E9B6B9F344 for ; Fri, 7 Feb 2014 19:31:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D84B200ED for ; Fri, 7 Feb 2014 19:31:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 616EC2011E for ; Fri, 7 Feb 2014 19:31:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752962AbaBGTbC (ORCPT ); Fri, 7 Feb 2014 14:31:02 -0500 Received: from mail-lb0-f181.google.com ([209.85.217.181]:48197 "EHLO mail-lb0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751463AbaBGTbA (ORCPT ); Fri, 7 Feb 2014 14:31:00 -0500 Received: by mail-lb0-f181.google.com with SMTP id z11so1974817lbi.26 for ; Fri, 07 Feb 2014 11:30:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=oNbTWewetFSIyKptlyL7UmNu1NU3CHGeBcK8nrxOyZc=; b=u5nUGIXPJ3M0OluRk6USXLq1LZR8P9ntm1Vwt97eSS4VWk4kA16PYDBKbWVL6WbuRk Lc4wT8ThqCVXGzRysVfso4/GcecU1SAOkqURA2f6i+JJQh7eC6rizCqoQINIRL7U5t+5 Il00wmta+rAxpMwBcJy3nNmRA4xFoHEi5cmj3buASrQZue8jIUYnzcvEYEzyHsjf0JiO yhRSX2Trd0s+ssC+eQ+lzXS04TTNANmjJTc2HM7wnJEu08XNNWhhuZNi26FiUTwt2HfB uW+K2U1ZyvcsUEsPza6VFCI9Nm5FoPuOAIa9sJv3wJt4jWNDAR++dtYKfFEiYtFm7GVb SyVw== X-Received: by 10.152.234.36 with SMTP id ub4mr11356360lac.13.1391801458634; Fri, 07 Feb 2014 11:30:58 -0800 (PST) Received: from localhost.localdomain ([109.194.127.69]) by mx.google.com with ESMTPSA id ri4sm5884335lbb.6.2014.02.07.11.30.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Feb 2014 11:30:53 -0800 (PST) From: Alexander Mezin To: linux-acpi@vger.kernel.org Cc: Alexander Mezin Subject: [PATCH 1/2] ACPI / AC: Notify when state changes in get_ac_property Date: Sat, 8 Feb 2014 02:28:52 +0700 Message-Id: <1391801333-18519-1-git-send-email-mezin.alexander@gmail.com> X-Mailer: git-send-email 1.8.5.4 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Do the same thing as in acpi_ac_resume. BIOS on my laptop (HP Pavilion dv6-6179er) don't send proper notifications when AC adapter is plugged/unplugged. This change makes it possible to workaround the problem by using acpid and a shell script. This patch has the same effect as commit 50a2bc5429f07ec4d53df2d287b03bdbceb281bb "ACPI / AC: change notification handler type to ACPI_ALL_NOTIFY" Aforementioned commit could be reverted. Signed-off-by: Alexander Mezin --- drivers/acpi/ac.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index e7515aa..cdba639 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -90,12 +90,16 @@ static int get_ac_property(struct power_supply *psy, union power_supply_propval *val) { struct acpi_ac *ac = to_acpi_ac(psy); + unsigned long long old_state; if (!ac) return -ENODEV; + old_state = ac->state; if (acpi_ac_get_state(ac)) return -ENODEV; + if (old_state != ac->state) + kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); switch (psp) { case POWER_SUPPLY_PROP_ONLINE: