예제 #1
0
파일: reader.c 프로젝트: bilboed/wine
static void test_read_state_(IXmlReader *reader, XmlReadState expected,
                                    XmlReadState exp_broken, int todo, int line)
{
    XmlReadState state;
    HRESULT hr;
    int broken_state;

    state = -1; /* invalid value */
    hr = IXmlReader_GetProperty(reader, XmlReaderProperty_ReadState, (LONG_PTR*)&state);
    ok_(__FILE__, line)(hr == S_OK, "Expected S_OK, got %08x\n", hr);

    if (exp_broken == -1)
        broken_state = 0;
    else
        broken_state = broken(exp_broken == state);

    if (todo)
    {
    todo_wine
        ok_(__FILE__, line)(state == expected || broken_state, "Expected (%s), got (%s)\n",
                                   state_to_str(expected), state_to_str(state));
    }
    else
        ok_(__FILE__, line)(state == expected || broken_state, "Expected (%s), got (%s)\n",
                                   state_to_str(expected), state_to_str(state));
}
예제 #2
0
void wcd9xxx_clsh_fsm(struct snd_soc_codec *codec,
		struct wcd9xxx_clsh_cdc_data *cdc_clsh_d,
		u8 req_state, bool req_type, u8 clsh_event)
{
	u8 old_state, new_state;

	switch (clsh_event) {

	case WCD9XXX_CLSH_EVENT_PRE_DAC:

		/* PRE_DAC event should be used only for Enable */
		BUG_ON(req_type != WCD9XXX_CLSH_REQ_ENABLE);

		old_state = cdc_clsh_d->state;
		new_state = old_state | req_state;

		(*clsh_state_fp[new_state]) (codec, cdc_clsh_d,
							req_state, req_type);
		cdc_clsh_d->state = new_state;
		dev_dbg(codec->dev, "%s: ClassH state transition from %s to %s\n",
			__func__, state_to_str(old_state),
			state_to_str(cdc_clsh_d->state));

		break;

	case WCD9XXX_CLSH_EVENT_POST_PA:

		if (req_type == WCD9XXX_CLSH_REQ_DISABLE) {
			if (req_state == WCD9XXX_CLSH_STATE_LO
					&& --cdc_lo_count > 0)
				break;

			old_state = cdc_clsh_d->state;
			new_state = old_state & (~req_state);

			if (new_state < NUM_CLSH_STATES) {
				(*clsh_state_fp[new_state]) (codec, cdc_clsh_d,
							req_state, req_type);
				cdc_clsh_d->state = new_state;
				dev_dbg(codec->dev, "%s: ClassH state transition from %s to %s\n",
					__func__, state_to_str(old_state),
					state_to_str(cdc_clsh_d->state));

			} else {
				dev_dbg(codec->dev, "%s: wrong new state = %x\n",
						__func__, new_state);
			}


		} else if (req_state != WCD9XXX_CLSH_STATE_LO) {
			wcd9xxx_clsh_enable_post_pa(codec);
		}

		break;
	}

}
예제 #3
0
static void wcd9xxx_clsh_state_err(struct snd_soc_codec *codec,
		struct wcd9xxx_clsh_cdc_data *clsh_d,
		u8 req_state, bool is_enable)
{
	dev_dbg(codec->dev, "%s Wrong request for class H state machine requested to %s %s"
			, __func__, is_enable ? "enable" : "disable",
			state_to_str(req_state));
	WARN_ON(1);
}
예제 #4
0
static void wcd_clsh_state_err(struct snd_soc_codec *codec,
		struct wcd_clsh_cdc_data *clsh_d,
		u8 req_state, bool is_enable, int mode)
{
	char msg[128];

	dev_err(codec->dev,
		"%s Wrong request for class H state machine requested to %s %s",
		__func__, is_enable ? "enable" : "disable",
		state_to_str(req_state, msg, sizeof(msg)));
	WARN_ON(1);
}
예제 #5
0
void eee_account_dump(EeeAccount *self)
{
    g_return_if_fail(IS_EEE_ACCOUNT(self));

    g_debug("EeeAccount(name=%s, server=%s, state=%s)", self->name, self->server, state_to_str(self->state));
}
예제 #6
0
/*
 * Function: wcd_clsh_fsm
 * Params: codec, cdc_clsh_d, req_state, req_type, clsh_event
 * Description:
 * This function handles PRE DAC and POST DAC conditions of different devices
 * and updates class H configuration of different combination of devices
 * based on validity of their states. cdc_clsh_d will contain current
 * class h state information
 */
