diff options
author | Ville Syrjala <syrjala@sci.fi> | 2008-03-04 17:28:49 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-03-04 19:35:13 -0500 |
commit | 245904a4ce08c48495b2fd6d6c317c26ddf2b57a (patch) | |
tree | bd1728d67783b2e05c9a39050642c0a7ee2ffe21 /drivers/mfd | |
parent | 7e533705bd973267c488f8c3a7c7246ecad3a414 (diff) |
sm501: remove a duplicated table
misc_div is a subset of px_div so eliminate the smaller table.
Signed-off-by: Ville Syrjala <syrjala@sci.fi>
Cc: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/sm501.c | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index afd82966f9a0..4de8d467762a 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c | |||
@@ -53,26 +53,7 @@ struct sm501_devdata { | |||
53 | #define MHZ (1000 * 1000) | 53 | #define MHZ (1000 * 1000) |
54 | 54 | ||
55 | #ifdef DEBUG | 55 | #ifdef DEBUG |
56 | static const unsigned int misc_div[] = { | 56 | static const unsigned int div_tab[] = { |
57 | [0] = 1, | ||
58 | [1] = 2, | ||
59 | [2] = 4, | ||
60 | [3] = 8, | ||
61 | [4] = 16, | ||
62 | [5] = 32, | ||
63 | [6] = 64, | ||
64 | [7] = 128, | ||
65 | [8] = 3, | ||
66 | [9] = 6, | ||
67 | [10] = 12, | ||
68 | [11] = 24, | ||
69 | [12] = 48, | ||
70 | [13] = 96, | ||
71 | [14] = 192, | ||
72 | [15] = 384, | ||
73 | }; | ||
74 | |||
75 | static const unsigned int px_div[] = { | ||
76 | [0] = 1, | 57 | [0] = 1, |
77 | [1] = 2, | 58 | [1] = 2, |
78 | [2] = 4, | 59 | [2] = 4, |
@@ -101,12 +82,12 @@ static const unsigned int px_div[] = { | |||
101 | 82 | ||
102 | static unsigned long decode_div(unsigned long pll2, unsigned long val, | 83 | static unsigned long decode_div(unsigned long pll2, unsigned long val, |
103 | unsigned int lshft, unsigned int selbit, | 84 | unsigned int lshft, unsigned int selbit, |
104 | unsigned long mask, const unsigned int *dtab) | 85 | unsigned long mask) |
105 | { | 86 | { |
106 | if (val & selbit) | 87 | if (val & selbit) |
107 | pll2 = 288 * MHZ; | 88 | pll2 = 288 * MHZ; |
108 | 89 | ||
109 | return pll2 / dtab[(val >> lshft) & mask]; | 90 | return pll2 / div_tab[(val >> lshft) & mask]; |
110 | } | 91 | } |
111 | 92 | ||
112 | #define fmt_freq(x) ((x) / MHZ), ((x) % MHZ), (x) | 93 | #define fmt_freq(x) ((x) / MHZ), ((x) % MHZ), (x) |
@@ -141,10 +122,10 @@ static void sm501_dump_clk(struct sm501_devdata *sm) | |||
141 | } | 122 | } |
142 | 123 | ||
143 | sdclk0 = (misct & (1<<12)) ? pll2 : 288 * MHZ; | 124 | sdclk0 = (misct & (1<<12)) ? pll2 : 288 * MHZ; |
144 | sdclk0 /= misc_div[((misct >> 8) & 0xf)]; | 125 | sdclk0 /= div_tab[((misct >> 8) & 0xf)]; |
145 | 126 | ||
146 | sdclk1 = (misct & (1<<20)) ? pll2 : 288 * MHZ; | 127 | sdclk1 = (misct & (1<<20)) ? pll2 : 288 * MHZ; |
147 | sdclk1 /= misc_div[((misct >> 16) & 0xf)]; | 128 | sdclk1 /= div_tab[((misct >> 16) & 0xf)]; |
148 | 129 | ||
149 | dev_dbg(sm->dev, "MISCT=%08lx, PM0=%08lx, PM1=%08lx\n", | 130 | dev_dbg(sm->dev, "MISCT=%08lx, PM0=%08lx, PM1=%08lx\n", |
150 | misct, pm0, pm1); | 131 | misct, pm0, pm1); |
@@ -158,19 +139,19 @@ static void sm501_dump_clk(struct sm501_devdata *sm) | |||
158 | "P2 %ld.%ld MHz (%ld), V2 %ld.%ld (%ld), " | 139 | "P2 %ld.%ld MHz (%ld), V2 %ld.%ld (%ld), " |
159 | "M %ld.%ld (%ld), MX1 %ld.%ld (%ld)\n", | 140 | "M %ld.%ld (%ld), MX1 %ld.%ld (%ld)\n", |
160 | (pmc & 3 ) == 0 ? '*' : '-', | 141 | (pmc & 3 ) == 0 ? '*' : '-', |
161 | fmt_freq(decode_div(pll2, pm0, 24, 1<<29, 31, px_div)), | 142 | fmt_freq(decode_div(pll2, pm0, 24, 1<<29, 31)), |
162 | fmt_freq(decode_div(pll2, pm0, 16, 1<<20, 15, misc_div)), | 143 | fmt_freq(decode_div(pll2, pm0, 16, 1<<20, 15)), |
163 | fmt_freq(decode_div(pll2, pm0, 8, 1<<12, 15, misc_div)), | 144 | fmt_freq(decode_div(pll2, pm0, 8, 1<<12, 15)), |
164 | fmt_freq(decode_div(pll2, pm0, 0, 1<<4, 15, misc_div))); | 145 | fmt_freq(decode_div(pll2, pm0, 0, 1<<4, 15))); |
165 | 146 | ||
166 | dev_dbg(sm->dev, "PM1[%c]: " | 147 | dev_dbg(sm->dev, "PM1[%c]: " |
167 | "P2 %ld.%ld MHz (%ld), V2 %ld.%ld (%ld), " | 148 | "P2 %ld.%ld MHz (%ld), V2 %ld.%ld (%ld), " |
168 | "M %ld.%ld (%ld), MX1 %ld.%ld (%ld)\n", | 149 | "M %ld.%ld (%ld), MX1 %ld.%ld (%ld)\n", |
169 | (pmc & 3 ) == 1 ? '*' : '-', | 150 | (pmc & 3 ) == 1 ? '*' : '-', |
170 | fmt_freq(decode_div(pll2, pm1, 24, 1<<29, 31, px_div)), | 151 | fmt_freq(decode_div(pll2, pm1, 24, 1<<29, 31)), |
171 | fmt_freq(decode_div(pll2, pm1, 16, 1<<20, 15, misc_div)), | 152 | fmt_freq(decode_div(pll2, pm1, 16, 1<<20, 15)), |
172 | fmt_freq(decode_div(pll2, pm1, 8, 1<<12, 15, misc_div)), | 153 | fmt_freq(decode_div(pll2, pm1, 8, 1<<12, 15)), |
173 | fmt_freq(decode_div(pll2, pm1, 0, 1<<4, 15, misc_div))); | 154 | fmt_freq(decode_div(pll2, pm1, 0, 1<<4, 15))); |
174 | } | 155 | } |
175 | 156 | ||
176 | static void sm501_dump_regs(struct sm501_devdata *sm) | 157 | static void sm501_dump_regs(struct sm501_devdata *sm) |