Discussion:
usb core changes
Richard Kennedy
2006-04-05 08:56:39 UTC
Permalink
For 2.6.16, looking at usb_skeleton.c & core/usb.c it seem that we now
need to reference count the use of the usb_device.

This patch adds this to the hfa384x_usb.c create & destroy methods.

Without this patch if I unload and then reload the module the network
never comes back up, but I haven't yet tracked down why.
With the patch unload/load work correctly.

Richard
Chris Rankin
2006-04-05 11:42:49 UTC
Permalink
Post by Richard Kennedy
For 2.6.16, looking at usb_skeleton.c & core/usb.c it seem that we now
need to reference count the use of the usb_device.
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16))
+ // ref count the usb device
+ hw->usb = usb_get_dev(usb);
+#else
hw->usb = usb;
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16))
+ // release ref count on usb device
+ usb_put_dev(hw->usb);
+#endif
This kind of preprocessor logic is frowned upon by the Linux kernel developers. It would be better
to create some inline functions in wlan_compat.h instead:

/* Completely untested, but you get the idea... */

#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16))
inline struct usb_device*
usb_get_dev(struct usb_device *usb)
{
return usb;
}

inline void
usb_put_dev(struct usb_device *usb) { (void)usb; }
#endif

And then just pretend that we're coding for 2.6.16 by calling usb_get_dev() and usb_put_dev() in
the driver.

Cheers,
Chris






___________________________________________________________
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
Loading...