Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 49600 | Differences between
and this patch

Collapse All | Expand All

(-)linux-2.4.22-1.2130.nptl/drivers/usb/storage/scsiglue.c (-10 / +27 lines)
Lines 213-221 Link Here
213
static int device_reset( Scsi_Cmnd *srb )
213
static int device_reset( Scsi_Cmnd *srb )
214
{
214
{
215
	struct us_data *us = (struct us_data *)srb->host->hostdata[0];
215
	struct us_data *us = (struct us_data *)srb->host->hostdata[0];
216
	int rc;
216
217
217
	US_DEBUGP("device_reset() called\n" );
218
	US_DEBUGP("device_reset() called\n" );
218
	return us->transport_reset(us);
219
	spin_unlock_irq(&io_request_lock);
220
	down(&(us->dev_semaphore));
221
	if (!us->pusb_dev) {
222
		up(&(us->dev_semaphore));
223
		spin_lock_irq(&io_request_lock);
224
		return SUCCESS;
225
	}
226
	rc = us->transport_reset(us);
227
	up(&(us->dev_semaphore));
228
	spin_lock_irq(&io_request_lock);
229
	return rc;
219
}
230
}
220
231
221
/* This resets the device port, and simulates the device
232
/* This resets the device port, and simulates the device
Lines 230-256 Link Here
230
	/* we use the usb_reset_device() function to handle this for us */
241
	/* we use the usb_reset_device() function to handle this for us */
231
	US_DEBUGP("bus_reset() called\n");
242
	US_DEBUGP("bus_reset() called\n");
232
243
244
	spin_unlock_irq(&io_request_lock);
245
246
	down(&(us->dev_semaphore));
247
233
	/* if the device has been removed, this worked */
248
	/* if the device has been removed, this worked */
234
	if (!us->pusb_dev) {
249
	if (!us->pusb_dev) {
235
		US_DEBUGP("-- device removed already\n");
250
		US_DEBUGP("-- device removed already\n");
251
		up(&(us->dev_semaphore));
252
		spin_lock_irq(&io_request_lock);
236
		return SUCCESS;
253
		return SUCCESS;
237
	}
254
	}
238
255
239
	spin_unlock_irq(&io_request_lock);
240
241
	/* release the IRQ, if we have one */
256
	/* release the IRQ, if we have one */
242
	down(&(us->irq_urb_sem));
243
	if (us->irq_urb) {
257
	if (us->irq_urb) {
244
		US_DEBUGP("-- releasing irq URB\n");
258
		US_DEBUGP("-- releasing irq URB\n");
245
		result = usb_unlink_urb(us->irq_urb);
259
		result = usb_unlink_urb(us->irq_urb);
246
		US_DEBUGP("-- usb_unlink_urb() returned %d\n", result);
260
		US_DEBUGP("-- usb_unlink_urb() returned %d\n", result);
247
	}
261
	}
248
	up(&(us->irq_urb_sem));
249
262
250
	/* attempt to reset the port */
263
	/* attempt to reset the port */
251
	if (usb_reset_device(us->pusb_dev) < 0) {
264
	if (usb_reset_device(us->pusb_dev) < 0) {
252
		spin_lock_irq(&io_request_lock);
265
		/*
253
		return FAILED;
266
		 * Do not return errors, or else the error handler might
267
		 * invoke host_reset, which is not implemented.
268
		 */
269
		goto bail_out;
254
	}
270
	}
255
271
256
	/* FIXME: This needs to lock out driver probing while it's working
272
	/* FIXME: This needs to lock out driver probing while it's working
Lines 281-297 Link Here
281
		up(&intf->driver->serialize);
297
		up(&intf->driver->serialize);
282
	}
298
	}
283
299
300
bail_out:
284
	/* re-allocate the IRQ URB and submit it to restore connectivity
301
	/* re-allocate the IRQ URB and submit it to restore connectivity
285
	 * for CBI devices
302
	 * for CBI devices
286
	 */
303
	 */
287
	if (us->protocol == US_PR_CBI) {
304
	if (us->protocol == US_PR_CBI) {
288
		down(&(us->irq_urb_sem));
289
		us->irq_urb->dev = us->pusb_dev;
305
		us->irq_urb->dev = us->pusb_dev;
290
		result = usb_submit_urb(us->irq_urb);
306
		result = usb_submit_urb(us->irq_urb);
291
		US_DEBUGP("usb_submit_urb() returns %d\n", result);
307
		US_DEBUGP("usb_submit_urb() returns %d\n", result);
292
		up(&(us->irq_urb_sem));
293
	}
308
	}
294
	
309
310
	up(&(us->dev_semaphore));
311
295
	spin_lock_irq(&io_request_lock);
312
	spin_lock_irq(&io_request_lock);
296
313
297
	US_DEBUGP("bus_reset() complete\n");
314
	US_DEBUGP("bus_reset() complete\n");
(-)linux-2.4.22-1.2130.nptl/drivers/usb/storage/usb.c (-10 / +3 lines)
Lines 513-518 Link Here
513
 * strucuture is current.  This includes the ep_int field, which gives us
513
 * strucuture is current.  This includes the ep_int field, which gives us
514
 * the endpoint for the interrupt.
514
 * the endpoint for the interrupt.
515
 * Returns non-zero on failure, zero on success
