[kernel] r6319 - people/waldi/linux-kbuild-2.6/src/mod
Bastian Blank
waldi at costa.debian.org
Tue Mar 28 16:03:50 UTC 2006
Author: waldi
Date: Tue Mar 28 16:03:41 2006
New Revision: 6319
Removed:
people/waldi/linux-kbuild-2.6/src/mod/module_devicetable_impl_2_6_16.tpp
Modified:
people/waldi/linux-kbuild-2.6/src/mod/module_devicetable_impl_2_6_16.cpp
people/waldi/linux-kbuild-2.6/src/mod/module_devicetable_impl_2_6_16.hpp
Log:
src/mod/module_devicetable_impl_2_6_16.cpp,
src/mod/module_devicetable_impl_2_6_16.hpp,
src/mod/module_devicetable_impl_2_6_16.tpp:
Only allow explicit instanziation of the implementation.
Modified: people/waldi/linux-kbuild-2.6/src/mod/module_devicetable_impl_2_6_16.cpp
==============================================================================
--- people/waldi/linux-kbuild-2.6/src/mod/module_devicetable_impl_2_6_16.cpp (original)
+++ people/waldi/linux-kbuild-2.6/src/mod/module_devicetable_impl_2_6_16.cpp Tue Mar 28 16:03:41 2006
@@ -22,6 +22,7 @@
#include <cstdio>
#include <stdint.h>
+#include <sstream>
using namespace linuxkernel::module_devicetable;
@@ -163,6 +164,144 @@
bInterfaceProtocol.write (out, match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL, true);
}
+#define _do_convert(name) name = Elf::convert<Elf_data, typeof (id.name)> () (id.name)
+
+template<typename Elf_class, typename Elf_data>
+table_entry_data<device_ccw, version_2_6_16, Elf_class, Elf_data>::table_entry_data (const device_id<device_ccw, Elf_class> &id) throw ()
+{
+ _do_convert (match_flags);
+ _do_convert (cu_type);
+ _do_convert (dev_type);
+ _do_convert (cu_model);
+ _do_convert (dev_model);
+}
+
+template<typename Elf_class, typename Elf_data>
+table_entry_data<device_ieee1394, version_2_6_16, Elf_class, Elf_data>::table_entry_data (const device_id<device_ieee1394, Elf_class> &id) throw ()
+{
+ _do_convert (match_flags);
+ _do_convert (vendor_id);
+ _do_convert (model_id);
+ _do_convert (specifier_id);
+ _do_convert (version);
+}
+
+template<typename Elf_class, typename Elf_data>
+table_entry_data<device_pci, version_2_6_16, Elf_class, Elf_data>::table_entry_data (const device_id<device_pci, Elf_class> &id) throw ()
+{
+ _do_convert (vendor);
+ _do_convert (device);
+ _do_convert (subvendor);
+ _do_convert (subdevice);
+ _do_convert (class_id);
+ _do_convert (class_mask);
+}
+
+template<typename Elf_class, typename Elf_data>
+table_entry_data<device_pnp, version_2_6_16, Elf_class, Elf_data>::table_entry_data (const device_id<device_pnp, Elf_class> &id) throw ()
+{
+ std::stringstream s;
+ s << 'd';
+ s << static_cast <const char *> (static_cast <const void *> (id.id));
+ str = s.str ();
+}
+
+template<typename Elf_class, typename Elf_data>
+table_entry_data<device_pnp_card, version_2_6_16, Elf_class, Elf_data>::table_entry_data (const device_id<device_pnp_card, Elf_class> &id) throw ()
+{
+ std::stringstream s;
+ s << 'c';
+ s << static_cast <const char *> (static_cast <const void *> (id.id));
+ for (int i = 0; i < PNP_MAX_DEVICES; i++)
+ {
+ if (! *id.devs[i].id)
+ break;
+ s << 'd';
+ s << static_cast <const char *> (static_cast <const void *> (id.devs[i].id));
+ }
+ str = s.str ();
+}
+
+template<typename Elf_class, typename Elf_data>
+table_entry_data<device_usb, version_2_6_16, Elf_class, Elf_data>::table_entry_data (const device_id<device_usb, Elf_class> &id, uint16_t _bcdDevice_initial, int _bcdDevice_initial_digits, unsigned char _range_lo, unsigned char _range_hi) throw ()
+{
+ _do_convert (match_flags);
+ _do_convert (idVendor);
+ _do_convert (idProduct);
+ _do_convert (bDeviceClass);
+ _do_convert (bDeviceSubClass);
+ _do_convert (bDeviceProtocol);
+ _do_convert (bInterfaceClass);
+ _do_convert (bInterfaceSubClass);
+ _do_convert (bInterfaceProtocol);
+ bcdDevice_initial = _bcdDevice_initial;
+ bcdDevice_initial_digits = _bcdDevice_initial_digits;
+ range_lo = _range_lo;
+ range_hi = _range_hi;
+}
+
+template<typename Elf_class, typename Elf_data>
+void table_entry_data<device_usb, version_2_6_16, Elf_class, Elf_data>::add
+(const device_id<device_usb, Elf_class> &id, std::vector<table_entry *> &table) throw ()
+{
+ uint16_t match_flags;
+ uint16_t idVendor;
+ uint16_t bcdDevice_lo = 0;
+ uint16_t bcdDevice_hi = ~0;
+ uint8_t bDeviceClass;
+ uint8_t bInterfaceClass;
+
+ _do_convert (match_flags);
+ _do_convert (idVendor);
+ if (match_flags & USB_DEVICE_ID_MATCH_DEV_LO)
+ _do_convert (bcdDevice_lo);
+ if (match_flags & USB_DEVICE_ID_MATCH_DEV_HI)
+ _do_convert (bcdDevice_hi);
+ _do_convert (bDeviceClass);
+ _do_convert (bInterfaceClass);
+
+ if (!(idVendor | bDeviceClass | bInterfaceClass))
+ return;
+
+ for (int ndigits = 3; bcdDevice_lo <= bcdDevice_hi; ndigits--)
+ {
+ unsigned char clo = bcdDevice_lo & 0xf;
+ unsigned char chi = bcdDevice_hi & 0xf;
+
+ if (chi > 9) /* it's bcd not hex */
+ chi = 9;
+
+ bcdDevice_lo >>= 4;
+ bcdDevice_hi >>= 4;
+
+ if (bcdDevice_lo == bcdDevice_hi || !ndigits)
+ {
+ table.push_back (new table_entry_data<device_usb, version_2_6_16, Elf_class, Elf_data> (id, bcdDevice_lo, ndigits, clo, chi));
+ return;
+ }
+
+ if (clo > 0)
+ table.push_back (new table_entry_data<device_usb, version_2_6_16, Elf_class, Elf_data> (id, bcdDevice_lo++, ndigits, clo, 9));
+
+ if (chi < 9)
+ table.push_back (new table_entry_data<device_usb, version_2_6_16, Elf_class, Elf_data> (id, bcdDevice_hi--, ndigits, 0, chi));
+ }
+}
+
+template<typename device, typename Elf_class, typename Elf_data>
+table_data<device, version_2_6_16, Elf_class, Elf_data>::table_data (const void *mem, size_t size) throw (std::runtime_error)
+{
+ if (size % sizeof (devin))
+ throw std::runtime_error ("Bad size");
+ size_t len = size / sizeof (devin);
+ // Remove the terminator.
+ len--;
+ const devin *e = static_cast <const devin *> (mem);
+ this->entries.reserve (len);
+ for (size_t i = 0; i < len; ++i)
+ table_entry_data<device, version_2_6_16, Elf_class, Elf_data>::add (e[i], this->entries);
+}
+
template class table_data<device_ccw, version_2_6_16, Elf::file_class_32, Elf::file_data_2LSB>;
template class table_data<device_ccw, version_2_6_16, Elf::file_class_32, Elf::file_data_2MSB>;
template class table_data<device_ccw, version_2_6_16, Elf::file_class_64, Elf::file_data_2LSB>;
Modified: people/waldi/linux-kbuild-2.6/src/mod/module_devicetable_impl_2_6_16.hpp
==============================================================================
--- people/waldi/linux-kbuild-2.6/src/mod/module_devicetable_impl_2_6_16.hpp (original)
+++ people/waldi/linux-kbuild-2.6/src/mod/module_devicetable_impl_2_6_16.hpp Tue Mar 28 16:03:41 2006
@@ -388,8 +388,4 @@
}
}
-#ifndef DISABLE_TEMPLATES
-#include "module_devicetable_impl_2_6_16.tpp"
-#endif
-
#endif
More information about the Kernel-svn-changes
mailing list