diff options
Diffstat (limited to 'drivers/media/dvb/dvb-usb/af9005.c')
-rw-r--r-- | drivers/media/dvb/dvb-usb/af9005.c | 55 |
1 files changed, 7 insertions, 48 deletions
diff --git a/drivers/media/dvb/dvb-usb/af9005.c b/drivers/media/dvb/dvb-usb/af9005.c index cfd6107d5349..985646316591 100644 --- a/drivers/media/dvb/dvb-usb/af9005.c +++ b/drivers/media/dvb/dvb-usb/af9005.c | |||
@@ -54,50 +54,6 @@ struct af9005_device_state { | |||
54 | int led_state; | 54 | int led_state; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | static int af9005_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, | ||
58 | u8 *rbuf, u16 rlen, int delay_ms) | ||
59 | { | ||
60 | int actlen, ret = -ENOMEM; | ||
61 | |||
62 | if (wbuf == NULL || wlen == 0) | ||
63 | return -EINVAL; | ||
64 | |||
65 | if ((ret = mutex_lock_interruptible(&d->usb_mutex))) | ||
66 | return ret; | ||
67 | |||
68 | deb_xfer(">>> "); | ||
69 | debug_dump(wbuf, wlen, deb_xfer); | ||
70 | |||
71 | ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev, | ||
72 | 2), wbuf, wlen, | ||
73 | &actlen, 2000); | ||
74 | |||
75 | if (ret) | ||
76 | err("bulk message failed: %d (%d/%d)", ret, wlen, actlen); | ||
77 | else | ||
78 | ret = actlen != wlen ? -1 : 0; | ||
79 | |||
80 | /* an answer is expected, and no error before */ | ||
81 | if (!ret && rbuf && rlen) { | ||
82 | if (delay_ms) | ||
83 | msleep(delay_ms); | ||
84 | |||
85 | ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, | ||
86 | 0x01), rbuf, | ||
87 | rlen, &actlen, 2000); | ||
88 | |||
89 | if (ret) | ||
90 | err("recv bulk message failed: %d", ret); | ||
91 | else { | ||
92 | deb_xfer("<<< "); | ||
93 | debug_dump(rbuf, actlen, deb_xfer); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | mutex_unlock(&d->usb_mutex); | ||
98 | return ret; | ||
99 | } | ||
100 | |||
101 | static int af9005_generic_read_write(struct dvb_usb_device *d, u16 reg, | 57 | static int af9005_generic_read_write(struct dvb_usb_device *d, u16 reg, |
102 | int readwrite, int type, u8 * values, int len) | 58 | int readwrite, int type, u8 * values, int len) |
103 | { | 59 | { |
@@ -146,7 +102,7 @@ static int af9005_generic_read_write(struct dvb_usb_device *d, u16 reg, | |||
146 | obuf[8] = values[0]; | 102 | obuf[8] = values[0]; |
147 | obuf[7] = command; | 103 | obuf[7] = command; |
148 | 104 | ||
149 | ret = af9005_usb_generic_rw(d, obuf, 16, ibuf, 17, 0); | 105 | ret = dvb_usb_generic_rw(d, obuf, 16, ibuf, 17, 0); |
150 | if (ret) | 106 | if (ret) |
151 | return ret; | 107 | return ret; |
152 | 108 | ||
@@ -534,7 +490,7 @@ int af9005_send_command(struct dvb_usb_device *d, u8 command, u8 * wbuf, | |||
534 | buf[6] = wlen; | 490 | buf[6] = wlen; |
535 | for (i = 0; i < wlen; i++) | 491 | for (i = 0; i < wlen; i++) |
536 | buf[7 + i] = wbuf[i]; | 492 | buf[7 + i] = wbuf[i]; |
537 | ret = af9005_usb_generic_rw(d, buf, wlen + 7, ibuf, rlen + 7, 0); | 493 | ret = dvb_usb_generic_rw(d, buf, wlen + 7, ibuf, rlen + 7, 0); |
538 | if (ret) | 494 | if (ret) |
539 | return ret; | 495 | return ret; |
540 | if (ibuf[2] != 0x27) { | 496 | if (ibuf[2] != 0x27) { |
@@ -581,7 +537,7 @@ int af9005_read_eeprom(struct dvb_usb_device *d, u8 address, u8 * values, | |||
581 | 537 | ||
582 | obuf[6] = len; | 538 | obuf[6] = len; |
583 | obuf[7] = address; | 539 | obuf[7] = address; |
584 | ret = af9005_usb_generic_rw(d, obuf, 16, ibuf, 14, 0); | 540 | ret = dvb_usb_generic_rw(d, obuf, 16, ibuf, 14, 0); |
585 | if (ret) | 541 | if (ret) |
586 | return ret; | 542 | return ret; |
587 | if (ibuf[2] != 0x2b) { | 543 | if (ibuf[2] != 0x2b) { |
@@ -882,7 +838,7 @@ static int af9005_rc_query(struct dvb_usb_device *d, u32 * event, int *state) | |||
882 | obuf[2] = 0x40; /* read remote */ | 838 | obuf[2] = 0x40; /* read remote */ |
883 | obuf[3] = 1; /* rest of packet length */ | 839 | obuf[3] = 1; /* rest of packet length */ |
884 | obuf[4] = st->sequence++; /* sequence number */ | 840 | obuf[4] = st->sequence++; /* sequence number */ |
885 | ret = af9005_usb_generic_rw(d, obuf, 5, ibuf, 256, 0); | 841 | ret = dvb_usb_generic_rw(d, obuf, 5, ibuf, 256, 0); |
886 | if (ret) { | 842 | if (ret) { |
887 | err("rc query failed"); | 843 | err("rc query failed"); |
888 | return ret; | 844 | return ret; |
@@ -1074,6 +1030,9 @@ static struct dvb_usb_device_properties af9005_properties = { | |||
1074 | .rc_key_map_size = 0, | 1030 | .rc_key_map_size = 0, |
1075 | .rc_query = af9005_rc_query, | 1031 | .rc_query = af9005_rc_query, |
1076 | 1032 | ||
1033 | .generic_bulk_ctrl_endpoint = 2, | ||
1034 | .generic_bulk_ctrl_endpoint_response = 1, | ||
1035 | |||
1077 | .num_device_descs = 3, | 1036 | .num_device_descs = 3, |
1078 | .devices = { | 1037 | .devices = { |
1079 | {.name = "Afatech DVB-T USB1.1 stick", | 1038 | {.name = "Afatech DVB-T USB1.1 stick", |