summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb
diff options
context:
space:
mode:
authorAndrew de Quincy <devnull@localhost>2004-04-12 18:36:50 +0000
committerAndrew de Quincy <devnull@localhost>2004-04-12 18:36:50 +0000
commitd3f66cf78ea4d18a2ab9a1fad0c5c187699b9014 (patch)
treef5d02f60e7883013acf4c7e5b8f788bc4abdf59c /linux/drivers/media/dvb
parent2a0743639143251a5ce3138d11c0712fec8b50b7 (diff)
downloadmediapointer-dvb-s2-d3f66cf78ea4d18a2ab9a1fad0c5c187699b9014.tar.gz
mediapointer-dvb-s2-d3f66cf78ea4d18a2ab9a1fad0c5c187699b9014.tar.bz2
Added timeout to write loop
Diffstat (limited to 'linux/drivers/media/dvb')
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index 64449e255..068c49e48 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -611,7 +611,7 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private* ca, int slot, u8* ebu
/* OK, store it in the buffer */
buf[i] = status;
- }
+ }
/* check for read error (RE should now go to 0) */
if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0) goto exit;
@@ -1198,6 +1198,8 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file, const char *buf, size_
char fragbuf[HOST_LINK_BUF_SIZE];
int fragpos = 0;
int fraglen;
+ unsigned long timeout;
+ int written;
dprintk ("%s\n", __FUNCTION__);
@@ -1222,14 +1224,22 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file, const char *buf, size_
fragbuf[1] = ((fragpos + fraglen) < count) ? 0x80 : 0x00;
if ((status = copy_from_user(fragbuf+2, buf+fragpos, fraglen)) != 0) goto exit;
- // FIXME: can this loop be improved?
- while(1) {
+ timeout = jiffies + HZ/2;
+ written = 0;
+ while(!time_after(jiffies, timeout)) {
status = dvb_ca_en50221_write_data(ca, slot, fragbuf, fraglen+2);
- if (status == (fraglen+2)) break;
+ if (status == (fraglen+2)) {
+ written = 1;
+ break;
+ }
if (status != -EAGAIN) goto exit;
dvb_delay(1);
}
+ if (!written) {
+ status = -EIO;
+ goto exit;
+ }
fragpos += fraglen;
}
@@ -1347,7 +1357,7 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char *buf, size_t count
fraglen -= 2;
}
- if ((status = dvb_ringbuffer_pkt_read(&ca->slot_info[slot].rx_buffer, idx, 2, buf + pktlen, fraglen, 1)) < 0) {
+ if ((status = dvb_ringbuffer_pkt_read(&ca->slot_info[slot].rx_buffer, idx, 2, buf + pktlen, fraglen, 1)) < 0) {
goto exit;
}
pktlen += fraglen;