On Tue, Apr 02, 2002 at 10:35:29AM +1000, Brad Hards wrote:
> On Tue, 2 Apr 2002 10:19, Greg KH wrote:
> >
> > In looking at the code, I realized that the following patch could reduce
> > the use of the #ifdefs in the code.  In the end all that happens is a
> > change to hid.h, the hid-core.c patch is just backing out Brad's
> > changes.  Is it ok for me to make this change?
> I personally find this sort of thing unneccessarily subtle.
> The #ifdef is perfectly clear ("OK, the behaviour depends on a couple of 
> CONFIG options..."), isn't really that ugly, and there isn't much difference 
> between having the code removed by the pre-processor or the optimiser.

But it is the "preferred way to do things" according to the unwritten
coding style rules :)

> However if you are going to do it at all, I think you should do it for the 
> HIDDEV and HIDINPUT cases equally.

Ok, here's a patch that does it.  Turns out, someone already fixed up
the header file to do this correctly, so all we have to do is remove the
#ifdef in the code.  I did leave 2 of them in, just to keep the size of
the code smaller, as I don't know if the compiler would have optimized
the whole chunk out.

Does this look ok?

thanks,

greg k-h


diff -Nru a/drivers/usb/hid-core.c b/drivers/usb/hid-core.c
--- a/drivers/usb/hid-core.c    Mon Apr  1 16:43:23 2002
+++ b/drivers/usb/hid-core.c    Mon Apr  1 16:43:23 2002
@@ -46,9 +46,7 @@
 #include <linux/usb.h>
 
 #include "hid.h"
-#ifdef CONFIG_USB_HIDDEV
 #include <linux/hiddev.h>
-#endif
 
 /*
  * Version Information
@@ -1441,10 +1439,8 @@
 
        if (!hidinput_connect(hid))
                hid->claimed |= HID_CLAIMED_INPUT;
-#ifdef CONFIG_USB_HIDDEV
        if (!hiddev_connect(hid))
                hid->claimed |= HID_CLAIMED_HIDDEV;
-#endif
 
        if (!hid->claimed) {
                hid_free_device(hid);
@@ -1513,9 +1509,7 @@
 
 static int __init hid_init(void)
 {
-#ifdef CONFIG_USB_HIDDEV
        hiddev_init();
-#endif
        usb_register(&hid_driver);
        info(DRIVER_VERSION ":" DRIVER_DESC);
 
@@ -1524,9 +1518,7 @@
 
 static void __exit hid_exit(void)
 {
-#ifdef CONFIG_USB_HIDDEV
        hiddev_exit();
-#endif
        usb_deregister(&hid_driver);
 }
 

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to