Lines Matching defs:supply
319 struct power_supply *supply;
322 supply = node_to_item(node, struct power_supply, list);
323 if (!strncmp(name, supply->name, sizeof(supply->name)))
324 return supply;
333 struct power_supply *supply;
335 supply = calloc(1, sizeof(struct power_supply));
336 if (!supply)
339 strlcpy(supply->name, name, sizeof(supply->name));
340 strlcpy(supply->type, type, sizeof(supply->type));
341 snprintf(supply->cap_path, sizeof(supply->cap_path),
343 supply->online = online;
344 list_add_tail(&charger->supplies, &supply->list);
346 LOGV("... added %s %s %d\n", supply->name, supply->type, online);
347 return supply;
350 static void remove_supply(struct charger *charger, struct power_supply *supply)
352 if (!supply)
354 list_remove(&supply->list);
356 free(supply);
422 struct power_supply *supply = NULL;
448 supply = find_supply(charger, uevent->ps_name);
449 if (supply) {
450 was_online = supply->online;
451 supply->online = online;
455 if (!supply) {
456 supply = add_supply(charger, uevent->ps_name, ps_type, uevent->path,
458 if (!supply) {
459 LOGE("cannot add supply '%s' (%s %d)\n", uevent->ps_name,
465 charger->battery = supply;
467 LOGE("supply '%s' already exists..\n", uevent->ps_name);
470 if (supply) {
471 if (charger->battery == supply)
473 remove_supply(charger, supply);
474 supply = NULL;
477 if (!supply) {
478 LOGE("power supply '%s' not found ('%s' %d)\n",
486 /* allow battery to be managed in the supply list but make it not
491 else if (supply && !was_online && online)
495 LOGI("power supply %s (%s) %s (action=%s num_online=%d num_supplies=%d)\n",
881 /* online supply present, reset shutdown timer if set */