515
 * Returns non-zero on failure, zero on success
516
 *
517
 * ss->dev_semaphore is expected taken, except for a newly minted,
518
 * unregistered device.
516
 */ 
519
 */ 
517
static int usb_stor_allocate_irq(struct us_data *ss)
520
static int usb_stor_allocate_irq(struct us_data *ss)
518
{
521
{
Lines 522-534 Link Here
522
525
523
	US_DEBUGP("Allocating IRQ for CBI transport\n");
526
	US_DEBUGP("Allocating IRQ for CBI transport\n");
524
527
525
	/* lock access to the data structure */
526
	down(&(ss->irq_urb_sem));
527
528
	/* allocate the URB */
528
	/* allocate the URB */
529
	ss->irq_urb = usb_alloc_urb(0);
529
	ss->irq_urb = usb_alloc_urb(0);
530
	if (!ss->irq_urb) {
530
	if (!ss->irq_urb) {
531
		up(&(ss->irq_urb_sem));
532
		US_DEBUGP("couldn't allocate interrupt URB");
531
		US_DEBUGP("couldn't allocate interrupt URB");
533
		return 1;
532
		return 1;
534
	}
533
	}
Lines 549-560 Link Here
549
	US_DEBUGP("usb_submit_urb() returns %d\n", result);
548
	US_DEBUGP("usb_submit_urb() returns %d\n", result);
550
	if (result) {
549
	if (result) {
551
		usb_free_urb(ss->irq_urb);
550
		usb_free_urb(ss->irq_urb);
552
		up(&(ss->irq_urb_sem));
553
		return 2;
551
		return 2;
554
	}
552
	}
555
553
556
	/* unlock the data structure and return success */
557
	up(&(ss->irq_urb_sem));
558
	return 0;
554
	return 0;
559
}
555
}
560
556
Lines 782-788 Link Here
782
		init_completion(&(ss->notify));
778
		init_completion(&(ss->notify));
783
		init_MUTEX_LOCKED(&(ss->ip_waitq));
779
		init_MUTEX_LOCKED(&(ss->ip_waitq));
784
		spin_lock_init(&(ss->queue_exclusion));
780
		spin_lock_init(&(ss->queue_exclusion));
785
		init_MUTEX(&(ss->irq_urb_sem));
786
		init_MUTEX(&(ss->current_urb_sem));
781
		init_MUTEX(&(ss->current_urb_sem));
787
		init_MUTEX(&(ss->dev_semaphore));
782
		init_MUTEX(&(ss->dev_semaphore));
788
783
Lines 1079-1085 Link Here
1079
	down(&(ss->dev_semaphore));
1074
	down(&(ss->dev_semaphore));
1080
1075
1081
	/* release the IRQ, if we have one */
1076
	/* release the IRQ, if we have one */
1082
	down(&(ss->irq_urb_sem));
1083
	if (ss->irq_urb) {
1077
	if (ss->irq_urb) {
1084
		US_DEBUGP("-- releasing irq URB\n");
1078
		US_DEBUGP("-- releasing irq URB\n");
1085
		result = usb_unlink_urb(ss->irq_urb);
1079
		result = usb_unlink_urb(ss->irq_urb);
Lines 1087-1093 Link Here
1087
		usb_free_urb(ss->irq_urb);
1081
		usb_free_urb(ss->irq_urb);
1088
		ss->irq_urb = NULL;
1082
		ss->irq_urb = NULL;
1089
	}
1083
	}
1090
	up(&(ss->irq_urb_sem));
1091
1084
1092
	/* free up the main URB for this device */
1085
	/* free up the main URB for this device */
1093
	US_DEBUGP("-- releasing main URB\n");
1086
	US_DEBUGP("-- releasing main URB\n");
(-)linux-2.4.22-1.2130.nptl/drivers/usb/storage/usb.h (-2 / +1 lines)
Lines 118-124 Link Here
118
	struct us_data		*next;		 /* next device */
118
	struct us_data		*next;		 /* next device */
119
119
120
	/* the device we're working with */
120
	/* the device we're working with */
121
	struct semaphore	dev_semaphore;	 /* protect pusb_dev */
121
	struct semaphore	dev_semaphore;	 /* protect many things */
122
	struct usb_device	*pusb_dev;	 /* this usb_device */
122
	struct usb_device	*pusb_dev;	 /* this usb_device */
123
123
124
	unsigned int		flags;		 /* from filter initially */
124
	unsigned int		flags;		 /* from filter initially */
Lines 164-170 Link Here
164
	atomic_t		ip_wanted[1];	 /* is an IRQ expected?	 */
164
	atomic_t		ip_wanted[1];	 /* is an IRQ expected?	 */
165
165
166
	/* interrupt communications data */
166
	/* interrupt communications data */
167
	struct semaphore	irq_urb_sem;	 /* to protect irq_urb	 */
168
	struct urb		*irq_urb;	 /* for USB int requests */
167
	struct urb		*irq_urb;	 /* for USB int requests */
169
	unsigned char		irqbuf[2];	 /* buffer for USB IRQ	 */
168
	unsigned char		irqbuf[2];	 /* buffer for USB IRQ	 */
170
	unsigned char		irqdata[2];	 /* data from USB IRQ	 */
169
	unsigned char		irqdata[2];	 /* data from USB IRQ	 */

Return to bug 49600