Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp866268ybb; Fri, 3 Apr 2020 13:21:18 -0700 (PDT) X-Google-Smtp-Source: APiQypLuAPrOsI8MYCKIulItXIG2jPGQXHDPJXHBgMHHTzILzHldnwLtV44pyre/c+HuAl0Njrfy X-Received: by 2002:a9d:5187:: with SMTP id y7mr7876901otg.159.1585945278457; Fri, 03 Apr 2020 13:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585945278; cv=none; d=google.com; s=arc-20160816; b=mqFcmiJi5oihmqAOqqUqdWj9UmDYe8OOdC9im6W/nr4DeWYZ/T6xKWCNY+3KsUZUxJ iLpYZtAYTBpzKDPZ2sR5QugcVLr5Yy8s70gjscnlHwp8YTCOBm7aqDSKSCCOhTsyxouW JQYi2rqt/YwekAO71Xd+XsJ0i0w1QfnAOI/o9mfCmVng/IWkE/5qwU53VyfavlaEvi4S jz8ERwi+Hlaip/qCPiRsyHIOaEXeOBbBiMu6pEkQ43xK8ygq2VDmmQmBCUM3o72szTxz Fv+jJ0YZO1KvxlkzmCPLEU21ECz4ltbhsq1HYFKs7/qxnp6RlAwpwf93JKhpjN07aFyK tEJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:content-transfer-encoding :mime-version:subject:from:references:in-reply-to:message-id:date :dkim-signature; bh=vnNa2ge+xj1njb9//EtfxRBjSJ8TZwki4lAZq/dK5DU=; b=lGhchN8GnV7UgxXXKRkym4FxEw/+pY6stN+haS02W1s28Rhd4Q11Gt3Ck/CCT06Z4N 1IvXv0XJL3IPsI8KsNFTX39QtyX9+o4PMxBWmUBJIEKPoBOrpglAQjSQ+rB0TNRbGdRm 3HvgucJv5X8gIBGJdJdcvSFaJnH+YxEOMXh/NeAA+7AkYbRcqvwygrpv+cuPrweYHA12 mtn4NxjNNCjH4Rtqs+/qjOWy14F4mCTUFf9HiknnAFc6BDI9IWb8Xj3j9xMx05AYjx2p SvkzjQL7PYdxudnGxZIemazjQ0zFRPhTe/RntZ5BlxpEnL9/pXCaScIaJWnl+ULMntRT DvOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=nxz83yBU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x33si4143103otb.48.2020.04.03.13.21.06; Fri, 03 Apr 2020 13:21:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=nxz83yBU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728359AbgDCUUk (ORCPT + 99 others); Fri, 3 Apr 2020 16:20:40 -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?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH v3 02/11] power: charger-manager: don't write through desc->properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: Andrey Smirnov , Guenter Roeck , Sebastian Reichel Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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++; } -- 2.20.1