4 * @brief Meilhaus device base class.
5 * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
7 * @author Krzysztof Gantzke (k.gantzke@meilhaus.de)
11 * Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
13 * This file is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include "meinternal.h"
30 #include "medefines.h"
40 static int me_device_io_irq_start(struct me_device *device,
45 int irq_edge, int irq_arg, int flags)
47 int err = ME_ERRNO_SUCCESS;
50 PDEBUG("executed.\n");
52 // Check subdevice index.
53 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
54 PERROR("Invalid subdevice.\n");
55 return ME_ERRNO_INVALID_SUBDEVICE;
58 err = me_dlock_enter(&device->dlock, filep);
61 PERROR("Cannot enter device.\n");
64 // Get subdevice instance.
65 s = me_slist_get_subdevice(&device->slist, subdevice);
68 // Call subdevice method.
69 err = s->me_subdevice_io_irq_start(s,
73 irq_edge, irq_arg, flags);
75 // Something really bad happened.
76 PERROR("Cannot get subdevice instance.\n");
77 err = ME_ERRNO_INTERNAL;
81 me_dlock_exit(&device->dlock, filep);
86 static int me_device_io_irq_wait(struct me_device *device,
91 int *value, int time_out, int flags)
93 int err = ME_ERRNO_SUCCESS;
96 PDEBUG("executed.\n");
98 // Check subdevice index.
99 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
100 PERROR("Invalid subdevice.\n");
101 return ME_ERRNO_INVALID_SUBDEVICE;
104 err = me_dlock_enter(&device->dlock, filep);
107 PERROR("Cannot enter device.\n");
110 // Get subdevice instance.
111 s = me_slist_get_subdevice(&device->slist, subdevice);
114 // Call subdevice method.
115 err = s->me_subdevice_io_irq_wait(s,
119 value, time_out, flags);
121 // Something really bad happened.
122 PERROR("Cannot get subdevice instance.\n");
123 err = ME_ERRNO_INTERNAL;
127 me_dlock_exit(&device->dlock, filep);
132 static int me_device_io_irq_stop(struct me_device *device,
134 int subdevice, int channel, int flags)
136 int err = ME_ERRNO_SUCCESS;
139 PDEBUG("executed.\n");
141 // Check subdevice index.
142 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
143 PERROR("Invalid subdevice.\n");
144 return ME_ERRNO_INVALID_SUBDEVICE;
147 err = me_dlock_enter(&device->dlock, filep);
150 PERROR("Cannot enter device.\n");
153 // Get subdevice instance.
154 s = me_slist_get_subdevice(&device->slist, subdevice);
157 // Call subdevice method.
158 err = s->me_subdevice_io_irq_stop(s, filep, channel, flags);
160 // Something really bad happened.
161 PERROR("Cannot get subdevice instance.\n");
162 err = ME_ERRNO_INTERNAL;
166 me_dlock_exit(&device->dlock, filep);
171 static int me_device_io_reset_device(struct me_device *device,
172 struct file *filep, int flags)
174 int err = ME_ERRNO_SUCCESS;
178 PDEBUG("executed.\n");
180 /* Get the number of subdevices. */
181 n = me_slist_get_number_subdevices(&device->slist);
184 err = me_dlock_enter(&device->dlock, filep);
187 PERROR("Cannot enter device.\n");
191 /* Reset every subdevice in list. */
192 for (i = 0; i < n; i++) {
193 s = me_slist_get_subdevice(&device->slist, i);
194 err = s->me_subdevice_io_reset_subdevice(s, filep, flags);
197 PERROR("Cannot reset subdevice.\n");
203 me_dlock_exit(&device->dlock, filep);
208 static int me_device_io_reset_subdevice(struct me_device *device,
210 int subdevice, int flags)
212 int err = ME_ERRNO_SUCCESS;
215 PDEBUG("executed.\n");
217 // Check subdevice index.
219 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
220 PERROR("Invalid subdevice.\n");
221 return ME_ERRNO_INVALID_SUBDEVICE;
224 err = me_dlock_enter(&device->dlock, filep);
227 PERROR("Cannot enter device.\n");
230 // Get subdevice instance.
231 s = me_slist_get_subdevice(&device->slist, subdevice);
234 // Call subdevice method.
235 err = s->me_subdevice_io_reset_subdevice(s, filep, flags);
237 // Something really bad happened.
238 PERROR("Cannot get subdevice instance.\n");
239 err = ME_ERRNO_INTERNAL;
243 me_dlock_exit(&device->dlock, filep);
248 static int me_device_io_single_config(struct me_device *device,
255 int trig_type, int trig_edge, int flags)
257 int err = ME_ERRNO_SUCCESS;
260 PDEBUG("executed.\n");
262 // Check subdevice index.
264 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
265 PERROR("Invalid subdevice.\n");
266 return ME_ERRNO_INVALID_SUBDEVICE;
269 err = me_dlock_enter(&device->dlock, filep);
272 PERROR("Cannot enter device.\n");
275 // Get subdevice instance.
276 s = me_slist_get_subdevice(&device->slist, subdevice);
279 // Call subdevice method.
280 err = s->me_subdevice_io_single_config(s,
289 // Something really bad happened.
290 PERROR("Cannot get subdevice instance.\n");
291 err = ME_ERRNO_INTERNAL;
295 me_dlock_exit(&device->dlock, filep);
300 static int me_device_io_single_read(struct me_device *device,
304 int *value, int time_out, int flags)
306 int err = ME_ERRNO_SUCCESS;
309 PDEBUG("executed.\n");
311 // Check subdevice index.
313 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
314 PERROR("Invalid subdevice.\n");
315 return ME_ERRNO_INVALID_SUBDEVICE;
318 err = me_dlock_enter(&device->dlock, filep);
321 PERROR("Cannot enter device.\n");
324 // Get subdevice instance.
325 s = me_slist_get_subdevice(&device->slist, subdevice);
328 // Call subdevice method.
329 err = s->me_subdevice_io_single_read(s,
332 value, time_out, flags);
334 // Something really bad happened.
335 PERROR("Cannot get subdevice instance.\n");
336 err = ME_ERRNO_INTERNAL;
340 me_dlock_exit(&device->dlock, filep);
345 static int me_device_io_single_write(struct me_device *device,
349 int value, int time_out, int flags)
351 int err = ME_ERRNO_SUCCESS;
354 PDEBUG("executed.\n");
356 // Check subdevice index.
358 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
359 PERROR("Invalid subdevice.\n");
360 return ME_ERRNO_INVALID_SUBDEVICE;
363 err = me_dlock_enter(&device->dlock, filep);
366 PERROR("Cannot enter device.\n");
369 // Get subdevice instance.
370 s = me_slist_get_subdevice(&device->slist, subdevice);
373 // Call subdevice method.
374 err = s->me_subdevice_io_single_write(s,
377 value, time_out, flags);
379 // Something really bad happened.
380 PERROR("Cannot get subdevice instance.\n");
381 err = ME_ERRNO_INTERNAL;
385 me_dlock_exit(&device->dlock, filep);
390 static int me_device_io_stream_config(struct me_device *device,
393 meIOStreamConfig_t *config_list,
395 meIOStreamTrigger_t *trigger,
396 int fifo_irq_threshold, int flags)
398 int err = ME_ERRNO_SUCCESS;
401 PDEBUG("executed.\n");
403 // Check subdevice index.
405 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
406 PERROR("Invalid subdevice.\n");
407 return ME_ERRNO_INVALID_SUBDEVICE;
410 err = me_dlock_enter(&device->dlock, filep);
413 PERROR("Cannot enter device.\n");
416 // Get subdevice instance.
417 s = me_slist_get_subdevice(&device->slist, subdevice);
420 // Call subdevice method.
421 err = s->me_subdevice_io_stream_config(s,
429 // Something really bad happened.
430 PERROR("Cannot get subdevice instance.\n");
431 err = ME_ERRNO_INTERNAL;
435 me_dlock_exit(&device->dlock, filep);
440 static int me_device_io_stream_new_values(struct me_device *device,
443 int time_out, int *count, int flags)
445 int err = ME_ERRNO_SUCCESS;
448 PDEBUG("executed.\n");
450 // Check subdevice index.
452 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
453 PERROR("Invalid subdevice.\n");
454 return ME_ERRNO_INVALID_SUBDEVICE;
457 err = me_dlock_enter(&device->dlock, filep);
460 PERROR("Cannot enter device.\n");
463 // Get subdevice instance.
464 s = me_slist_get_subdevice(&device->slist, subdevice);
467 // Call subdevice method.
468 err = s->me_subdevice_io_stream_new_values(s,
473 // Something really bad happened.
474 PERROR("Cannot get subdevice instance.\n");
475 err = ME_ERRNO_INTERNAL;
479 me_dlock_exit(&device->dlock, filep);
484 static int me_device_io_stream_read(struct me_device *device,
488 int *values, int *count, int flags)
490 int err = ME_ERRNO_SUCCESS;
493 PDEBUG("executed.\n");
495 // Check subdevice index.
497 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
498 PERROR("Invalid subdevice.\n");
499 return ME_ERRNO_INVALID_SUBDEVICE;
502 err = me_dlock_enter(&device->dlock, filep);
505 PERROR("Cannot enter device.\n");
508 // Get subdevice instance.
509 s = me_slist_get_subdevice(&device->slist, subdevice);
512 // Call subdevice method.
513 err = s->me_subdevice_io_stream_read(s,
516 values, count, flags);
518 // Something really bad happened.
519 PERROR("Cannot get subdevice instance.\n");
520 err = ME_ERRNO_INTERNAL;
524 me_dlock_exit(&device->dlock, filep);
529 static int me_device_io_stream_start(struct me_device *device,
532 int start_mode, int time_out, int flags)
534 int err = ME_ERRNO_SUCCESS;
537 PDEBUG("executed.\n");
539 // Check subdevice index.
541 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
542 PERROR("Invalid subdevice.\n");
543 return ME_ERRNO_INVALID_SUBDEVICE;
546 err = me_dlock_enter(&device->dlock, filep);
549 PERROR("Cannot enter device.\n");
552 // Get subdevice instance.
553 s = me_slist_get_subdevice(&device->slist, subdevice);
556 // Call subdevice method.
557 err = s->me_subdevice_io_stream_start(s,
562 // Something really bad happened.
563 PERROR("Cannot get subdevice instance.\n");
564 err = ME_ERRNO_INTERNAL;
568 me_dlock_exit(&device->dlock, filep);
573 static int me_device_io_stream_status(struct me_device *device,
577 int *status, int *count, int flags)
579 int err = ME_ERRNO_SUCCESS;
582 PDEBUG("executed.\n");
584 // Check subdevice index.
586 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
587 PERROR("Invalid subdevice.\n");
588 return ME_ERRNO_INVALID_SUBDEVICE;
591 err = me_dlock_enter(&device->dlock, filep);
594 PERROR("Cannot enter device.\n");
597 // Get subdevice instance.
598 s = me_slist_get_subdevice(&device->slist, subdevice);
601 // Call subdevice method.
602 err = s->me_subdevice_io_stream_status(s,
605 status, count, flags);
607 // Something really bad happened.
608 PERROR("Cannot get subdevice instance.\n");
609 err = ME_ERRNO_INTERNAL;
613 me_dlock_exit(&device->dlock, filep);
618 static int me_device_io_stream_stop(struct me_device *device,
620 int subdevice, int stop_mode, int flags)
622 int err = ME_ERRNO_SUCCESS;
625 PDEBUG("executed.\n");
627 // Check subdevice index.
629 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
630 PERROR("Invalid subdevice.\n");
631 return ME_ERRNO_INVALID_SUBDEVICE;
634 err = me_dlock_enter(&device->dlock, filep);
637 PERROR("Cannot enter device.\n");
640 // Get subdevice instance.
641 s = me_slist_get_subdevice(&device->slist, subdevice);
644 // Call subdevice method.
645 err = s->me_subdevice_io_stream_stop(s,
646 filep, stop_mode, flags);
648 // Something really bad happened.
649 PERROR("Cannot get subdevice instance.\n");
650 err = ME_ERRNO_INTERNAL;
654 me_dlock_exit(&device->dlock, filep);
659 static int me_device_io_stream_write(struct me_device *device,
663 int *values, int *count, int flags)
665 int err = ME_ERRNO_SUCCESS;
668 PDEBUG("executed.\n");
670 // Check subdevice index.
672 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
673 PERROR("Invalid subdevice.\n");
674 return ME_ERRNO_INVALID_SUBDEVICE;
677 err = me_dlock_enter(&device->dlock, filep);
680 PERROR("Cannot enter device.\n");
683 // Get subdevice instance.
684 s = me_slist_get_subdevice(&device->slist, subdevice);
687 // Call subdevice method.
688 err = s->me_subdevice_io_stream_write(s,
691 values, count, flags);
693 // Something really bad happened.
694 PERROR("Cannot get subdevice instance.\n");
695 err = ME_ERRNO_INTERNAL;
699 me_dlock_exit(&device->dlock, filep);
704 static int me_device_lock_device(struct me_device *device,
705 struct file *filep, int lock, int flags)
707 PDEBUG("executed.\n");
709 return me_dlock_lock(&device->dlock,
710 filep, lock, flags, &device->slist);
713 static int me_device_lock_subdevice(struct me_device *device,
715 int subdevice, int lock, int flags)
717 int err = ME_ERRNO_SUCCESS;
720 PDEBUG("executed.\n");
722 // Check subdevice index.
724 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
725 PERROR("Invalid subdevice.\n");
726 return ME_ERRNO_INVALID_SUBDEVICE;
729 err = me_dlock_enter(&device->dlock, filep);
732 PERROR("Cannot enter device.\n");
735 // Get subdevice instance.
736 s = me_slist_get_subdevice(&device->slist, subdevice);
739 // Call subdevice method.
740 err = s->me_subdevice_lock_subdevice(s, filep, lock, flags);
742 // Something really bad happened.
743 PERROR("Cannot get subdevice instance.\n");
744 err = ME_ERRNO_INTERNAL;
748 me_dlock_exit(&device->dlock, filep);
753 static int me_device_query_description_device(struct me_device *device,
756 PDEBUG("executed.\n");
757 *description = device->device_description;
758 return ME_ERRNO_SUCCESS;
761 static int me_device_query_info_device(struct me_device *device,
767 int *dev_no, int *func_no, int *plugged)
769 PDEBUG("executed.\n");
771 if (device->bus_type == ME_BUS_TYPE_PCI) {
772 *vendor_id = device->info.pci.vendor_id;
773 *device_id = device->info.pci.device_id;
774 *serial_no = device->info.pci.serial_no;
775 *bus_type = ME_BUS_TYPE_PCI;
776 *bus_no = device->info.pci.pci_bus_no;
777 *dev_no = device->info.pci.pci_dev_no;
778 *func_no = device->info.pci.pci_func_no;
779 *plugged = ME_PLUGGED_IN;
781 *plugged = ME_PLUGGED_OUT;
783 return ME_ERRNO_SUCCESS;
786 static int me_device_query_name_device(struct me_device *device, char **name)
788 PDEBUG("executed.\n");
789 *name = device->device_name;
790 return ME_ERRNO_SUCCESS;
793 static int me_device_query_name_device_driver(struct me_device *device,
796 PDEBUG("executed.\n");
797 *name = device->driver_name;
798 return ME_ERRNO_SUCCESS;
801 static int me_device_query_number_subdevices(struct me_device *device,
804 PDEBUG("executed.\n");
805 return me_slist_query_number_subdevices(&device->slist, number);
808 static int me_device_query_number_channels(struct me_device *device,
809 int subdevice, int *number)
811 int err = ME_ERRNO_SUCCESS;
814 PDEBUG("executed.\n");
816 // Check subdevice index.
818 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
819 PERROR("Invalid subdevice.\n");
820 return ME_ERRNO_INVALID_SUBDEVICE;
822 // Get subdevice instance.
823 s = me_slist_get_subdevice(&device->slist, subdevice);
826 // Call subdevice method.
827 err = s->me_subdevice_query_number_channels(s, number);
829 // Something really bad happened.
830 PERROR("Cannot get subdevice instance.\n");
831 err = ME_ERRNO_INTERNAL;
837 static int me_device_query_number_ranges(struct me_device *device,
838 int subdevice, int unit, int *count)
840 int err = ME_ERRNO_SUCCESS;
843 PDEBUG("executed.\n");
845 // Check subdevice index.
847 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
848 PERROR("Invalid subdevice.\n");
849 return ME_ERRNO_INVALID_SUBDEVICE;
851 // Get subdevice instance.
852 s = me_slist_get_subdevice(&device->slist, subdevice);
855 // Call subdevice method.
856 err = s->me_subdevice_query_number_ranges(s, unit, count);
858 // Something really bad happened.
859 PERROR("Cannot get subdevice instance.\n");
860 err = ME_ERRNO_INTERNAL;
866 static int me_device_query_range_by_min_max(struct me_device *device,
870 int *max, int *maxdata, int *range)
872 int err = ME_ERRNO_SUCCESS;
875 PDEBUG("executed.\n");
877 // Check subdevice index.
879 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
880 PERROR("Invalid subdevice.\n");
881 return ME_ERRNO_INVALID_SUBDEVICE;
883 // Get subdevice instance.
884 s = me_slist_get_subdevice(&device->slist, subdevice);
887 // Call subdevice method.
888 err = s->me_subdevice_query_range_by_min_max(s,
894 // Something really bad happened.
895 PERROR("Cannot get subdevice instance.\n");
896 err = ME_ERRNO_INTERNAL;
902 static int me_device_query_range_info(struct me_device *device,
906 int *min, int *max, int *maxdata)
908 int err = ME_ERRNO_SUCCESS;
911 PDEBUG("executed.\n");
913 // Check subdevice index.
915 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
916 PERROR("Invalid subdevice.\n");
917 return ME_ERRNO_INVALID_SUBDEVICE;
919 // Get subdevice instance.
920 s = me_slist_get_subdevice(&device->slist, subdevice);
923 // Call subdevice method.
924 err = s->me_subdevice_query_range_info(s,
926 unit, min, max, maxdata);
928 // Something really bad happened.
929 PERROR("Cannot get subdevice instance.\n");
930 err = ME_ERRNO_INTERNAL;
936 static int me_device_query_subdevice_by_type(struct me_device *device,
939 int subtype, int *subdevice)
941 PDEBUG("executed.\n");
943 return me_slist_get_subdevice_by_type(&device->slist,
945 type, subtype, subdevice);
948 static int me_device_query_subdevice_type(struct me_device *device,
950 int *type, int *subtype)
952 int err = ME_ERRNO_SUCCESS;
955 PDEBUG("executed.\n");
957 // Check subdevice index.
959 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
960 PERROR("Invalid subdevice.\n");
961 return ME_ERRNO_INVALID_SUBDEVICE;
963 // Get subdevice instance.
964 s = me_slist_get_subdevice(&device->slist, subdevice);
967 // Call subdevice method.
968 err = s->me_subdevice_query_subdevice_type(s, type, subtype);
970 // Something really bad happened.
971 PERROR("Cannot get subdevice instance.\n");
972 err = ME_ERRNO_INTERNAL;
978 static int me_device_query_subdevice_caps(struct me_device *device,
979 int subdevice, int *caps)
981 int err = ME_ERRNO_SUCCESS;
984 PDEBUG("executed.\n");
986 // Check subdevice index.
988 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
989 PERROR("Invalid subdevice.\n");
990 return ME_ERRNO_INVALID_SUBDEVICE;
992 // Get subdevice instance.
993 s = me_slist_get_subdevice(&device->slist, subdevice);
996 // Call subdevice method.
997 err = s->me_subdevice_query_subdevice_caps(s, caps);
999 // Something really bad happened.
1000 PERROR("Cannot get subdevice instance.\n");
1001 err = ME_ERRNO_INTERNAL;
1007 static int me_device_query_subdevice_caps_args(struct me_device *device,
1009 int cap, int *args, int count)
1011 int err = ME_ERRNO_SUCCESS;
1014 PDEBUG("executed.\n");
1016 // Check subdevice index.
1018 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
1019 PERROR("Invalid subdevice.\n");
1020 return ME_ERRNO_INVALID_SUBDEVICE;
1022 // Get subdevice instance.
1023 s = me_slist_get_subdevice(&device->slist, subdevice);
1026 // Call subdevice method.
1027 err = s->me_subdevice_query_subdevice_caps_args(s,
1031 // Something really bad happened.
1032 PERROR("Cannot get subdevice instance.\n");
1033 err = ME_ERRNO_INTERNAL;
1039 static int me_device_query_timer(struct me_device *device,
1042 int *base_frequency,
1043 uint64_t *min_ticks, uint64_t *max_ticks)
1045 int err = ME_ERRNO_SUCCESS;
1048 PDEBUG("executed.\n");
1050 // Check subdevice index.
1052 if (subdevice >= me_slist_get_number_subdevices(&device->slist)) {
1053 PERROR("Invalid subdevice.\n");
1054 return ME_ERRNO_INVALID_SUBDEVICE;
1056 // Get subdevice instance.
1057 s = me_slist_get_subdevice(&device->slist, subdevice);
1060 // Call subdevice method.
1061 err = s->me_subdevice_query_timer(s,
1064 min_ticks, max_ticks);
1066 // Something really bad happened.
1067 PERROR("Cannot get subdevice instance.\n");
1068 err = ME_ERRNO_INTERNAL;
1074 static int me_device_query_version_device_driver(struct me_device *device,
1076 /** @todo Versions shold be read from driver. I must overwrite this function in each module. Here should be returned an error!
1079 PDEBUG("executed.\n");
1080 *version = ME_VERSION_DRIVER;
1081 return ME_ERRNO_SUCCESS;
1084 static int me_device_config_load(struct me_device *device, struct file *filep,
1085 me_cfg_device_entry_t *config)
1087 PDEBUG("executed.\n");
1088 return ME_ERRNO_SUCCESS; //If no need for config return success.
1089 // return ME_ERRNO_NOT_SUPPORTED;
1092 static void me_device_destructor(me_device_t *me_device)
1094 PDEBUG("executed.\n");
1095 me_device_deinit(me_device);
1099 /* //me_device_usb_init
1100 int me_device_usb_init(me_device_t *me_device, struct usb_interface *interface)
1102 PDEBUG("executed.\n");
1107 static int get_device_descriptions(uint16_t device_id,
1109 char **device_description,
1111 /** @todo This is wrong concept! Static table has too strong limitations!
1112 * 'device_name' and 'driver_name' should be calculated from 'device_id'
1113 * 'device_description' should be read from device or moved to user space and handled by library!
1116 PDEBUG("executed.\n");
1118 switch (device_id) {
1119 case PCI_DEVICE_ID_MEILHAUS_ME1000:
1120 case PCI_DEVICE_ID_MEILHAUS_ME1000_A:
1121 case PCI_DEVICE_ID_MEILHAUS_ME1000_B:
1122 *device_name = ME1000_NAME_DEVICE_ME1000;
1123 *device_description = ME1000_DESCRIPTION_DEVICE_ME1000;
1124 *driver_name = ME1000_NAME_DRIVER;
1127 case PCI_DEVICE_ID_MEILHAUS_ME1400:
1128 *device_name = ME1400_NAME_DEVICE_ME1400;
1129 *device_description = ME1400_DESCRIPTION_DEVICE_ME1400;
1130 *driver_name = ME1400_NAME_DRIVER;
1133 case PCI_DEVICE_ID_MEILHAUS_ME140A:
1134 *device_name = ME1400_NAME_DEVICE_ME1400A;
1135 *device_description = ME1400_DESCRIPTION_DEVICE_ME1400A;
1136 *driver_name = ME1400_NAME_DRIVER;
1139 case PCI_DEVICE_ID_MEILHAUS_ME140B:
1140 *device_name = ME1400_NAME_DEVICE_ME1400B;
1141 *device_description = ME1400_DESCRIPTION_DEVICE_ME1400B;
1142 *driver_name = ME1400_NAME_DRIVER;
1145 case PCI_DEVICE_ID_MEILHAUS_ME14E0:
1146 *device_name = ME1400_NAME_DEVICE_ME1400E;
1147 *device_description = ME1400_DESCRIPTION_DEVICE_ME1400E;
1148 *driver_name = ME1400_NAME_DRIVER;
1151 case PCI_DEVICE_ID_MEILHAUS_ME14EA:
1152 *device_name = ME1400_NAME_DEVICE_ME1400EA;
1153 *device_description = ME1400_DESCRIPTION_DEVICE_ME1400EA;
1154 *driver_name = ME1400_NAME_DRIVER;
1157 case PCI_DEVICE_ID_MEILHAUS_ME14EB:
1158 *device_name = ME1400_NAME_DEVICE_ME1400EB;
1159 *device_description = ME1400_DESCRIPTION_DEVICE_ME1400EB;
1160 *driver_name = ME1400_NAME_DRIVER;
1163 case PCI_DEVICE_ID_MEILHAUS_ME140C:
1164 *device_name = ME1400_NAME_DEVICE_ME1400C;
1165 *device_description = ME1400_DESCRIPTION_DEVICE_ME1400C;
1166 *driver_name = ME1400_NAME_DRIVER;
1169 case PCI_DEVICE_ID_MEILHAUS_ME140D:
1170 *device_name = ME1400_NAME_DEVICE_ME1400D;
1171 *device_description = ME1400_DESCRIPTION_DEVICE_ME1400D;
1172 *driver_name = ME1400_NAME_DRIVER;
1175 case PCI_DEVICE_ID_MEILHAUS_ME1600_4U:
1176 *device_name = ME1600_NAME_DEVICE_ME16004U;
1177 *device_description = ME1600_DESCRIPTION_DEVICE_ME16004U;
1178 *driver_name = ME1600_NAME_DRIVER;
1181 case PCI_DEVICE_ID_MEILHAUS_ME1600_8U:
1182 *device_name = ME1600_NAME_DEVICE_ME16008U;
1183 *device_description = ME1600_DESCRIPTION_DEVICE_ME16008U;
1184 *driver_name = ME1600_NAME_DRIVER;
1187 case PCI_DEVICE_ID_MEILHAUS_ME1600_12U:
1188 *device_name = ME1600_NAME_DEVICE_ME160012U;
1189 *device_description = ME1600_DESCRIPTION_DEVICE_ME160012U;
1190 *driver_name = ME1600_NAME_DRIVER;
1193 case PCI_DEVICE_ID_MEILHAUS_ME1600_16U:
1194 *device_name = ME1600_NAME_DEVICE_ME160016U;
1195 *device_description = ME1600_DESCRIPTION_DEVICE_ME160016U;
1196 *driver_name = ME1600_NAME_DRIVER;
1199 case PCI_DEVICE_ID_MEILHAUS_ME1600_16U_8I:
1200 *device_name = ME1600_NAME_DEVICE_ME160016U8I;
1201 *device_description = ME1600_DESCRIPTION_DEVICE_ME160016U8I;
1202 *driver_name = ME1600_NAME_DRIVER;
1205 case PCI_DEVICE_ID_MEILHAUS_ME4610:
1206 *device_name = ME4600_NAME_DEVICE_ME4610;
1207 *device_description = ME4600_DESCRIPTION_DEVICE_ME4610;
1208 *driver_name = ME4600_NAME_DRIVER;
1211 case PCI_DEVICE_ID_MEILHAUS_ME4650:
1212 *device_name = ME4600_NAME_DEVICE_ME4650;
1213 *device_description = ME4600_DESCRIPTION_DEVICE_ME4650;
1214 *driver_name = ME4600_NAME_DRIVER;
1217 case PCI_DEVICE_ID_MEILHAUS_ME4660:
1218 *device_name = ME4600_NAME_DEVICE_ME4660;
1219 *device_description = ME4600_DESCRIPTION_DEVICE_ME4660;
1220 *driver_name = ME4600_NAME_DRIVER;
1223 case PCI_DEVICE_ID_MEILHAUS_ME4660I:
1224 *device_name = ME4600_NAME_DEVICE_ME4660I;
1225 *device_description = ME4600_DESCRIPTION_DEVICE_ME4660I;
1226 *driver_name = ME4600_NAME_DRIVER;
1229 case PCI_DEVICE_ID_MEILHAUS_ME4660S:
1230 *device_name = ME4600_NAME_DEVICE_ME4660S;
1231 *device_description = ME4600_DESCRIPTION_DEVICE_ME4660S;
1232 *driver_name = ME4600_NAME_DRIVER;
1235 case PCI_DEVICE_ID_MEILHAUS_ME4660IS:
1236 *device_name = ME4600_NAME_DEVICE_ME4660IS;
1237 *device_description = ME4600_DESCRIPTION_DEVICE_ME4660IS;
1238 *driver_name = ME4600_NAME_DRIVER;
1241 case PCI_DEVICE_ID_MEILHAUS_ME4670:
1242 *device_name = ME4600_NAME_DEVICE_ME4670;
1243 *device_description = ME4600_DESCRIPTION_DEVICE_ME4670;
1244 *driver_name = ME4600_NAME_DRIVER;
1247 case PCI_DEVICE_ID_MEILHAUS_ME4670I:
1248 *device_name = ME4600_NAME_DEVICE_ME4670I;
1249 *device_description = ME4600_DESCRIPTION_DEVICE_ME4670I;
1250 *driver_name = ME4600_NAME_DRIVER;
1253 case PCI_DEVICE_ID_MEILHAUS_ME4670S:
1254 *device_name = ME4600_NAME_DEVICE_ME4670S;
1255 *device_description = ME4600_DESCRIPTION_DEVICE_ME4670S;
1256 *driver_name = ME4600_NAME_DRIVER;
1259 case PCI_DEVICE_ID_MEILHAUS_ME4670IS:
1260 *device_name = ME4600_NAME_DEVICE_ME4670IS;
1261 *device_description = ME4600_DESCRIPTION_DEVICE_ME4670IS;
1262 *driver_name = ME4600_NAME_DRIVER;
1265 case PCI_DEVICE_ID_MEILHAUS_ME4680:
1266 *device_name = ME4600_NAME_DEVICE_ME4680;
1267 *device_description = ME4600_DESCRIPTION_DEVICE_ME4680;
1268 *driver_name = ME4600_NAME_DRIVER;
1271 case PCI_DEVICE_ID_MEILHAUS_ME4680I:
1272 *device_name = ME4600_NAME_DEVICE_ME4680I;
1273 *device_description = ME4600_DESCRIPTION_DEVICE_ME4680I;
1274 *driver_name = ME4600_NAME_DRIVER;
1277 case PCI_DEVICE_ID_MEILHAUS_ME4680S:
1278 *device_name = ME4600_NAME_DEVICE_ME4680S;
1279 *device_description = ME4600_DESCRIPTION_DEVICE_ME4680S;
1280 *driver_name = ME4600_NAME_DRIVER;
1283 case PCI_DEVICE_ID_MEILHAUS_ME4680IS:
1284 *device_name = ME4600_NAME_DEVICE_ME4680IS;
1285 *device_description = ME4600_DESCRIPTION_DEVICE_ME4680IS;
1286 *driver_name = ME4600_NAME_DRIVER;
1289 case PCI_DEVICE_ID_MEILHAUS_ME6004:
1290 *device_name = ME6000_NAME_DEVICE_ME60004;
1291 *device_description = ME6000_DESCRIPTION_DEVICE_ME60004;
1292 *driver_name = ME6000_NAME_DRIVER;
1295 case PCI_DEVICE_ID_MEILHAUS_ME6008:
1296 *device_name = ME6000_NAME_DEVICE_ME60008;
1297 *device_description = ME6000_DESCRIPTION_DEVICE_ME60008;
1298 *driver_name = ME6000_NAME_DRIVER;
1301 case PCI_DEVICE_ID_MEILHAUS_ME600F:
1302 *device_name = ME6000_NAME_DEVICE_ME600016;
1303 *device_description = ME6000_DESCRIPTION_DEVICE_ME600016;
1304 *driver_name = ME6000_NAME_DRIVER;
1307 case PCI_DEVICE_ID_MEILHAUS_ME6014:
1308 *device_name = ME6000_NAME_DEVICE_ME6000I4;
1309 *device_description = ME6000_DESCRIPTION_DEVICE_ME6000I4;
1310 *driver_name = ME6000_NAME_DRIVER;
1313 case PCI_DEVICE_ID_MEILHAUS_ME6018:
1314 *device_name = ME6000_NAME_DEVICE_ME6000I8;
1315 *device_description = ME6000_DESCRIPTION_DEVICE_ME6000I8;
1316 *driver_name = ME6000_NAME_DRIVER;
1319 case PCI_DEVICE_ID_MEILHAUS_ME601F:
1320 *device_name = ME6000_NAME_DEVICE_ME6000I16;
1321 *device_description = ME6000_DESCRIPTION_DEVICE_ME6000I16;
1322 *driver_name = ME6000_NAME_DRIVER;
1325 case PCI_DEVICE_ID_MEILHAUS_ME6034:
1326 *device_name = ME6000_NAME_DEVICE_ME6000ISLE4;
1327 *device_description = ME6000_DESCRIPTION_DEVICE_ME6000ISLE4;
1328 *driver_name = ME6000_NAME_DRIVER;
1331 case PCI_DEVICE_ID_MEILHAUS_ME6038:
1332 *device_name = ME6000_NAME_DEVICE_ME6000ISLE8;
1333 *device_description = ME6000_DESCRIPTION_DEVICE_ME6000ISLE8;
1334 *driver_name = ME6000_NAME_DRIVER;
1337 case PCI_DEVICE_ID_MEILHAUS_ME603F:
1338 *device_name = ME6000_NAME_DEVICE_ME6000ISLE16;
1339 *device_description = ME6000_DESCRIPTION_DEVICE_ME6000ISLE16;
1340 *driver_name = ME6000_NAME_DRIVER;
1343 case PCI_DEVICE_ID_MEILHAUS_ME6104:
1344 *device_name = ME6000_NAME_DEVICE_ME61004;
1345 *device_description = ME6000_DESCRIPTION_DEVICE_ME61004;
1346 *driver_name = ME6000_NAME_DRIVER;
1349 case PCI_DEVICE_ID_MEILHAUS_ME6108:
1350 *device_name = ME6000_NAME_DEVICE_ME61008;
1351 *device_description = ME6000_DESCRIPTION_DEVICE_ME61008;
1352 *driver_name = ME6000_NAME_DRIVER;
1355 case PCI_DEVICE_ID_MEILHAUS_ME610F:
1356 *device_name = ME6000_NAME_DEVICE_ME610016;
1357 *device_description = ME6000_DESCRIPTION_DEVICE_ME610016;
1358 *driver_name = ME6000_NAME_DRIVER;
1361 case PCI_DEVICE_ID_MEILHAUS_ME6114:
1362 *device_name = ME6000_NAME_DEVICE_ME6100I4;
1363 *device_description = ME6000_DESCRIPTION_DEVICE_ME6100I4;
1364 *driver_name = ME6000_NAME_DRIVER;
1367 case PCI_DEVICE_ID_MEILHAUS_ME6118:
1368 *device_name = ME6000_NAME_DEVICE_ME6100I8;
1369 *device_description = ME6000_DESCRIPTION_DEVICE_ME6100I8;
1370 *driver_name = ME6000_NAME_DRIVER;
1373 case PCI_DEVICE_ID_MEILHAUS_ME611F:
1374 *device_name = ME6000_NAME_DEVICE_ME6100I16;
1375 *device_description = ME6000_DESCRIPTION_DEVICE_ME6100I16;
1376 *driver_name = ME6000_NAME_DRIVER;
1379 case PCI_DEVICE_ID_MEILHAUS_ME6134:
1380 *device_name = ME6000_NAME_DEVICE_ME6100ISLE4;
1381 *device_description = ME6000_DESCRIPTION_DEVICE_ME6100ISLE4;
1382 *driver_name = ME6000_NAME_DRIVER;
1385 case PCI_DEVICE_ID_MEILHAUS_ME6138:
1386 *device_name = ME6000_NAME_DEVICE_ME6100ISLE8;
1387 *device_description = ME6000_DESCRIPTION_DEVICE_ME6100ISLE8;
1388 *driver_name = ME6000_NAME_DRIVER;
1391 case PCI_DEVICE_ID_MEILHAUS_ME613F:
1392 *device_name = ME6000_NAME_DEVICE_ME6100ISLE16;
1393 *device_description = ME6000_DESCRIPTION_DEVICE_ME6100ISLE16;
1394 *driver_name = ME6000_NAME_DRIVER;
1397 case PCI_DEVICE_ID_MEILHAUS_ME6044:
1398 *device_name = ME6000_NAME_DEVICE_ME60004DIO;
1399 *device_description = ME6000_DESCRIPTION_DEVICE_ME60004DIO;
1400 *driver_name = ME6000_NAME_DRIVER;
1403 case PCI_DEVICE_ID_MEILHAUS_ME6048:
1404 *device_name = ME6000_NAME_DEVICE_ME60008DIO;
1405 *device_description = ME6000_DESCRIPTION_DEVICE_ME60008DIO;
1406 *driver_name = ME6000_NAME_DRIVER;
1409 case PCI_DEVICE_ID_MEILHAUS_ME604F:
1410 *device_name = ME6000_NAME_DEVICE_ME600016DIO;
1411 *device_description = ME6000_DESCRIPTION_DEVICE_ME600016DIO;
1412 *driver_name = ME6000_NAME_DRIVER;
1415 case PCI_DEVICE_ID_MEILHAUS_ME6054:
1416 *device_name = ME6000_NAME_DEVICE_ME6000I4DIO;
1417 *device_description = ME6000_DESCRIPTION_DEVICE_ME6000I4DIO;
1418 *driver_name = ME6000_NAME_DRIVER;
1421 case PCI_DEVICE_ID_MEILHAUS_ME6058:
1422 *device_name = ME6000_NAME_DEVICE_ME6000I8DIO;
1423 *device_description = ME6000_DESCRIPTION_DEVICE_ME6000I8DIO;
1424 *driver_name = ME6000_NAME_DRIVER;
1427 case PCI_DEVICE_ID_MEILHAUS_ME605F:
1428 *device_name = ME6000_NAME_DEVICE_ME6000I16DIO;
1429 *device_description = ME6000_DESCRIPTION_DEVICE_ME6000I16DIO;
1430 *driver_name = ME6000_NAME_DRIVER;
1433 case PCI_DEVICE_ID_MEILHAUS_ME6074:
1434 *device_name = ME6000_NAME_DEVICE_ME6000ISLE4DIO;
1435 *device_description = ME6000_DESCRIPTION_DEVICE_ME6000ISLE4DIO;
1436 *driver_name = ME6000_NAME_DRIVER;
1439 case PCI_DEVICE_ID_MEILHAUS_ME6078:
1440 *device_name = ME6000_NAME_DEVICE_ME6000ISLE8DIO;
1441 *device_description = ME6000_DESCRIPTION_DEVICE_ME6000ISLE8DIO;
1442 *driver_name = ME6000_NAME_DRIVER;
1445 case PCI_DEVICE_ID_MEILHAUS_ME607F:
1446 *device_name = ME6000_NAME_DEVICE_ME6000ISLE16DIO;
1447 *device_description = ME6000_DESCRIPTION_DEVICE_ME6000ISLE16DIO;
1448 *driver_name = ME6000_NAME_DRIVER;
1451 case PCI_DEVICE_ID_MEILHAUS_ME6144:
1452 *device_name = ME6000_NAME_DEVICE_ME61004DIO;
1453 *device_description = ME6000_DESCRIPTION_DEVICE_ME61004DIO;
1454 *driver_name = ME6000_NAME_DRIVER;
1457 case PCI_DEVICE_ID_MEILHAUS_ME6148:
1458 *device_name = ME6000_NAME_DEVICE_ME61008DIO;
1459 *device_description = ME6000_DESCRIPTION_DEVICE_ME61008DIO;
1460 *driver_name = ME6000_NAME_DRIVER;
1463 case PCI_DEVICE_ID_MEILHAUS_ME614F:
1464 *device_name = ME6000_NAME_DEVICE_ME610016DIO;
1465 *device_description = ME6000_DESCRIPTION_DEVICE_ME610016DIO;
1466 *driver_name = ME6000_NAME_DRIVER;
1469 case PCI_DEVICE_ID_MEILHAUS_ME6154:
1470 *device_name = ME6000_NAME_DEVICE_ME6100I4DIO;
1471 *device_description = ME6000_DESCRIPTION_DEVICE_ME6100I4DIO;
1472 *driver_name = ME6000_NAME_DRIVER;
1475 case PCI_DEVICE_ID_MEILHAUS_ME6158:
1476 *device_name = ME6000_NAME_DEVICE_ME6100I8DIO;
1477 *device_description = ME6000_DESCRIPTION_DEVICE_ME6100I8DIO;
1478 *driver_name = ME6000_NAME_DRIVER;
1481 case PCI_DEVICE_ID_MEILHAUS_ME615F:
1482 *device_name = ME6000_NAME_DEVICE_ME6100I16DIO;
1483 *device_description = ME6000_DESCRIPTION_DEVICE_ME6100I16DIO;
1484 *driver_name = ME6000_NAME_DRIVER;
1487 case PCI_DEVICE_ID_MEILHAUS_ME6174:
1488 *device_name = ME6000_NAME_DEVICE_ME6100ISLE4DIO;
1489 *device_description = ME6000_DESCRIPTION_DEVICE_ME6100ISLE4DIO;
1490 *driver_name = ME6000_NAME_DRIVER;
1493 case PCI_DEVICE_ID_MEILHAUS_ME6178:
1494 *device_name = ME6000_NAME_DEVICE_ME6100ISLE8DIO;
1495 *device_description = ME6000_DESCRIPTION_DEVICE_ME6100ISLE8DIO;
1496 *driver_name = ME6000_NAME_DRIVER;
1499 case PCI_DEVICE_ID_MEILHAUS_ME617F:
1500 *device_name = ME6000_NAME_DEVICE_ME6100ISLE16DIO;
1501 *device_description = ME6000_DESCRIPTION_DEVICE_ME6100ISLE16DIO;
1502 *driver_name = ME6000_NAME_DRIVER;
1505 case PCI_DEVICE_ID_MEILHAUS_ME6259:
1506 *device_name = ME6000_NAME_DEVICE_ME6200I9DIO;
1507 *device_description = ME6000_DESCRIPTION_DEVICE_ME6200I9DIO;
1508 *driver_name = ME6000_NAME_DRIVER;
1511 case PCI_DEVICE_ID_MEILHAUS_ME6359:
1512 *device_name = ME6000_NAME_DEVICE_ME6300I9DIO;
1513 *device_description = ME6000_DESCRIPTION_DEVICE_ME6300I9DIO;
1514 *driver_name = ME6000_NAME_DRIVER;
1517 case PCI_DEVICE_ID_MEILHAUS_ME0630:
1518 *device_name = ME0600_NAME_DEVICE_ME0630;
1519 *device_description = ME0600_DESCRIPTION_DEVICE_ME0630;
1520 *driver_name = ME0600_NAME_DRIVER;
1523 case PCI_DEVICE_ID_MEILHAUS_ME8100_A:
1524 *device_name = ME8100_NAME_DEVICE_ME8100A;
1525 *device_description = ME8100_DESCRIPTION_DEVICE_ME8100A;
1526 *driver_name = ME8100_NAME_DRIVER;
1529 case PCI_DEVICE_ID_MEILHAUS_ME8100_B:
1530 *device_name = ME8100_NAME_DEVICE_ME8100B;
1531 *device_description = ME8100_DESCRIPTION_DEVICE_ME8100B;
1532 *driver_name = ME8100_NAME_DRIVER;
1535 case PCI_DEVICE_ID_MEILHAUS_ME8200_A:
1536 *device_name = ME8200_NAME_DEVICE_ME8200A;
1537 *device_description = ME8200_DESCRIPTION_DEVICE_ME8200A;
1538 *driver_name = ME8200_NAME_DRIVER;
1541 case PCI_DEVICE_ID_MEILHAUS_ME8200_B:
1542 *device_name = ME8200_NAME_DEVICE_ME8200B;
1543 *device_description = ME8200_DESCRIPTION_DEVICE_ME8200B;
1544 *driver_name = ME8200_NAME_DRIVER;
1547 case PCI_DEVICE_ID_MEILHAUS_ME0940:
1548 *device_name = ME0900_NAME_DEVICE_ME0940;
1549 *device_description = ME0900_DESCRIPTION_DEVICE_ME0940;
1550 *driver_name = ME0900_NAME_DRIVER;
1553 case PCI_DEVICE_ID_MEILHAUS_ME0950:
1554 *device_name = ME0900_NAME_DEVICE_ME0950;
1555 *device_description = ME0900_DESCRIPTION_DEVICE_ME0950;
1556 *driver_name = ME0900_NAME_DRIVER;
1559 case PCI_DEVICE_ID_MEILHAUS_ME0960:
1560 *device_name = ME0900_NAME_DEVICE_ME0960;
1561 *device_description = ME0900_DESCRIPTION_DEVICE_ME0960;
1562 *driver_name = ME0900_NAME_DRIVER;
1565 case USB_DEVICE_ID_MEPHISTO_S1:
1566 *device_name = MEPHISTO_S1_NAME_DEVICE;
1567 *device_description = MEPHISTO_S1_DESCRIPTION_DEVICE;
1568 *driver_name = MEPHISTO_S1_NAME_DRIVER;
1572 *device_name = EMPTY_NAME_DEVICE;
1573 *device_description = EMPTY_DESCRIPTION_DEVICE;
1574 *driver_name = EMPTY_NAME_DRIVER;
1576 PERROR("Invalid device id.\n");
1584 int me_device_pci_init(me_device_t *me_device, struct pci_dev *pci_device)
1589 PDEBUG("executed.\n");
1591 // Initialize device list head.
1592 INIT_LIST_HEAD(&me_device->list);
1594 // Initialize device description strings.
1595 err = get_device_descriptions(pci_device->device,
1596 &me_device->device_name,
1597 &me_device->device_description,
1598 &me_device->driver_name);
1601 PERROR("Cannot initialize device description strings.\n");
1604 // Enable the pci device.
1605 err = pci_enable_device(pci_device);
1608 PERROR("Cannot enable PCI device.\n");
1611 // Request the PCI register regions.
1612 err = pci_request_regions(pci_device, me_device->device_name);
1615 PERROR("Cannot request PCI regions.\n");
1618 // The bus carrying the device is a PCI bus.
1619 me_device->bus_type = ME_BUS_TYPE_PCI;
1621 // Store the PCI information for later usage.
1622 me_device->info.pci.pci_device = pci_device;
1624 // Get PCI register bases and sizes.
1625 for (i = 0; i < 6; i++) {
1626 me_device->info.pci.reg_bases[i] =
1627 pci_resource_start(pci_device, i);
1628 me_device->info.pci.reg_sizes[i] =
1629 pci_resource_len(pci_device, i);
1632 // Get the PCI location.
1633 me_device->info.pci.pci_bus_no = pci_device->bus->number;
1634 me_device->info.pci.pci_dev_no = PCI_SLOT(pci_device->devfn);
1635 me_device->info.pci.pci_func_no = PCI_FUNC(pci_device->devfn);
1637 // Get Meilhaus specific device information.
1638 me_device->info.pci.vendor_id = pci_device->vendor;
1639 me_device->info.pci.device_id = pci_device->device;
1640 pci_read_config_byte(pci_device, 0x08,
1641 &me_device->info.pci.hw_revision);
1642 pci_read_config_dword(pci_device, 0x2C, &me_device->info.pci.serial_no);
1644 // Get the interrupt request number.
1645 me_device->irq = pci_device->irq;
1647 // Initialize device lock instance.
1648 err = me_dlock_init(&me_device->dlock);
1651 PERROR("Cannot initialize device lock instance.\n");
1654 // Initialize subdevice list instance.
1655 me_slist_init(&me_device->slist);
1658 PERROR("Cannot initialize subdevice list instance.\n");
1661 // Initialize method pointers.
1662 me_device->me_device_io_irq_start = me_device_io_irq_start;
1663 me_device->me_device_io_irq_wait = me_device_io_irq_wait;
1664 me_device->me_device_io_irq_stop = me_device_io_irq_stop;
1665 me_device->me_device_io_reset_device = me_device_io_reset_device;
1666 me_device->me_device_io_reset_subdevice = me_device_io_reset_subdevice;
1667 me_device->me_device_io_single_config = me_device_io_single_config;
1668 me_device->me_device_io_single_read = me_device_io_single_read;
1669 me_device->me_device_io_single_write = me_device_io_single_write;
1670 me_device->me_device_io_stream_config = me_device_io_stream_config;
1671 me_device->me_device_io_stream_new_values =
1672 me_device_io_stream_new_values;
1673 me_device->me_device_io_stream_read = me_device_io_stream_read;
1674 me_device->me_device_io_stream_start = me_device_io_stream_start;
1675 me_device->me_device_io_stream_status = me_device_io_stream_status;
1676 me_device->me_device_io_stream_stop = me_device_io_stream_stop;
1677 me_device->me_device_io_stream_write = me_device_io_stream_write;
1678 me_device->me_device_lock_device = me_device_lock_device;
1679 me_device->me_device_lock_subdevice = me_device_lock_subdevice;
1680 me_device->me_device_query_description_device =
1681 me_device_query_description_device;
1682 me_device->me_device_query_info_device = me_device_query_info_device;
1683 me_device->me_device_query_name_device = me_device_query_name_device;
1684 me_device->me_device_query_name_device_driver =
1685 me_device_query_name_device_driver;
1686 me_device->me_device_query_number_subdevices =
1687 me_device_query_number_subdevices;
1688 me_device->me_device_query_number_channels =
1689 me_device_query_number_channels;
1690 me_device->me_device_query_number_ranges =
1691 me_device_query_number_ranges;
1692 me_device->me_device_query_range_by_min_max =
1693 me_device_query_range_by_min_max;
1694 me_device->me_device_query_range_info = me_device_query_range_info;
1695 me_device->me_device_query_subdevice_by_type =
1696 me_device_query_subdevice_by_type;
1697 me_device->me_device_query_subdevice_type =
1698 me_device_query_subdevice_type;
1699 me_device->me_device_query_subdevice_caps =
1700 me_device_query_subdevice_caps;
1701 me_device->me_device_query_subdevice_caps_args =
1702 me_device_query_subdevice_caps_args;
1703 me_device->me_device_query_timer = me_device_query_timer;
1704 me_device->me_device_query_version_device_driver =
1705 me_device_query_version_device_driver;
1706 me_device->me_device_config_load = me_device_config_load;
1707 me_device->me_device_destructor = me_device_destructor;
1712 me_dlock_deinit(&me_device->dlock);
1715 pci_release_regions(pci_device);
1718 pci_disable_device(pci_device);
1723 void me_device_deinit(me_device_t *me_device)
1725 PDEBUG("executed.\n");
1727 me_slist_deinit(&me_device->slist);
1728 me_dlock_deinit(&me_device->dlock);
1730 if (me_device->bus_type == ME_BUS_TYPE_PCI) {
1731 pci_release_regions(me_device->info.pci.pci_device);
1732 pci_disable_device(me_device->info.pci.pci_device);
1737 // Must be an USB device.