summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Miguel Silva <rui.silva@linaro.org>2016-08-26 10:52:05 (GMT)
committerGreg Kroah-Hartman <gregkh@google.com>2016-08-26 11:16:11 (GMT)
commit6ac9166d4e91a6dea03b64b64f128e0f927aa7ec (patch)
treeabad7e484d3962ab440cffb570eebc88de27ddce
parentcc43368a3cde151739ad20cbf71139530bd53f1a (diff)
downloadlinux-6ac9166d4e91a6dea03b64b64f128e0f927aa7ec.tar.xz
greybus: power_supply: fix name setting location
We were checking for existing power supply names in the wrong place, i.e, we were checking before any of the module power supply were registered, because of that of course no name collision was detected. Move the check to the register loop and with that we guarantee that this mechanism works for greybus power supply naming. Tested: using gbsim and using power supply with the same name and check that: 1. no problems creating sysfs entries; 2. naming is done following the desired rules. Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
-rw-r--r--drivers/staging/greybus/power_supply.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/staging/greybus/power_supply.c b/drivers/staging/greybus/power_supply.c
index 199a19a..578d38b 100644
--- a/drivers/staging/greybus/power_supply.c
+++ b/drivers/staging/greybus/power_supply.c
@@ -870,19 +870,19 @@ static int gb_power_supply_config(struct gb_power_supplies *supplies, int id)
if (ret < 0)
return ret;
- ret = gb_power_supply_prop_descriptors_get(gbpsy);
- if (ret < 0)
- return ret;
-
- /* guarantee that we have an unique name, before register */
- return __gb_power_supply_set_name(gbpsy->model_name, gbpsy->name,
- sizeof(gbpsy->name));
+ return gb_power_supply_prop_descriptors_get(gbpsy);
}
static int gb_power_supply_enable(struct gb_power_supply *gbpsy)
{
int ret;
+ /* guarantee that we have an unique name, before register */
+ ret = __gb_power_supply_set_name(gbpsy->model_name, gbpsy->name,
+ sizeof(gbpsy->name));
+ if (ret < 0)
+ return ret;
+
ret = gb_power_supply_register(gbpsy);
if (ret < 0)
return ret;