aboutsummaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorSebastian Reichel <sebastian.reichel@collabora.com>2018-09-28 15:14:22 +0200
committerSebastian Reichel <sre@kernel.org>2018-12-13 00:16:16 +0100
commitefcca6bdfba1d579d86bd3f5ea65e5bf8e7deebe (patch)
treec87e90ee86d4797054a9cf6fd669e395e87ce55e /drivers/power
parent750688c7cdfd3ffd6189d96cbf0ff8f19bdebbdb (diff)
downloadlinux-stericsson-efcca6bdfba1d579d86bd3f5ea65e5bf8e7deebe.tar.gz
power: supply: charger-manager: simplify generation of sysfs attribute group name
This is a simple cleanup and there should be no functional changes. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/charger-manager.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
index dc0c9a6c7d21..2e579da5c0b9 100644
--- a/drivers/power/supply/charger-manager.c
+++ b/drivers/power/supply/charger-manager.c
@@ -1368,8 +1368,7 @@ static int charger_manager_register_sysfs(struct charger_manager *cm)
struct charger_desc *desc = cm->desc;
struct charger_regulator *charger;
int chargers_externally_control = 1;
- char buf[11];
- char *str;
+ char *name;
int ret;
int i;
@@ -1377,19 +1376,15 @@ static int charger_manager_register_sysfs(struct charger_manager *cm)
for (i = 0; i < desc->num_charger_regulators; i++) {
charger = &desc->charger_regulators[i];
- snprintf(buf, 10, "charger.%d", i);
- str = devm_kzalloc(cm->dev,
- strlen(buf) + 1, GFP_KERNEL);
- if (!str)
+ name = devm_kasprintf(cm->dev, GFP_KERNEL, "charger.%d", i);
+ if (!name)
return -ENOMEM;
- strcpy(str, buf);
-
charger->attrs[0] = &charger->attr_name.attr;
charger->attrs[1] = &charger->attr_state.attr;
charger->attrs[2] = &charger->attr_externally_control.attr;
charger->attrs[3] = NULL;
- charger->attr_g.name = str;
+ charger->attr_g.name = name;
charger->attr_g.attrs = charger->attrs;
sysfs_attr_init(&charger->attr_name.attr);