Skip to content

Commit dc57a3e

Browse files
alexb0gregkh
authored andcommitted
Staging: echo cleanup
before: errors lines of code errors/KLOC drivers/staging/echo/ 213 1701 125.2 after: errors lines of code errors/KLOC drivers/staging/echo/ 8 1685 4.7 Compile tested. Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 2961f24 commit dc57a3e

5 files changed

Lines changed: 247 additions & 263 deletions

File tree

‎drivers/staging/echo/bit_operations.h‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
* You should have received a copy of the GNU General Public License
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24-
*
25-
* $Id: bit_operations.h,v 1.11 2006/11/28 15:37:03 steveu Exp $
2624
*/
2725

2826
/*! \file */
@@ -34,7 +32,7 @@
3432
/*! \brief Find the bit position of the highest set bit in a word
3533
\param bits The word to be searched
3634
\return The bit number of the highest set bit, or -1 if the word is zero. */
37-
static __inline__ int top_bit(unsigned int bits)
35+
static inline int top_bit(unsigned int bits)
3836
{
3937
int res;
4038

@@ -50,7 +48,7 @@ static __inline__ int top_bit(unsigned int bits)
5048
/*! \brief Find the bit position of the lowest set bit in a word
5149
\param bits The word to be searched
5250
\return The bit number of the lowest set bit, or -1 if the word is zero. */
53-
static __inline__ int bottom_bit(unsigned int bits)
51+
static inline int bottom_bit(unsigned int bits)
5452
{
5553
int res;
5654

@@ -63,7 +61,7 @@ static __inline__ int bottom_bit(unsigned int bits)
6361
return res;
6462
}
6563
#else
66-
static __inline__ int top_bit(unsigned int bits)
64+
static inline int top_bit(unsigned int bits)
6765
{
6866
int i;
6967

@@ -93,7 +91,7 @@ static __inline__ int top_bit(unsigned int bits)
9391
return i;
9492
}
9593

96-
static __inline__ int bottom_bit(unsigned int bits)
94+
static inline int bottom_bit(unsigned int bits)
9795
{
9896
int i;
9997

@@ -127,7 +125,7 @@ static __inline__ int bottom_bit(unsigned int bits)
127125
/*! \brief Bit reverse a byte.
128126
\param data The byte to be reversed.
129127
\return The bit reversed version of data. */
130-
static __inline__ uint8_t bit_reverse8(uint8_t x)
128+
static inline uint8_t bit_reverse8(uint8_t x)
131129
{
132130
#if defined(__i386__) || defined(__x86_64__)
133131
/* If multiply is fast */
@@ -172,32 +170,32 @@ uint32_t make_mask32(uint32_t x);
172170
uint16_t make_mask16(uint16_t x);
173171

174172
/*! \brief Find the least significant one in a word, and return a word
175-
with just that bit set.
173+
with just that bit set.
176174
\param x The word to be searched.
177175
\return The word with the single set bit. */
178-
static __inline__ uint32_t least_significant_one32(uint32_t x)
176+
static inline uint32_t least_significant_one32(uint32_t x)
179177
{
180-
return (x & (-(int32_t) x));
178+
return x & (-(int32_t) x);
181179
}
182180

183181
/*! \brief Find the most significant one in a word, and return a word
184-
with just that bit set.
182+
with just that bit set.
185183
\param x The word to be searched.
186184
\return The word with the single set bit. */
187-
static __inline__ uint32_t most_significant_one32(uint32_t x)
185+
static inline uint32_t most_significant_one32(uint32_t x)
188186
{
189187
#if defined(__i386__) || defined(__x86_64__)
190188
return 1 << top_bit(x);
191189
#else
192190
x = make_mask32(x);
193-
return (x ^ (x >> 1));
191+
return x ^ (x >> 1);
194192
#endif
195193
}
196194

197195
/*! \brief Find the parity of a byte.
198196
\param x The byte to be checked.
199197
\return 1 for odd, or 0 for even. */
200-
static __inline__ int parity8(uint8_t x)
198+
static inline int parity8(uint8_t x)
201199
{
202200
x = (x ^ (x >> 4)) & 0x0F;
203201
return (0x6996 >> x) & 1;
@@ -206,7 +204,7 @@ static __inline__ int parity8(uint8_t x)
206204
/*! \brief Find the parity of a 16 bit word.
207205
\param x The word to be checked.
208206
\return 1 for odd, or 0 for even. */
209-
static __inline__ int parity16(uint16_t x)
207+
static inline int parity16(uint16_t x)
210208
{
211209
x ^= (x >> 8);
212210
x = (x ^ (x >> 4)) & 0x0F;
@@ -216,7 +214,7 @@ static __inline__ int parity16(uint16_t x)
216214
/*! \brief Find the parity of a 32 bit word.
217215
\param x The word to be checked.
218216
\return 1 for odd, or 0 for even. */
219-
static __inline__ int parity32(uint32_t x)
217+
static inline int parity32(uint32_t x)
220218
{
221219
x ^= (x >> 16);
222220
x ^= (x >> 8);

‎drivers/staging/echo/echo.c‎

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
* You should have received a copy of the GNU General Public License
2828
* along with this program; if not, write to the Free Software
2929
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30-
*
31-
* $Id: echo.c,v 1.20 2006/12/01 18:00:48 steveu Exp $
3230
*/
3331

3432
/*! \file */
@@ -113,17 +111,17 @@
113111

114112
#define MIN_TX_POWER_FOR_ADAPTION 64
115113
#define MIN_RX_POWER_FOR_ADAPTION 64
116-
#define DTD_HANGOVER 600 /* 600 samples, or 75ms */
117-
#define DC_LOG2BETA 3 /* log2() of DC filter Beta */
114+
#define DTD_HANGOVER 600 /* 600 samples, or 75ms */
115+
#define DC_LOG2BETA 3 /* log2() of DC filter Beta */
118116

119117
/*-----------------------------------------------------------------------*\
120-
FUNCTIONS
118+
FUNCTIONS
121119
\*-----------------------------------------------------------------------*/
122120

123121
/* adapting coeffs using the traditional stochastic descent (N)LMS algorithm */
124122

125123
#ifdef __bfin__
126-
static void __inline__ lms_adapt_bg(struct oslec_state *ec, int clean,
124+
static inline void lms_adapt_bg(struct oslec_state *ec, int clean,
127125
int shift)
128126
{
129127
int i, j;
@@ -147,13 +145,13 @@ static void __inline__ lms_adapt_bg(struct oslec_state *ec, int clean,
147145

148146
/* st: and en: help us locate the assembler in echo.s */
149147

150-
//asm("st:");
148+
/* asm("st:"); */
151149
n = ec->taps;
152150
for (i = 0, j = offset2; i < n; i++, j++) {
153151
exp = *phist++ * factor;
154152
ec->fir_taps16[1][i] += (int16_t) ((exp + (1 << 14)) >> 15);
155153
}
156-
//asm("en:");
154+
/* asm("en:"); */
157155

158156
/* Note the asm for the inner loop above generated by Blackfin gcc
159157
4.1.1 is pretty good (note even parallel instructions used):
@@ -195,7 +193,7 @@ static void __inline__ lms_adapt_bg(struct oslec_state *ec, int clean,
195193
*/
196194

197195
#else
198-
static __inline__ void lms_adapt_bg(struct oslec_state *ec, int clean,
196+
static inline void lms_adapt_bg(struct oslec_state *ec, int clean,
199197
int shift)
200198
{
201199
int i;
@@ -249,9 +247,8 @@ struct oslec_state *oslec_create(int len, int adaption_mode)
249247
fir16_create(&ec->fir_state, ec->fir_taps16[0], ec->taps);
250248
fir16_create(&ec->fir_state_bg, ec->fir_taps16[1], ec->taps);
251249

252-
for (i = 0; i < 5; i++) {
250+
for (i = 0; i < 5; i++)
253251
ec->xvtx[i] = ec->yvtx[i] = ec->xvrx[i] = ec->yvrx[i] = 0;
254-
}
255252

256253
ec->cng_level = 1000;
257254
oslec_adaption_mode(ec, adaption_mode);
@@ -271,14 +268,13 @@ struct oslec_state *oslec_create(int len, int adaption_mode)
271268

272269
return ec;
273270

274-
error_oom:
271+
error_oom:
275272
for (i = 0; i < 2; i++)
276273
kfree(ec->fir_taps16[i]);
277274

278275
kfree(ec);
279276
return NULL;
280277
}
281-
282278
EXPORT_SYMBOL_GPL(oslec_create);
283279

284280
void oslec_free(struct oslec_state *ec)
@@ -292,14 +288,12 @@ void oslec_free(struct oslec_state *ec)
292288
kfree(ec->snapshot);
293289
kfree(ec);
294290
}
295-
296291
EXPORT_SYMBOL_GPL(oslec_free);
297292

298293
void oslec_adaption_mode(struct oslec_state *ec, int adaption_mode)
299294
{
300295
ec->adaption_mode = adaption_mode;
301296
}
302-
303297
EXPORT_SYMBOL_GPL(oslec_adaption_mode);
304298

305299
void oslec_flush(struct oslec_state *ec)
@@ -326,14 +320,12 @@ void oslec_flush(struct oslec_state *ec)
326320
ec->curr_pos = ec->taps - 1;
327321
ec->Pstates = 0;
328322
}
329-
330323
EXPORT_SYMBOL_GPL(oslec_flush);
331324

332325
void oslec_snapshot(struct oslec_state *ec)
333326
{
334327
memcpy(ec->snapshot, ec->fir_taps16[0], ec->taps * sizeof(int16_t));
335328
}
336-
337329
EXPORT_SYMBOL_GPL(oslec_snapshot);
338330

339331
/* Dual Path Echo Canceller ------------------------------------------------*/
@@ -399,7 +391,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
399391
/* efficient "out with the old and in with the new" algorithm so
400392
we don't have to recalculate over the whole block of
401393
samples. */
402-
new = (int)tx *(int)tx;
394+
new = (int)tx * (int)tx;
403395
old = (int)ec->fir_state.history[ec->fir_state.curr_pos] *
404396
(int)ec->fir_state.history[ec->fir_state.curr_pos];
405397
ec->Pstates +=
@@ -498,15 +490,15 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
498490

499491
if ((ec->adaption_mode & ECHO_CAN_USE_ADAPTION) &&
500492
(ec->nonupdate_dwell == 0) &&
501-
(8 * ec->Lclean_bg <
502-
7 * ec->Lclean) /* (ec->Lclean_bg < 0.875*ec->Lclean) */ &&
503-
(8 * ec->Lclean_bg <
504-
ec->Ltx) /* (ec->Lclean_bg < 0.125*ec->Ltx) */ ) {
493+
/* (ec->Lclean_bg < 0.875*ec->Lclean) */
494+
(8 * ec->Lclean_bg < 7 * ec->Lclean) &&
495+
/* (ec->Lclean_bg < 0.125*ec->Ltx) */
496+
(8 * ec->Lclean_bg < ec->Ltx)) {
505497
if (ec->cond_met == 6) {
506498
/* BG filter has had better results for 6 consecutive samples */
507499
ec->adapt = 1;
508500
memcpy(ec->fir_taps16[0], ec->fir_taps16[1],
509-
ec->taps * sizeof(int16_t));
501+
ec->taps * sizeof(int16_t));
510502
} else
511503
ec->cond_met++;
512504
} else
@@ -580,7 +572,6 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
580572

581573
return (int16_t) ec->clean_nlp << 1;
582574
}
583-
584575
EXPORT_SYMBOL_GPL(oslec_update);
585576

586577
/* This function is seperated from the echo canceller is it is usually called
@@ -604,7 +595,7 @@ EXPORT_SYMBOL_GPL(oslec_update);
604595
precision, which noise shapes things, giving very clean DC removal.
605596
*/
606597

607-
int16_t oslec_hpf_tx(struct oslec_state * ec, int16_t tx)
598+
int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx)
608599
{
609600
int tmp, tmp1;
610601

@@ -629,7 +620,6 @@ int16_t oslec_hpf_tx(struct oslec_state * ec, int16_t tx)
629620

630621
return tx;
631622
}
632-
633623
EXPORT_SYMBOL_GPL(oslec_hpf_tx);
634624

635625
MODULE_LICENSE("GPL");

‎drivers/staging/echo/echo.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
* You should have received a copy of the GNU General Public License
2424
* along with this program; if not, write to the Free Software
2525
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26-
*
27-
* $Id: echo.h,v 1.9 2006/10/24 13:45:28 steveu Exp $
2826
*/
2927

3028
#ifndef __ECHO_H

‎drivers/staging/echo/fir.h‎

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
* You should have received a copy of the GNU General Public License
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24-
*
25-
* $Id: fir.h,v 1.8 2006/10/24 13:45:28 steveu Exp $
2624
*/
2725

2826
/*! \page fir_page FIR filtering
@@ -102,8 +100,8 @@ struct fir_float_state_t {
102100
float *history;
103101
};
104102

105-
static __inline__ const int16_t *fir16_create(struct fir16_state_t *fir,
106-
const int16_t * coeffs, int taps)
103+
static inline const int16_t *fir16_create(struct fir16_state_t *fir,
104+
const int16_t *coeffs, int taps)
107105
{
108106
fir->taps = taps;
109107
fir->curr_pos = taps - 1;
@@ -116,7 +114,7 @@ static __inline__ const int16_t *fir16_create(struct fir16_state_t *fir,
116114
return fir->history;
117115
}
118116

119-
static __inline__ void fir16_flush(struct fir16_state_t *fir)
117+
static inline void fir16_flush(struct fir16_state_t *fir)
120118
{
121119
#if defined(USE_MMX) || defined(USE_SSE2) || defined(__bfin__)
122120
memset(fir->history, 0, 2 * fir->taps * sizeof(int16_t));
@@ -125,7 +123,7 @@ static __inline__ void fir16_flush(struct fir16_state_t *fir)
125123
#endif
126124
}
127125

128-
static __inline__ void fir16_free(struct fir16_state_t *fir)
126+
static inline void fir16_free(struct fir16_state_t *fir)
129127
{
130128
kfree(fir->history);
131129
}
@@ -148,16 +146,16 @@ static inline int32_t dot_asm(short *x, short *y, int len)
148146
"A0 += R0.L*R1.L (IS);\n\t"
149147
"R0 = A0;\n\t"
150148
"%0 = R0;\n\t"
151-
:"=&d"(dot)
152-
:"a"(x), "a"(y), "a"(len)
153-
:"I0", "I1", "A1", "A0", "R0", "R1"
149+
: "=&d"(dot)
150+
: "a"(x), "a"(y), "a"(len)
151+
: "I0", "I1", "A1", "A0", "R0", "R1"
154152
);
155153

156154
return dot;
157155
}
158156
#endif
159157

160-
static __inline__ int16_t fir16(struct fir16_state_t *fir, int16_t sample)
158+
static inline int16_t fir16(struct fir16_state_t *fir, int16_t sample)
161159
{
162160
int32_t y;
163161
#if defined(USE_MMX)
@@ -250,8 +248,8 @@ static __inline__ int16_t fir16(struct fir16_state_t *fir, int16_t sample)
250248
return (int16_t) (y >> 15);
251249
}
252250

253-
static __inline__ const int16_t *fir32_create(struct fir32_state_t *fir,
254-
const int32_t * coeffs, int taps)
251+
static inline const int16_t *fir32_create(struct fir32_state_t *fir,
252+
const int32_t *coeffs, int taps)
255253
{
256254
fir->taps = taps;
257255
fir->curr_pos = taps - 1;
@@ -260,17 +258,17 @@ static __inline__ const int16_t *fir32_create(struct fir32_state_t *fir,
260258
return fir->history;
261259
}
262260

263-
static __inline__ void fir32_flush(struct fir32_state_t *fir)
261+
static inline void fir32_flush(struct fir32_state_t *fir)
264262
{
265263
memset(fir->history, 0, fir->taps * sizeof(int16_t));
266264
}
267265

268-
static __inline__ void fir32_free(struct fir32_state_t *fir)
266+
static inline void fir32_free(struct fir32_state_t *fir)
269267
{
270268
kfree(fir->history);
271269
}
272270

273-
static __inline__ int16_t fir32(struct fir32_state_t *fir, int16_t sample)
271+
static inline int16_t fir32(struct fir32_state_t *fir, int16_t sample)
274272
{
275273
int i;
276274
int32_t y;

0 commit comments

Comments
 (0)