From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D42AC43603 for ; Thu, 5 Dec 2019 15:45:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 703C7206DB for ; Thu, 5 Dec 2019 15:45:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=castello.eng.br header.i=@castello.eng.br header.b="f5pmWoLw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729685AbfLEPpd (ORCPT ); Thu, 5 Dec 2019 10:45:33 -0500 Received: from gateway23.websitewelcome.com ([192.185.50.108]:13521 "EHLO gateway23.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729967AbfLEPpa (ORCPT ); Thu, 5 Dec 2019 10:45:30 -0500 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 9CFB214697 for ; Thu, 5 Dec 2019 09:45:29 -0600 (CST) Received: from br164.hostgator.com.br ([192.185.176.180]) by cmsmtp with SMTP id ctJpixPfSW4frctJpiK88A; Thu, 05 Dec 2019 09:45:29 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=castello.eng.br; s=default; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=v/IFCcTbO/DrE6m1PJu/yWJCqP1uo1Mldd05pOJ8dG8=; b=f5pmWoLwdHuJU762BAsu7SszOm OUK4UpyOjkHdbi/3dsGZYny5Kpat+YPDHfwX/sb/H/8yvMZqwRaV/CppM53CRI8ifdNCTRz6pDbxn 25n/5GWCpakBz4KLMFPLFxxi9j+joiSMXP/Xxk8JpGPHB80mfgxrLD6gd9jdjy44vH6KcNzSF95mP He09l7LUgoEmkeINVmis2ZDpy6i81pDNVXR35qy3FSxKqX3x6aojZ+9eT/u29c+fiQVXLJAIgrRRo KTFjKKliw/HFVCZBqP5WQ4yFuFU3w+zn5AIE3NhKOfb863sqQkIVCUrqIdLFRyj0uZ+LHp4J1JRx9 3muYoWSQ==; Received: from [191.31.196.215] (port=35544 helo=castello.bz.toradex.local) by br164.hostgator.com.br with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1ictJo-001jEH-G0; Thu, 05 Dec 2019 12:45:28 -0300 From: Matheus Castello To: sre@kernel.org, krzk@kernel.org, robh+dt@kernel.org Cc: mark.rutland@arm.com, cw00.choi@samsung.com, b.zolnierkie@samsung.com, lee.jones@linaro.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Matheus Castello Subject: [PATCH v8 5/5] power: supply: max17040: Send uevent in SOC and status change Date: Thu, 5 Dec 2019 12:44:10 -0300 Message-Id: <20191205154410.29462-6-matheus@castello.eng.br> X-Mailer: git-send-email 2.24.0.rc2 In-Reply-To: <20191205154410.29462-1-matheus@castello.eng.br> References: <20191205154410.29462-1-matheus@castello.eng.br> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - br164.hostgator.com.br X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - castello.eng.br X-BWhitelist: no X-Source-IP: 191.31.196.215 X-Source-L: No X-Exim-ID: 1ictJo-001jEH-G0 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (castello.bz.toradex.local) [191.31.196.215]:35544 X-Source-Auth: matheus@castello.eng.br X-Email-Count: 59 X-Source-Cap: Y2FzdGUyNDg7Y2FzdGUyNDg7YnIxNjQuaG9zdGdhdG9yLmNvbS5icg== X-Local-Domain: yes Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Notify core through power_supply_changed() in case of changes in state of charge and power supply status. This is useful for user-space to efficiently update current battery level. Signed-off-by: Matheus Castello Reviewed-by: Krzysztof Kozlowski --- drivers/power/supply/max17040_battery.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c index 2a2a1fd8d4eb..c1188e94cf54 100644 --- a/drivers/power/supply/max17040_battery.c +++ b/drivers/power/supply/max17040_battery.c @@ -207,10 +207,19 @@ static void max17040_check_changes(struct i2c_client *client) static void max17040_work(struct work_struct *work) { struct max17040_chip *chip; + int last_soc, last_status; chip = container_of(work, struct max17040_chip, work.work); + + /* store SOC and status to check changes */ + last_soc = chip->soc; + last_status = chip->status; max17040_check_changes(chip->client); + /* check changes and send uevent */ + if (last_soc != chip->soc || last_status != chip->status) + power_supply_changed(chip->battery); + queue_delayed_work(system_power_efficient_wq, &chip->work, MAX17040_DELAY); } -- 2.24.0.rc2