LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [2.4 patch] fix USB Gadget Config.in
@ 2003-11-18 17:28 Adrian Bunk
  2003-11-25 20:28 ` David Brownell
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Bunk @ 2003-11-18 17:28 UTC (permalink / raw)
  To: Marcelo Tosatti, David Brownell; +Cc: linux-kernel, greg, linux-usb-devel

I got the following link error in 2.4.23-rc1:

<--  snip  -->

...
ld -m elf_i386  -r -o built-in.o net2280.o g_zero.o g_ether.o
g_ether.o(.text+0x1bc0): In function `usb_gadget_get_string':
: multiple definition of `usb_gadget_get_string'
g_zero.o(.text+0x1100): first defined here
make[3]: *** [built-in.o] Error 1
make[3]: Leaving directory 
`/home/bunk/linux/kernel-2.4/linux-2.4.23-rc1-full/drivers/usb/gadget'

<--  snip  -->


.config contained the following:

<--  snip  -->

...
#
# Support for USB gadgets
#
CONFIG_USB_GADGET=y

#
# USB Peripheral Controller Drivers
#
# CONFIG_USB_GADGET_CONTROLLER is not set
CONFIG_USB_NET2280=y
CONFIG_USB_GADGET_CONTROLLER=y

#
# USB Gadget Drivers
#
CONFIG_USB_ZERO=y
CONFIG_USB_ZERO_NET2280=y
CONFIG_USB_ETH=y
CONFIG_USB_ETH_NET2280=y
...

<--  snip  -->


The patch below fixes this issue.

The main change is to remove the problematic

  define_tristate CONFIG_USB_GADGET_CONTROLLER n

and solving it different, and allowing a statically CONFIG_USB_ETH only 
when CONFIG_USB_ZERO isn't statically.

cu
Adrian


--- linux-2.4.23-rc1-full/drivers/usb/gadget/Config.in.old	2003-11-18 02:39:48.000000000 +0100
+++ linux-2.4.23-rc1-full/drivers/usb/gadget/Config.in	2003-11-18 12:06:12.000000000 +0100
@@ -5,8 +5,7 @@
 # Long term, this likely doesn't all belong in one directory
 # Plan to split it up eventually.
 #
-# CAREFUL!  Some versions of "xconfig" don't execute this correctly.
-#
+
 mainmenu_option next_comment
 comment 'Support for USB gadgets'
 
@@ -19,16 +18,15 @@
   #
   comment 'USB Peripheral Controller Drivers'
   
-  # assume all the dependencies may be undefined ("== true", yeech)
-  define_tristate CONFIG_USB_GADGET_CONTROLLER n
-  if [ "$CONFIG_PCI" = "y" ] ; then
-    tristate '  NetChip 2280 support' CONFIG_USB_NET2280
+  dep_tristate '  NetChip 2280 support' CONFIG_USB_NET2280 $CONFIG_PCI
+
+  if [ "$CONFIG_USB_NET2280" = "y" -o "$CONFIG_USB_NET2280" = "m" ]; then
     define_tristate CONFIG_USB_GADGET_CONTROLLER $CONFIG_USB_NET2280
+  else
+    define_tristate CONFIG_USB_GADGET_CONTROLLER n
   fi
 
-  # pxa2xx_udc, goku_udc, and others also work on 2.4 ...
-
-  if [ "$CONFIG_USB_GADGET_CONTROLLER" = "y" -o "$CONFIG_USB_GADGET_CONTROLLER" = "m" ] ; then
+  if [ "$CONFIG_USB_GADGET_CONTROLLER" != "n" ]; then
 
   #
   # no reason not to enable more than one gadget driver module, but
@@ -43,9 +41,20 @@
   #
   # (b) specific hardware features like iso endpoints may be required
   #
+  # at most one gadget driver is allowed to be compiled statically
+  # into the kernel
+  #
+
   comment 'USB Gadget Drivers'
 