void wcd_clsh_fsm(struct snd_soc_codec *codec,
		struct wcd_clsh_cdc_data *cdc_clsh_d,
		u8 clsh_event, u8 req_state,
		int int_mode)
{
	u8 old_state, new_state;
	char msg0[128], msg1[128];

	switch (clsh_event) {
	case WCD_CLSH_EVENT_PRE_DAC:
		old_state = cdc_clsh_d->state;
		new_state = old_state | req_state;

		if (!wcd_clsh_is_state_valid(new_state)) {
			dev_err(codec->dev,
				"%s: Class-H not a valid new state: %s\n",
				__func__,
				state_to_str(new_state, msg0, sizeof(msg0)));
			return;
		}
		if (new_state == old_state) {
			dev_err(codec->dev,
				"%s: Class-H already in requested state: %s\n",
				__func__,
				state_to_str(new_state, msg0, sizeof(msg0)));
			return;
		}
		cdc_clsh_d->state = new_state;
		wcd_clsh_set_int_mode(cdc_clsh_d, req_state, int_mode);
		(*clsh_state_fp[new_state]) (codec, cdc_clsh_d, req_state,
					     CLSH_REQ_ENABLE, int_mode);
		dev_dbg(codec->dev,
			"%s: ClassH state transition from %s to %s\n",
			__func__, state_to_str(old_state, msg0, sizeof(msg0)),
			state_to_str(cdc_clsh_d->state, msg1, sizeof(msg1)));
		break;
	case WCD_CLSH_EVENT_POST_PA:
		old_state = cdc_clsh_d->state;
		new_state = old_state & (~req_state);
		if (new_state < NUM_CLSH_STATES_V2) {
			if (!wcd_clsh_is_state_valid(old_state)) {
				dev_err(codec->dev,
					"%s:Invalid old state:%s\n",
					__func__,
					state_to_str(old_state, msg0,
						     sizeof(msg0)));
				return;
			}
			if (new_state == old_state) {
				dev_err(codec->dev,
					"%s: Class-H already in requested state: %s\n",
					__func__,
					state_to_str(new_state, msg0,
						     sizeof(msg0)));
				return;
			}
			(*clsh_state_fp[old_state]) (codec, cdc_clsh_d,
					req_state, CLSH_REQ_DISABLE,
					int_mode);
			cdc_clsh_d->state = new_state;
			wcd_clsh_set_int_mode(cdc_clsh_d, req_state, CLS_NONE);
			dev_dbg(codec->dev, "%s: ClassH state transition from %s to %s\n",
				__func__, state_to_str(old_state, msg0,
						       sizeof(msg0)),
				state_to_str(cdc_clsh_d->state, msg1,
					     sizeof(msg1)));
		}
		break;
	};
}
예제 #7
0
static void charger_gas_gauge_update(struct charger_info *di)
{
	struct power_supply *battery;
	union power_supply_propval val;
	int capacity;
	int raw_capacity;
	int voltage_uV;
	int current_uA;
	int temperature_cC;
	int qpassed_mAh;
	int status;
	int ret;

	battery = get_battery_power_supply(di);
	if (!battery) {
		dev_err(di->dev, "Failed to get battery power supply supplicant for charger\n");
		goto error;
	}

	if (!battery->get_property) {
		dev_err(di->dev, "bettery power supply has null get_property method\n");
		goto error;
	}

	ret = battery->get_property(battery, POWER_SUPPLY_PROP_CAPACITY, &val);
	if (ret) {
		dev_err(di->dev, "Failed to read battery capacity: %d\n", ret);
		goto error;
	}
	capacity = val.intval;

	ret = battery->get_property(battery, POWER_SUPPLY_PROP_CAPACITY_LEVEL, &val);
	if (ret) {
		dev_err(di->dev, "Failed to read battery raw capacity: %d\n", ret);
		goto error;
	}
	raw_capacity = val.intval;

	ret = battery->get_property(battery, POWER_SUPPLY_PROP_VOLTAGE_NOW, &val);
	if (ret) {
		dev_err(di->dev, "Failed to read battery voltage: %d\n", ret);
		voltage_uV = 0;
	} else {
		voltage_uV = val.intval;
	}

	ret = battery->get_property(battery, POWER_SUPPLY_PROP_CURRENT_NOW, &val);
	if (ret) {
		dev_err(di->dev, "Failed to read battery current: %d\n", ret);
		current_uA = 0;
	} else {
		current_uA = val.intval;
	}

	ret = battery->get_property(battery, POWER_SUPPLY_PROP_TEMP, &val);
	if (ret) {
		dev_warn(di->dev, "Failed to read battery temperature: %d\n", ret);
		temperature_cC = 0;
	} else {
		temperature_cC = val.intval;
	}

	ret = battery->get_property(battery, POWER_SUPPLY_PROP_STATUS, &val);
	if (ret) {
		dev_err(di->dev, "Failed to read battery status: %d\n", ret);
		goto error;
	}
	status = val.intval;

	ret = battery->get_property(battery,
		POWER_SUPPLY_PROP_CHARGE_COUNTER, &val);
	if (ret) {
		dev_warn(di->dev, "Failed to read charge counter: %d\n", ret);
		qpassed_mAh = 0;
	} else {
		qpassed_mAh = val.intval;
	}

	/* store values in device info */
	di->gg_capacity = capacity;
	di->gg_raw_capacity = raw_capacity;
	di->gg_status = status;
	di->gg_voltage_uV = voltage_uV;
	di->gg_current_uA = current_uA;
	di->gg_temperature_cC = temperature_cC;
	di->gg_qpassed_mAh = qpassed_mAh;

	dev_info(di->dev, "capacity=%d%% raw_capacity=%d%% status=%02x voltage_uV=%d current_uA=%d "
			"temperature_cC=%d qpassed_mAh=%d state=%s\n",
			di->gg_capacity, di->gg_raw_capacity, di->gg_status, di->gg_voltage_uV,
			di->gg_current_uA, di->gg_temperature_cC, di->gg_qpassed_mAh, state_to_str(di->state));

error:
	return;
}
예제 #8
0
static void charger_work(struct work_struct *work)
{
	struct charger_info *di = container_of(work, struct charger_info, work);
	int next_state;
	bool limiting_active;
	bool charge_source;

	if (is_charging(di))
		charger_pet_watchdog(di);

	charger_lock(di);

	/* update inputs and limit conditions */
	charger_gas_gauge_update(di);
	charger_check_temp_limits(di);
	charger_check_battery_level(di);

	/* aggregate limiting factors */
	limiting_active = di->battery_full || di->charge_disabled ||
		di->temperature_lockout;

	/* hardware ready for charging? */
	charge_source = di->vbus_online && !di->otg_online;

	dev_dbg(di->dev, "%s: battery_full=%d charge_disabled=%d temperature_lockout=%d "
			"invalid_charger=%d vbus_online=%d usb_online=%d otg_online=%d\n", __func__,
			di->battery_full, di->charge_disabled, di->temperature_lockout,
			di->invalid_charger, di->vbus_online, di->usb_online, di->otg_online);

	/* determine the next charger state */
	switch (di->state) {
		case CHARGER_STATE_UNPLUGGED:
		case CHARGER_STATE_CHARGING:
			if (charge_source) {
				if (limiting_active)
					next_state = CHARGER_STATE_NOT_CHARGING;
				else
					next_state = CHARGER_STATE_CHARGING;
			} else {
				next_state = CHARGER_STATE_UNPLUGGED;
			}
			break;

		case CHARGER_STATE_NOT_CHARGING:
			if (charge_source) {
				if (limiting_active)
					next_state = CHARGER_STATE_NOT_CHARGING;
				else
					next_state = CHARGER_STATE_CHARGING;
			} else {
				next_state = CHARGER_STATE_UNPLUGGED;
			}
			break;

		default:
			next_state = di->state; // silence compiler warning
	}

	/* if the state changed, fulfill the required changes */
	if (next_state != di->state) {
		dev_info(di->dev, "transitioning from %s to %s\n", state_to_str(di->state),
				state_to_str(next_state));

		switch (next_state) {
			case CHARGER_STATE_UNPLUGGED:
				wake_lock_timeout(&di->wake_lock, HZ / 2);
				charger_stop_usb_charger(di);
				break;

			case CHARGER_STATE_NOT_CHARGING:
				if (!is_powered(di))
					wake_lock(&di->wake_lock);

				charger_stop_usb_charger(di);
				break;

			case CHARGER_STATE_CHARGING:
				if (!is_powered(di))
					wake_lock(&di->wake_lock);

				charger_start_usb_charger(di);
				break;
		}

		di->state = next_state;
		power_supply_changed(&di->usb);

		twl6030_eval_led_state(di->led, is_powered(di), is_charging(di));
	}

	charger_unlock(di);

	/* update timer */
	mod_timer(&di->timer, di->monitor_interval_jiffies + jiffies);
}
/*
 * Function: wcd9xxx_clsh_fsm
 * Params: codec, cdc_clsh_d, req_state, req_type, clsh_event
 * Description:
 * This function handles PRE DAC and POST DAC conditions of different devices
 * and updates class H configuration of different combination of devices
 * based on validity of their states. cdc_clsh_d will contain current
 * class h state information
 */
