From patchwork Thu Jan 14 22:36:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 12021025 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED, 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 2C430C433E0 for ; Thu, 14 Jan 2021 22:37:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F31B42339E for ; Thu, 14 Jan 2021 22:37:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728157AbhANWhT (ORCPT ); Thu, 14 Jan 2021 17:37:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726439AbhANWhS (ORCPT ); Thu, 14 Jan 2021 17:37:18 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B3F2C061575; Thu, 14 Jan 2021 14:36:38 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id C91691F4587E Received: by jupiter.universe (Postfix, from userid 1000) id 296C54800BB; Thu, 14 Jan 2021 23:36:35 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel Cc: linux-omap@vger.kernel.org, linux-pm@vger.kernel.org, Sebastian Reichel , kernel@collabora.com, Arthur Demchenkov , Carl Philipp Klemm , Merlijn Wajer , Pavel Machek , Tony Lindgren Subject: [PATCH] power: supply: cpcap-battery: constify psy_desc Date: Thu, 14 Jan 2021 23:36:17 +0100 Message-Id: <20210114223617.313588-1-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org There is no dynamic information in cpcap-battery's power-supply description struct, so let's make it static const. Cc: Arthur Demchenkov Cc: Carl Philipp Klemm Cc: Merlijn Wajer Cc: Pavel Machek Cc: Tony Lindgren Signed-off-by: Sebastian Reichel Acked-by: Pavel Machek Acked-by: Tony Lindgren --- I noticed this while reviewing Tony's patch series. --- drivers/power/supply/cpcap-battery.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c index 86ed41d9627f..6d5bcdb9f45d 100644 --- a/drivers/power/supply/cpcap-battery.c +++ b/drivers/power/supply/cpcap-battery.c @@ -999,9 +999,19 @@ static const struct of_device_id cpcap_battery_id_table[] = { MODULE_DEVICE_TABLE(of, cpcap_battery_id_table); #endif +static const struct power_supply_desc cpcap_charger_battery_desc = { + .name = "battery", + .type = POWER_SUPPLY_TYPE_BATTERY, + .properties = cpcap_battery_props, + .num_properties = ARRAY_SIZE(cpcap_battery_props), + .get_property = cpcap_battery_get_property, + .set_property = cpcap_battery_set_property, + .property_is_writeable = cpcap_battery_property_is_writeable, + .external_power_changed = cpcap_battery_external_power_changed, +}; + static int cpcap_battery_probe(struct platform_device *pdev) { - struct power_supply_desc *psy_desc; struct cpcap_battery_ddata *ddata; const struct of_device_id *match; struct power_supply_config psy_cfg = {}; @@ -1056,23 +1066,11 @@ static int cpcap_battery_probe(struct platform_device *pdev) if (error) return error; - psy_desc = devm_kzalloc(ddata->dev, sizeof(*psy_desc), GFP_KERNEL); - if (!psy_desc) - return -ENOMEM; - - psy_desc->name = "battery"; - psy_desc->type = POWER_SUPPLY_TYPE_BATTERY; - psy_desc->properties = cpcap_battery_props; - psy_desc->num_properties = ARRAY_SIZE(cpcap_battery_props); - psy_desc->get_property = cpcap_battery_get_property; - psy_desc->set_property = cpcap_battery_set_property; - psy_desc->property_is_writeable = cpcap_battery_property_is_writeable; - psy_desc->external_power_changed = cpcap_battery_external_power_changed; - psy_cfg.of_node = pdev->dev.of_node; psy_cfg.drv_data = ddata; - ddata->psy = devm_power_supply_register(ddata->dev, psy_desc, + ddata->psy = devm_power_supply_register(ddata->dev, + &cpcap_charger_battery_desc, &psy_cfg); error = PTR_ERR_OR_ZERO(ddata->psy); if (error) {