Commit 7408338a authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Adam Wujek

sofpll: simplify a string array (and shrink by 72 bytes)

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 098116fc
...@@ -37,20 +37,20 @@ int spll_n_chan_ref, spll_n_chan_out; ...@@ -37,20 +37,20 @@ int spll_n_chan_ref, spll_n_chan_out;
#define MAIN_CHANNEL (spll_n_chan_ref) #define MAIN_CHANNEL (spll_n_chan_ref)
static const struct stringlist_entry seq_states [] = static const char *seq_states[] =
{ {
{ SEQ_START_EXT, "start-ext" }, [SEQ_START_EXT] = "start-ext",
{ SEQ_WAIT_EXT, "wait-ext" }, [SEQ_WAIT_EXT] = "wait-ext",
{ SEQ_START_HELPER, "start-helper" }, [SEQ_START_HELPER] = "start-helper",
{ SEQ_WAIT_HELPER, "wait-helper" }, [SEQ_WAIT_HELPER] = "wait-helper",
{ SEQ_START_MAIN, "start-main" }, [SEQ_START_MAIN] = "start-main",
{ SEQ_WAIT_MAIN, "wait-main" }, [SEQ_WAIT_MAIN] = "wait-main",
{ SEQ_DISABLED, "disabled" }, [SEQ_DISABLED] = "disabled",
{ SEQ_READY, "ready" }, [SEQ_READY] = "ready",
{ SEQ_CLEAR_DACS, "clear-dacs" }, [SEQ_CLEAR_DACS] = "clear-dacs",
{ SEQ_WAIT_CLEAR_DACS, "wait-clear-dacs" }, [SEQ_WAIT_CLEAR_DACS] = "wait-clear-dacs",
{ 0, NULL }
}; };
#define SEQ_STATES_NR ARRAY_SIZE(seq_states)
volatile struct softpll_state softpll; volatile struct softpll_state softpll;
...@@ -481,11 +481,15 @@ void spll_get_num_channels(int *n_ref, int *n_out) ...@@ -481,11 +481,15 @@ void spll_get_num_channels(int *n_ref, int *n_out)
void spll_show_stats() void spll_show_stats()
{ {
struct softpll_state *s = (struct softpll_state *)&softpll; struct softpll_state *s = (struct softpll_state *)&softpll;
const char *statename = seq_states[s->seq_state];
if (s->seq_state >= SEQ_STATES_NR)
statename = "<Unknown>";
if (softpll.mode > 0) if (softpll.mode > 0)
pp_printf("softpll: irqs %d seq %s mode %d " pp_printf("softpll: irqs %d seq %s mode %d "
"alignment_state %d HL%d ML%d HY=%d MY=%d DelCnt=%d\n", "alignment_state %d HL%d ML%d HY=%d MY=%d DelCnt=%d\n",
s->irq_count, stringlist_lookup(seq_states, s->seq_state), s->irq_count, statename,
s->mode, s->ext.align_state, s->mode, s->ext.align_state,
s->helper.ld.locked, s->mpll.ld.locked, s->helper.ld.locked, s->mpll.ld.locked,
s->helper.pi.y, s->mpll.pi.y, s->helper.pi.y, s->mpll.pi.y,
......
...@@ -124,13 +124,3 @@ void spll_enable_tagger(int channel, int enable) ...@@ -124,13 +124,3 @@ void spll_enable_tagger(int channel, int enable)
pll_verbose("%s: ch %d, OCER 0x%x, RCER 0x%x\n", __FUNCTION__, channel, SPLL->OCER, SPLL->RCER); pll_verbose("%s: ch %d, OCER 0x%x, RCER 0x%x\n", __FUNCTION__, channel, SPLL->OCER, SPLL->RCER);
} }
const char *stringlist_lookup(const struct stringlist_entry *slist, int id)
{
int i;
for(i=0; slist[i].str; i++) {
if(slist[i].id == id)
return slist[i].str;
}
return "<unknown>";
}
...@@ -50,11 +50,6 @@ typedef struct { ...@@ -50,11 +50,6 @@ typedef struct {
int lock_changed; int lock_changed;
} spll_lock_det_t; } spll_lock_det_t;
struct stringlist_entry {
int id;
const char *str;
};
/* initializes the PI controller state. Currently almost a stub. */ /* initializes the PI controller state. Currently almost a stub. */
void pi_init(spll_pi_t *pi); void pi_init(spll_pi_t *pi);
...@@ -67,6 +62,4 @@ int ld_update(spll_lock_det_t *ld, int y); ...@@ -67,6 +62,4 @@ int ld_update(spll_lock_det_t *ld, int y);
void spll_enable_tagger(int channel, int enable); void spll_enable_tagger(int channel, int enable);
const char *stringlist_lookup(const struct stringlist_entry *slist, int id);
#endif // __SPLL_COMMON_H #endif // __SPLL_COMMON_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment