speedtch usbatm.h,1.11,1.12

Roman Kagan rkagan at mail.ru
Thu Apr 14 04:27:32 EDT 2005

On Thu, Apr 07, 2005 at 10:52:47PM +0100, Duncan Sands wrote:
> Modified Files:
> 	usbatm.h 
> Log Message:
> Add various convenience output routines (usb_err, atm_err, ...).  Since the ATM layer hasn't
> been ported to the new device model yet, atm_err and friends are currently the same as usb_err
> etc.  The idea is that we want to use dev_err etc, but we have two devices: a USB device and
> an ATM device.  Thus the two sets of macros.  I think we should use atm_xxx ones whenever the
> ATM device is around, and otherwise use the usb_xxx ones.

This makes my kernel OOPS on NULL dereference when I disconnect the
modem before killing br2684ctl.  The problem is that, if the usb device
has been disconnected while the atm device is held by a reference from
userspace, then, when it's released, usbatm_atm_close,
usbatm_atm_dev_close, usbatm_cancel_send are called with an invalidated
usb device.

The appended patch changes atm_xxx macros to tag the messages with the
atm device number instead.  (I've been tempted to use atm_dev.type too,
but the atm layer uses there directly what we pass to atmdev_register(),
rather than making a private copy, and we give it the subriver's
driver_name, which can get destroyed before atm_dev is released).


Index: usbatm.h
RCS file: /home/cvs/usbatm/usbatm.h,v
retrieving revision 1.12
diff -u -p -r1.12 usbatm.h
--- usbatm.h	7 Apr 2005 21:52:43 -0000	1.12
+++ usbatm.h	14 Apr 2005 07:55:30 -0000
@@ -59,14 +59,24 @@
 #define usb_dbg(instance, format, arg...)	\
 	dev_dbg(&(instance)->usb_intf->dev , format , ## arg)
+/* FIXME: move to dev_* once ATM is driver model aware */
+#define atm_printk(level, instance, format, arg...)  \
+        printk(level "ATM dev %d: " format , (instance)->atm_dev->number, ## arg)
 #define atm_err(instance, format, arg...)	\
-	usb_err(instance, format, ## arg)
+	atm_printk(KERN_ERR, instance, format, ## arg)
 #define atm_info(instance, format, arg...)	\
-	usb_info(instance, format, ## arg)
+	atm_printk(KERN_INFO, instance, format, ## arg)
 #define atm_warn(instance, format, arg...)	\
-	usb_warn(instance, format, ## arg)
+	atm_printk(KERN_WARNING, instance, format, ## arg)
+#ifdef DEBUG
+#define atm_dbg(instance, format, arg...)	\
+	atm_printk(KERN_DEBUG, instance, format, ## arg)
 #define atm_dbg(instance, format, arg...)	\
-	usb_dbg(instance, format, ## arg)
+	do { (void) instance; } while (0)
 /* mini driver */

More information about the Usbatm mailing list