aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/gspca/sq905c.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/media/video/gspca/sq905c.c b/drivers/media/video/gspca/sq905c.c
index 916892505432..81020f6f739e 100644
--- a/drivers/media/video/gspca/sq905c.c
+++ b/drivers/media/video/gspca/sq905c.c
@@ -119,7 +119,6 @@ static void sq905c_dostream(struct work_struct *work)
119 int bytes_left; /* bytes remaining in current frame. */ 119 int bytes_left; /* bytes remaining in current frame. */
120 int data_len; /* size to use for the next read. */ 120 int data_len; /* size to use for the next read. */
121 int act_len; 121 int act_len;
122 int discarding = 0; /* true if we failed to get space for frame. */
123 int packet_type; 122 int packet_type;
124 int ret; 123 int ret;
125 u8 *buffer; 124 u8 *buffer;
@@ -131,8 +130,6 @@ static void sq905c_dostream(struct work_struct *work)
131 } 130 }
132 131
133 while (gspca_dev->present && gspca_dev->streaming) { 132 while (gspca_dev->present && gspca_dev->streaming) {
134 if (!gspca_dev->present)
135 goto quit_stream;
136 /* Request the header, which tells the size to download */ 133 /* Request the header, which tells the size to download */
137 ret = usb_bulk_msg(gspca_dev->dev, 134 ret = usb_bulk_msg(gspca_dev->dev,
138 usb_rcvbulkpipe(gspca_dev->dev, 0x81), 135 usb_rcvbulkpipe(gspca_dev->dev, 0x81),
@@ -150,16 +147,12 @@ static void sq905c_dostream(struct work_struct *work)
150 /* We keep the header. It has other information, too. */ 147 /* We keep the header. It has other information, too. */
151 packet_type = FIRST_PACKET; 148 packet_type = FIRST_PACKET;
152 frame = gspca_get_i_frame(gspca_dev); 149 frame = gspca_get_i_frame(gspca_dev);
153 if (frame && !discarding) { 150 if (frame)
154 gspca_frame_add(gspca_dev, packet_type, 151 gspca_frame_add(gspca_dev, packet_type,
155 frame, buffer, FRAME_HEADER_LEN); 152 frame, buffer, FRAME_HEADER_LEN);
156 } else 153 while (bytes_left > 0 && gspca_dev->present) {
157 discarding = 1;
158 while (bytes_left > 0) {
159 data_len = bytes_left > SQ905C_MAX_TRANSFER ? 154 data_len = bytes_left > SQ905C_MAX_TRANSFER ?
160 SQ905C_MAX_TRANSFER : bytes_left; 155 SQ905C_MAX_TRANSFER : bytes_left;
161 if (!gspca_dev->present)
162 goto quit_stream;
163 ret = usb_bulk_msg(gspca_dev->dev, 156 ret = usb_bulk_msg(gspca_dev->dev,
164 usb_rcvbulkpipe(gspca_dev->dev, 0x81), 157 usb_rcvbulkpipe(gspca_dev->dev, 0x81),
165 buffer, data_len, &act_len, 158 buffer, data_len, &act_len,
@@ -174,19 +167,17 @@ static void sq905c_dostream(struct work_struct *work)
174 packet_type = LAST_PACKET; 167 packet_type = LAST_PACKET;
175 else 168 else
176 packet_type = INTER_PACKET; 169 packet_type = INTER_PACKET;
177 frame = gspca_get_i_frame(gspca_dev); 170 if (frame)
178 if (frame && !discarding)
179 gspca_frame_add(gspca_dev, packet_type, 171 gspca_frame_add(gspca_dev, packet_type,
180 frame, buffer, data_len); 172 frame, buffer, data_len);
181 else
182 discarding = 1;
183 } 173 }
184 } 174 }
185quit_stream: 175quit_stream:
186 mutex_lock(&gspca_dev->usb_lock); 176 if (gspca_dev->present) {
187 if (gspca_dev->present) 177 mutex_lock(&gspca_dev->usb_lock);
188 sq905c_command(gspca_dev, SQ905C_CLEAR, 0); 178 sq905c_command(gspca_dev, SQ905C_CLEAR, 0);
189 mutex_unlock(&gspca_dev->usb_lock); 179 mutex_unlock(&gspca_dev->usb_lock);
180 }
190 kfree(buffer); 181 kfree(buffer);
191} 182}
192 183