Clarify usb_powered() and fix some code.

Either by mistake or because its meaning changed, usb_powered() doesn't mean
what the name suggest, so clarify its meaning by renaming it to usb_powered_only.
So use of usb_powered() are replaced by usb_inserted() when it makes more sense.

Change-Id: I112887e2d8560e84587bee5f55c826dde8c806d8
Reviewed-on: http://gerrit.rockbox.org/1097
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
This commit is contained in:
Amaury Pouly 2015-01-02 22:15:31 +01:00
parent 1ab91550e6
commit dc127f213c
11 changed files with 20 additions and 22 deletions

View File

@ -1149,12 +1149,10 @@ const char *get_token_value(struct gui_wps *gwps,
}
}
#endif
#ifdef HAVE_USB_POWER
case SKIN_TOKEN_USB_POWERED:
if (usb_powered())
case SKIN_TOKEN_USB_INSERTED:
if (usb_inserted())
return "u";
return NULL;
#endif
case SKIN_TOKEN_BATTERY_SLEEPTIME:
{
if (get_sleep_timer() == 0)

View File

@ -586,7 +586,8 @@ static void init(void)
mounted = true; /* mounting done @ end of USB mode */
}
#ifdef HAVE_USB_POWER
if (usb_powered()) /* avoid deadlock */
/* if there is no host or user requested no USB, skip this */
if (usb_powered_only())
break;
#endif
}

View File

@ -712,9 +712,7 @@ static const struct plugin_api rockbox_api = {
charging_state,
# endif
#endif
#ifdef HAVE_USB_POWER
usb_powered,
#endif
usb_inserted,
/* misc */
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)

View File

@ -160,12 +160,12 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 232
#define PLUGIN_API_VERSION 233
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
#define PLUGIN_MIN_API_VERSION 232
#define PLUGIN_MIN_API_VERSION 233
/* plugin return codes */
/* internal returns start at 0x100 to make exit(1..255) work */
@ -823,9 +823,8 @@ struct plugin_api {
bool (*charging_state)(void);
# endif
#endif
#ifdef HAVE_USB_POWER
bool (*usb_powered)(void);
#endif
/* usb */
bool (*usb_inserted)(void);
/* misc */
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)

View File

@ -358,11 +358,12 @@ static unsigned int charge_state(void)
ret |= BIT_CHARGING;
#endif
#endif
/* USB insertion means nothing if USB cannot power the device */
#ifdef HAVE_USB_POWER
if (rb->usb_powered())
if (rb->usb_inserted())
ret |= BIT_USB_POWER;
#endif
return ret;
return ret;
}
#endif

View File

@ -199,7 +199,8 @@ int usb_detect(void);
void usb_status_event(int current_status);
#endif
#ifdef HAVE_USB_POWER
bool usb_powered(void);
/* returns whether the USB is in powered-only state */
bool usb_powered_only(void);
#ifdef HAVE_USB_CHARGING_ENABLE
enum {
USB_CHARGING_DISABLE, /* the USB code will never ask for more than 100mA */

View File

@ -329,9 +329,9 @@ static int runcurrent(void)
if (usb_inserted()
#ifdef HAVE_USB_POWER
#if (CURRENT_USB < CURRENT_NORMAL)
|| usb_powered()
|| usb_powered_only()
#else
&& !usb_powered()
&& !usb_powered_only()
#endif
#endif
) {

View File

@ -769,7 +769,7 @@ int usb_release_exclusive_storage(void)
}
#ifdef HAVE_USB_POWER
bool usb_powered(void)
bool usb_powered_only(void)
{
return usb_state == USB_POWERED;
}

View File

@ -43,7 +43,7 @@ static const struct tag_info legal_tags[] =
{ SKIN_TOKEN_BATTERY_SLEEPTIME, "bs", "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_BATTERY_CHARGING, "bc", "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_BATTERY_CHARGER_CONNECTED, "bp", "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_USB_POWERED, "bu", "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_USB_INSERTED, "bu", "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_RTC_PRESENT, "cc", "", FEATURE_TAG },

View File

@ -102,7 +102,7 @@ enum skin_token_type {
SKIN_TOKEN_BATTERY_CHARGER_CONNECTED,
SKIN_TOKEN_BATTERY_CHARGING,
SKIN_TOKEN_BATTERY_SLEEPTIME,
SKIN_TOKEN_USB_POWERED,
SKIN_TOKEN_USB_INSERTED,
/* Sound */
SKIN_TOKEN_SOUND_PITCH,

View File

@ -313,7 +313,7 @@ bool is_new_player(void)
#endif
#ifdef HAVE_USB_POWER
bool usb_powered(void)
bool usb_powered_only(void)
{
return false;
}