Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp593125ybz; Wed, 15 Apr 2020 14:45:01 -0700 (PDT) X-Google-Smtp-Source: APiQypL84tKJelQ9oKZTdOfkFxNG9sGPgks+wWAFb3kVFIdzSrJ8+8hTUIkS0HT0oTImR6Hvp7fi X-Received: by 2002:a17:906:d7a2:: with SMTP id pk2mr7212716ejb.272.1586987101094; Wed, 15 Apr 2020 14:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586987101; cv=none; d=google.com; s=arc-20160816; b=FSgaBgH+GJ1jmt+VI68IylERvd3Ebt1IDJZM8QtkZBm8u0EtuzUauVM194a9AL4JNv dVUHR4EjyKPsN9/ogMC8z1DiY2ULKjyu/idIPX6kXh35dQTytoUMEu+z92LLOM5VIGQS 4zJ0o8s25Jbh6Pq1w8QroBEFY93w9CM9TQl5E19wNXMeDq7YXvYzp8rzueBD2GMimRpm 4Z/PVThMmc56d5NypmPb+/XJpZyz3O3fu8zS1yJj5ppmj4YhHo7yU4apid7F8yHedtJE 0M0dUS4Q7xC0uVaggreLCNAfLPw6P9yjRiXMGDzZ1kwOGHr9qL1U38xY4deU/YizLb1j DcWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=HX4DqsqCphRo2Fs2w1lE5jcg4fNvbTkh7BNhC4T7qTE=; b=H8j6JEe8Fid00KlHZYTHbavsNlFAsdRXKnOQDG/Jbml5hlLng60bAc6/wwjEmq8fYx lbb3rLaKRAJ7erSI948NRqMtuz6epEC+BMPAMAEDoar2ryKttYKmKgrjvvGsfTzao8rH oRep3zzgd1+tTBi1JTgHAC49g6cJFAq3CB9kD7J3jkPq7zBzwU2Mqfu1RoQQLKJTtabf hKlRe21GaN3f0pCiXsbWeApY9Fjdc2f3Y0W+RFsZiDr7UplH2Isga6QSUxbRsqEP5wmL 1qEyNx697XtAI/Ly7y4yu78cjUumlvc74TalcGtdDU0emyKRW55Dl4ukL1bNE7X0s1tv WK1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p5si11343240edd.220.2020.04.15.14.44.37; Wed, 15 Apr 2020 14:45:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391128AbgDNP52 (ORCPT + 99 others); Tue, 14 Apr 2020 11:57:28 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:45260 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387417AbgDNP5Z (ORCPT ); Tue, 14 Apr 2020 11:57:25 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 0D0582A04F7 Subject: Re: [PATCH 3/4] power: supply: generic-adc-battery: Prepare for const properties To: Sebastian Reichel , Sebastian Reichel Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com References: <20200413183853.1088823-1-sebastian.reichel@collabora.com> <20200413183853.1088823-4-sebastian.reichel@collabora.com> From: Enric Balletbo i Serra Message-ID: <7ae59eca-35b2-59ed-8fc9-212fdb8decc5@collabora.com> Date: Tue, 14 Apr 2020 17:57:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200413183853.1088823-4-sebastian.reichel@collabora.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sebastian, On 13/4/20 20:38, Sebastian Reichel wrote: > This prepares the driver to work with the properties entry > in power_supply_desc marked as const. > > Signed-off-by: Sebastian Reichel Reviewed-by: Enric Balletbo i Serra > --- > drivers/power/supply/generic-adc-battery.c | 22 +++++++++++----------- > 1 file changed, 11 insertions(+), 11 deletions(-) > > diff --git a/drivers/power/supply/generic-adc-battery.c b/drivers/power/supply/generic-adc-battery.c > index bc462d1ec963..caa829738ef7 100644 > --- a/drivers/power/supply/generic-adc-battery.c > +++ b/drivers/power/supply/generic-adc-battery.c > @@ -241,6 +241,7 @@ static int gab_probe(struct platform_device *pdev) > struct power_supply_desc *psy_desc; > struct power_supply_config psy_cfg = {}; > struct gab_platform_data *pdata = pdev->dev.platform_data; > + enum power_supply_property *properties; > int ret = 0; > int chan; > int index = ARRAY_SIZE(gab_props); > @@ -268,16 +269,16 @@ static int gab_probe(struct platform_device *pdev) > * copying the static properties and allocating extra memory for holding > * the extra configurable properties received from platform data. > */ > - psy_desc->properties = kcalloc(ARRAY_SIZE(gab_props) + > - ARRAY_SIZE(gab_chan_name), > - sizeof(*psy_desc->properties), > - GFP_KERNEL); > - if (!psy_desc->properties) { > + properties = kcalloc(ARRAY_SIZE(gab_props) + > + ARRAY_SIZE(gab_chan_name), > + sizeof(*properties), > + GFP_KERNEL); > + if (!properties) { > ret = -ENOMEM; > goto first_mem_fail; > } > > - memcpy(psy_desc->properties, gab_props, sizeof(gab_props)); > + memcpy(properties, gab_props, sizeof(gab_props)); > > /* > * getting channel from iio and copying the battery properties > @@ -294,13 +295,11 @@ static int gab_probe(struct platform_device *pdev) > int index2; > > for (index2 = 0; index2 < index; index2++) { > - if (psy_desc->properties[index2] == > - gab_dyn_props[chan]) > + if (properties[index2] == gab_dyn_props[chan]) > break; /* already known */ > } > if (index2 == index) /* really new */ > - psy_desc->properties[index++] = > - gab_dyn_props[chan]; > + properties[index++] = gab_dyn_props[chan]; > any = true; > } > } > @@ -317,6 +316,7 @@ static int gab_probe(struct platform_device *pdev) > * as come channels may be not be supported by the device.So > * we need to take care of that. > */ > + psy_desc->properties = properties; > psy_desc->num_properties = index; > > adc_bat->psy = power_supply_register(&pdev->dev, psy_desc, &psy_cfg); > @@ -358,7 +358,7 @@ static int gab_probe(struct platform_device *pdev) > iio_channel_release(adc_bat->channel[chan]); > } > second_mem_fail: > - kfree(psy_desc->properties); > + kfree(properties); > first_mem_fail: > return ret; > } >