-  dep_tristate '  Gadget Zero (DEVELOPMENT)' CONFIG_USB_ZERO $CONFIG_USB_GADGET_CONTROLLER
+    dep_tristate '  Gadget Zero (DEVELOPMENT)' CONFIG_USB_ZERO $CONFIG_USB_GADGET_CONTROLLER
+
+    if [ "$CONFIG_USB_ZERO" != "y" ]; then 
+      dep_tristate '  Ethernet Gadget (EXPERIMENTAL)' CONFIG_USB_ETH $CONFIG_USB_GADGET_CONTROLLER $CONFIG_NET $CONFIG_EXPERIMENTAL
+    else
+      dep_tristate '  Ethernet Gadget (EXPERIMENTAL)' CONFIG_USB_ETH $CONFIG_NET $CONFIG_EXPERIMENTAL m
+    fi
+
   if [ "$CONFIG_USB_ZERO" = "y" -o "$CONFIG_USB_ZERO" = "m" ]; then
       if [ "$CONFIG_USB_NET2280" = "y" -o "$CONFIG_USB_NET2280" = "m" ]; then
   	define_bool CONFIG_USB_ZERO_NET2280 y
@@ -56,8 +65,7 @@
       fi fi fi
       # ...
   fi
-  
-  dep_tristate '  Ethernet Gadget (EXPERIMENTAL)' CONFIG_USB_ETH $CONFIG_USB_GADGET_CONTROLLER $CONFIG_NET
+
   if [ "$CONFIG_USB_ETH" = "y" -o "$CONFIG_USB_ETH" = "m" ]; then
       if [ "$CONFIG_USB_NET2280" = "y" -o "$CONFIG_USB_NET2280" = "m" ]; then
   	define_bool CONFIG_USB_ETH_NET2280 y

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [2.4 patch] fix USB Gadget Config.in
  2003-11-18 17:28 [2.4 patch] fix USB Gadget Config.in Adrian Bunk
