Re: [RFC][PATCH] avoid multiple inclusions of file in gadget driver

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

 



Hi Viral,

On Tuesday 16 March 2010 11:05:15 Viral Mehta wrote:
> Avoid multiple inclusions.
> Guard composite.c, config.c, epautoconf.c,
> and ubstring.c from being included for multiple times.
> 
> For e.g.,
> g_audio driver already includes these files

More specifically, audio.c does.

> g_video gadget driver which may be used for Video
> surveillance will also include them
> 
> Now, if g_webcam is a simple union of g_audio and g_video,
> it will get a compilation error for redefinition of symbols without this
> patch.

Your gadget driver should include one or more functions. It must not include 
other gadget drivers. The proper way to solve this is to use u_audio.c and 
f_audio.c in your gadget driver, not audio.c.

> 
> Signed-off-by: Viral Mehta <viral.mehta@xxxxxxxxxxxxxxx>
> ---
> 
> diff -Nurp linux-2.6.34-rc1.org/drivers/usb/gadget/composite.c
> linux-2.6.34-rc1/drivers/usb/gadget/composite.c ---
> linux-2.6.34-rc1.org/drivers/usb/gadget/composite.c 2010-03-16
> 14:04:31.000000000 -0400 +++
> linux-2.6.34-rc1/drivers/usb/gadget/composite.c     2010-03-16
> 14:07:09.000000000 -0400 @@ -18,6 +18,9 @@
>   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 
> USA */
> 
> +#ifndef __COMPOSITE__C
> +#define __COMPOSITE__C
> +
>  /* #define VERBOSE_DEBUG */
> 
>  #include <linux/kallsyms.h>
> @@ -1148,3 +1151,5 @@ void /* __exit */ usb_composite_unregist
>                 return;
>         usb_gadget_unregister_driver(&composite_driver);
>  }
> +
> +#endif /* __COMPOSITE__C */
> diff -Nurp linux-2.6.34-rc1.org/drivers/usb/gadget/config.c
> linux-2.6.34-rc1/drivers/usb/gadget/config.c ---
> linux-2.6.34-rc1.org/drivers/usb/gadget/config.c    2010-03-16
> 14:04:31.000000000 -0400 +++ linux-2.6.34-rc1/drivers/usb/gadget/config.c 
>       2010-03-16 14:07:09.000000000 -0400 @@ -18,6 +18,9 @@
>   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 
> USA */
> 
> +#ifndef __CONFIG_C
> +#define __CONFIG_C
> +
>  #include <linux/errno.h>
>  #include <linux/kernel.h>
>  #include <linux/list.h>
> @@ -189,3 +192,5 @@ usb_find_endpoint(
>         }
>         return NULL;
>  }
> +
> +#endif /* __CONFIG_C */
> diff -Nurp linux-2.6.34-rc1.org/drivers/usb/gadget/epautoconf.c
> linux-2.6.34-rc1/drivers/usb/gadget/epautoconf.c ---
> linux-2.6.34-rc1.org/drivers/usb/gadget/epautoconf.c        2010-03-16
> 14:04:31.000000000 -0400 +++
> linux-2.6.34-rc1/drivers/usb/gadget/epautoconf.c    2010-03-16
> 14:07:09.000000000 -0400 @@ -19,6 +19,9 @@
>   *
>   */
> 
> +#ifndef __EPAUTOCONF_C
> +#define __EPAUTOCONF_C
> +
>  #include <linux/kernel.h>
>  #include <linux/init.h>
>  #include <linux/types.h>
> @@ -317,3 +320,4 @@ void __init usb_ep_autoconfig_reset (str
>         epnum = 0;
>  }
> 
> +#endif /* __EPAUTOCONF_C */
> diff -Nurp linux-2.6.34-rc1.org/drivers/usb/gadget/usbstring.c
> linux-2.6.34-rc1/drivers/usb/gadget/usbstring.c ---
> linux-2.6.34-rc1.org/drivers/usb/gadget/usbstring.c 2010-03-16
> 14:04:31.000000000 -0400 +++
> linux-2.6.34-rc1/drivers/usb/gadget/usbstring.c     2010-03-16
> 14:07:09.000000000 -0400 @@ -7,6 +7,9 @@
>   * (at your option) any later version.
>   */
> 
> +#ifndef __USBSTRING_C
> +#define __USBSTRING_C
> +
>  #include <linux/errno.h>
>  #include <linux/kernel.h>
>  #include <linux/list.h>
> @@ -134,3 +137,4 @@ usb_gadget_get_string (struct usb_gadget
>         return buf [0];
>  }
> 
> +#endif /* __USBSTRING_C */

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux