aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/pci/cx25821/cx25821-audio-upstream.c96
1 files changed, 28 insertions, 68 deletions
diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.c b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
index d930f308e94e..d6dfb5765d0b 100644
--- a/drivers/media/pci/cx25821/cx25821-audio-upstream.c
+++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
@@ -321,81 +321,41 @@ static void cx25821_audioups_handler(struct work_struct *work)
321static int cx25821_openfile_audio(struct cx25821_dev *dev, 321static int cx25821_openfile_audio(struct cx25821_dev *dev,
322 struct sram_channel *sram_ch) 322 struct sram_channel *sram_ch)
323{ 323{
324 struct file *myfile; 324 char *p = (void *)dev->_audiodata_buf_virt_addr;
325 int i = 0, j = 0; 325 struct file *file;
326 int line_size = AUDIO_LINE_SIZE; 326 loff_t offset;
327 ssize_t vfs_read_retval = 0; 327 int i, j;
328 char mybuf[line_size];
329 loff_t pos;
330 loff_t offset = (unsigned long)0;
331 mm_segment_t old_fs;
332
333 myfile = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0);
334
335 if (IS_ERR(myfile)) {
336 const int open_errno = -PTR_ERR(myfile);
337 pr_err("%s(): ERROR opening file(%s) with errno = %d!\n",
338 __func__, dev->_audiofilename, open_errno);
339 return PTR_ERR(myfile);
340 } else {
341 if (!(myfile->f_op)) {
342 pr_err("%s(): File has no file operations registered!\n",
343 __func__);
344 filp_close(myfile, NULL);
345 return -EIO;
346 }
347
348 if (!myfile->f_op->read) {
349 pr_err("%s(): File has no READ operations registered!\n",
350 __func__);
351 filp_close(myfile, NULL);
352 return -EIO;
353 }
354
355 pos = myfile->f_pos;
356 old_fs = get_fs();
357 set_fs(KERNEL_DS);
358
359 for (j = 0; j < NUM_AUDIO_FRAMES; j++) {
360 for (i = 0; i < dev->_audio_lines_count; i++) {
361 pos = offset;
362
363 vfs_read_retval = vfs_read(myfile, mybuf,
364 line_size, &pos);
365
366 if (vfs_read_retval > 0 &&
367 vfs_read_retval == line_size &&
368 dev->_audiodata_buf_virt_addr != NULL) {
369 memcpy((void *)(dev->
370 _audiodata_buf_virt_addr
371 + offset / 4), mybuf,
372 vfs_read_retval);
373 }
374 328
375 offset += vfs_read_retval; 329 file = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0);
330 if (IS_ERR(file)) {
331 pr_err("%s(): ERROR opening file(%s) with errno = %ld!\n",
332 __func__, dev->_audiofilename, PTR_ERR(file));
333 return PTR_ERR(file);
334 }
376 335
377 if (vfs_read_retval < line_size) { 336 for (j = 0, offset = 0; j < NUM_AUDIO_FRAMES; j++) {
378 pr_info("Done: exit %s() since no more bytes to read from Audio file\n", 337 for (i = 0; i < dev->_audio_lines_count; i++) {
379 __func__); 338 char buf[AUDIO_LINE_SIZE];
380 break; 339 int n = kernel_read(file, offset, buf,
381 } 340 AUDIO_LINE_SIZE);
341
342 if (n < AUDIO_LINE_SIZE) {
343 pr_info("Done: exit %s() since no more bytes to read from Audio file\n",
344 __func__);
345 dev->_audiofile_status = END_OF_FILE;
346 fput(file);
347 return 0;
382 } 348 }
383 349
384 if (i > 0) 350 if (p)
385 dev->_audioframe_count++; 351 memcpy(p + offset, buf, n);
386 352
387 if (vfs_read_retval < line_size) 353 offset += n;
388 break;
389 } 354 }
390 355 dev->_audioframe_count++;
391 dev->_audiofile_status = (vfs_read_retval == line_size) ?
392 IN_PROGRESS : END_OF_FILE;
393
394 set_fs(old_fs);
395 myfile->f_pos = 0;
396 filp_close(myfile, NULL);
397 } 356 }
398 357 dev->_audiofile_status = IN_PROGRESS;
358 fput(file);
399 return 0; 359 return 0;
400} 360}
401 361