From patchwork Fri Apr 3 20:20:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 212391 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=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED 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 5BADBC2BA16 for ; Fri, 3 Apr 2020 20:21:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2BF28207FF for ; Fri, 3 Apr 2020 20:21:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="nxz83yBU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728241AbgDCUUh (ORCPT ); Fri, 3 Apr 2020 16:20:37 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:1086 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727867AbgDCUUf (ORCPT ); Fri, 3 Apr 2020 16:20:35 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 48vBBl1nhTzpX; Fri, 3 Apr 2020 22:20:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1585945231; bh=Uo9Dg3wLKTkFKZCWLFRcaiKTWxbVtqoScgjUwEkb2W8=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=nxz83yBUg1uqm/R9KaMLxkSsgsiD0pHoYlrtlPa7cN6e7iUsNhapQ5kn5tAD+fLJs kliv3pYb58PuQP2Mw/8oni4J8ad0OjktVOaLT9aZQcYT0YGamLmJPWerSurv3fhQJ2 H7pXlkfdllJfgRo6l0Bom9ecUpJxpbytsMhVpMaTfOhN+gu86y5C2kpqOOtZala9XU elFyWZ8UDBeIM+Lupvlz57izjhrf7/1mcyz822YKcv+BfTIXZnKywOs60/ozMGyyVv CwrtXu7Wwv3WlSOApWLPS9yyyERhoC7xE8nndeYw8G1zwNEX5smbg/TUvFbDFZoxxm WMSVUKcSgptBg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Fri, 03 Apr 2020 22:20:31 +0200 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v3 02/11] power: charger-manager: don't write through desc->properties MIME-Version: 1.0 To: Andrey Smirnov , Guenter Roeck , Sebastian Reichel Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org psy_desc->properties will become pointer to const. Avoid writing through the pointer to enable constification of the tables elsewhere. Signed-off-by: Michał Mirosław --- v3: initial version --- drivers/power/supply/charger-manager.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index 887f5bb879e5..7ecb82107efb 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -1425,15 +1425,18 @@ static int cm_init_thermal_data(struct charger_manager *cm, struct power_supply *fuel_gauge) { struct charger_desc *desc = cm->desc; + enum power_supply_property *props; union power_supply_propval val; int ret; + props = (void *)cm->charger_psy_desc.properties; + /* Verify whether fuel gauge provides battery temperature */ ret = power_supply_get_property(fuel_gauge, POWER_SUPPLY_PROP_TEMP, &val); if (!ret) { - cm->charger_psy_desc.properties[cm->charger_psy_desc.num_properties] = + props[cm->charger_psy_desc.num_properties] = POWER_SUPPLY_PROP_TEMP; cm->charger_psy_desc.num_properties++; cm->desc->measure_battery_temp = true; @@ -1446,7 +1449,7 @@ static int cm_init_thermal_data(struct charger_manager *cm, return PTR_ERR(cm->tzd_batt); /* Use external thermometer */ - cm->charger_psy_desc.properties[cm->charger_psy_desc.num_properties] = + props[cm->charger_psy_desc.num_properties] = POWER_SUPPLY_PROP_TEMP_AMBIENT; cm->charger_psy_desc.num_properties++; cm->desc->measure_battery_temp = true; @@ -1622,6 +1625,7 @@ static int charger_manager_probe(struct platform_device *pdev) union power_supply_propval val; struct power_supply *fuel_gauge; struct power_supply_config psy_cfg = {}; + enum power_supply_property *props; if (IS_ERR(desc)) { dev_err(&pdev->dev, "No platform data (desc) found\n"); @@ -1717,7 +1721,7 @@ static int charger_manager_probe(struct platform_device *pdev) cm->charger_psy_desc.name = cm->psy_name_buf; /* Allocate for psy properties because they may vary */ - cm->charger_psy_desc.properties = + cm->charger_psy_desc.properties = props = devm_kcalloc(&pdev->dev, ARRAY_SIZE(default_charger_props) + NUM_CHARGER_PSY_OPTIONAL, @@ -1725,7 +1729,7 @@ static int charger_manager_probe(struct platform_device *pdev) if (!cm->charger_psy_desc.properties) return -ENOMEM; - memcpy(cm->charger_psy_desc.properties, default_charger_props, + memcpy(props, default_charger_props, sizeof(enum power_supply_property) * ARRAY_SIZE(default_charger_props)); @@ -1738,14 +1742,14 @@ static int charger_manager_probe(struct platform_device *pdev) } if (!power_supply_get_property(fuel_gauge, POWER_SUPPLY_PROP_CHARGE_NOW, &val)) { - cm->charger_psy_desc.properties[cm->charger_psy_desc.num_properties] = + props[cm->charger_psy_desc.num_properties] = POWER_SUPPLY_PROP_CHARGE_NOW; cm->charger_psy_desc.num_properties++; } if (!power_supply_get_property(fuel_gauge, POWER_SUPPLY_PROP_CURRENT_NOW, &val)) { - cm->charger_psy_desc.properties[cm->charger_psy_desc.num_properties] = + props[cm->charger_psy_desc.num_properties] = POWER_SUPPLY_PROP_CURRENT_NOW; cm->charger_psy_desc.num_properties++; }