@ 2003-11-25 20:28 ` David Brownell
  0 siblings, 0 replies; 2+ messages in thread
From: David Brownell @ 2003-11-25 20:28 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: Marcelo Tosatti, linux-kernel, greg, linux-usb-devel

[-- Attachment #1: Type: text/plain, Size: 1388 bytes --]

Adrian Bunk wrote:

> .config contained the following:
> 
> ... (illegal but not disallowed) ...

> The main change is to remove the problematic
> 
>   define_tristate CONFIG_USB_GADGET_CONTROLLER n

That came from Al Borchers when he provided the "serial" gadget
driver. It helped clean up the preceding Config.in.  I don't know
precisely how he landed with that solution, likely something to
do with "undefined" dependencies interpreted (wrongly) as "true".

In what way was that problematic for you?

Agreed that some of the controller drivers might fit better as
"dep_tristate": net2280 and goku_udc depending on PCI; pxa2xx and
superh UDCs depending on those arch symbols.

On the other hand, see the updated Config.in below (more drivers
than 2.4.23-rc5):  it works with "menuconfig" and "config", on
x86 and ARM, and correctly prevents configuring both PCI-based
controllers; but I'd not say "better" because it breaks rudely
on "xconfig" (all those settings disabled).


> and solving it different, and allowing a statically CONFIG_USB_ETH only 
> when CONFIG_USB_ZERO isn't statically.

Seems incorrect; if ZERO is statically linked, ETH must not be linked
either statically or dynamically.  (And so on for the other drivers.)

There may be a nice solution to these problems within the Config.in
constraints, but I don't think we've found one yet.

- Dave



> cu
> Adrian
> 
> 

[-- Attachment #2: Config.in --]
[-- Type: text/plain, Size: 6025 bytes --]

#
# USB device-side configuration
# for 2.4 kbuild, drivers/usb/gadget/Config.in
#
# Long term, this likely doesn't all belong in one directory
# Plan to split it up eventually.
#
# CAREFUL!  Some versions of "xconfig" don't execute this correctly.
#
mainmenu_option next_comment
comment 'Support for USB gadgets'

bool 'Support for USB Gadgets' CONFIG_USB_GADGET
if [ "$CONFIG_USB_GADGET" = "y" ]; then
  
  #
  # really want _exactly one_ device controller driver at a time,
  # since they control compile options for gadget drivers.
  #
  comment 'USB Peripheral Controller Drivers'
  
  # assume all the dependencies may be undefined ("== true", yeech)
  define_tristate CONFIG_USB_GADGET_CONTROLLER n
  if [ "$CONFIG_PCI" = "" ] ; then
     define_bool CONFIG_PCI n
  fi
  if [ "$CONFIG_ARCH_PXA" = "" ] ; then
     define_bool CONFIG_ARCH_PXA n
  fi
  if [ "$CONFIG_ARCH_SUPERH" = "" ] ; then
     define_bool CONFIG_ARCH_SUPERH n
  fi
  
  if [ "$CONFIG_USB_GADGET_CONTROLLER" = "n" ] ; then
    dep_tristate '  NetChip 2280 support' CONFIG_USB_NET2280 $CONFIG_PCI
    define_tristate CONFIG_USB_GADGET_CONTROLLER $CONFIG_USB_NET2280
  fi
  if [ "$CONFIG_USB_GADGET_CONTROLLER" = "n" ] ; then
    dep_tristate '  PXA 2xx UDC support' CONFIG_USB_PXA2XX $CONFIG_ARCH_PXA
    define_tristate CONFIG_USB_GADGET_CONTROLLER $CONFIG_USB_PXA2XX
  fi
  if [ "$CONFIG_USB_GADGET_CONTROLLER" = "n" ] ; then
    dep_tristate '  Toshiba TC86C001 (Goku-S) support' CONFIG_USB_GOKU $CONFIG_PCI
    define_tristate CONFIG_USB_GADGET_CONTROLLER $CONFIG_USB_GOKU
  fi
  if [ "$CONFIG_USB_GADGET_CONTROLLER" = "n" ] ; then
    dep_tristate '  Renesas SH7705/7727 UDC support' CONFIG_USB_SUPERH $CONFIG_SUPERH
    define_tristate CONFIG_USB_GADGET_CONTROLLER $CONFIG_USB_SUPERH
  fi

  if [ "$CONFIG_USB_GADGET_CONTROLLER" = "y" -o "$CONFIG_USB_GADGET_CONTROLLER" = "m" ] ; then

  #
  # no reason not to enable more than one gadget driver module, but
  # for static linking that would make no sense since the usb model
  # has exactly one of these upstream connections and only one
  # lowest-level driver can control it.
  #
  # gadget drivers are compiled to work on specific hardware, since
  #
  # (a) gadget driver need hardware-specific configuration, like what
  #     endpoint names and numbers to use, maxpacket sizes, etc
  #
  # (b) specific hardware features like iso endpoints may be required
  #
  comment 'USB Gadget Drivers'

  dep_tristate '  Gadget Zero (DEVELOPMENT)' CONFIG_USB_ZERO $CONFIG_USB_GADGET_CONTROLLER
  if [ "$CONFIG_USB_ZERO" = "y" -o "$CONFIG_USB_ZERO" = "m" ]; then
      if [ "$CONFIG_USB_NET2280" = "y" -o "$CONFIG_USB_NET2280" = "m" ]; then
  	define_bool CONFIG_USB_ZERO_NET2280 y
      else if [ "$CONFIG_USB_PXA2XX" = "y" -o "$CONFIG_USB_PXA2XX" = "m" ]; then
  	define_bool CONFIG_USB_ZERO_PXA2XX y
      else if [ "$CONFIG_USB_GOKU" = "y" -o "$CONFIG_USB_GOKU" = "m" ]; then
  	define_bool CONFIG_USB_ZERO_GOKU y
      else if [ "$CONFIG_USB_SUPERH" = "y" -o "$CONFIG_USB_SUPERH" = "m" ]; then
  	define_bool CONFIG_USB_ZERO_SUPERH y
      fi fi fi fi
      # ...
  fi
  
  dep_tristate '  Ethernet Gadget (EXPERIMENTAL)' CONFIG_USB_ETH $CONFIG_USB_GADGET_CONTROLLER $CONFIG_NET
  if [ "$CONFIG_USB_ETH" = "y" -o "$CONFIG_USB_ETH" = "m" ]; then
      if [ "$CONFIG_USB_NET2280" = "y" -o "$CONFIG_USB_NET2280" = "m" ]; then
  	define_bool CONFIG_USB_ETH_NET2280 y
      else if [ "$CONFIG_USB_PXA2XX" = "y" -o "$CONFIG_USB_PXA2XX" = "m" ]; then
  	define_bool CONFIG_USB_ETH_PXA2XX y
      else if [ "$CONFIG_USB_GOKU" = "y" -o "$CONFIG_USB_GOKU" = "m" ]; then
  	define_bool CONFIG_USB_ETH_GOKU y
      else if [ "$CONFIG_USB_SUPERH" = "y" -o "$CONFIG_USB_SUPERH" = "m" ]; then
  	define_bool CONFIG_USB_ETH_SUPERH y
      fi fi fi fi
      # ...
  fi
  
  dep_tristate '  Gadget Filesystem API (EXPERIMENTAL)' CONFIG_USB_GADGETFS $CONFIG_USB_GADGET_CONTROLLER
  if [ "$CONFIG_USB_GADGETFS" = "y" -o "$CONFIG_USB_GADGETFS" = "m" ]; then
      if [ "$CONFIG_USB_NET2280" = "y" -o "$CONFIG_USB_NET2280" = "m" ]; then
  	define_bool CONFIG_USB_GADGETFS_NET2280 y
      else if [ "$CONFIG_USB_PXA2XX" = "y" -o "$CONFIG_USB_PXA2XX" = "m" ]; then
  	define_bool CONFIG_USB_GADGETFS_PXA2XX y
      else if [ "$CONFIG_USB_GOKU" = "y" -o "$CONFIG_USB_GOKU" = "m" ]; then
  	define_bool CONFIG_USB_GADGETFS_GOKU y
      else if [ "$CONFIG_USB_SUPERH" = "y" -o "$CONFIG_USB_SUPERH" = "m" ]; then
  	define_bool CONFIG_USB_GADGETFS_SUPERH y
      fi fi fi fi
      # ...
  fi
  
  dep_tristate '  File-backed Storage Gadget (DEVELOPMENT)' CONFIG_USB_FILE_STORAGE $CONFIG_USB_GADGET_CONTROLLER
  if [ "$CONFIG_USB_FILE_STORAGE" = "y" -o "$CONFIG_USB_FILE_STORAGE" = "m" ]; then
      if [ "$CONFIG_USB_NET2280" = "y" -o "$CONFIG_USB_NET2280" = "m" ]; then
  	define_bool CONFIG_USB_FILE_STORAGE_NET2280 y
      else if [ "$CONFIG_USB_PXA2XX" = "y" -o "$CONFIG_USB_PXA2XX" = "m" ]; then
  	define_bool CONFIG_USB_FILE_STORAGE_PXA2XX y
      else if [ "$CONFIG_USB_GOKU" = "y" -o "$CONFIG_USB_GOKU" = "m" ]; then
  	define_bool CONFIG_USB_FILE_STORAGE_GOKU y
      else if [ "$CONFIG_USB_SUPERH" = "y" -o "$CONFIG_USB_SUPERH" = "m" ]; then
  	define_bool CONFIG_USB_FILE_STORAGE_SUPERH y
      fi fi fi fi
      # ...
  fi
  
  dep_tristate '  Serial Gadget (EXPERIMENTAL)' CONFIG_USB_G_SERIAL $CONFIG_USB_GADGET_CONTROLLER
  if [ "$CONFIG_USB_G_SERIAL" = "y" -o "$CONFIG_USB_G_SERIAL" = "m" ]; then
      if [ "$CONFIG_USB_NET2280" = "y" -o "$CONFIG_USB_NET2280" = "m" ]; then
  	define_bool CONFIG_USB_G_SERIAL_NET2280 y
      else if [ "$CONFIG_USB_PXA2XX" = "y" -o "$CONFIG_USB_PXA2XX" = "m" ]; then
  	define_bool CONFIG_USB_G_SERIAL_PXA2XX y
      else if [ "$CONFIG_USB_GOKU" = "y" -o "$CONFIG_USB_GOKU" = "m" ]; then
  	define_bool CONFIG_USB_G_SERIAL_GOKU y
      else if [ "$CONFIG_USB_SUPERH" = "y" -o "$CONFIG_USB_SUPERH" = "m" ]; then
  	define_bool CONFIG_USB_G_SERIAL_SUPERH y
      fi fi fi fi
      # ...
  fi
  
  # ... or other gadget drivers:  printer class, hid, etc ...

  fi
fi
endmenu

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-11-25 20:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-18 17:28 [2.4 patch] fix USB Gadget Config.in Adrian Bunk
2003-11-25 20:28 ` David Brownell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).