diff options
-rw-r--r-- | drivers/staging/echo/echo.c | 36 | ||||
-rw-r--r-- | drivers/staging/echo/fir.h | 14 |
2 files changed, 22 insertions, 28 deletions
diff --git a/drivers/staging/echo/echo.c b/drivers/staging/echo/echo.c index 140f3f0e0609..a2d307865eab 100644 --- a/drivers/staging/echo/echo.c +++ b/drivers/staging/echo/echo.c | |||
@@ -109,8 +109,6 @@ | |||
109 | #include <linux/module.h> | 109 | #include <linux/module.h> |
110 | #include <linux/kernel.h> | 110 | #include <linux/kernel.h> |
111 | #include <linux/slab.h> | 111 | #include <linux/slab.h> |
112 | #define malloc(a) kmalloc((a), GFP_KERNEL) | ||
113 | #define free(a) kfree(a) | ||
114 | 112 | ||
115 | #include "bit_operations.h" | 113 | #include "bit_operations.h" |
116 | #include "echo.h" | 114 | #include "echo.h" |
@@ -238,27 +236,19 @@ struct oslec_state *oslec_create(int len, int adaption_mode) | |||
238 | { | 236 | { |
239 | struct oslec_state *ec; | 237 | struct oslec_state *ec; |
240 | int i; | 238 | int i; |
241 | int j; | ||
242 | 239 | ||
243 | ec = kmalloc(sizeof(*ec), GFP_KERNEL); | 240 | ec = kzalloc(sizeof(*ec), GFP_KERNEL); |
244 | if (ec == NULL) | 241 | if (!ec) |
245 | return NULL; | 242 | return NULL; |
246 | memset(ec, 0, sizeof(*ec)); | ||
247 | 243 | ||
248 | ec->taps = len; | 244 | ec->taps = len; |
249 | ec->log2taps = top_bit(len); | 245 | ec->log2taps = top_bit(len); |
250 | ec->curr_pos = ec->taps - 1; | 246 | ec->curr_pos = ec->taps - 1; |
251 | 247 | ||
252 | for (i = 0; i < 2; i++) | 248 | for (i = 0; i < 2; i++) { |
253 | { | 249 | ec->fir_taps16[i] = kcalloc(ec->taps, sizeof(int16_t), GFP_KERNEL); |
254 | if ((ec->fir_taps16[i] = (int16_t *) malloc((ec->taps)*sizeof(int16_t))) == NULL) | 250 | if (!ec->fir_taps16[i]) |
255 | { | 251 | goto error_oom; |
256 | for (j = 0; j < i; j++) | ||
257 | kfree(ec->fir_taps16[j]); | ||
258 | kfree(ec); | ||
259 | return NULL; | ||
260 | } | ||
261 | memset(ec->fir_taps16[i], 0, (ec->taps)*sizeof(int16_t)); | ||
262 | } | 252 | } |
263 | 253 | ||
264 | fir16_create(&ec->fir_state, | 254 | fir16_create(&ec->fir_state, |
@@ -275,8 +265,9 @@ struct oslec_state *oslec_create(int len, int adaption_mode) | |||
275 | ec->cng_level = 1000; | 265 | ec->cng_level = 1000; |
276 | oslec_adaption_mode(ec, adaption_mode); | 266 | oslec_adaption_mode(ec, adaption_mode); |
277 | 267 | ||
278 | ec->snapshot = (int16_t*)malloc(ec->taps*sizeof(int16_t)); | 268 | ec->snapshot = kcalloc(ec->taps, sizeof(int16_t), GFP_KERNEL); |
279 | memset(ec->snapshot, 0, sizeof(int16_t)*ec->taps); | 269 | if (!ec->snapshot) |
270 | goto error_oom; | ||
280 | 271 | ||
281 | ec->cond_met = 0; | 272 | ec->cond_met = 0; |
282 | ec->Pstates = 0; | 273 | ec->Pstates = 0; |
@@ -288,6 +279,13 @@ struct oslec_state *oslec_create(int len, int adaption_mode) | |||
288 | ec->Lbgn_upper_acc = ec->Lbgn_upper << 13; | 279 | ec->Lbgn_upper_acc = ec->Lbgn_upper << 13; |
289 | 280 | ||
290 | return ec; | 281 | return ec; |
282 | |||
283 | error_oom: | ||
284 | for (i = 0; i < 2; i++) | ||
285 | kfree(ec->fir_taps16[i]); | ||
286 | |||
287 | kfree(ec); | ||
288 | return NULL; | ||
291 | } | 289 | } |
292 | EXPORT_SYMBOL_GPL(oslec_create); | 290 | EXPORT_SYMBOL_GPL(oslec_create); |
293 | /*- End of function --------------------------------------------------------*/ | 291 | /*- End of function --------------------------------------------------------*/ |
diff --git a/drivers/staging/echo/fir.h b/drivers/staging/echo/fir.h index 277d20e43f14..c29e1e245c6e 100644 --- a/drivers/staging/echo/fir.h +++ b/drivers/staging/echo/fir.h | |||
@@ -117,11 +117,9 @@ static __inline__ const int16_t *fir16_create(fir16_state_t *fir, | |||
117 | fir->curr_pos = taps - 1; | 117 | fir->curr_pos = taps - 1; |
118 | fir->coeffs = coeffs; | 118 | fir->coeffs = coeffs; |
119 | #if defined(USE_MMX) || defined(USE_SSE2) || defined(__bfin__) | 119 | #if defined(USE_MMX) || defined(USE_SSE2) || defined(__bfin__) |
120 | if ((fir->history = malloc(2*taps*sizeof(int16_t)))) | 120 | fir->history = kcalloc(2*taps, sizeof(int16_t), GFP_KERNEL); |
121 | memset(fir->history, 0, 2*taps*sizeof(int16_t)); | ||
122 | #else | 121 | #else |
123 | if ((fir->history = (int16_t *) malloc(taps*sizeof(int16_t)))) | 122 | fir->history = kcalloc(taps, sizeof(int16_t), GFP_KERNEL); |
124 | memset(fir->history, 0, taps*sizeof(int16_t)); | ||
125 | #endif | 123 | #endif |
126 | return fir->history; | 124 | return fir->history; |
127 | } | 125 | } |
@@ -139,7 +137,7 @@ static __inline__ void fir16_flush(fir16_state_t *fir) | |||
139 | 137 | ||
140 | static __inline__ void fir16_free(fir16_state_t *fir) | 138 | static __inline__ void fir16_free(fir16_state_t *fir) |
141 | { | 139 | { |
142 | free(fir->history); | 140 | kfree(fir->history); |
143 | } | 141 | } |
144 | /*- End of function --------------------------------------------------------*/ | 142 | /*- End of function --------------------------------------------------------*/ |
145 | 143 | ||
@@ -275,9 +273,7 @@ static __inline__ const int16_t *fir32_create(fir32_state_t *fir, | |||
275 | fir->taps = taps; | 273 | fir->taps = taps; |
276 | fir->curr_pos = taps - 1; | 274 | fir->curr_pos = taps - 1; |
277 | fir->coeffs = coeffs; | 275 | fir->coeffs = coeffs; |
278 | fir->history = (int16_t *) malloc(taps*sizeof(int16_t)); | 276 | fir->history = kcalloc(taps, sizeof(int16_t), GFP_KERNEL); |
279 | if (fir->history) | ||
280 | memset(fir->history, '\0', taps*sizeof(int16_t)); | ||
281 | return fir->history; | 277 | return fir->history; |
282 | } | 278 | } |
283 | /*- End of function --------------------------------------------------------*/ | 279 | /*- End of function --------------------------------------------------------*/ |
@@ -290,7 +286,7 @@ static __inline__ void fir32_flush(fir32_state_t *fir) | |||
290 | 286 | ||
291 | static __inline__ void fir32_free(fir32_state_t *fir) | 287 | static __inline__ void fir32_free(fir32_state_t *fir) |
292 | { | 288 | { |
293 | free(fir->history); | 289 | kfree(fir->history); |
294 | } | 290 | } |
295 | /*- End of function --------------------------------------------------------*/ | 291 | /*- End of function --------------------------------------------------------*/ |
296 | 292 | ||