V4L/DVB (3438): Optical cleanup for dmxdev.c
Used Lindent, manually changed some line breaks. Removed invalid email addresses, useless casts and useless initialization of return values. Signed-off-by: Andreas Oberritter <obi@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
parent
bbad7dc548
commit
f705e6e494
|
@ -1,9 +1,8 @@
|
|||
/*
|
||||
* dmxdev.c - DVB demultiplexer device
|
||||
*
|
||||
* Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
|
||||
* & Marcus Metzler <marcus@convergence.de>
|
||||
for convergence integrated media GmbH
|
||||
* Copyright (C) 2000 Ralph Metzler & Marcus Metzler
|
||||
* for convergence integrated media GmbH
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
|
@ -32,7 +31,6 @@
|
|||
#include <linux/wait.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/system.h>
|
||||
|
||||
#include "dmxdev.h"
|
||||
|
||||
static int debug;
|
||||
|
@ -52,7 +50,8 @@ static inline void dvb_dmxdev_buffer_init(struct dmxdev_buffer *buffer)
|
|||
init_waitqueue_head(&buffer->queue);
|
||||
}
|
||||
|
||||
static inline int dvb_dmxdev_buffer_write(struct dmxdev_buffer *buf, const u8 *src, int len)
|
||||
static inline int dvb_dmxdev_buffer_write(struct dmxdev_buffer *buf,
|
||||
const u8 *src, int len)
|
||||
{
|
||||
int split;
|
||||
int free;
|
||||
|
@ -87,7 +86,8 @@ static inline int dvb_dmxdev_buffer_write(struct dmxdev_buffer *buf, const u8 *s
|
|||
}
|
||||
|
||||
static ssize_t dvb_dmxdev_buffer_read(struct dmxdev_buffer *src,
|
||||
int non_blocking, char __user *buf, size_t count, loff_t *ppos)
|
||||
int non_blocking, char __user *buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
unsigned long todo = count;
|
||||
int split, avail, error;
|
||||
|
@ -269,14 +269,16 @@ static ssize_t dvb_dvr_read(struct file *file, char __user *buf, size_t count,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static inline void dvb_dmxdev_filter_state_set(struct dmxdev_filter *dmxdevfilter, int state)
|
||||
static inline void dvb_dmxdev_filter_state_set(struct dmxdev_filter
|
||||
*dmxdevfilter, int state)
|
||||
{
|
||||
spin_lock_irq(&dmxdevfilter->dev->lock);
|
||||
dmxdevfilter->state = state;
|
||||
spin_unlock_irq(&dmxdevfilter->dev->lock);
|
||||
}
|
||||
|
||||
static int dvb_dmxdev_set_buffer_size(struct dmxdev_filter *dmxdevfilter, unsigned long size)
|
||||
static int dvb_dmxdev_set_buffer_size(struct dmxdev_filter *dmxdevfilter,
|
||||
unsigned long size)
|
||||
{
|
||||
struct dmxdev_buffer *buf = &dmxdevfilter->buffer;
|
||||
void *mem;
|
||||
|
@ -323,14 +325,16 @@ static void dvb_dmxdev_filter_timer(struct dmxdev_filter *dmxdevfilter)
|
|||
if (para->timeout) {
|
||||
dmxdevfilter->timer.function = dvb_dmxdev_filter_timeout;
|
||||
dmxdevfilter->timer.data = (unsigned long)dmxdevfilter;
|
||||
dmxdevfilter->timer.expires=jiffies+1+(HZ/2+HZ*para->timeout)/1000;
|
||||
dmxdevfilter->timer.expires =
|
||||
jiffies + 1 + (HZ / 2 + HZ * para->timeout) / 1000;
|
||||
add_timer(&dmxdevfilter->timer);
|
||||
}
|
||||
}
|
||||
|
||||
static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
|
||||
const u8 *buffer2, size_t buffer2_len,
|
||||
struct dmx_section_filter *filter, enum dmx_success success)
|
||||
struct dmx_section_filter *filter,
|
||||
enum dmx_success success)
|
||||
{
|
||||
struct dmxdev_filter *dmxdevfilter = filter->priv;
|
||||
int ret;
|
||||
|
@ -347,11 +351,12 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
|
|||
del_timer(&dmxdevfilter->timer);
|
||||
dprintk("dmxdev: section callback %02x %02x %02x %02x %02x %02x\n",
|
||||
buffer1[0], buffer1[1],
|
||||
buffer1[2], buffer1[3],
|
||||
buffer1[4], buffer1[5]);
|
||||
ret=dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer1, buffer1_len);
|
||||
buffer1[2], buffer1[3], buffer1[4], buffer1[5]);
|
||||
ret = dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer1,
|
||||
buffer1_len);
|
||||
if (ret == buffer1_len) {
|
||||
ret=dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer2, buffer2_len);
|
||||
ret = dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer2,
|
||||
buffer2_len);
|
||||
}
|
||||
if (ret < 0) {
|
||||
dmxdevfilter->buffer.pwrite = dmxdevfilter->buffer.pread;
|
||||
|
@ -366,7 +371,8 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
|
|||
|
||||
static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
|
||||
const u8 *buffer2, size_t buffer2_len,
|
||||
struct dmx_ts_feed *feed, enum dmx_success success)
|
||||
struct dmx_ts_feed *feed,
|
||||
enum dmx_success success)
|
||||
{
|
||||
struct dmxdev_filter *dmxdevfilter = feed->priv;
|
||||
struct dmxdev_buffer *buffer;
|
||||
|
@ -399,9 +405,7 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* stop feed but only mark the specified filter as stopped (state set) */
|
||||
|
||||
static int dvb_dmxdev_feed_stop(struct dmxdev_filter *dmxdevfilter)
|
||||
{
|
||||
dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET);
|
||||
|
@ -420,9 +424,7 @@ static int dvb_dmxdev_feed_stop(struct dmxdev_filter *dmxdevfilter)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* start feed associated with the specified filter */
|
||||
|
||||
static int dvb_dmxdev_feed_start(struct dmxdev_filter *filter)
|
||||
{
|
||||
dvb_dmxdev_filter_state_set(filter, DMXDEV_STATE_GO);
|
||||
|
@ -430,10 +432,8 @@ static int dvb_dmxdev_feed_start(struct dmxdev_filter *filter)
|
|||
switch (filter->type) {
|
||||
case DMXDEV_TYPE_SEC:
|
||||
return filter->feed.sec->start_filtering(filter->feed.sec);
|
||||
break;
|
||||
case DMXDEV_TYPE_PES:
|
||||
return filter->feed.ts->start_filtering(filter->feed.ts);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -441,10 +441,8 @@ static int dvb_dmxdev_feed_start(struct dmxdev_filter *filter)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* restart section feed if it has filters left associated with it,
|
||||
otherwise release the feed */
|
||||
|
||||
static int dvb_dmxdev_feed_restart(struct dmxdev_filter *filter)
|
||||
{
|
||||
int i;
|
||||
|
@ -459,7 +457,8 @@ static int dvb_dmxdev_feed_restart(struct dmxdev_filter *filter)
|
|||
return 0;
|
||||
}
|
||||
|
||||
filter->dev->demux->release_section_feed(dmxdev->demux, filter->feed.sec);
|
||||
filter->dev->demux->release_section_feed(dmxdev->demux,
|
||||
filter->feed.sec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -542,6 +541,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
|
|||
*secfilter = NULL;
|
||||
*secfeed = NULL;
|
||||
|
||||
|
||||
/* find active filter/feed with same PID */
|
||||
for (i = 0; i < dmxdev->filternum; i++) {
|
||||
if (dmxdev->filter[i].state >= DMXDEV_STATE_GO &&
|
||||
|
@ -565,7 +565,6 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
|
|||
|
||||
ret = (*secfeed)->set(*secfeed, para->pid, 32768,
|
||||
(para->flags & DMX_CHECK_CRC) ? 1 : 0);
|
||||
|
||||
if (ret < 0) {
|
||||
printk("DVB (%s): could not set feed\n",
|
||||
__FUNCTION__);
|
||||
|
@ -577,7 +576,6 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
|
|||
}
|
||||
|
||||
ret = (*secfeed)->allocate_filter(*secfeed, secfilter);
|
||||
|
||||
if (ret < 0) {
|
||||
dvb_dmxdev_feed_restart(filter);
|
||||
filter->feed.sec->start_filtering(*secfeed);
|
||||
|
@ -603,14 +601,12 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
|
|||
filter->todo = 0;
|
||||
|
||||
ret = filter->feed.sec->start_filtering(filter->feed.sec);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
dvb_dmxdev_filter_timer(filter);
|
||||
break;
|
||||
}
|
||||
|
||||
case DMXDEV_TYPE_PES:
|
||||
{
|
||||
struct timespec timeout = { 0 };
|
||||
|
@ -643,20 +639,20 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
(*tsfeed)->priv = (void *) filter;
|
||||
(*tsfeed)->priv = filter;
|
||||
|
||||
ret = (*tsfeed)->set(*tsfeed, para->pid, ts_type, ts_pes,
|
||||
32768, timeout);
|
||||
|
||||
if (ret < 0) {
|
||||
dmxdev->demux->release_ts_feed(dmxdev->demux, *tsfeed);
|
||||
dmxdev->demux->release_ts_feed(dmxdev->demux,
|
||||
*tsfeed);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = filter->feed.ts->start_filtering(filter->feed.ts);
|
||||
|
||||
if (ret < 0) {
|
||||
dmxdev->demux->release_ts_feed(dmxdev->demux, *tsfeed);
|
||||
dmxdev->demux->release_ts_feed(dmxdev->demux,
|
||||
*tsfeed);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -706,8 +702,8 @@ static int dvb_demux_open(struct inode *inode, struct file *file)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev, struct dmxdev_filter *dmxdevfilter)
|
||||
static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev,
|
||||
struct dmxdev_filter *dmxdevfilter)
|
||||
{
|
||||
if (mutex_lock_interruptible(&dmxdev->mutex))
|
||||
return -ERESTARTSYS;
|
||||
|
@ -744,7 +740,6 @@ static inline void invert_mode(dmx_filter_t *filter)
|
|||
filter->mode[i] ^= 0xff;
|
||||
}
|
||||
|
||||
|
||||
static int dvb_dmxdev_filter_set(struct dmxdev *dmxdev,
|
||||
struct dmxdev_filter *dmxdevfilter,
|
||||
struct dmx_sct_filter_params *params)
|
||||
|
@ -775,7 +770,8 @@ static int dvb_dmxdev_pes_filter_set(struct dmxdev *dmxdev,
|
|||
return -EINVAL;
|
||||
|
||||
dmxdevfilter->type = DMXDEV_TYPE_PES;
|
||||
memcpy(&dmxdevfilter->params, params, sizeof(struct dmx_pes_filter_params));
|
||||
memcpy(&dmxdevfilter->params, params,
|
||||
sizeof(struct dmx_pes_filter_params));
|
||||
|
||||
dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET);
|
||||
|
||||
|
@ -786,7 +782,8 @@ static int dvb_dmxdev_pes_filter_set(struct dmxdev *dmxdev,
|
|||
}
|
||||
|
||||
static ssize_t dvb_dmxdev_read_sec(struct dmxdev_filter *dfil,
|
||||
struct file *file, char __user *buf, size_t count, loff_t *ppos)
|
||||
struct file *file, char __user *buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
int result, hcount;
|
||||
int done = 0;
|
||||
|
@ -795,7 +792,8 @@ static ssize_t dvb_dmxdev_read_sec(struct dmxdev_filter *dfil,
|
|||
hcount = 3 + dfil->todo;
|
||||
if (hcount > count)
|
||||
hcount = count;
|
||||
result=dvb_dmxdev_buffer_read(&dfil->buffer, file->f_flags&O_NONBLOCK,
|
||||
result = dvb_dmxdev_buffer_read(&dfil->buffer,
|
||||
file->f_flags & O_NONBLOCK,
|
||||
buf, hcount, ppos);
|
||||
if (result < 0) {
|
||||
dfil->todo = 0;
|
||||
|
@ -815,7 +813,8 @@ static ssize_t dvb_dmxdev_read_sec(struct dmxdev_filter *dfil,
|
|||
}
|
||||
if (count > dfil->todo)
|
||||
count = dfil->todo;
|
||||
result=dvb_dmxdev_buffer_read(&dfil->buffer, file->f_flags&O_NONBLOCK,
|
||||
result = dvb_dmxdev_buffer_read(&dfil->buffer,
|
||||
file->f_flags & O_NONBLOCK,
|
||||
buf, count, ppos);
|
||||
if (result < 0)
|
||||
return result;
|
||||
|
@ -823,12 +822,12 @@ static ssize_t dvb_dmxdev_read_sec(struct dmxdev_filter *dfil,
|
|||
return (result + done);
|
||||
}
|
||||
|
||||
|
||||
static ssize_t
|
||||
dvb_demux_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
|
||||
dvb_demux_read(struct file *file, char __user *buf, size_t count,
|
||||
loff_t *ppos)
|
||||
{
|
||||
struct dmxdev_filter *dmxdevfilter = file->private_data;
|
||||
int ret=0;
|
||||
int ret;
|
||||
|
||||
if (mutex_lock_interruptible(&dmxdevfilter->mutex))
|
||||
return -ERESTARTSYS;
|
||||
|
@ -844,7 +843,6 @@ dvb_demux_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
|
||||
unsigned int cmd, void *parg)
|
||||
{
|
||||
|
@ -883,8 +881,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
|
|||
mutex_unlock(&dmxdev->mutex);
|
||||
return -ERESTARTSYS;
|
||||
}
|
||||
ret = dvb_dmxdev_filter_set(dmxdev, dmxdevfilter,
|
||||
(struct dmx_sct_filter_params *)parg);
|
||||
ret = dvb_dmxdev_filter_set(dmxdev, dmxdevfilter, parg);
|
||||
mutex_unlock(&dmxdevfilter->mutex);
|
||||
break;
|
||||
|
||||
|
@ -893,8 +890,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
|
|||
mutex_unlock(&dmxdev->mutex);
|
||||
return -ERESTARTSYS;
|
||||
}
|
||||
ret=dvb_dmxdev_pes_filter_set(dmxdev, dmxdevfilter,
|
||||
(struct dmx_pes_filter_params *)parg);
|
||||
ret = dvb_dmxdev_pes_filter_set(dmxdev, dmxdevfilter, parg);
|
||||
mutex_unlock(&dmxdevfilter->mutex);
|
||||
break;
|
||||
|
||||
|
@ -915,7 +911,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
|
|||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
dmxdev->demux->get_pes_pids(dmxdev->demux, (u16 *)parg);
|
||||
dmxdev->demux->get_pes_pids(dmxdev->demux, parg);
|
||||
break;
|
||||
|
||||
case DMX_GET_CAPS:
|
||||
|
@ -947,6 +943,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
|
|||
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
mutex_unlock(&dmxdev->mutex);
|
||||
return ret;
|
||||
|
@ -958,7 +955,6 @@ static int dvb_demux_ioctl(struct inode *inode, struct file *file,
|
|||
return dvb_usercopy(inode, file, cmd, arg, dvb_demux_do_ioctl);
|
||||
}
|
||||
|
||||
|
||||
static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
|
||||
{
|
||||
struct dmxdev_filter *dmxdevfilter = file->private_data;
|
||||
|
@ -983,7 +979,6 @@ static unsigned int dvb_demux_poll (struct file *file, poll_table *wait)
|
|||
return mask;
|
||||
}
|
||||
|
||||
|
||||
static int dvb_demux_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct dmxdev_filter *dmxdevfilter = file->private_data;
|
||||
|
@ -992,7 +987,6 @@ static int dvb_demux_release(struct inode *inode, struct file *file)
|
|||
return dvb_dmxdev_filter_free(dmxdev, dmxdevfilter);
|
||||
}
|
||||
|
||||
|
||||
static struct file_operations dvb_demux_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.read = dvb_demux_read,
|
||||
|
@ -1002,7 +996,6 @@ static struct file_operations dvb_demux_fops = {
|
|||
.poll = dvb_demux_poll,
|
||||
};
|
||||
|
||||
|
||||
static struct dvb_device dvbdev_demux = {
|
||||
.priv = NULL,
|
||||
.users = 1,
|
||||
|
@ -1010,14 +1003,12 @@ static struct dvb_device dvbdev_demux = {
|
|||
.fops = &dvb_demux_fops
|
||||
};
|
||||
|
||||
|
||||
static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
|
||||
unsigned int cmd, void *parg)
|
||||
{
|
||||
struct dvb_device *dvbdev = file->private_data;
|
||||
struct dmxdev *dmxdev = dvbdev->priv;
|
||||
|
||||
int ret=0;
|
||||
int ret;
|
||||
|
||||
if (mutex_lock_interruptible(&dmxdev->mutex))
|
||||
return -ERESTARTSYS;
|
||||
|
@ -1030,19 +1021,18 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
|
|||
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
mutex_unlock(&dmxdev->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int dvb_dvr_ioctl(struct inode *inode, struct file *file,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
return dvb_usercopy(inode, file, cmd, arg, dvb_dvr_do_ioctl);
|
||||
}
|
||||
|
||||
|
||||
static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
|
||||
{
|
||||
struct dvb_device *dvbdev = file->private_data;
|
||||
|
@ -1065,7 +1055,6 @@ static unsigned int dvb_dvr_poll (struct file *file, poll_table *wait)
|
|||
return mask;
|
||||
}
|
||||
|
||||
|
||||
static struct file_operations dvb_dvr_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.read = dvb_dvr_read,
|
||||
|
@ -1083,8 +1072,7 @@ static struct dvb_device dvbdev_dvr = {
|
|||
.fops = &dvb_dvr_fops
|
||||
};
|
||||
|
||||
int
|
||||
dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
|
||||
int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1100,20 +1088,23 @@ dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
|
|||
for (i = 0; i < dmxdev->filternum; i++) {
|
||||
dmxdev->filter[i].dev = dmxdev;
|
||||
dmxdev->filter[i].buffer.data = NULL;
|
||||
dvb_dmxdev_filter_state_set(&dmxdev->filter[i], DMXDEV_STATE_FREE);
|
||||
dvb_dmxdev_filter_state_set(&dmxdev->filter[i],
|
||||
DMXDEV_STATE_FREE);
|
||||
}
|
||||
|
||||
dvb_register_device(dvb_adapter, &dmxdev->dvbdev, &dvbdev_demux, dmxdev, DVB_DEVICE_DEMUX);
|
||||
dvb_register_device(dvb_adapter, &dmxdev->dvr_dvbdev, &dvbdev_dvr, dmxdev, DVB_DEVICE_DVR);
|
||||
dvb_register_device(dvb_adapter, &dmxdev->dvbdev, &dvbdev_demux, dmxdev,
|
||||
DVB_DEVICE_DEMUX);
|
||||
dvb_register_device(dvb_adapter, &dmxdev->dvr_dvbdev, &dvbdev_dvr,
|
||||
dmxdev, DVB_DEVICE_DVR);
|
||||
|
||||
dvb_dmxdev_buffer_init(&dmxdev->dvr_buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(dvb_dmxdev_init);
|
||||
|
||||
void
|
||||
dvb_dmxdev_release(struct dmxdev *dmxdev)
|
||||
void dvb_dmxdev_release(struct dmxdev *dmxdev)
|
||||
{
|
||||
dvb_unregister_device(dmxdev->dvbdev);
|
||||
dvb_unregister_device(dmxdev->dvr_dvbdev);
|
||||
|
@ -1122,4 +1113,5 @@ dvb_dmxdev_release(struct dmxdev *dmxdev)
|
|||
dmxdev->filter = NULL;
|
||||
dmxdev->demux->close(dmxdev->demux);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(dvb_dmxdev_release);
|
||||
|
|
Loading…
Reference in New Issue