[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] [PATCH] Add return value to usb_main( )



Alan please could you commit this patch.

Thanks

Commit message:

Make the usb_main( ) function to return an error value so we can show
an error message and stop the usb initialization if something goes
wrong.
Index: sys/usb/src.km/init.c
===================================================================
RCS file: /mint/freemint/sys/usb/src.km/init.c,v
retrieving revision 1.5
diff -u -8 -r1.5 init.c
--- sys/usb/src.km/init.c	1 Apr 2014 09:45:14 -0000	1.5
+++ sys/usb/src.km/init.c	4 Apr 2014 14:16:24 -0000
@@ -140,18 +140,17 @@
 #endif
 
 	bootmessage();
 
 	usb_stop();
 
 	setup_usb_module_api();
 
-	usb_main(0);
+	if ((err = usb_main(0)))
+		goto error;
 
 	usb_hub_init();
 
-#ifndef TOSONLY
 error:
-#endif
 	return err;
 }
 
Index: sys/usb/src.km/usb.c
===================================================================
RCS file: /mint/freemint/sys/usb/src.km/usb.c,v
retrieving revision 1.13
diff -u -8 -r1.13 usb.c
--- sys/usb/src.km/usb.c	1 Apr 2014 09:45:45 -0000	1.13
+++ sys/usb/src.km/usb.c	4 Apr 2014 14:16:25 -0000
@@ -46,29 +46,30 @@
 static long asynch_allowed;
 char usb_started; /* flag for the started/stopped USB status */
 
 static long 	usb_find_interface_driver	(struct usb_device *dev, unsigned ifnum);
 
 /***************************************************************************
  * Init USB Device
  */
-void
-usb_main(void *dummy)
+
+long usb_main(void *dummy)
 {
 	/* load driver for usb host controller */
 	ucd_load(1);
 
-	if (usb_init() >= 0)
+	if (!usb_init())
 	{	
 		/* load device driver modules */
 		udd_load(1);
-		return;
+		return 0;
 	}
 	DEBUG(("Failing with USB init"));
+	return -1;
 }
 
 long usb_init(void)
 {
 	struct ucdif *a;
 	struct usb_device *dev;
 	int i;
 
Index: sys/usb/src.km/usb.h
===================================================================
RCS file: /mint/freemint/sys/usb/src.km/usb.h,v
retrieving revision 1.9
diff -u -8 -r1.9 usb.h
--- sys/usb/src.km/usb.h	4 Apr 2014 11:38:59 -0000	1.9
+++ sys/usb/src.km/usb.h	4 Apr 2014 14:16:25 -0000
@@ -260,17 +260,17 @@
 //long usb_mem_init(void);
 //void usb_mem_stop(void);
 
 /* low level functions */
 long 		usb_lowlevel_init	(long handle, const struct pci_device_id *ent);
 long 		usb_lowlevel_stop	(void);
 
 /* routines */
-void		usb_main		(void *dummy);
+long		usb_main		(void *dummy);
 long 		usb_init		(void); /* initialize the USB Controller */
 long 		usb_stop		(void); /* stop the USB Controller */
 
 
 long		usb_set_protocol	(struct usb_device *dev, long ifnum, long protocol);
 long 		usb_set_idle		(struct usb_device *dev, long ifnum, long duration,
 						long report_id);
 long 		usb_control_msg		(struct usb_device *dev, unsigned long pipe,