This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
fix host-side build problem
- From: Bart Veer <bartv at ecoscentric dot com>
- To: ecos-patches at ecos dot sourceware dot org
- Date: Sun, 26 Jun 2005 22:20:34 +0100 (BST)
- Subject: fix host-side build problem
There has been a change to one of the Linux header files,
<linux/usbdevice_fs.h>, which prevents the io/usb/slave host-side test
support from building. Unfortunately some distributions including FC3
still use the old header while others including Debian use the new
version. This patch adds an autoconf test to detect the version of the
header, and usbhost.c adapts accordingly.
Bart
Index: io/usb/slave/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/usb/slave/current/ChangeLog,v
retrieving revision 1.12
diff -u -r1.12 ChangeLog
--- io/usb/slave/current/ChangeLog 27 Mar 2003 23:17:24 -0000 1.12
+++ io/usb/slave/current/ChangeLog 26 Jun 2005 20:36:22 -0000
@@ -1,3 +1,13 @@
+2005-06-26 Bart Veer <bartv@ecoscentric.com>
+
+ * host/usbhost.c, host/configure.in: cope with incompatible
+ changes to the system header <linux/usbdevice_fs.h>
+
+ * host/acconfig.h: new file to support the above
+
+ * host/Makefile.in, host/aclocal.m4, host/config.h.in,
+ host/configure, host/stamp-h.in: regenerate
+
2003-03-27 Bart Veer <bartv@ecoscentric.com>
* host/Makefile.am, host/Makefile.in:
Index: io/usb/slave/current/host/configure.in
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/usb/slave/current/host/configure.in,v
retrieving revision 1.3
diff -u -r1.3 configure.in
--- io/usb/slave/current/host/configure.in 23 Sep 2002 20:10:44 -0000 1.3
+++ io/usb/slave/current/host/configure.in 26 Jun 2005 20:36:37 -0000
@@ -9,6 +9,7 @@
dnl ####ECOSGPLCOPYRIGHTBEGIN####
dnl -------------------------------------------
dnl This file is part of eCos, the Embedded Configurable Operating System.
+dnl Copyright (C) 2005 eCosCentric Ltd
dnl Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
dnl
dnl eCos is free software; you can redistribute it and/or modify it under
@@ -98,6 +99,14 @@
AC_CHECK_HEADERS("linux/usb.h" "linux/usbdevice_fs.h",,SUPPORTED="no")
if test "${SUPPORTED}" = "no" ; then
AC_MSG_WARN([Required Linux kernel functionality does not appear to be available])
+ else
+ AC_TRY_COMPILE([
+ #include <linux/usbdevice_fs.h>
+ ], [
+ static struct usbdevfs_ctrltransfer xx = { .bRequestType = 0 };
+ ],
+ AC_DEFINE(CYGBLD_USE_NEW_FIELD_NAMES)
+ )
fi
fi
fi
@@ -108,8 +117,5 @@
AM_CONDITIONAL(SUPPORTED, test "${SUPPORTED}" = "yes")
-dnl There is no real need for a config.h file at this time, since the code
-dnl is specific to Linux. This may change in future.
-dnl AM_CONFIG_HEADER(config.h:config.h.in)
-
+AM_CONFIG_HEADER(config.h:config.h.in)
AC_OUTPUT(Makefile:Makefile.in)
Index: io/usb/slave/current/host/usbhost.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/usb/slave/current/host/usbhost.c,v
retrieving revision 1.2
diff -u -r1.2 usbhost.c
--- io/usb/slave/current/host/usbhost.c 21 Sep 2002 22:06:59 -0000 1.2
+++ io/usb/slave/current/host/usbhost.c 26 Jun 2005 20:36:46 -0000
@@ -10,6 +10,7 @@
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2005 eCosCentric Ltd.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
@@ -86,9 +87,23 @@
#include <linux/usb.h>
#include <linux/usbdevice_fs.h>
#include "../tests/protocol.h"
+#include "config.h"
/*}}}*/
+/*{{{ Backwards compatibility */
+
+// The header file <linux/usbdevice_fs.h> has changed in an incompatible
+// way. This is detected by autoconf
+#ifndef CYGBLD_USE_NEW_FIELD_NAMES
+# define bRequestType requesttype
+# define bRequest request
+# define wValue value
+# define wIndex index
+# define wLength length
+#endif
+
+/*}}}*/
/*{{{ Statics */
// ----------------------------------------------------------------------------
@@ -308,22 +323,22 @@
int this_len = length - 1;
int ioctl_result;
- transfer.requesttype = USB_TYPE_CLASS | USB_RECIP_DEVICE;
+ transfer.bRequestType = USB_TYPE_CLASS | USB_RECIP_DEVICE;
if (this_len > 4) {
this_len = 4;
}
switch (this_len) {
- case 1: transfer.request = USBTEST_CONTROL_DATA1; break;
- case 2: transfer.request = USBTEST_CONTROL_DATA2; break;
- case 3: transfer.request = USBTEST_CONTROL_DATA3; break;
- case 4: transfer.request = USBTEST_CONTROL_DATA4; break;
+ case 1: transfer.bRequest = USBTEST_CONTROL_DATA1; break;
+ case 2: transfer.bRequest = USBTEST_CONTROL_DATA2; break;
+ case 3: transfer.bRequest = USBTEST_CONTROL_DATA3; break;
+ case 4: transfer.bRequest = USBTEST_CONTROL_DATA4; break;
default:
fprintf(stderr, "usbhost: internal error, confusion about transfer length.\n");
exit(EXIT_FAILURE);
}
- transfer.value = (buf[i] << 8) | buf[i+1]; // Possible read beyond end of buffer,
- transfer.index = (buf[i+2] << 8) | buf[i+3]; // but not worth worrying about.
- transfer.length = 0;
+ transfer.wValue = (buf[i] << 8) | buf[i+1]; // Possible read beyond end of buffer,
+ transfer.wIndex = (buf[i+2] << 8) | buf[i+3]; // but not worth worrying about.
+ transfer.wLength = 0;
transfer.timeout = 10 * 1000; // ten seconds, the target should always accept data faster than this.
transfer.data = NULL;
@@ -339,11 +354,11 @@
length = 0;
}
#endif
- transfer.requesttype = request_type;
- transfer.request = request;
- transfer.value = value;
- transfer.index = index;
- transfer.length = length;
+ transfer.bRequestType = request_type;
+ transfer.bRequest = request;
+ transfer.wValue = value;
+ transfer.wIndex = index;
+ transfer.wLength = length;
transfer.timeout = 10000;
transfer.data = data;
Index: io/usb/slave/current/host/acconfig.h
===================================================================
RCS file: io/usb/slave/current/host/acconfig.h
diff -N io/usb/slave/current/host/acconfig.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ io/usb/slave/current/host/acconfig.h 26 Jun 2005 20:36:24 -0000
@@ -0,0 +1,51 @@
+#ifndef CYGONCE_USBHOST_CONFIG_H
+# define CYGONCE_USBHOST_CONFIG_H
+
+//======================================================================
+//
+// acconfig.h
+//
+// Configuration header for usbhost
+//
+//======================================================================
+//####COPYRIGHTBEGIN####
+//
+// ----------------------------------------------------------------------------
+// Copyright (C) 2005 eCosCentric Ltd
+//
+// This file is part of the eCos host tools.
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// ----------------------------------------------------------------------------
+//
+//####COPYRIGHTEND####
+//======================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): bartv
+// Contact(s): bartv
+// Date: 2005/06/26
+// Version: 0.01
+//
+//####DESCRIPTIONEND####
+//======================================================================
+
+#undef PACKAGE
+#undef VERSION
+#undef CYGBLD_USE_NEW_FIELD_NAMES
+
+#endif // CYGONCE_USBHOST_CONFIG_H
+// End of config.h