• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  *   Copyright (c) International Business Machines  Corp., 2001
4  *
5  *   This program is free software;  you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation; either version 2 of the License, or
8  *   (at your option) any later version.
9  *
10  *   This program is distributed in the hope that it will be useful,
11  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13  *   the GNU General Public License for more details.
14  *
15  *   You should have received a copy of the GNU General Public License
16  *   along with this program;  if not, write to the Free Software
17  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  *
20  * This file will include functions that will drive the
21  * kernel module tusb to test various usb functions
22  * and kernel calls. Each function will need to setup the tif
23  * structure so that the in parameters and out parameters
24  * are correctly initialized
25  *
26  * use tif structure for passing params between user
27  * space and kernel space, in some tests it is really
28  * not needed but makes easy to maintain all tests if
29  * have the same process to read in params in the
30  * kernel module no matter what the test is
31  *
32  * author: Sean Ruyle (srruyle@us.ibm.com)
33  * date:   6/4/2003
34  *
35  * tusb_ki.c
36  */
37 
38 #include <stdlib.h>
39 #include <stdio.h>
40 #include <sys/ioctl.h>
41 #include "../tusb/tusb.h"
42 
43 /*
44  * this generic function can be used
45  * for any test calls that need no
46  * additional setup beyond the normal
47  * for making the ioctl call,
48  * if the additional setup, ie: input
49  * or output values are needed, set
50  * tif in_data and out_data values
51  * along with the corresponding length
52  * in a more specific function
53  */
ki_generic(int fd,int flag)54 int ki_generic(int fd, int flag)
55 {
56 	int rc;
57 	tusb_interface_t tif;
58 
59 	/*
60 	 * build interface structure
61 	 */
62 	tif.in_len = 0;
63 	tif.in_data = 0;
64 	tif.out_len = 0;
65 	tif.out_data = 0;
66 	tif.out_rc = 0;
67 
68 	/*
69 	 * ioctl call for flag
70 	 */
71 	rc = ioctl(fd, flag, &tif);
72 	if (rc) {
73 		printf("Ioctl error\n");
74 		return rc;
75 	}
76 	if (tif.out_rc) {
77 		printf("Specific errorr: ");
78 		return tif.out_rc;
79 	}
80 
81 	return rc;
82 }
83