void wcd9xxx_clsh_fsm(struct snd_soc_codec *codec,
		struct wcd9xxx_clsh_cdc_data *cdc_clsh_d,
		u8 req_state, bool req_type, u8 clsh_event)
{
	u8 old_state, new_state;
	char msg0[128], msg1[128];

	switch (clsh_event) {
	case WCD9XXX_CLSH_EVENT_PRE_DAC:
		/* PRE_DAC event should be used only for Enable */
		BUG_ON(req_type != WCD9XXX_CLSH_REQ_ENABLE);

		old_state = cdc_clsh_d->state;
		new_state = old_state | req_state;

		if (!wcd9xxx_clsh_is_state_valid(new_state)) {
			dev_dbg(codec->dev,
				"%s: classH not a valid new state: %s\n",
				__func__,
				state_to_str(new_state, msg0, sizeof(msg0)));
			return;
		}
		if (new_state == old_state) {
			dev_dbg(codec->dev,
				"%s: classH already in requested state: %s\n",
				__func__,
				state_to_str(new_state, msg0, sizeof(msg0)));
			return;
		}
		(*clsh_state_fp[new_state]) (codec, cdc_clsh_d, req_state,
					     req_type);
		cdc_clsh_d->state = new_state;
		dev_dbg(codec->dev,
			"%s: ClassH state transition from %s to %s\n",
			__func__, state_to_str(old_state, msg0, sizeof(msg0)),
			state_to_str(cdc_clsh_d->state, msg1, sizeof(msg1)));

		break;
	case WCD9XXX_CLSH_EVENT_POST_PA:
		if (req_type == WCD9XXX_CLSH_REQ_DISABLE) {
			old_state = cdc_clsh_d->state;
			new_state = old_state & (~req_state);

			if (new_state < NUM_CLSH_STATES) {
				if (!wcd9xxx_clsh_is_state_valid(old_state)) {
					dev_dbg(codec->dev,
						"%s:Invalid old state:%s\n",
						__func__,
						state_to_str(old_state, msg0,
						sizeof(msg0)));
					return;
				}
				if (new_state == old_state) {
					dev_dbg(codec->dev,
					"%s: clsH already in old state: %s\n",
					__func__,
					state_to_str(new_state, msg0,
					sizeof(msg0)));
					return;
				}
				(*clsh_state_fp[old_state]) (codec, cdc_clsh_d,
							     req_state,
							     req_type);
				cdc_clsh_d->state = new_state;
				dev_dbg(codec->dev, "%s: ClassH state transition from %s to %s\n",
					__func__, state_to_str(old_state, msg0,
							       sizeof(msg0)),
					state_to_str(cdc_clsh_d->state, msg1,
						     sizeof(msg1)));

			} else {
				dev_dbg(codec->dev, "%s:wrong new state=0x%x\n",
						__func__, new_state);
			}
		} else if (!(cdc_clsh_d->state & WCD9XXX_CLSH_STATE_LO)) {
			wcd9xxx_clsh_enable_post_pa(codec, cdc_clsh_d);
		}

		break;
	}

}
예제 #10
0
파일: api_test.c 프로젝트: 01org/murphy
static void resource_callback(mrp_res_context_t *cx,
                  const mrp_res_resource_set_t *rs,
                  void *userdata)
{
    my_app_data *my_data = (my_app_data *) userdata;
    mrp_res_resource_t *res;
    mrp_res_attribute_t *attr;

    MRP_UNUSED(cx);

    printf("> resource_callback\n");

    if (!mrp_res_equal_resource_set(rs, my_data->rs))
        return;

    /* here compare the resource set difference */

    res = mrp_res_get_resource_by_name(rs, "audio_playback");

    if (!res) {
        printf("audio_playback not present in resource set\n");
        return;
    }

    printf("resource set state: %s\n", state_to_str(rs->state));

    printf("resource 0 name '%s' -> '%s'\n", res->name, state_to_str(res->state));

    res = mrp_res_get_resource_by_name(rs, "video_playback");

    if (!res) {
        printf("video_playback not present in resource set\n");
        return;
    }

    printf("resource 1 name '%s' -> '%s'\n", res->name, state_to_str(res->state));

    /* let's copy the changed set for ourselves */

    /* Delete must not mean releasing the set! Otherwise this won't work.
     * It's up to the user to make sure that there's a working reference
     * to the resource set.
     */
    mrp_res_delete_resource_set(my_data->rs);

    /* copying must also have no semantic meaning */
    my_data->rs = mrp_res_copy_resource_set(rs);

    /* print the current role attribute */

    res = mrp_res_get_resource_by_name(rs, "audio_playback");
    attr = mrp_res_get_attribute_by_name(res, "role");

    if (res && attr)
        printf("attribute '%s' has role '%s'\n", res->name, attr->string);

    /* acquiring a copy of an existing release set means:
     *  - acquired state: update, since otherwise no meaning
     *  - pending state: acquire, since previous state not known/meaningless
     *  - lost state: update, since otherwise will fail
     *  - available: update or acquire
     */
}
예제 #11
0
void NS_CLASS print_rt_table(void *arg)
{
    char rt_buf[2048], ifname[64], seqno_str[11];
    int len = 0;
    int i = 0;
    rt_table_t *entry;
    precursor_t *pr;
    struct timeval now;
    struct tm *time;

    if (rt_tbl.num_entries == 0)
	goto schedule;

    gettimeofday(&now, NULL);

#ifdef NS_PORT
    time = gmtime(&now.tv_sec);
#else
    time = localtime(&now.tv_sec);
#endif

    len +=
	sprintf(rt_buf,
		"# Time: %02d:%02d:%02d.%03ld IP: %s seqno: %u entries/active: %u/%u\n",
		time->tm_hour, time->tm_min, time->tm_sec, now.tv_usec / 1000,
		devs_ip_to_str(), this_host.seqno, rt_tbl.num_entries,
		rt_tbl.num_active);
    len +=
	sprintf(rt_buf + len,
		"%-15s %-15s %-3s %-3s %-5s %-6s %-5s %-5s %-15s\n",
		"Destination", "Next hop", "HC", "St.", "Seqno", "Expire",
		"Flags", "Iface", "Precursors");

    write(log_rt_fd, rt_buf, len);
    len = 0;

    for (i = 0; i < RT_TABLESIZE; i++) {
	entry = rt_tbl.tbl[i];
	while (entry != NULL) {

	    if (entry->flags & RT_INV_SEQNO)
		sprintf(seqno_str, "-");
	    else
		sprintf(seqno_str, "%u", entry->dest_seqno);

	    /* Print routing table entries one by one... */
	    if (entry->precursors == NULL)
		len += sprintf(rt_buf + len,
			       "%-15s %-15s %-3d %-3s %-5s %-6lu %-5s %-5s\n",
			       ip_to_str(entry->dest_addr),
			       ip_to_str(entry->next_hop), entry->hcnt,
			       state_to_str(entry->state), seqno_str,
			       (entry->hcnt == 255) ? 0 :
			       timeval_diff(&entry->rt_timer.timeout, &now),
			       rt_flags_to_str(entry->flags),
			       if_indextoname(entry->ifindex, ifname));

	    else {
		len += sprintf(rt_buf + len,
			       "%-15s %-15s %-3d %-3s %-5s %-6lu %-5s %-5s %-15s\n",
			       ip_to_str(entry->dest_addr),
			       ip_to_str(entry->next_hop), entry->hcnt,
			       state_to_str(entry->state), seqno_str,
			       (entry->hcnt == 255) ? 0 :
			       timeval_diff(&entry->rt_timer.timeout, &now),
			       rt_flags_to_str(entry->flags),
			       if_indextoname(entry->ifindex, ifname),
			       ip_to_str(entry->precursors->neighbor));

		/* Print all precursors for the current routing entry */
		for (pr = entry->precursors->next; pr != NULL; pr = pr->next) {
		    len += sprintf(rt_buf + len, "%64s %-15s\n", "*",
				   ip_to_str(pr->neighbor));

		    /* Since the precursor list is grown dynamically
		     * the write buffer should be flushed for every
		     * entry to avoid buffer overflows */
		    write(log_rt_fd, rt_buf, len);
		    len = 0;

		}
	    }
	    if (len > 0) {
		write(log_rt_fd, rt_buf, len);
		len = 0;
	    }
	    entry = entry->next;
	}
    }
    /* Schedule a new printing of routing table... */
  schedule:
    timer_set_timeout(&rt_log_timer, rt_log_interval);
}